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
Alistair[m]1 has joined #rust-embedded
<Alistair[m]1> <andar1an[m]> "seems like tock supports riscv..." <- Yeah! Tock has pretty good support for RISC-V. Even runs on QEMU
<Alistair[m]1> and the Rust userspace for Tock is starting to get embedded-hal support. We can even drive displays now: https://github.com/tock/libtock-rs/tree/master/demos
jr-oss has quit [Quit: ZNC 1.7.2+deb3 - https://znc.in]
jr-oss has joined #rust-embedded
AtleoS has joined #rust-embedded
chek has quit [Ping timeout: 252 seconds]
PaulDFaria[m] has joined #rust-embedded
<PaulDFaria[m]> What's the current recommendation for one-time initialization of a static now that we can no longer create mutable references to static mut values? I was previously just using `static mut A: T = ...` with `unsafe { static = initial_value };` then using `static B: &'static T = &A`. I understand now why it's UB, but I can't figure out what a zero-cost alternative looks like. I don't care if the init is more expensive, I just want
<PaulDFaria[m]> the reads later on to be as cheap as possible.
chek has joined #rust-embedded
<GrantM11235[m]> You can use https://crates.io/crates/static_cell
<PaulDFaria[m]> Oh that also lists alternatives too. I'll read up on all the options. Thank you!
MathiasKoch[m] has quit [Quit: Idle timeout reached: 172800s]
Curid[m] has quit [Quit: Idle timeout reached: 172800s]
RobertJrdens[m] has joined #rust-embedded
<RobertJrdens[m]> <PaulDFaria[m]> "What's the current recommendatio..." <- Also `cortex_m::singleton!()`
<JamesMunns[m]> I need to make a flow chart for this :D
<JamesMunns[m]> Let's see, the qualifiers I can think of:... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/HsnjtIIgXCFWQbWOPzILvIRM>)
<JamesMunns[m]> not sure the ordering of questions, but open to other qualifier suggestions :)
<thejpster[m]> Despite https://github.com/rust-lang/team/pull/1471, and https://github.com/rust-embedded/wg/pull/763, I'm still in https://github.com/orgs/rust-embedded/teams/all and getting pings on tickets (like the minutes for yesterday).
<thejpster[m]> Should I have been removed automatically, or do I have to do that manually? Is there a "guide to leaving the WG" that covers all the steps you need to take?
<thejpster[m]> For now, I've left all the github teams manually.
<JamesMunns[m]> CC therealprof ^
<JamesMunns[m]> I thought that was all managed by the rust-lang bots, it's possible the all team wasn't? Not sure. Sorry for the noise!
<thejpster[m]> I was left in the Cortex-M team too. And for the avoidance of doubt, I'm not that bothered - I just want the WG to have a better process so that it doesn't bother someone in the future.
<JamesMunns[m]> yeah, there's no "wg-embedded-all" team, it's likely that's a manual one, OR we should add the following to the `wg-embedded.toml`:... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/xHVHytfniHorlgueTBkqzPuV>)
<JamesMunns[m]> lemme open a WG issue.
<JamesMunns[m]> Robert Jördens I don't think it's possible to use `singleton!` for uninit memory
<JamesMunns[m]> at least, if the "has been taken" boolean is also resident in uninit mem, and not in normal .bss/.data
<JamesMunns[m]> yeah, the bool here would be uninit too
<RobertJrdens[m]> Right. Feels like a fixable (make the flag MaybeUninit as well) bug (as it is undocumented and doesn't require any unsafe to hit it) in cortex-m.
<JamesMunns[m]> yeah, it can't just be MU, it needs to be unsafely declared "was init at some point"
<JamesMunns[m]> unless we split the bool into regular static, but then we have to explain that the $meta only forwards to the PAYLOAD of the object, not the metadata
<RobertJrdens[m]> Agreed.
<RobertJrdens[m]> Taking a step back, `singleton!()` does two arguably distinct things: the singleton and the static mut part. Maybe worth splitting
<JamesMunns[m]> open to discuss, hoping to address that with grounded, which I hope to later upstream to the wg.
<RobertJrdens[m]> <JamesMunns[m]> "* In Uninit memory? Y/N..." <- > <@jamesmunns:beeper.com> * In Uninit memory? Y/N... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/pveXzIbpHAoarfhgCeSevFWx>)
<RobertJrdens[m]> Ah. That's your `init at compiletime"
<RobertJrdens[m]> s/`/"/, s/compiletime/compile time/
<RobertJrdens[m]> And expand the "shared" question to DMA aspects. May or may not be the same as "shared across cores".
<RobertJrdens[m]> And "Does it ever change after initialization?"
<JamesMunns[m]> Not *sure* we need to capture "DMA" as a separate item, if it's shared access, it'll always be code that "gives it away" and "takes it back" from DMA ownership
<JamesMunns[m]> (I could be wrong, but that's my current thought)
<RobertJrdens[m]> Well the interlocking/handover mechanism changes. For DMA it's MMIO flags, for cores/interrupts it's Atomic flags, Mutexes, IRQ prio levels etc.
<RobertJrdens[m]> And the Mutex case is one that may show up the the flow diagram.
<thejpster[m]> bartmassey and the docs team - have you seen https://opentitan.org/book/doc/rust_for_c_devs.html before?
<JamesMunns[m]> yeah, there might be some room for specialization too. grounded has a "re-allocatable" item, which you could use to safely give ownership for DMA transfer, where if you `forget` the "Box", it's leaked forever
<JamesMunns[m]> RobertJrdens[m]: yesish... but I don't think DMA will ever do the unlocking itself. And you'd need a HAL-specific type to do that for you
<JamesMunns[m]> JamesMunns[m]: IMO the code will always do the locking/unlocking "by proxy" on behalf of the DMA.
<thejpster[m]> > Rust does not quite support inline assembly yet.
<thejpster[m]> Maybe they'll take patches for the book.
<RobertJrdens[m]> And as a sidenote/special case of this I'd really like to know if anyone has made a full analysis of the correctness of use ITCM on e.g. STM32H7 (initialize, copy from flash, start executing). Or are there no soundness/UB pitfalls (which would be surprising)?
<JamesMunns[m]> might be worth pinging the oxide folks, I know they use it in prod too, largely with their own HAL stack IIRC.
bartmassey[m] has joined #rust-embedded
<bartmassey[m]> thejpster[m]: I have not. There are so many Rust resources now I can't keep easy track of 'em all.
<bartmassey[m]> Thanks huge for this link!
<JamesMunns[m]> bartmassey[m]: > <@po8:matrix.org> I have not. There are so many Rust resources now I can't keep easy track of 'em all.... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/yjQylZYnLuaWFqpboxypcFWT>)
<RobertJrdens[m]> The UB definition tends to refer to data only, not to instructions. So I have no idea. What the assumptions from the LLVM side of things.
<RobertJrdens[m]> * The UB definition tends to refer to data only, not to instructions. So I have no idea what the assumptions from the LLVM side of things are.
<bartmassey[m]> thejpster[m]: > <@thejpster:matrix.org> > Rust does not quite support inline assembly yet.... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/EhXudjjkBwkfpoYxjafNFsmc>)
<JamesMunns[m]> RobertJrdens[m]: hmmm, yeah, also might be worth pinging Amanieu d'Antras
<thejpster[m]> bartmassey: ah, I meant maybe Open Titan will take patches. So we can fix the part that says "inline assembly isn't stable yet".
<bartmassey[m]> thejpster[m]: Ah I thought I remembered something like that left in our book. Knew I'd seen it somewhere
<JamesMunns[m]> Robert Jördens my current thoughts on this: https://gist.github.com/jamesmunns/4e54d64737b67523cc193578584752c6
<JamesMunns[m]> Happy to take comments or suggestions. I'd probably say `singleton!()` could work anywhere `StaticCell` does
<vollbrecht[m]> JamesMunns[m]: > <@jamesmunns:beeper.com> Robert Jördens my current thoughts on this: https://gist.github.com/jamesmunns/4e54d64737b67523cc193578584752c6... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/lPSxVkDSVKKzhffdxhlnYYag>)
<vollbrecht[m]> * "This is weird, sorta like oncecell but only once per clean boot? Dunno." sounds like waking up from deep-sleep and accessing rtc memory again on esp's ;D
<JamesMunns[m]> yeah, that's a fair point!
<JamesMunns[m]> I should probably add "example use cases" for each line item, like "this is when you are doing RTC backed up mem", or "this is when you want uninit buffers for DMA" etc.
<vollbrecht[m]> yeah good idea, even if that example doesn't cover the complete usability of an item in the list.
cr1901_ has joined #rust-embedded
cr1901 has quit [Ping timeout: 268 seconds]
<RobertJrdens[m]> <JamesMunns[m]> "Robert Jördens my current..." <- > <@jamesmunns:beeper.com> Robert Jördens my current thoughts on this: https://gist.github.com/jamesmunns/4e54d64737b67523cc193578584752c6... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/jhDISHlfwVgsrZdejMtrAMHo>)
<JamesMunns[m]> yeah, "reboot persistent" is definitely weird, tho a major use case I want to use grounded for (I already do, but inside of the existing uninit types, I need to put a safer API on it)
IlPalazzo-ojiis1 has joined #rust-embedded
korken89[m] has quit [Quit: Idle timeout reached: 172800s]
<diondokter[m]> Is anybody aware of a Rust crate built on top of something like nusb that can talk the PICOTOOL protocol over USB to an RPi Pico?
<diondokter[m]> Lol, pi pico docs
AmanieudAntras[m has joined #rust-embedded
<AmanieudAntras[m> <JamesMunns[m]> "hmmm, yeah, also might be..." <- What is the specific question?
<JamesMunns[m]> <AmanieudAntras[m> "What is the specific question?" <- I think it was roughly "is `fence()` suitable for soundness around ICTM/Instruction cache initialization/management, or is there something else (portable) we should be doing? Or does it always require platform specific asm barriers? Maybe Robert Jördens can clarify better.
badyjoke[m] has joined #rust-embedded
<badyjoke[m]> Hello, what do you think of RTIC ? In the case I don't have a supported hal (or only a pac) for embassy is it a good choice ?
<RobertJrdens[m]> Is the mere presence of uninitialized/invalid instruction memory a problem? Is writing instructions into that memory (copy from flash into MaybeUninit ITCM, proper DMB/DSB/ISB/fence/flushes) and then later executing them OK?
<JamesMunns[m]> badyjoke[m]: RTIC is definitely well known here, but you could use either embassy or RTIC with your own custom HAL. Neither has to be a "fallback" choice :)
<diondokter[m]> Yeah, they each have their strengths
<RobertJrdens[m]> JamesMunns[m]: And you can use components of embassy on RTIC as well. They aren't even mutually exclusive.
henrik_alser[m] has quit [Quit: Idle timeout reached: 172800s]
<AmanieudAntras[m> <RobertJrdens[m]> "Is the mere presence of uninitia..." <- It should be fine. Fundamentally that's not much different than calling `dlopen` in a Linux process.
cr1901_ is now known as cr1901
mburton[m] has quit [Quit: Idle timeout reached: 172800s]
AtleoS has quit [Ping timeout: 246 seconds]
AtleoS has joined #rust-embedded
<AlexandrosLiarok> Anyone using nix has a working workflow for packaging embedded rust projects?
RockBoynton[m] has joined #rust-embedded
<RockBoynton[m]> <AlexandrosLiarok> "Anyone using nix has a working..." <- yes, using naersk. I can send what I have when I'm back at my computer
<AlexandrosLiarok> <RockBoynton[m]> "yes, using naersk. I can send..." <- Thanks a ton. I did have something woth naersk working but had some issues with nested projects with relative sibling paths.
<AlexandrosLiarok> s/woth/with/
<AlexandrosLiarok> AlexandrosLiarok: I think I just made things work with pkgsCross infra but needed some hacks to patch cargoBuildHook
<AlexandrosLiarok> AlexandrosLiarok: Isn't naersk unmaintained?
AtleoS has quit [Ping timeout: 246 seconds]
<RockBoynton[m]> <AlexandrosLiarok> "Thanks a ton. I did have..." <- I have everything in a cargo workspace and add a -p to the cargo flags
IlPalazzo-ojiis1 has quit [Quit: Leaving.]