<re_irc>
Isn't it possible to get the defmt working after we jump to the Firmware.
<re_irc>
I am not able to get the defmt (deferred formatting) work for my Firmware.
crabbedhaloablut has quit [Ping timeout: 255 seconds]
crabbedhaloablut has joined #rust-embedded
starblue has quit [Ping timeout: 260 seconds]
starblue has joined #rust-embedded
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #rust-embedded
<re_irc>
< (@chemicstry:matrix.org)> : I'm not sure if trustzone causes you additional issues, but it could be that you are reinitializing RTT block from firmware, which throws off the debugger. You have to initialize RTT manually in that case, because defmt/rtt_target libs do not support reusing already initialized block. Here is what I did: https://gist.github.com/chemicstry/939293905c7766330c73f39efaee2ebd You then wire up...
<re_irc>
... "TERMINAL_CHANNEL" as defmt sink
<re_irc>
< (@chemicstry:matrix.org)> I'm not sure if trustzone causes you additional issues, but it could be that you are reinitializing RTT block from firmware, which throws off the debugger. You have to initialize RTT manually in that case, because defmt/rtt_target libs do not support reusing already initialized block. Here is what I did: https://gist.github.com/chemicstry/939293905c7766330c73f39efaee2ebd You then wire up returned...
<re_irc>
... "UpChannel" as defmt sink
<re_irc>
< (@chemicstry:matrix.org)> oh and you also need to define rtt block section in linker so that it is always in the same RAM location
<re_irc>
< (@chemicstry:matrix.org)> for both bootloader and firmware
fooker has quit [Ping timeout: 268 seconds]
fooker has joined #rust-embedded
<re_irc>
<riskable> Anyone have any ideas why this single bit of code would cause my firmware to hang?
<re_irc>
.product("Riskeyboard 70")
<re_irc>
.manufacturer("Riskable")
<re_irc>
let usb_key_dev = UsbDeviceBuilder::new(usb_bus, UsbVidPid(VID, PID))
<re_irc>
<riskable> It's an old stm32f4xx_hal (stm32f411) project that I resurrected recently to make a very minor change. It compiles fine after making the change but when I flash and run it it just hangs. I put in a zillion debug statements to figure out that's where it hangs 🤷
<re_irc>
<riskable> The thing that baffles me: This isn't part of the code that changed! haha
<re_irc>
<riskable> I even tried getting rid of basically everything else the code does. It's an RTIC (0.5) project and I basically reduced it to a bare bones thing to narrow this down
<re_irc>
< (@dirbaio:matrix.org)> maybe it's panicking. Maybe add a "panic!("foo");" to check that your panic message printing is working
<re_irc>
< (@dirbaio:matrix.org)> that looksok, it should print the panic message...
<re_irc>
<riskable> For reference, I suspect this _could_ be a bug that was introduced in some version of "stm32f4xx-hal" version 0.9.X but since that package went through a pretty rapid and regular evolution no one noticed (it's now on 0.14.X). Right now I'm thinking I'll try various older versions of the 0.9 series to see if that fixes it and if not probably start porting this to the latest & greatest RTIC stuff
<re_irc>
< (@anand21:matrix.org)> : Thank you for the response. so what i understood is We need to add this code in the firmware, and avoid re initialisation of rtt.
<re_irc>
is this correct?
<re_irc>
< (@chemicstry:matrix.org)> : well it's a snippet from a "startup" code so it has a lot of hacks and might need massaging to get working. But the general idea is that you have to do same initialization as those libs do (defmt/rtt), but omit overwriting RTT block if it's already there
<re_irc>
< (@chemicstry:matrix.org)> I guess you could also modify the libs and submit a PR for such use case
<re_irc>
< (@anand21:matrix.org)> : Ok thank you for the clarification. Will try to raise a PR.
<re_irc>
<riskable> OK nothing I've tried works so *I guess I'm porting this code to RTIC 1.1! This is going to take _hours_... Sigh
<re_irc>
< (@datdenkikniet:matrix.org)> can you see any useful information when you break the program at the point where it hangs?
<re_irc>
< (@datdenkikniet:matrix.org)> (defmt-rtt has support for backtraces, I believe)
<re_irc>
< (@datdenkikniet:matrix.org)> * believe, but not sure if/what kind of changes it would require to activate it if you haven't, yet)
<re_irc>
< (@datdenkikniet:matrix.org)> maybe can you find some useful information in the backtrace when you break the program at the point where it hangs?
<re_irc>
< (@datdenkikniet:matrix.org)> maybe can you find some useful information in the backtrace if you interrupt the program at the point where it hangs?
<re_irc>
< (@datdenkikniet:matrix.org)> as in: is it "just" that line with the UsbDeviceBuilder, or does the point at which "build" hangs give some useful feedback?
<re_irc>
< (@datdenkikniet:matrix.org)> +(assuming that it's "build")
cr1901 has quit [Read error: Connection reset by peer]
cr1901 has joined #rust-embedded
cr1901_ has joined #rust-embedded
cr1901_ has quit [Remote host closed the connection]
cr1901 has quit [Read error: Connection reset by peer]
cr1901 has joined #rust-embedded
cr1901 has quit [Read error: Connection reset by peer]
cr1901 has joined #rust-embedded
cr1901 has quit [Read error: Connection reset by peer]
cr1901 has joined #rust-embedded
<re_irc>
<riskable> OK so I just updated everything to the latest & greatest RTIC, stmf4xx_hal, and others and... Wow, I wish the borrow checker could've told me this _before_ haha:
<re_irc>
ERROR panicked at 'already borrowed: BorrowMutError', /home/riskable/.cargo/registry/src/github.com-1ecc6299db9ec823/usb-device-0.2.9/src/bus.rs:194:36
cr1901 has quit [Read error: Connection reset by peer]
cr1901 has joined #rust-embedded
DepthDeluxe_ has joined #rust-embedded
<re_irc>
<riskable> For reference, if you're getting a similar 'already borrowed' error when trying to use "UsbDeviceBuilder" it's because you need to create your other USB devices _before_ that in the code. For example, I'm creating a USB mouse and a keyboard. I had the mouse code after I was calling "UsbDeviceBuilder" which was causing that error.
<re_irc>
< (@korken89:matrix.org)> They do not interact with locks
<re_irc>
< (@korken89:matrix.org)> That does not matter in RTIC, locals are simply "&mut" references to static memory with appropriate imposed lifetime
<re_irc>
< (@korken89:matrix.org)> The side effect must be from optimization happening in a different way