ChanServ changed the topic of #rust-embedded to: Welcome to the Rust Embedded IRC channel! Bridged to #rust-embedded:matrix.org and logged at https://libera.irclog.whitequark.org/rust-embedded, code of conduct at https://www.rust-lang.org/conduct.html
<re_irc> <@whitequark:matrix.org> _stares at probe-run_
<re_irc> <@whitequark:matrix.org> fn analyze_vector_table(core: &mut Core) -> anyhow::Result<(u32, u32)> {
<re_irc> let stack_start = core.read_core_reg::<u32>(SP)?;
<re_irc> I do not think that does what it says it does.
<re_irc> let reset_address = cortexm::set_thumb_bit(core.read_core_reg::<u32>(PC)?);
<re_irc> <@whitequark:matrix.org> (I checked, it was like that in the very first commit that introduced either the name or the code)
<re_irc> <@jamesmunns:beeper.com> just because it's getting the measured pc/sp instead of the values from the actual code image/vector table?
<re_irc> <@whitequark:matrix.org> yes
<re_irc> <@jamesmunns:beeper.com> I think they halt on start before reading that?
<re_irc> <@jamesmunns:beeper.com> "get values that normally live in the vector table"? :p
<re_irc> <@whitequark:matrix.org> I implemented most of https://github.com/knurling-rs/probe-run/issues/354 and this is the one place where there are issues still
<re_irc> <@whitequark:matrix.org> it doesn't make much of a difference one way or another in the current implementation, largely by a series of coincidences
<re_irc> <@jamesmunns:beeper.com> Yeah, I don't know all of the decisions that went into that. I wonder what rtt-host does. I think it might actually scan for the rtt block? But if you're attaching (and promise that the elf is what is currently running), I dunno why you wouldn't just pull those values from the elf
<re_irc> <@whitequark:matrix.org> no idea! I think it may predate elf analysis
<re_irc> <@whitequark:matrix.org> in any case I'll just fix it up to do what it says on the tin
<re_irc> <@jamesmunns:beeper.com> Maybe! probe-run always used the elf tho to store the interned data, and I think (maybe later?) get line numbers from debuginfo
<re_irc> <@whitequark:matrix.org> ahh huh
<re_irc> <@jamesmunns:beeper.com> : Either way, they'll probably appreciate that :D
<re_irc> <@whitequark:matrix.org> oh I forgot probe-rs has its own channel
<re_irc> <@adamgreig:matrix.org> (though note that probe-run isn't a probe-rs project)
<re_irc> <@whitequark:matrix.org> oh right.
<re_irc> <@adamgreig:matrix.org> "probe-rs-cli run" is, though, heh
<re_irc> <@whitequark:matrix.org> : _stares_ so it actually _feeds the reset vector read from hardware_ *into the elf parser*
<re_irc> <@whitequark:matrix.org> _*after throwing out the reset vector it got from the elf*_
<re_irc> <@jamesmunns:beeper.com> thats certainly a thing to do
<re_irc> <@adamgreig:matrix.org> (at first, probe-rs was mostly a library plus cargo-flash/cargo-embed, knurling wrote probe-run using probe-rs, it was a great idea and became very widely used, probe-rs has more recently added "probe-rs-cli run" which does some of the same things in a different way, I guess)
<re_irc> <@adamgreig:matrix.org> (the "probe-rs-cli" binary was today renamed to just "probe-rs", too)
limpkin has quit [Server closed connection]
limpkin has joined #rust-embedded
starblue2 has joined #rust-embedded
starblue1 has quit [Ping timeout: 240 seconds]
<re_irc> <@whitequark:matrix.org> https://github.com/knurling-rs/probe-run/pull/414
<re_irc> <@whitequark:matrix.org> ... wait, i could have been using cargo embed all this time ? oops
cr1901_ has joined #rust-embedded
cr1901 has quit [Ping timeout: 240 seconds]
kenny has quit [Ping timeout: 258 seconds]
kenny has joined #rust-embedded
<re_irc> <@thejpster:matrix.org> : How do you know which four bytes of the ELF are the reset vector?
crabbedhaloablut has quit [Ping timeout: 240 seconds]
Darius has joined #rust-embedded
Darius has quit [Server closed connection]
<re_irc> This is what I do in stackdump. You just get the vector table section from the name. This works because everyone uses cortex-m-rt (in Rust and on cortex m)
crabbedhaloablut has joined #rust-embedded
richardeoin has quit [Server closed connection]
richardeoin has joined #rust-embedded
Guest62 has joined #rust-embedded
<Guest62> hello guys, did someone wrtie RISC-V RTOS in Rust already?
Guest62 has quit [Client Quit]
<re_irc> <@burrbull:matrix.org> https://github.com/rtic-rs/rtic/pull/733
<re_irc> <@pollyglot:pyjam.as> what does the "x lines y" reactions by heisenbridge mean?
<re_irc> <@pollyglot:pyjam.as> also Hi 👋
<re_irc> <@k900:conduit.0upti.me> It means it copied the long post to the IRC side
<re_irc> <@pollyglot:pyjam.as> doesn't it do that with every message?
<re_irc> <@pollyglot:pyjam.as> I'm viewing this from the Matrix side
<re_irc> <@k900:conduit.0upti.me> It does that, but longer messages are broken up into more than one on IRC
<re_irc> <@k900:conduit.0upti.me> I'm not sure why this is considered important information
<re_irc> <@k900:conduit.0upti.me> But it marks those specially
<re_irc> <@pollyglot:pyjam.as> oh okay
<re_irc> <@pollyglot:pyjam.as> thanks!
<re_irc> <@osten_music:matrix.org> Hey, I'm wondering if the flash (read, write, erase) implementations for various microcontrollers has been standardized with traits?
seds has quit [Server closed connection]
seds has joined #rust-embedded
starblue2 has quit [Ping timeout: 252 seconds]
starblue2 has joined #rust-embedded
<re_irc> <@romancardenas:matrix.org> Is there any mechanism to force atomic-polyfill to use the critical-section emulation even if I'm using a riscv32imac target?
<re_irc> <@dirbaio:matrix.org> no ( :
<re_irc> <@dirbaio:matrix.org> * :(
<re_irc> <@dirbaio:matrix.org> why do you need it?
<re_irc> <@romancardenas:matrix.org> because I'm facing a lot of problems with my board and compare exchange functions
<re_irc> <@romancardenas:matrix.org> I don't know why but load stores work OK and compare_exchange etc. cause exceptions
<re_irc> <@dirbaio:matrix.org> which chip is it? perhaps itps -imc and not -imac?
<re_irc> <@romancardenas:matrix.org> I discussed this with the RTIC folks and seems a bug in the rustc codegen
<re_irc> <@dirbaio:matrix.org> * it's
<re_irc> <@romancardenas:matrix.org> It is an FE310g002, so it is imac
<re_irc> <@dirbaio:matrix.org> O_o
<re_irc> <@romancardenas:matrix.org> I tried to change the target to imc but the e310x-hal crate uses atomics so... I'm doomed
<re_irc> <@dirbaio:matrix.org> well, you can still run -imc code on an -imac chip if you don't trust the CAS instruction implementation (either silicon's or rustc's)
<re_irc> <@dirbaio:matrix.org> : oh, oog
<re_irc> <@dirbaio:matrix.org> * oof
<re_irc> <@romancardenas:matrix.org> I'll try to do a crappy fork of atomic-polyfill and add a feature to skip the build cfgs
<re_irc> <@dirbaio:matrix.org> if it uses only atomic load/store and not CAS you can force-enable these on -imc with these flags https://github.com/knurling-rs/defmt/pull/707#issuecomment-1488035240
<re_irc> <@dirbaio:matrix.org> -imc can do load/store fine, rustc should make these available in "core::sync::atomic" like it does in thumbv6m but it doesn't. see https://github.com/rust-lang/rust/issues/99668
<re_irc> <@dirbaio:matrix.org> these flags force-enable them
<re_irc> <@romancardenas:matrix.org> I'll take a look, thanks!
<re_irc> <@dirbaio:matrix.org> if e310x-hal uses CAS then... good luck 😓
<re_irc> <@dirbaio:matrix.org> : is there an issue for this?
<re_irc> <@dirbaio:matrix.org> * a rustc
<re_irc> <@dirbaio:matrix.org> if these things don't get reported they won't get fixed...
<re_irc> <@romancardenas:matrix.org> I opened it a while ago: https://github.com/rust-lang/rust/issues/110857
<re_irc> error[E0432]: unresolved import `core::sync::atomic::AtomicU32`
<re_irc> <@romancardenas:matrix.org> Whit those rustc flags I get the following error:
<re_irc> <@romancardenas:matrix.org> The "e310x-hal" crate imports "AtomicU32" and it seems that the flags are not enough...
<re_irc> <@dirbaio:matrix.org> huh, not sure then. Perhaps they're outdated or something
<re_irc> I haven't personally tried them...
<re_irc> <@dirbaio:matrix.org> perhaps you need build-std
dne has quit [Server closed connection]
dne has joined #rust-embedded
<re_irc> <@romancardenas:matrix.org> I ended up doing the polyfill hack
<re_irc> <@romancardenas:matrix.org> Would you be interested on this feature ?
<re_irc> <@romancardenas:matrix.org> I can open a PR if so
<re_irc> <@romancardenas:matrix.org> In case someone wants to take a look: https://github.com/embassy-rs/atomic-polyfill/pull/25
<re_irc> <@9names:matrix.org> do you know which instructions it's generating for the compare exchange?
<re_irc> <@romancardenas:matrix.org> Nope, and I don't think I know how to check that. Could you provide me some pointers to do that?
<re_irc> something like
<re_irc> cargo objdump --release -- --disassemble
<re_irc> <@9names:matrix.org> sure! usually i would use cargo-binutils' objdump to get that info out.
<re_irc> <@9names:matrix.org> if you don't already have cargo binutils:
<re_irc> cargo install cargo-binutils
<re_irc> rustup component add llvm-tools-preview
<re_irc> <@romancardenas:matrix.org> Thanks, I'll take a look!
IlPalazzo-ojiisa has joined #rust-embedded
<re_irc> <@9names:matrix.org> I'll be asleep soon, so here's the spoiler of what I'm guessing _might_ be the cause (from the chip reference manual):
<re_irc> > The E31 core supports the RISC‑V standard Atomic (A) extension on the DTIM and the peripheral memory region. Atomic memory operations to regions that do not support them generate an
<re_irc> > access exception precisely at the core. The load-reserved and store-conditional instructions are only supported on cached regions, hence generate an access exception on DTIM and other uncached memory regions.
<re_irc> <@9names:matrix.org> this is definitely better than the case for bl602, where they had atomic operations but didn't have any atomic memory regions 🙃
<re_irc> <@romancardenas:matrix.org> Ooops, it definitely sounds like that's the problem
<re_irc> <@whitequark:matrix.org> : the ones loaded at the beginning of flash? the code in probe-run already made the assumption that the IVT is located there, at least
<re_irc> <@whitequark:matrix.org> (I would say "the ones mapped at 0x0" but I think probe-run also specifically assumes flash is being used rather than SRAM)
<re_irc> <@dirbaio:matrix.org> probably easier to look for the ".vector_table" section?
<re_irc> <@diondokter:matrix.org> I think that is what happens yes
<re_irc> <@dirbaio:matrix.org> no, it currently flashes the elf, then reset-and-halts the core, and then _reads_ PC and SP from it
<re_irc> <@diondokter:matrix.org> Oh ah
<re_irc> <@diondokter:matrix.org> It used to do it though :)
<re_irc> <@diondokter:matrix.org> At least for the stacktrace
<re_irc> <@dirbaio:matrix.org> yeah, I don't understand why it was changed
<re_irc> <@dirbaio:matrix.org> git history doesn't have much clues
<re_irc> <@dirbaio:matrix.org> it breaks if your ELF is not the very first thing that runs at boot (bootroms, bootloaders, softdevice...)
<re_irc> <@dirbaio:matrix.org> because it gives the bootloader's reset vector, not your ELF's
<re_irc> <@dirbaio:matrix.org> 🤷
<re_irc> <@diondokter:matrix.org> Been working fine with our bootloader though...
<re_irc> <@dirbaio:matrix.org> this is what caused probe-run 0.3.8 to break (was broken for lots of people for ~1mo until 0.3.9 was released)
<re_irc> <@dirbaio:matrix.org> 0.3.9 added some checks to make it not explode if the reset vector doesn't point to inside the ELF
<re_irc> <@dirbaio:matrix.org> but it's still using the wrong reset vector 🤷
<re_irc> <@romancardenas:matrix.org> : Found the following atomic instructions:
<re_irc> lr.w.aqa4, (a1)
<re_irc> sc.w.rla5, a5, (a1)
<re_irc> The atomic variables are part of a static struct, so probably they're not on a cached region...
<re_irc> ...
<re_irc> <@jamesmunns:beeper.com> : has a PR open that changes this, I believe, there was some discussion last night
<re_irc> <@jamesmunns:beeper.com> (I could see "halt and read" as a fallback option if the elf doesn't have that section, but I'm not sure if anything else would work reasonably if you are missing debuginfo)
<re_irc> <@onsdag:matrix.org> : This is very specific to Espressif RISC-Vs since they’ve got sort of a different interrupt handling mechanism. I do have the CLIC in the back of my mind though, and I know is working on a software emulation to make RTIC work on virtually any RISC-V (although it doesn’t take full advantage of the hardware acceleration part of the framework, the runtime guarantees still hold)
<re_irc> <@onsdag:matrix.org> +of the CLIC
<re_irc> <@onsdag:matrix.org> : Dunno why the quote disappeared but that was pertaining this
edm has quit [Server closed connection]
edm has joined #rust-embedded
Dr_Who has joined #rust-embedded
emerent has quit [Ping timeout: 246 seconds]
emerent has joined #rust-embedded
cr1901_ is now known as cr1901
<re_irc> <@fork027:matrix.org> Hey all, trying to get through the discovery package with the mirco:bit board, and getting stuck with gdb. I have an older mac OS not supported by homebrew, and don't know how to proceed without gdb. any advice?
<re_irc> I've gotten minicom to open, but not in connection to any specific project or file, it opens a generic terminal regardless of the path fed to the command.
dc740 has joined #rust-embedded
dc740 has quit [Remote host closed the connection]
dc740 has joined #rust-embedded
IlPalazzo-ojiisa has quit [Quit: Leaving.]
xnor has quit [Server closed connection]
xnor has joined #rust-embedded
dc740 has quit [Remote host closed the connection]
Rahix has quit [Quit: ZNC - https://znc.in]
Rahix has joined #rust-embedded
<re_irc> <@pacarito:mozilla.org> Is there an updated version of https://docs.rust-embedded.org/book/intro/index.html , buecause my Debian system is missing some of the packages referenced there.
<re_irc> <@pacarito:mozilla.org> +?
<re_irc> <@pacarito:mozilla.org> * because
<re_irc> <@adamgreig:matrix.org> which packages in particular? that's the latest version but it may need updating
<re_irc> <@pacarito:mozilla.org> "db-arm-none-eabi openocd qemu-system-arm"
<re_irc> <@adamgreig:matrix.org> for debian that page suggests gdb-multiarch which I think you should have?
<re_irc> <@adamgreig:matrix.org> and afaik openocd and qemu-system-arm are still around
jr-oss has quit [Server closed connection]
jr-oss has joined #rust-embedded