<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.
<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, 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
<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.
<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.
<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.
<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]>
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.
<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?
<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