Monday, 2020-01-27

*** tpb has joined #tomu00:00
*** rohitksingh has joined #tomu03:21
*** rohitksingh has quit IRC04:16
daurnimatorokay back again06:52
daurnimatorI wrote a little program that prints hello world in a loop while counting06:53
daurnimatorit seems to stop at hello world 853906:53
daurnimatorgdb tells me its in `#0  0x000015d8 in ?? ()`06:54
daurnimatorNote: CPU is currently in a trap: Supervisor external interrupt at 0x0000139006:54
xobsHmm... Can't print out the debug symbols.07:10
xobsTry doing add-symbol-file on https://github.com/im-tomu/foboot/blob/master/releases/v2.0.3/pvt-foboot-v2.0.3.dfu07:11
tpbTitle: foboot/pvt-foboot-v2.0.3.dfu at master · im-tomu/foboot · GitHub (at github.com)07:11
xobsThen add a breakpoint on trap_entry07:11
xobsI.e. Download the elf, then inside gdb run "add-symbol-file pvt-foboot-v2.0.3.elf 0"07:12
xobsSorry, I probably shouldn't be doing this while on the train. I mean  https://github.com/im-tomu/foboot/blob/master/releases/v2.0.3/pvt-bios-v2.0.3.elf07:12
tpbTitle: foboot/pvt-bios-v2.0.3.elf at master · im-tomu/foboot · GitHub (at github.com)07:12
daurnimatorHave you ever had an issue where the led is purple when trying to do a colour wheel07:19
daurnimatorbut then when I single step through it.... it goes blue?07:19
daurnimator(I'm working on two issues in parallel here)07:29
daurnimatorgoing back to the debug mode issues: I'm having trouble even getting it stuck in that routine again. The device is now not responding to wishbone requests07:29
xobsWhen that happens, do you see it disappearing with "dmesg"?  That's the sort of thing that'll happen when something else tries to request a descriptor from the device when it's in that mode.07:31
*** krogozinski has quit IRC07:38
daurnimatoryes07:49
*** krogozinski has joined #tomu08:02
daurnimatorxobs: so how do I debug that?08:03
xobsDoes it happen after you type a command?  Or is it something else that's trying to enumerate usb?08:22
daurnimatornope08:22
daurnimatorhappens after I dfu-util up my code. it *might* run for a few milliseconds, but then it drops off usb08:22
xobsDo you see error messages in dmesg about it not responding, or does it simply disconnect?08:23
daurnimatorjust disconnects08:24
xobsIf you run "hexdump -C debug.bin | head" on the resulting binary, do you see the magic hex value anywhere in there?08:24
xobsSee if "5a 07 69 b4" is anywhere in there.08:25
daurnimatorits not there until `000011e0`08:26
xobsThat's why it's disconnecting, thenm.  You need to put that in the first 64 words (256 bytes).08:26
daurnimatorhmmm... that's what I thought I was doing... I wonder wtf is before it08:26
daurnimatoroops08:27
daurnimatorsorry. I dumped the .elf file08:27
daurnimatorits actually at 000001e008:28
daurnimatorwhich I suppose isn't much better08:28
xobsOh. `    for (i = 0; i < 32; i++) {`.  Guess it needs to be in the first 32 words (128 bytes).08:28
daurnimatorI still get to ask "wtf is before it" :P08:28
daurnimatorokay found the problem.... somehow _start is getting placed at 200401e808:30
daurnimatormaybe I was just getting lucky before as _start was my *only* symbol in an optimized build08:31
daurnimatorxobs: this is where I need to know more about how linker scripts work... `*(.text.start)` => what does that do?08:31
daurnimatoris that telling the linker to put the link section ".text.start" first?08:32
daurnimatoror is it saying the symbol "start" in the .text section?08:32
xobsIt says to insert everything in the ".text.start" section at that address.08:32
daurnimatoror something else08:32
daurnimatorokay so I at least guessed that correctly08:32
daurnimatorso now..... why *isn't* that happening08:33
daurnimatoro.o its like my linksection attribute is getting ignored08:34
daurnimatordoh, I was silly somewhere else08:44
daurnimatorbtw, what is the symbol `_gp` for?08:44
daurnimatorINFO [wishbone_tool::gdb] unrecognized GDB command: vCont;c:009:06
xobsI haven't seen that one myself.  I'm assuming it means "continue (thread #0)".09:08
xobsThere.  I added it as an alias.  Released v0.6.6.09:12
daurnimatorGot when I tried to use `stepi`09:12
xobsYes, that appears to be the command for "continue thread 0".09:14
xobshttps://sourceware.org/gdb/onlinedocs/gdb/Packets.html#vCont-packet09:14
tpbTitle: Debugging with GDB: Packets (at sourceware.org)09:14
daurnimatorso now that I have a _start symbol in the right place09:16
daurnimatormy setting of bss to 0 seems to be failing somehow?09:16
daurnimatoror at least... getting stuck in a loop maybe?09:16
daurnimatorbut whenever break execution, it seems to be stuck in that loop09:17
daurnimatorxobs: now that all patches I needed in zig are upstreamed... would you have time to have a go?09:18
xobsIs your bss aligned on 4-byte boundaries?  You can try doing `p/x &_sbss` and `p/x &_ebss` in gdb.09:24
daurnimatoryes.... and... they're both 0x1000000009:26
daurnimatori.e. 0-length bss09:26
daurnimatorwhy the fuck is it even in that loop09:26
xobsThat's fine, it means you have no BSS.09:26
daurnimatorokay something weird going on in linking.... all the linker things are 42949672909:30
xobsThat's a very strange number. 0x20000000-1.09:31
daurnimatormy program sees them as 0x20000000-1. but gdb sees them as 0x1000000009:33
daurnimatoris there something obvious that might be causing that?09:33
xobsYou should be looking at the address of them, not the actual value.09:33
daurnimatoryes I'm looking at the address09:34
xobsWhat do you get in gdb when you do `p/x &_sbss` and `p/x _sbss`?  Also, `x/x _sbss`09:35
daurnimator(FYI I called it _fbss)09:36
daurnimator1. 0x1000000009:37
daurnimator2. '_fbss' has unknown type; cast it to its declared type09:37
daurnimator3. same again09:37
xobsYou could do `p/x (int)_fbss`09:37
daurnimator`x/x (u32)_fbss` I get: 0xa <_start+10>:0x0000001309:38
xobsThat makes sense.09:38
daurnimator`p/x (u32)_fbss` I get: 0xa09:38
daurnimatorhuh.... Note: CPU is currently in a trap: Misaligned load address of 0xffffffff at 0x2004090409:39
xobsWell that looks promising.09:40
xobsWhat do you get when you do `disassemble 0x20040904`?09:40
xobsOr even `list *0x20040904`?09:40
daurnimator   0x20040904 <+24>:lwa3,0(a1)09:40
xobsYou can also do `b 0x20040904` followed by `mon reset`, and then `cont`09:41
xobsThat will reset and break on that particular line.09:41
*** js has quit IRC09:42
daurnimatorokay... I'm on the line09:42
xobsAnd I'm guessing `p/x $a1` will give you `0xffffffff`.09:43
xobsWhat is the line?  What does `list` give you?09:43
daurnimatorIt's in the zig standard library. zig/lib/std/io/out_stream.zig:3909:44
xobsYou can get a backtrace with `bt` and figure out how it got there.09:44
xobsYou can go up the stack with `up`, to figure out where it is in your code (if anywhere).09:44
daurnimatorI know how it got there... it should be there09:45
xobsBut it sounds like it's printing something out, and there is no stdout.09:45
daurnimatorI hooked it up to messible09:45
xobsWhat if you print "self"?09:46
xobsOr, actually, a1 is the "format" argument.09:47
daurnimatorxobs: can I walk you through getting to exactly where I am? :)09:47
xobsSo something there is printing, but giving you a NULL format string.09:48
xobsSure.09:49
daurnimatorxobs: 1. download and unpack zig master build: https://ziglang.org/download/09:49
tpbTitle: Releases · The Zig Programming Language (at ziglang.org)09:49
xobsGot it09:49
daurnimatorcheckout my PR https://github.com/im-tomu/fomu-workshop/pull/140/ e.g.: `cd fomu-workshop; git fetch origin refs/pull/140/head; git checkout FETCH_HEAD`09:50
tpbTitle: Add zig example by daurnimator · Pull Request #140 · im-tomu/fomu-workshop · GitHub (at github.com)09:50
daurnimator3. `cd riscv-zig-blink` then run: `../path/to/zig build run`09:51
xobsI get a ton of "error: PathAlreadyExists" messages09:52
xobsOh, it's just one error, but it's three pages long.09:54
daurnimatorhuh? which path?09:55
xobsIt doesn't specify.  And the entirety of the backtrace is in lib\zig\std09:56
daurnimatorcan you share the output?09:56
xobshttps://gist.github.com/xobs/d813a5b2d1161cd009edb22688dc7cdd09:57
tpbTitle: zig build run · GitHub (at gist.github.com)09:57
daurnimatoroh you're on windows, interesting09:57
daurnimatorugh, I actually have a PR that tidies up those code paths.10:02
daurnimator(but I didn't finish it for windows yet.... so it won't help you now)10:02
daurnimatorI guess you don't have a linux system handy?10:02
xobsI'll try in a Linux window.10:03
xobs`Unable to spawn llvm-objcopy: FileNotFound`.  Are there additional dependencies for zig?10:05
daurnimatorah no. that's in my build.zig file10:05
daurnimatorI didn't have binutils riscv objcopy on my machine; but native llvm-objcopy worked10:06
daurnimatorin build.zig you can just swap out "llvm-objcopy" for the objcopy you have10:07
xobsSo there's this variable `bss` which is a thing, but has an address of 0xffffffc8.10:10
xobsLikewise, &data and &rodata are at really weird locations.10:10
daurnimator&data would be a pointer to the pointer10:11
daurnimator(`data` is what we call a 'slice': its a struct with a pointer `.ptr` and a length `.len`)10:12
*** TheJJ has quit IRC10:15
xobs&data should be the address of data, which is invalid because it looks like the stack pointer is pointing to 0x10020000 for some reason.  I manually set it to 0x1001fffc and now at least I'm getting "PANIC: reached unreachable code"10:17
xobsNow, `p &data` gives 0x1001ff88, which looks like the right address for something that lives on the stack.10:18
daurnimatordid the preceding `la sp, _fstack + 4` not work or something?10:18
xobs&_fstack is 0x1001fffc, so that's adding 4 to it.10:19
xobsAh.10:24
xobs`assert(dest.len >= source.len);` -> `p dest: $14 = {ptr = 0x10000000 "\n", len = 0}`  `p source: {ptr = 0x200413b4 <panic> "\260\002\004 ", len = 224}`10:25
daurnimatorthat length is the result of `&_erodata - &_frodata`10:27
xobsRight, but `dest.len` is 0, which is not >= 224.10:30
daurnimatorcorrect: &_fdata and &_edata seem to be the same value?10:32
daurnimatorxobs: so where do _fdata and _edata come from? is it metadata from the bootloader somehow?10:41
daurnimatorno... they'd have to be hardcoded into the binary. they come from sram ORIGIN in the linker script10:42
*** TheJJ has joined #tomu10:42
xobsSo _fdata is the address of the start of data in RAM, frodata is the start of the data as it exists on the storage medium.  Since it's in the writable data section, you need to copy the entirety of the section from disk to RAM.10:43
xobsThe length of both should be 224.  You can ignore _edata since it's somewhat nonsensical.10:43
xobs_edata should be _fdata + (_eroata + _frodata)10:43
xobs * Er, _fdata + (_eroata - _frodata)10:44
daurnimator`.data : AT (ADDR(.rodata) + SIZEOF (.rodata))` <== is this meant to set the size of it somehow?10:45
xobsAh, okay.  So some confusion in the renaming of things.10:45
xobsThere's readonly data (,rodata), read-write data (.data), executable data (.text), writable data that happens to be zero (.bss), and stack.10:46
xobs.rodata and .text are effectively the same thing.  They live on SPI flash, and are XIP, so you can ignore them.10:46
xobs.bss is all zeroes, so you can ignore that, too.10:46
daurnimatorI thought in the linker script it was trying to set .data to be at least the size of .rodata?10:46
xobs.data must live in RAM, but RAM is uninitialized.  So pointers all point to the data as if it were in RAM, but the runtime needs to set that up.10:47
daurnimatorokay.... so the issue as I see it is that _edata isn't set correctly?10:48
xobsSo the linker script tells ld to place the physical bytes in the image just following .rodata, but to make all pointers look like they're in RAM.  Specifically, it's setting it up so that the .data section is stored on disk immediately following .rodata.10:48
xobsI think it is, I think it's just that you have no symbols in your data section.10:49
daurnimatorokay10:49
xobsThat line is trying to copy the entirety of rodata into data, but it needs to copy 0 bytes from &(rodata+rodata.len) into data.10:50
daurnimatorso why am I coping from rodata to data again?10:50
daurnimatorah, so I need to just copy from the end of rodata?10:50
xobsBecause the data section is stored on flash just after rodata.10:50
xobsYes.10:50
daurnimatorokay, so what's the source slice? `{.ptr = _erodata, .len = &_edata - &_fdata }` ?10:51
xobsShould be.10:52
xobsIf you define a variable and it's wrong, then you're off by some :)10:52
daurnimatorgoing back to an earlier question: what's _gp?10:53
daurnimatorguard page?10:53
xobsI'm guessing it's "global pointer".10:55
xobsThe linker script has some history.10:55
daurnimatorShould I remove the bits I don't use/need?10:55
xobsLooks like it came from the riscv group before 2017.10:55
daurnimatore.g. s/_gp/./10:55
xobsI'd say so, yes.10:55
daurnimatorxobs: in wishbone server, because the terminal output is raw, all the log messages don't get printed at the start of a line11:03
daurnimatori.e. after you enter raw mode, make sure you print log messages with \r\n instead of just \n11:03
xobsHow do you mean?11:03
daurnimatorxobs: e.g. http://sprunge.us/CrGYjY11:04
xobsHmm... Wonder what I can do about that...11:05
xobsAlso, I wonder why I don't see that problem on my systems.  Bizarre.11:14
daurnimatorpretty normal so far for me to see things like: http://sprunge.us/x4vF7Z11:26
daurnimatorWOOOOOO disco11:29
xobsWoo!11:29
daurnimator(I think my sleep function is broken)11:31
xobsThat happens.11:41
xobsHere's basically how you'd do msleep: https://github.com/im-tomu/foboot/blob/master/sw/third_party/libbase/time.c#L35-L4311:43
tpbTitle: foboot/time.c at master · im-tomu/foboot · GitHub (at github.com)11:43
daurnimatorxobs: you'll see I already have that in src/main.zig11:45
xobsAh, okay then!11:46
daurnimatorpushed current code to same branch11:47
daurnimatorif you re-pull you'll get a disco party too :P11:47
xobsIt looks like you're treating it as a 32-bit register, but it's really four 8-bit registers, one at 0xe0002800, one at 0xe0002804, one at 0xe0002808, and one at 0xe000280c.11:48
xobsYou're only setting the upper 8 bits: https://rm.fomu.im/timer0.html#timer0-load3 (unless `comptime` is somehow spreading it out to four individal writes)11:49
tpbTitle: TIMER0 Fomu Bootloader documentation (at rm.fomu.im)11:49
daurnimatorah11:54
daurnimatorwhy is it set out like that? seems very weird11:54
xobsBecause on an FPGA, you're mostly routing-constrained.  So the CSR bus is 8-bits, which means the router needs to only route 8 wires around.11:54
xobsA 32-bit CSR bus would work, it would just be more difficult to meet timing.11:55
daurnimatorSo if it does a 32 bit store... what ends up happening?11:55
xobsThe upper 24 bits are simply not connected to anything.11:56
xobsWishbone has all 32-bits hooked up, but all the peripherals are on the CSR bus, which is only 8 bits.  So a 32-bit store from the CPU to main memory will send all bits to RAM.11:57
daurnimatorokay11:58
daurnimatorfixing now :)11:58
xobsBut a 32-bit store to anything on the Litex CSR bus (i.e. anything documented on rm.fomu.im) will result in only 8 actual bits stored.11:58
thaytanlol, oops12:33
thaytanI just tracked down strange misbehaviour on my system to me adding /opt/fomu/fomu-toolchain-linux_x86_64-v1.5.3/bin to my PATH12:33
thaytanwhich gave me an extra, higher priority, copy of python312:34
xobsPython is hard.12:40
*** rohitksingh has joined #tomu13:08
daurnimatorgdb crash :( https://sourceware.org/bugzilla/show_bug.cgi?id=2547013:09
tpbTitle: 25470 Assertion hit in maybe_negate_by_bytes (at sourceware.org)13:09
daurnimatorxobs: my PR has been updated again.13:09
daurnimatorbefore marking the PR ready for merge: how should I hook it up to travis?13:12
xobsdaurnimator: gdb crashes a surprising amount :(13:16
xobsAlso, will it work on Windows and Mac?13:16
daurnimatorxobs: should. just need to fix that issue you hit on windows before13:16
daurnimator( https://github.com/ziglang/zig/pull/4184 is the upstream issue that I'll fix it in )13:17
tpbTitle: Improvements to std.fs by daurnimator · Pull Request #4184 · ziglang/zig · GitHub (at github.com)13:17
daurnimatorxobs: you may also note that I added a build option to specify the objcopy binary. long term that will be inside of zig itself too13:28
xobsOh, cool!  Users who are doing the workshop should have riscv64-unknown-elf-objcopy, and it's nice to know that it won't be needed in the future.13:37
daurnimatorTBH I'm not sure why it blinks.... I set `    fomu.RGB.setRegister(.OFR, 0); // Amount of time to stay "off"`13:37
daurnimatorah, of course, I'll update the default so they don't need to pass an extra arg13:38
xobsI think you want IFR to be 0 as well.13:39
xobsSince that number is the time it takes to fade in/out.  You don't want to have it fade at all.13:40
xobsThat's what I ended up doing in https://github.com/xobs/circuitpython/blob/fomu/ports/litex/common-hal/neopixel_write/init.c#L69-L8013:40
daurnimatorhmm okay. I was copying from https://github.com/im-tomu/fomu-workshop/blob/53cffe1761e24e631d79143ff05f36c27bb86885/riscv-blink/src/rgb.c#L41-L4213:41
tpbTitle: fomu-workshop/rgb.c at 53cffe1761e24e631d79143ff05f36c27bb86885 · im-tomu/fomu-workshop · GitHub (at github.com)13:41
daurnimatorxobs: I decided to stick with the C one14:04
daurnimatorit is called "blink" after all14:04
daurnimatornot "rainbow"14:04
xobsIt may be worth it to rework it.  I like rainbows, and as you've noted the fade behavior is somewhat unintuitive.14:07
daurnimatorxobs: anything else you'd like me to add to the PR?14:08
xobsEventually we should add it to the actual page as a section in the workshop.14:10
xobsCan you add information on how to install Zig?14:11
daurnimator"goto https://ziglang.org/download/ and follow the instructions you feel are most relevant for you" ? :p14:12
tpbTitle: Releases · The Zig Programming Language (at ziglang.org)14:12
daurnimatoradded a little bit to the readme14:37
*** rohitksingh has quit IRC14:50
daurnimatorNow moving on to the verilog part of the workshop :P14:52
daurnimator==> it doesn't blink!14:52
daurnimatorhttp://sprunge.us/VA78cn14:52
xobsI thought you had a PVT board and not a hacker board.14:53
daurnimatorI do I think?14:55
xobsThat command is using the PCF file for the hacker board.14:56
xobsThe minimal blink example looks like it only works for Hacker boards, which probably should be considered a bug.14:58
daurnimatorhuzzah, the expanded example works15:04
* daurnimator learnt vhdl in uni; verilog is new to me15:06
xobsEventually we'll have vhdl. I think.15:08
*** emeb has joined #tomu15:20
daurnimatorxobs: thanks for helping me be stupid with linker files15:44
daurnimatorI understand them better now :)15:44
*** rohitksingh has joined #tomu15:48
*** im-tomu has left #tomu16:24
*** im-tomu has joined #tomu16:24
acathlaI broke my fomu :( where can I order a new one? xobs?16:42
*** rohitksingh has quit IRC16:48
*** rohitksingh has joined #tomu16:57
*** im-tomu has left #tomu17:26
*** im-tomu has joined #tomu17:27
*** rohitksingh has quit IRC17:48
*** rohitksingh has joined #tomu17:49
*** im-tomu has left #tomu18:36
*** im-tomu has joined #tomu18:37
*** rohitksingh has quit IRC19:14
polloacathla: Crowdsupply: https://www.crowdsupply.com/sutajio-kosagi/fomu19:21
pollobecause of manufacturing problems, there might be a delay before they get shipped though: https://www.crowdsupply.com/sutajio-kosagi/fomu/updates/pcbs-are-here19:22
*** rohitksingh has joined #tomu19:31
*** rohitksingh has quit IRC19:47
*** coderobe3 has joined #tomu19:49
*** Vercas_ has joined #tomu19:50
*** coderobe has quit IRC19:51
*** coderobe3 is now known as coderobe19:51
*** Vercas has quit IRC19:51
*** rohitksingh has joined #tomu20:03
acathlapollo, thank you.20:10
*** rohitksingh has quit IRC20:16
*** js has joined #tomu20:23
*** spacekookie_ has joined #tomu20:26
*** xantoz has quit IRC20:27
*** pollo has quit IRC20:27
*** pollo has joined #tomu20:28
*** js has quit IRC20:28
*** spacekookie has quit IRC20:28
*** rohitksingh has joined #tomu20:29
*** xantoz has joined #tomu20:30
*** kgugala has quit IRC20:35
*** rohitksingh has quit IRC20:39
*** CarlFK has quit IRC21:47
*** rohitksingh has joined #tomu22:56
*** js has joined #tomu23:08
*** rohitksingh has quit IRC23:14
*** CarlFK has joined #tomu23:28
*** im-tomu has left #tomu23:30
*** im-tomu has joined #tomu23:30
*** CarlFK has quit IRC23:37
*** CarlFK has joined #tomu23:38
*** CarlFK has quit IRC23:44
*** Vercas_ is now known as Vercas23:44
*** GNUtoo has quit IRC23:51

Generated by irclog2html.py 2.13.1 by Marius Gedminas - find it at mg.pov.lt!