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
fisch02 has quit [Ping timeout: 240 seconds]
tiwalun[m] has joined #rust-embedded
emerent has quit [Ping timeout: 272 seconds]
emerent_ has joined #rust-embedded
emerent_ is now known as emerent
emerent has quit [Ping timeout: 252 seconds]
emerent has joined #rust-embedded
emerent has quit [Ping timeout: 245 seconds]
fisch02 has joined #rust-embedded
cinemaSundays has joined #rust-embedded
dirbaio[m] has quit [Quit: Idle timeout reached: 172800s]
fisch02 has quit [Quit: Client closed]
chomp4570[m] has quit [Quit: Idle timeout reached: 172800s]
<JamesMunns[m]> @9names practically, I know you're right, and there has to be a reason for it. But uuuuuuuuugh
<JamesMunns[m]> I don't know how atomics aren't a given in a multicore design
<JamesMunns[m]> Sometimes simple is too simple
dirbaio[m] has joined #rust-embedded
<dirbaio[m]> You still have atomic load/store so you can do stuff like ringbuffers
<dirbaio[m]> <tiwalun[m]> "> <@thejpster:matrix.org> https:..." <- Ooo got the code somewhere?
mchodzikiewicz[m has quit [Quit: Idle timeout reached: 172800s]
<tiwalun[m]> <dirbaio[m]> "Ooo got the code somewhere?..." <- Yeah, I can share it later
cinemaSundays has quit [Quit: Connection closed for inactivity]
jsolano has quit [Quit: leaving]
<tiwalun[m]> <tiwalun[m]> "Yeah, I can share it later" <- Might take some more time than expected, it's not blinking anymore 😕 It worked 3 months ago 😅
i509vcb[m] has joined #rust-embedded
<i509vcb[m]> From the TI simplelink parts there is what they call the "Sensor Controller" but it uses some proprietary architecture.
jsolano has joined #rust-embedded
diondokter[m] has joined #rust-embedded
<diondokter[m]> If so, how do you share a flag between two cores? (While also being hardware-agnostic)
<diondokter[m]> The problem is not initializing it, but the other reading core may race the initializing core
<JamesMunns[m]> Ideally your init code would initialize it to a known value
<FreeKill[m]> You can't have both cores do that
<diondokter[m]> FreeKill[m]: Yeah that's the problem
<JamesMunns[m]> Ideally you'd have a predictable boot sequence
<JamesMunns[m]> Like how core1 on the rp2040 halts until started.
<diondokter[m]> This is for embassy dual core code. So we don't really know what the user does
<JamesMunns[m]> Failing that, putting it into an unsafe cell and using fences is likely to deter the optimizer from assuming things it shouldn't about the code
<diondokter[m]> And STM32, so both cores start at the same time
<FreeKill[m]> How do peripheral registers work at the end of the day? Those don't get initialised
<JamesMunns[m]> FreeKill[m]: Those use volatile access of memory outside of the abstract machine.
<FreeKill[m]> Isn't that kind of the same?
<diondokter[m]> FreeKill[m]: Right now they do volatile reads and writes. But that only works by the grace of the project.
<diondokter[m]> At some point they want to introduce separate operations for mmio memory
<diondokter[m]> FreeKill[m]: Well this is in the abstract machine
<JamesMunns[m]> FreeKill[m]: This is where you get into "poorly specified and frequently misunderstood bits of Rust" :)
<JamesMunns[m]> JamesMunns[m]: And yeah, if it's a static, it's inside the abstract machine
<diondokter[m]> So right now the dual core code has `init_primary` and `init_secondary` where the user gives both a reference to a `MaybeUninit<SharedData>`.
<diondokter[m]> The `init_secondary` needs to wait until `init_primary` is done, so there's an atomic int in the `SharedData` that once it's set to a specific value signals that `init_primary` is done. The second core does a spinloop on the value.
<JamesMunns[m]> You almost definitely want an unsafe cell if it can be modified outside of a single core
<FreeKill[m]> That sounds very exciting during a soft reboot situation
<diondokter[m]> JamesMunns[m]: Aren't atomics made for that though?
<JamesMunns[m]> Ah, but atomics are unsafecells
<diondokter[m]> Yeah
<JamesMunns[m]> I mean: it's Christmas and I've had a beer or two, so my answer is that atomics and things in unsafecells are likely to work, but I don't know if reading a "potentially uninit" atomic is sound or well specified
<JamesMunns[m]> * to work (and likely to keep working), but
<diondokter[m]> Like, what's annoying is that nothing really can go wrong with the operations themselves except that it potentially makes the compiler do weird optimizations
<JamesMunns[m]> But I'm also not sure if there IS an officially sound way to do this today. I want it for persistent data across soft resets. I put it in an unsafecell maybeuninit
<FreeKill[m]> JamesMunns[m]: The persistence of data across soft reset makes me scared of the sentence "once it's set to a specific value" :D
<diondokter[m]> Yeah, all other data is in extra UnsafeCells
<JamesMunns[m]> FreeKill[m]: RAM only loses values when the ram is unpowered (sleep modes, full power off), it'll generally persist across soft resets.
<FreeKill[m]> Exactly
<FreeKill[m]> So spinning the second core waiting for a specific value is spooky, because that specific value may be there from the last time :D
<JamesMunns[m]> So: yeah, you might want to unset the value as the second core acking the boot
<diondokter[m]> JamesMunns[m]: Yeah that's already done
<FreeKill[m]> That still leaves a window ;)
<FreeKill[m]> If you're VERY unlucky
<diondokter[m]> Yes
<diondokter[m]> I don't know how to fix that haha
<diondokter[m]> Two values maybe?
<FreeKill[m]> On our dual core STM32 we use the option byte that stops the second core being clocked at startup
<diondokter[m]> FreeKill[m]: Yep, that works. Not sure if we can/want mandate that in embassy as a whole though
<FreeKill[m]> There is also the hardware semaphore peripheral for this exact purpose, I think
<FreeKill[m]> I assume that's on all the dual cores
<diondokter[m]> I don't know...
<FreeKill[m]> But I think that has defined values at reset, which gets you out of this
<diondokter[m]> Anyways, gonna make a PR to make it a little better than it was, so... at least it's a bit better :P
<FreeKill[m]> better is better!
laenzi[m] has quit [Quit: Idle timeout reached: 172800s]
fisch02 has joined #rust-embedded
<i509vcb[m]> Hmm I've come across an SVD file that has no %s placeholders for array clusters
<i509vcb[m]> which is a little annoying since svd-tools and chiptool are not capable of reading said SVD file
<i509vcb[m]> Nor can I write a patch since the initial parse fails
<i509vcb[m]> PWM_DUTYCYCLE_REG_WR_VALUEn in https://raw.githubusercontent.com/SiliconLabs/wiseconnect/refs/heads/master/resources/ozone_config/siwx917.svd (line 9076) and another 44 instances all don't have a %s placeholder which ends up meaning the svd parser just bails