Thursday, 2018-11-01

*** tpb has joined #timvideos00:00
*** Kripton has quit IRC00:02
*** Kripton has joined #timvideos00:06
*** sb0 has quit IRC02:38
cr1901_modernmithro: Did a test on icebreaker... still can duplicate the crash, but... it's not actually crashing. I can reset the CPU using a push button and it goes back to the reset vector just fine.03:13
*** thaytan has quit IRC03:23
*** thaytan has joined #timvideos03:29
*** ChanServ sets mode: +v thaytan03:29
*** thaytan has quit IRC03:49
cr1901_modernmithro: I found the culprit of the BIOS crash on picorv3205:06
cr1901_modernTrying micropython right now w/ my hack05:07
*** thaytan has joined #timvideos05:08
*** ChanServ sets mode: +v thaytan05:08
cr1901_modernmicropython boots beyond the prompt with my hack, but as soon as I try to type anything it crashes.05:10
cr1901_modernmithro: Culprit is these two lines: Apparently write_hook isn't set properly on icebreaker/ice40 boards05:11
tpbTitle: litex/console.c at master · enjoy-digital/litex · GitHub (at
cr1901_modernso the BIOS goes and jumps to write_hook and locks up05:11
*** sb0 has joined #timvideos05:12
*** thaytan has quit IRC05:13
cr1901_modernmithro: There's also another problem... picorv32's irq and reset address are hardcoded at synthesis time; micropython links in its own copy of crt0, but when an interrupt occurs, the old version of the crt0 (that was linked into the BIOS) is run instead05:22
cr1901_modernI can already promise you by visual inspection that the addresses used by the micropython crt0 != the ones used by the BIOS crt005:22
cr1901_modernpicorv32 will need to be modified to permit a user to move the irq vector.05:23
cr1901_modernthe data*/global addresses.05:23
cr1901_modernActually, I think I might know an alternative...05:37
*** thaytan has joined #timvideos05:45
*** ChanServ sets mode: +v thaytan05:45
*** thaytan has quit IRC06:00
*** rohitksingh has joined #timvideos06:01
*** thaytan has joined #timvideos06:06
*** thaytan has quit IRC06:10
*** thaytan has joined #timvideos06:11
*** ChanServ sets mode: +v thaytan06:11
cr1901_modernBIOS boot is fixed; .bss wasn't being zero'd out in the startup code. When using SPRAM, this means that the CPU saw garbage06:11
*** thaytan has quit IRC06:19
cr1901_moderncc: daveshah, in case you're interested when you wake up ^^. I figured out _part_ of the problem06:21
cr1901_modernperhaps the whole problem...06:21
*** thaytan has joined #timvideos06:25
*** ChanServ sets mode: +v thaytan06:25
mithroCarlFK: <-- Have you seen that?06:40
mithroCarlFK: Did they come down in price recently? It's only $60 USD!?06:41
cr1901_modernmithro: To boot micropython on picorv32 requires me to modify picorv32 itself. All other bugs AFAICT are fixed (BIOS boots on icebreaker).07:08
mithrocr1901_modern: Why not use a jmp proxy?07:18
cr1901_modernBecause what happens if the proxy is at a different address in the micropython firmware versus the BIOS07:19
cr1901_modern(Meaning I already tried that)07:19
cr1901_modernmithro: This is what I got so fatr07:20
cr1901_modernfar* even07:20
cr1901_modernThe IRQ vector is hardcoded at synthesis time, right? Meaning the BIOS version will always be the one called.07:20
cr1901_modernHow do I modify the BIOS' copy of _irq_entry from the startup code of the micropython firmware?07:21
mithrocr1901_modern: you make the IRQ vector be in SRAM? When you start, the first thing you so is copy your IRQ vector to the correct location in SRAM?07:34
cr1901_modernmithro: How do I get the address of the BIOS' IRQ vector from the micropython crt0?07:39
mithroWhy do you need that?07:40
cr1901_modernBecause picorv32's IRQ vector is hardcoded07:40
cr1901_modernat synthesis time07:40
cr1901_modernin other words, even when running micropython, when an IRQ occurs, it jumps _back_ to the BIOS' copy of the crt007:41
mithrocr1901_modern: Put the IRQ vector in SRAM, the crt0 of the bios copies the BIOS IRQ vector into SRAM and when the crt0 of micropython copies the micropython IRQ vector into SRAM07:45
cr1901_modernLet's call the address of the IRQ vector _irq_entry07:47
cr1901_modernHow do I know that the C compiler is going to put _irq_entry in both the BIOS and micropython _at the same exact SRAM address_?07:47
cr1901_modern(spoiler alert: It didn't :(...)07:47
cr1901_modernIf micropython and the BIOS' _irq_entry don't share the same address, then micropython's crt0 will _clear_ the SRAM (as part of BSS clear), and then store to _irq_entry at a different location than the BIOS did07:49
cr1901_modern Micropython07:50
cr1901_modern BIOS07:50
mithroThe IRQ vector address is called _irq_entry which is in SRAM07:59
cr1901_modernThey are different in Micropython and BIOS07:59
mithroThe BIOS does "(*_irq_entry) = jump to bios_irq_entry;"08:00
cr1901_modernin order for a trampoline to work, they both need to be accessing the same address08:00
mithroThe micropython does "(*_irq_entry) = jump to micropython_irq_entry;"08:00
cr1901_modern1000095c <_irq_entry>08:00
mithroThere is only one _irq_entry value which is hard coded to X as you mentioned08:01
mithroX has to be in user modifiable region08:01
mithroYou replace the _irq_entry with a jump instruction to your own irq_entry table08:02
cr1901_modern1. This is downright horrifying08:03
cr1901_modern2. How do I do this from C?08:03
cr1901_modernwell okay ignore #208:03
cr1901_modernerr, I don't really have all that fine control over where the _irq_vector actually ends up08:04
mithroIt's pretty normal to have the original _irq_vector just be a second  jump to a user modifiable location08:06
cr1901_modernright, but this means a whole new linker script just for picorv3208:08
mithroIsn't the linker script custom to each CPU anyway?08:12
cr1901_modernmithro: In any case, I'm talking to clifford right now. If he accepts a PR to increase the number of QREGs, all my problems go away08:12
cr1901_modernI can just squirrel away the IRQ pointer in one of the new QREGs08:13
cr1901_modernactually I think I figured it out08:17
*** rohitksingh has quit IRC08:31
*** rohitksingh has joined #timvideos08:32
cr1901_modernmithro: It boots08:54
cr1901_modernmicropython on picorv32 on icebreaker boots08:54
tpbTitle: RISCV32 support by cr1901 · Pull Request #54 · fupy/micropython · GitHub (at
tpbTitle: PicoRV32 Enhancements by cr1901 · Pull Request #123 · enjoy-digital/litex · GitHub (at
cr1901_modernAfter these are merged, I'll make a PR for litex-buildenv09:21
cr1901_modernWell actually... LEDs aren;t working... hrm09:23
_florent_cr1901_modern: it seems fine, happy to merge if it's working09:48
cr1901_modern_florent_: Well, a trace of SPI flash activity isn't giving me many answers... hrm09:49
cr1901_modernIn any case, we get to the prompt and the prompt works besides the LEDs. That's an important milestone.09:49
_florent_cr1901_modern: so micropython boots but you are not able to toggle a led with it?09:49
cr1901_modern_florent_: Correct09:49
cr1901_modernThere's nothing indicating that the CPU jumped into the weeds09:50
_florent_cr1901_modern: ok, i can merge you PR is you want then,09:50
_florent_cr1901_modern: you'll create another one if the led issue is related to that09:50
cr1901_modern_florent_: Yes, that works for me.09:51
daveshahCould the LED issue be another endian one?09:51
daveshahTo do with the GPIO regs or something?09:51
cr1901_modernLED regs work fine outside of micropython09:53
daveshahOh, I see09:54
cr1901_modernOf course it's also 256kb of micropython code. I highly doubt I'm gonna figure out anything substantial from staring at that.09:55
daveshahSeems like something best debugged with a few printfs09:56
cr1901_modernone notable thing is that the SPI flash started fetching the next insn immediately after the last one is done, instead of waiting for picorv32 to finish09:57
cr1901_modernIn any case, at present, the bug doesn't make sense for me. I think I've gotten far enough tonight to be satisfied.09:58
daveshahDoes an import math and math.sin(1) work?09:58
cr1901_modernLemme reboot and check09:59
daveshahIf that's fine, then the LED issue is most likely somewhere in the Python driver stuff09:59
cr1901_modernmath.sin(1) indeed does work09:59
daveshahSounds good10:00
daveshahI've never had a broken Python design succeed at that and then fail later on10:00
cr1901_modernpicorv32 is fetching the next insn while executing the current one, correct?10:01
daveshahI think so, yes10:01
daveshahPretty sure I've noticed that before10:01
cr1901_modernThe insn before the last one was: lw      a5,28(s2)10:02
cr1901_modernpossible it went into the weeds10:02
daveshahSo did it crash, or just not work?10:02
cr1901_modernIME, if we access an invalid memory location, the CPU locks10:03
daveshahthere's no timeout or anything10:03
cr1901_modernWell, it's a problem for another day :P.10:08
* cr1901_modern zzz10:08
daveshah_florent_: ping?10:26
*** sb0 has quit IRC10:41
*** sb0 has joined #timvideos13:09
_florent_daveshah: i'm here now13:54
daveshah_florent_: I'm looking at the ECP5 PLLs, and I'm wondering how you would set attribute values on instances in migen13:56
daveshahor litex13:56
daveshahI would like to generate something like this13:56
tpbTitle: Snippet | IRCCloud (at
daveshah_florent_: thanks, I missed the tuple requirement14:04
daveshahI'll test this this evening when I'm home14:05
_florent_cool, thanks14:05
*** mauz555 has joined #timvideos14:41
*** mauz555 has quit IRC16:13
*** TimGremalm has quit IRC16:59
*** mauz555 has joined #timvideos17:03
*** TimGremalm has joined #timvideos17:10
*** rohitksingh has quit IRC17:30
*** rohitksingh has joined #timvideos17:42
*** rohitksingh has quit IRC18:10
CarlFK[m]tac-tics ridk5 what?19:17
*** mauz555 has quit IRC19:23
daveshah_florent_: PLL is working, but still getting a low percentage of failures (Memtest data failed: 17/524288 errors, Memtest addr failed: 18/8192 errors) with memtest19:45
daveshahI have a few ideas which I will test tomorrow19:45
_florent_daveshah: great for the PLL. Have you tried with different phase shifts?20:12
daveshah_florent_: not yet20:12
daveshahI realised the IO were is slow slew mode20:12
daveshahI'm trying to fix that first20:12
_florent_daveshah: ah ok20:12
daveshahat the moment ps_clk which is also output to the sdram has a phase of 270 degress20:12
daveshah_florent_: seeing more errors with fast slew20:19
daveshahthis is very strange20:19
daveshahMemtest data failed: 86/524288 errors20:20
daveshahMemtest addr failed: 78/8192 errors20:20
*** fischerm has quit IRC21:11
*** springermac has quit IRC21:24
*** fischerm has joined #timvideos22:12
*** TimGremalm has quit IRC23:30
*** TimGremalm has joined #timvideos23:31
*** thaytan has quit IRC23:40
*** thaytan has joined #timvideos23:40
*** ChanServ sets mode: +v thaytan23:40
*** thaytan has quit IRC23:44
*** thaytan has joined #timvideos23:46
*** ChanServ sets mode: +v thaytan23:46
*** thaytan has quit IRC23:47
*** thaytan has joined #timvideos23:47
*** ChanServ sets mode: +v thaytan23:47
*** thaytan has quit IRC23:48
*** thaytan has joined #timvideos23:49
*** ChanServ sets mode: +v thaytan23:49
*** Kripton has quit IRC23:50
*** thaytan has quit IRC23:50
*** Kripton has joined #timvideos23:51
*** thaytan has joined #timvideos23:51
*** ChanServ sets mode: +v thaytan23:51

Generated by 2.13.1 by Marius Gedminas - find it at!