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
lanre[m] has joined #rust-embedded
<lanre[m]> Sorry if i sound stupid, i am.
<lanre[m]> New to embedded rust and new to everything embedded that's not an arduino.
<lanre[m]> * Sorry if i sound stupid, i am.
<lanre[m]> New to embedded rust and new to everything embedded that's not an arduino.
<lanre[m]> Should i get a nRF52840 DK or a STM dev board?
<lanre[m]> * Sorry if i sound stupid, i am.
<lanre[m]> New to embedded rust and new to everything embedded that's not an arduino.
<lanre[m]> Should i get a nRF52840 DK or a STM32 dev board?
<JamesMunns[m]> No need to be mean to yourself, we all started fresh at some point :)
<JamesMunns[m]> Both STM32 and nRF52 make pretty good dev boards, I'd maybe recommend the nRF52: I find it a little less complicated than the STM32 sometimes, but either would be reasonable!
<JamesMunns[m]> We have a book based on the BBC microbit, which is also an nrf52 based board: https://docs.rust-embedded.org/discovery/microbit/
<JamesMunns[m]> And some other docs that might help!
<lanre[m]> JamesMunns[m]: > <@jamesmunns:beeper.com> And some other docs that might help!... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/ZgIZGXvYLOoVDwSgQQQLOsEz>)
<SbastiendHerbais> Anybody's got a good allocator to recommend? I have 32 MB of external SRAM that I'd like to use :D
<JamesMunns[m]> If you'd like to use the standard library, you might want to check out the ESP32 devices. They've implemented the standard library. Most other boards don't, because they don't have an operating system (the ESP32 optionally can be based on FreeRTOS)
<JamesMunns[m]> for the nrf52 though, you can check out embassy-nrf52, and the nrf-softdevice crate, those will give you access to BLE
<JamesMunns[m]> SbastiendHerbais: One I've been meaning to check out is "talc", which I think is a little inspired by mimalloc? The typical go-to is `linked-list-allocator`, which is simple but not the best for performance, depending on your access patterns
<SbastiendHerbais> Never heard of it before, it looks awesome, thanks!
<JamesMunns[m]> Ah it's based on dlmalloc not mimalloc
<lanre[m]> JamesMunns[m]: looks active and up to date, thanks. Do you recommend the full DK board, or should i work with the Seeed Studio XIAO nRF52840?
<lanre[m]> i also don't want to fry anything expensive
<JamesMunns[m]> I'd definitely recommend the DK, or another board that has a "debugger" on board, this will make learning and developing much easier. Both the microbit and the DK have this, but the XIAO doesn't.
<lanre[m]> JamesMunns[m]: is this debugger a UART console (sorry i have no clue what that means)?
<JamesMunns[m]> Yeah! So Cortex-M chips have what's called a "SWD" or "Single Wire Debug" port: if you've heard of "JTAG" before, it's like that.
<JamesMunns[m]> This lets your PC reprogram, or peek into the memory of the microcontroller. In Rust, we usually use this for programming the chips, and then getting logs back, or even using GDB to do "single step" debugging, being able to run one line of code at a time and peek into the memory of the chip to see what it is doing.
<JamesMunns[m]> This is really useful when your code crashes, which happens a lot when you are learning! If you don't have a debugger, it usually just stops running and you don't know why. With a debugger, you can get the exact reason why, and figure out where your code crashed.
<JamesMunns[m]> (those boards ALSO usually have a UART console through the debugger, and a "virtual console" you can use for logs)
<JamesMunns[m]> which means less external hardware to wire up :)
<JamesMunns[m]> Having an SWD debugger (like the one that comes on the DK), lets you use tools like https://probe.rs/ which makes programming the chip really easy
<JamesMunns[m]> and by the way, most STM32 boards like the Discovery or Nucleo boards will also have a debugger on board like this as well!
<lanre[m]> so SWD is not the USB interface?
<JamesMunns[m]> (but a lot of the cheaper dev boards, or boards from Adafruit or Sparkfun won't, unfortunately)
<JamesMunns[m]> nope! It's a different interface. the DK has two USB ports on it:
<JamesMunns[m]> one for the debugger, and one that is wired up to the nRF52
<lanre[m]> okay i better start reading then, thank you so much!
<JamesMunns[m]> Definitely feel free to ask questions here, there are lots of people that can help :)
<SbastiendHerbais> Any idea how I can fix this delightful error using talc:... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/dycZbRRRSVvQiAsOgdSeuGoA>)
<JamesMunns[m]> whew
<JamesMunns[m]> not sure, I haven't actually used talc, I just looked at it and it seemed cool
<SbastiendHerbais> I could just use a static mut that is linked into a new section for it, but it means i would need to modify probe-rs again
pbsds3 has quit [Ping timeout: 244 seconds]
Avery[m] has joined #rust-embedded
<Avery[m]> So I am wanting to attempt to use CAN to a global logger for defmt. But I can already tell that I am probably going to run into ownership issues because I would also like to use the peripheral for messages other than just logging. How might I go about dealing with this?
<Darius> put the messages on a queue?
<Darius> then the thing reading from the queue is all that needs to own the CAN peripheral
pbsds3 has joined #rust-embedded
<Avery[m]> That could be a solution if I run into issues, I've done it before in embassy (I'm using RTIC for this project) , but the peripheral already has a fifo built in. I'd end up having issues with a queue or a channel. I'm unsure how to get it from initialization to the defmt trait implementation
PedroFerreira[m] has quit [Quit: Idle timeout reached: 172800s]
<ryan-summers[m]> Avery: I did this with USB for a project where the USB is also used for a serial terminal. Check out https://github.com/quartiq/booster/blob/main/src/logger.rs. I used an MPMC queue for the log entries and then passed in the USB periodically for processing the queued logs
<MathiasKoch[m]> ryan-summers:
<MathiasKoch[m]> What are my options for no-alloc solutions instead of `String` in `Path<String, ..>`? (miniconf)
<thejpster[m]> Today I got timer interrupts working on a Cortex-R system and by jove itโ€™s tricky doing it from scratch without cortex-m and cortex-m-rt to help.
<thejpster[m]> I even got ThreadX running on top of my Rust code. Itโ€™s a ThreadX sandwich with Rust underneath it and Rust on top of it.
<thejpster[m]> Also itโ€™s completely unclear to me how to make a UART represent ownership with a PAC singleton. I ended up making the constructor unsafe.
vollbrecht[m] has quit [Quit: Idle timeout reached: 172800s]
dngrs[m] has joined #rust-embedded
<dngrs[m]> <MathiasKoch[m]> "ryan-summers:..." <- > <@mathias_koch:matrix.org> ryan-summers:
<dngrs[m]> > What are my options for no-alloc solutions instead of `String` in `Path<String, ..>`? (miniconf)
<dngrs[m]> Not sure if it helps in your situation but heapless has a String
<ryan-summers[m]> Yeah, it's anything that impl Write. heapless::String is what we use
<MathiasKoch[m]> ๐Ÿ‘๏ธ
<thejpster[m]> PE Micro announce a Rust SDK for controlling their embedded programmers. Nice to see.
<thejpster[m]> (I'm a few weeks late - I only saw it today in their newsletter)
<thejpster[m]> oh no. I copy-pasted my critical-section implementation, and then my code exploded because it tried to borrow the UART twice.
<thejpster[m]> it's probably not sufficient when you are running multiple threads in ThreadX
jakzale has quit [Remote host closed the connection]
jakzale has joined #rust-embedded
ilya-epifanov[m] has quit [Quit: Idle timeout reached: 172800s]
<thejpster[m]> hmm, actually it might have been enough. Disabling interrupts stops the timer interrupt from firing.
<thejpster[m]> Anyway, the actual problem was the tasks did not have enough stack.
<thejpster[m]> And now it uses a proper ThreadX mutex.
<diondokter[m]> thejpster[m]: > <@thejpster:matrix.org> hmm, actually it might have been enough. Disabling interrupts stops the timer interrupt from firing.... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/zSfMURvKXFUORdLhoQsEdWQC>)
<SbastiendHerbais> diondokter[m]: Bare metal for the win ๐Ÿ˜…
<thejpster[m]> I honestly thought TheadX would have some kind of stack watermark check. But maybe that's optional and I didn't turn it on.
<thejpster[m]> also I haven't configured a debugger that can inspect ThreadX task state. If I had that, this would have been obvious. Also I don't have defmt/rtt, so logging is really expensive.
<thejpster[m]> If anyone knows how to do defmt/rtt from inside QEMU without using a UART, I'd love to see that. I have an idea involving semihosting and spawing defmt-print on a pty, but I haven't done it yet.
<thejpster[m]> the comments say something about using atomic fences to guard access to atomic values, but I want to guard access to an RTOS mutex
<thejpster[m]> ah, maybe I want compiler_fence
<dirbaio[m]> the defmt repo has tests printing from a qemu firmware
<dirbaio[m]> over semihosting
<dirbaio[m]> thejpster: ^
<thejpster[m]> huh
<thejpster[m]> never actually thought to look at my own repo
<thejpster[m]> https://github.com/ferrous-systems/threadx-experiments/pull/10 - well there's the UART version.
<SbastiendHerbais> Is it normal that embassy_stm32 doesn't have (any) control registers for LPTIM{1..5}?
<SbastiendHerbais> (still in an STM32S7)
<SbastiendHerbais> s/STM32S7/STM32H7S7/
<SbastiendHerbais> Regular stm32h7xx-hal does have the control registers required and even a "high level" interface for it :(
<SbastiendHerbais> Can one use two HALs at once?
<dirbaio[m]> stm32h7xx-hal doesn't support stm32h7rs at all
<SbastiendHerbais> true, I forgot that, hmmm
<SbastiendHerbais> that is tricky
<dirbaio[m]> and stm32h7rs is not stm32h7 at all, it's a new family.
<dirbaio[m]> for example DMA is completely different
<SbastiendHerbais> I see, I am in a way enduring the early-adopter tax
<dirbaio[m]> yeah ๐Ÿฅฒ
<SbastiendHerbais> Do you have a hint on where to get started to add support for LPTIM in embassy-stm32?
<dirbaio[m]> what registers are you missing for lptim?
<SbastiendHerbais> from what I can see: all of them, lemme find you the list
<dirbaio[m]> I mean, they're present in the PAC
<dirbaio[m]> you should be able to do raw register access with pac::LPTIM1.whatever().write(....)
<SbastiendHerbais> Are they? ๐Ÿค”
<SbastiendHerbais> Ah yes you're right!
<SbastiendHerbais> Then it shouldn't be too hard to port code over from the C BSP from ST
<dirbaio[m]> what's missing is a high-level driver in embassy-stm32 (ie not raw register access)
<dirbaio[m]> you don't need one to use LPTIM, you can always use the registers directly
<dirbaio[m]> (but if you want to make one, PRs welcome, of course ๐Ÿ™ƒ)
<SbastiendHerbais> I'll try to make one, there are also pin assignment stuff missing iirc
<SbastiendHerbais> Like pins for PWM outputs
adamgreig[m] has joined #rust-embedded
<adamgreig[m]> hi @room, meeting time again! this week we're mainly focussing on discussing potential project goals that are relevant to embedded; the agenda discussion is https://github.com/rust-embedded/wg/discussions/778. please feel free to add anything else you want to discuss and if we have time left over we can get to them too. we'll start in a few mins!
<adamgreig[m]> and do add any announcements you have too
jannic[m] has joined #rust-embedded
<jannic[m]> I wondered if it would make sense if I joined the triage team. Should I add that question as an agenda item?
<adamgreig[m]> sure :)
therealprof[m] has joined #rust-embedded
<therealprof[m]> I think the triage team has kind of vanished. But we can certainly entertain giving people triage rights to shuffle stuff around a bit more efficiently.
<JamesMunns[m]> Everyone gets busy sometimes. I'm supportive of empowering folks that are willing to help now :)
<adamgreig[m]> ok, let's begin! does anyone have any announcements?
<adamgreig[m]> none from me this week
jessebraham[m] has joined #rust-embedded
<jessebraham[m]> therealprof[m]: Sorry, I had joined and then kind of disappeared for awhile. Happy to start performing my duties, but I'm not really sure what to do ๐Ÿ˜…
<jessebraham[m]> Is there any sort of documentation for onboarding people? Would be a good first step if not
<JamesMunns[m]> This is a good call, and we should maybe talk about that. I think "resolve issues you can", and "raise issues in the weekly meeting you can't" is a good start, but we definitely could use docs
<jessebraham[m]> I just feel kind of weird jumping into projects I'm not familiar with or directly involved with and using my gut you know? Haha
<jessebraham[m]> So being able to point people to rationale behind my decisions would be nice :)
<adamgreig[m]> yea, having even some brief docs might help make it feel easier or more sensible
<adamgreig[m]> cool, well let's start with project goals discussion and then talk about triage team members/docs?
<adamgreig[m]> James Munns already wrote this intro comment that links to the project goals description https://github.com/rust-embedded/wg/discussions/778#discussioncomment-10129529
<adamgreig[m]> but the gist is, the goals are a target that is agreed upon between someone interested in pushing it forward and the team(s) that would have to approve it, without a promise that it'l get merged but with at least an acknowledgement that it's something everyone involved wants to see happen
<adamgreig[m]> the goals for 2024H2 are already set, so we're talking about things to work on in 2025H1, for which discussions begin in october
<adamgreig[m]> (of course if we pick something now and it gets done sooner, that's great too)
<adamgreig[m]> the goals don't have to be huge, but since we're talking about fairly long term planning and work, they're probably all reasonably significant features/changes/stabilisations, I think?
<adamgreig[m]> so perhaps the best place to start is to see if people do have some ideas on what things embedded developers would really like to see in rust next year
<JamesMunns[m]> I think now might be good to enumerate any long term "suboptimal" items we've had, I tried to name mine :)
<adamgreig[m]> I checked out the last time we made a big effort to enumerate this sort of thing in 2019, and a lot of the items are in fact done now ๐ŸŽ‰
<JamesMunns[m]> It is good though to separate PROJECT goals and ECOSYSTEM goals, perhaps
<adamgreig[m]> so from that comment we have... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/LFcQcSfzuEbIPoDVHdmSyYVd>)
<adamgreig[m]> ah indeed, where "project goals" are things we'd have to work on with rust-lang, and ecosystem goals are things that happen outside of the rust project?
<JamesMunns[m]> e.g., what things do we need rust project team support for (compiler/stdlib features). As opposed to ecosystem goals, like "we should have a good USB host stack", etc.
<adamgreig[m]> like perhaps the "tools for mut statics" and then for us specifically probably things like the new documentation efforts
<JamesMunns[m]> oh, another long term one I'll add to my list, "ram funcs" stuff
<adamgreig[m]> there were also a few ideas on https://github.com/rust-embedded/wg/issues/775, including mutable statics and better support for trustzone-m ABIs
<therealprof[m]> JamesMunns[m]: I don't actually recall what exactly was missing there. I know it worked somewhat.
<jannic[m]> JamesMunns[m]: Making sure that a function in RAM doesn't internally call something in flash? That would be great!
<therealprof[m]> Was it just ergonomics?
<adamgreig[m]> you can put a function in ram, but there's no way to ensure all the functions it calls are also put in ram
<adamgreig[m]> including std/core functions and methods
<JamesMunns[m]> Yeah, it was the fact that ram functions can call non-ram functions
<jannic[m]> And intrinsics!
<JamesMunns[m]> including if the optimizer turned some code into a memcpy
<JamesMunns[m]> yeah
<JamesMunns[m]> lol
<adamgreig[m]> they have to get inlined, or you have to have manually annotated all the functions you call to put them in ram too (not possible for things in libraries/std)
<thejpster[m]> Just a drive by comment to say that, having written a lot of Cortex-R code lately, thereโ€™s almost zero Cortex-R examples to go on.
<thejpster[m]> Also, showing that a function is panic free.
<adamgreig[m]> panic-free functions and in-ram functions seem spiritually a bit similar
<therealprof[m]> Well, my motivation for ramfunc was to get rid of the flash read WS.
<thejpster[m]> Also it sucks that you canโ€™t stably recompile libcore with, say, M-Profile Vector Extensions. Or double precision FPU support.
<adamgreig[m]> yea, there's lots of good reasons to need it
<adamgreig[m]> runtime interrupts too
<adamgreig[m]> thejpster: that's the `build-std` stabilisation, right?
<JamesMunns[m]> thejpster[m]: Adam did mention "stabilize buildstd", I wonder if that's a path forward, esp with the long tail of riscv attributes?
<adamgreig[m]> yea, it feels like it might help unlock a lot of the "my target is a bit niche/my requirements are a bit specialist/the default options aren't quite right for me" customisations embedded people want
<JamesMunns[m]> We did have soft support for doing this at RustNL
<JamesMunns[m]> I think the response was something like "put together a proposal and we can start stabilizing things"
<JamesMunns[m]> so I think that could be a very good candidate.
<adamgreig[m]> yep, I understand the cargo team didn't appreciate how desirable it was and didn't have anyone working on it, but would be happy to look at proposals to get it stabilised
<therealprof[m]> Indeed.
<therealprof[m]> Seems like an important building block that unlock some more interesting features.
<adamgreig[m]> thejpster: for cortex-r, what sort of thing are you thinking of? more of a wg effort to improve docs/examples/libraries?
<JamesMunns[m]> yeah, tbh, I wonder if that's really our prime candidate to focus on
<adamgreig[m]> i fear without individuals who are specifically motivated to work on cortex-r it won't happen by itself, but i can definitely see the appeal for a lot of industrial embedded users
<JamesMunns[m]> adamgreig[m]: thejpster if we can get any end users or silicon vendors you know of to chime in on this, it would likely be very interesting.
<adamgreig[m]> the function-doesn't-panic annotation seems neat too and maybe the analysis/propagation that's needed is similar to ramfunc? the former seems like it might have a lot of use outside of embedded, while ramfunc is very very embedded-specific
<JamesMunns[m]> I know the answer is usually "it's complicated" tho
<JamesMunns[m]> adamgreig[m]: I wonder if dirbaio has opinions here from cargo-call-stack? Tho I think that has a lot of downstream-from-llvm issues
<adamgreig[m]> yea... i can't think of anyone i know well who's using cortex-r atm, it feels like really its own world distinct from the cortex-m users
<adamgreig[m]> better stack analysis would also be really nice for embedded but it's probably not as interesting as the other points
<JamesMunns[m]> I meant in term of the metadata necessary to do that kind of analysis, but there may not actually be any dots there to connect :)
<JamesMunns[m]> * kind of static analysis, but
<adamgreig[m]> oh sure, just pondering if it would also be a nice thing to have
<therealprof[m]> I'm sorry, something came up, gotta run.
<adamgreig[m]> anything else on our embedded wishlist?
<adamgreig[m]> it does feel a bit like we've got so much recently it's hard to know what else to want... or it's been so long we've forgotten, heh
<JamesMunns[m]> I think maybe focusing on build-std, and any second order capabilities might be a good first effort.
<adamgreig[m]> I guess the idea of what else is in scope has narrowed a bit. it would be cool if we could have New Linker Scripts That Don't Suck And Are Built In To Rust or something
<jannic[m]> Sorry if I missed it, but have the questions regarding how to do volatile accesses properly been resolved? And relationship between mmio and the rust memory access rules?
<adamgreig[m]> or zig's Yea Just Build C, Whatever
<JamesMunns[m]> jannic[m]: ohhh that's a good one
<JamesMunns[m]> JamesMunns[m]: Amanieu suggested shaking out a "specifically mmio and none of the other use cases of volatile" interface
<adamgreig[m]> probably as a method on pointers iirc?
<adamgreig[m]> like read_mmio instead of read_volatile
<adamgreig[m]> arbitrary self types would be nice for that too ๐Ÿฅบ
<JamesMunns[m]> For anyone who wasn't at RustNL: volatile is surprisingly poorly specified how it interacts with a lot of stuff, instead of trying to formalize all of volatile, it might be easier to say "this is a method SPECIFICALLY not for 'normal RAM addrs', e.g. you can never use it on a regular static and stuff"
<JamesMunns[m]> this makes it much easier to say "don't optimize, doesn't interact with anything outside the Rust model, no worries on provenance", etc.
<adamgreig[m]> (and e.g. limited to word size, whereas you can use write_volatile on a like 50kB struct pointer and who knows what will happen)
<adamgreig[m]> yea, that seems like a great one to prioritise too
<adamgreig[m]> iirc we talked about just introducing those as methods that are implemented in assembly in the cortex-m crate today and then consider moving into core?
bartmassey[m] has joined #rust-embedded
<bartmassey[m]> book report tl/dr; one more week. Done with the initial edit of the existing text, currently merging Henk and Adam's chapters and working on a script for easily re-numbering chapters. Then will set up publishing/CI and merge to main. See https://github.com/BartMassey-upstream/discovery-mb2:dev for the latest stuff.
<adamgreig[m]> sweet, good work!
<JamesMunns[m]> adamgreig[m]: maybe worth a standalone crate so riscv can join in on the fun?
<adamgreig[m]> either that or implement them in the riscv(-pac?) crate too?
<bartmassey[m]> Probably a traits crate and impls of the traits in the various ยตc crates?
<adamgreig[m]> perhaps easier to just have the impls in the central crate in that case
<adamgreig[m]> like portable-atomic
<bartmassey[m]> May have arch-specific barriers and such, so either compile features or traits I guess.
<adamgreig[m]> it's arch-specific asm, so we'll need compile features anyway
rmsyn[m] has joined #rust-embedded
<rmsyn[m]> adamgreig[m]: yeah, could always just feature-gate the arch-specific stuff
<JamesMunns[m]> adamgreig[m]: dunno if it makes sense but I wonder if there could be some path to stabilizing portable-atomic or critical-section
<dirbaio[m]> i'm not sure if you can get the "can't be reordered wrt other atomics, but can be reordered wrt other memory accesses" properties with inline asm...?
<adamgreig[m]> they're already stable, do you mean incorporate in std?
<JamesMunns[m]> adamgreig[m]: yeah, maybe "upstream" and not "stabilize"
<adamgreig[m]> dirbaio: you can add fences to ensure "can't be reordered" but not sure how it would interact with reordering with other memory accesses
<dirbaio[m]> fences would prevent all reordering
<adamgreig[m]> which i guess is in theory desirable.. maybe?
<JamesMunns[m]> adamgreig[m]: yeah, I think Amanieu suggested fence + asm block?
<dirbaio[m]> you do want to allow reordering with regular memory accesses
<dirbaio[m]> not allowing it would hurt perf
<adamgreig[m]> to make sure people can continue writing a DMA descriptor just after transferring ownership to the DMA engine :P
<JamesMunns[m]> Probably good to capture this in a new issue or something and bug Amanieu again in writing :)
<JamesMunns[m]> we might have it in the minutes from RustNL, but it was a pretty quick and off the cuff conversation
AmanieudAntras[m has joined #rust-embedded
<AmanieudAntras[m> It's not clear what is being asked for exactly...
<dirbaio[m]> q is: if we were to replace atomics with asm, is there a way to keep the semantics of volatile of "can't be reordered with other volatile accesses, can be reordered with regular memory accesses"
<AmanieudAntras[m> Asm is volatile by default unless you specifically use pure.
<dirbaio[m]> by "is volatile" you mean it allows reodering with all regular memory accesses, but not with other asm blocks?
<dirbaio[m]> seems it doesn't allow reordering by deault
<dirbaio[m]> s/deault/default/
<dirbaio[m]> but adding "nomem" would allow it?
<AmanieudAntras[m> Yes, nomem + !pure means it is volatile but not ordered with other memory accesses.
<dirbaio[m]> ah, awesome ๐Ÿ‘๏ธ
<adamgreig[m]> but can we put nomem on something that reads/writes a pointer in mmio?
<dirbaio[m]> thanks for clarifying
<JamesMunns[m]> adamgreig[m]: (specifically addresses that are outside the abstract machine)
<dirbaio[m]> adamgreig[m]: yea, the whole point is mmio is not "memory" according to the abstract machine, it's just IO
<adamgreig[m]> I guess if it won't touch any AM memory then maybe it won't make a difference, yea
<AmanieudAntras[m> nomem can't access any memory that is accessed by normal Rust. MMIO is fine as long as you don't also use normal read/write operations on that same MMIO.
<adamgreig[m]> seems like that could work nicely then
<jannic[m]> Related: While https://doc.rust-lang.org/std/ptr/fn.write_volatile.html does only guarantee "not be elided or reordered by the compiler across other volatile operations", does the rust compiler actually do reorder volatile accesses with non-volatile ones? Just because it would be allowed to, it doesn't mean that it does actually take advantage of the possibility.
<dirbaio[m]> it does
<JamesMunns[m]> also, technically ordering between atomics and volatiles is completely undefined, IIRC?
<JamesMunns[m]> (which is why we might want fences for this, for the "make sure your DMA RAM buffer is ready before you press 'go' via MMIO")
<adamgreig[m]> if we add fences we're back to no re-ordering, so that should probably be more something the HAL has to get right
<adamgreig[m]> anyway we are getting a bit off-topic ๐Ÿ˜… shall we run through the other points in the last 8min or so?
<adamgreig[m]> adamhott, you wanted to recruit volunteers?
<adamhott[m]> Yeah, I'd like 1-2 to review a proposal WIP
<adamhott[m]> for a Rust Foundation Project
<adamhott[m]> It's short doc
<adamhott[m]> Thanks adam
<adamgreig[m]> cool, get in touch with adamhott directly if you can help!
<adamhott[m]> yeah send me a DM if you can
<adamgreig[m]> ok, triage team chat, I think it's pretty uncontroversial to approve jannic joining, but shall we quickly discuss setting up some docs around it?
<JamesMunns[m]> First job for jessebraham and jannic, set down some docs, then start living it? :p
<adamgreig[m]> <JamesMunns[m]> "This is a good call, and we..." <- I think this isn't a bad summary
<adamgreig[m]> hah, yea
<adamgreig[m]> we have an ops/ folder in the wg repo so that could be a good place for something to live?
<jessebraham[m]> Sounds good!
<jannic[m]> Yes, I agree.
<adamgreig[m]> I see the goal as being trying to stop open issues/PRs getting forgotten about, so a mix of closing things that can be closed, and reminding people in the weekly meetings about them when they need working on, or otherwise letting them stew a bit when that's what's needed... but maybe have a ponder and we can discuss it further next week?
<adamgreig[m]> if you get anything together then please do pr before that though
<jessebraham[m]> Sure, I'll at least start thinking about it
<jannic[m]> IMHO the most important task is to go through all the issues every now and then and make sure nothing gets forgotten. Everything else (like how to label tasks) is just tooling to make that task easier.
<jessebraham[m]> Should be able to draft something up pretty quickly I think, though
<adamgreig[m]> finally, Folkert de Vries do you want to mention your PSA?
<adamgreig[m]> (@jannic, just filling out the teams repo update for you, do you have a zulip ID?)
<JamesMunns[m]> adamgreig[m]: oh, I need to do a pass on this, and I think figure out how our @\all team works
FolkertdeVries[m has joined #rust-embedded
<FolkertdeVries[m> yeah, so Tamme and I have been working on implementing error messages and some other changes for cmse that are required for stabilization
<adamgreig[m]> (and is there an email address you're happy to be publicly associated?)
<FolkertdeVries[m> I think that if/when this all gets merged, we can push for stabilization
<FolkertdeVries[m> I've also been working on naked functions (see agenda for links), another feature where I think thing are just blocked on someone doing the work
<FolkertdeVries[m> but very useful for (among other things) embedded
<jannic[m]> I do have a zulip account but I don't even know how zulip accounts are identified :-)
<FolkertdeVries[m> but given that I think nobody in rust's review rotation is particularly familiar with cmse, review from actual users would be useful
<adamgreig[m]> jannic[m]: if you view your profile, the URL is like /#user/NNNNN where NNNN is your ID
<JamesMunns[m]> I gotta run, thanks all!
<adamgreig[m]> Folkert de Vries: I saw the recent push on naked functions too, nice work!
<FolkertdeVries[m> a particular restriction that the current PRs impose is no generics in the signatures of cmse-entry and cmse-call functions
<adamgreig[m]> have you seen ejpcmac's comment here? https://github.com/rust-embedded/wg/issues/775#issuecomment-2218387137
<jannic[m]> adamgreig[m]: Can't find it in the Zulip app
<FolkertdeVries[m> we believe that this is not a restriction in practice, but if anyone has concerns now is the time to speak up about that
<adamgreig[m]> jannic[m]: click your avatar on top-right (for me anyway...)
<FolkertdeVries[m> adamgreig[m]: yes that's the whole reason we're doing this :)
<adamgreig[m]> aah great :)
<jannic[m]> adamgreig[m]: Had to open it in the web browser. /#user/719751
<adamgreig[m]> thanks! and is there an email address I can put?
<dirbaio[m]> inline asm for mmio generates worse code, because it won't use the cool addressing modes like `str r0, [r1, #4]`.
<adamgreig[m]> that's it for the meeting though, thanks everyone!
<adamhott[m]> Thanks all!
<jannic[m]> <adamgreig[m]> "(and is there an email address..." <- Just use jan@gondor.com. While I hate spam, this is already on all of my git commits, so it's probably a lost cause :-)
<dirbaio[m]> OTOH it can generate better code because it will actually assume mmio accesses can't alias with regular memory, which volatile doesn't seem to. see in the "cool_*" pair of functions how it moves the load of src out of the loop
<dirbaio[m]> but I think it'll overall be a loss, since str r0, [r1, #4] is quite common when doing multiple writes to different registers of a peripheral...
<adamgreig[m]> aah of course, it can't optimise that
<adamgreig[m]> that's annoying and perhaps does suggest a std read_mmio would be better?
<dirbaio[m]> yeah
<dirbaio[m]> I wouldn't try to roll it in our own crate
<dirbaio[m]> but of course there's the question of how does std implement it on top of llvm
<dirbaio[m]> I don't think "mmio write" semantics exist in llvm :D
<dirbaio[m]> it'd have to lower it to a volatile write
<SbastiendHerbais> dirbaio: There's actually some registers missing from Lptim in the metapac, in the official BSP:... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/mcQHnSRPPFogURKmALWYcgud>)
<dirbaio[m]> ๐Ÿฅฒ
<dirbaio[m]> PRs welcome to stm32-data
<SbastiendHerbais> Doesn't it use SVD files from ST?
<dirbaio[m]> yes and no.
<dirbaio[m]> no because it uses yamls that are checked in to the repo and manually maintained
<dirbaio[m]> yes because these yamls were originally extracted from svd (see instructions in the readme)
<dirbaio[m]> the reason is the SVDs are garbage quality
<dirbaio[m]> and plain wrong quite often
<SbastiendHerbais> Ugh, the pain of maintaining these ST chips is off the chart
<dirbaio[m]> yuppppp
<SbastiendHerbais> I'm starting to think I'd rather maintain a Linux box/raspberry pi up-to-date :sob:
<dirbaio[m]> this particular thing shouldn't be too hard to fix
<SbastiendHerbais> I'll give it a go
<dirbaio[m]> or follow the instructions in the readme to extract a new yaml from the h7rs svd and add it
<dirbaio[m]> either check whether an existing version has these regs
<dirbaio[m]> these regs are probably not new to the h7rs, so most likely the 1st
<SbastiendHerbais> I am already on the latest version AFAIK
<dirbaio[m]> version of the peripheral IP I mean
Jonathan[m] has joined #rust-embedded
<Jonathan[m]> Hi!
<lanre[m]> I'm trying to work with a pn532 NFC board. I've found what seems to be the only crate to interface with this board over I2C, but using it requires me to downgrade to a embedded_hal version around 0.2.6 that requires the Write and Read traits for I2Cdev, which i've seen dropped but the functions thereof still being implemented in newer versions. Is the downgrade a good idea? (i'm new)
thalesfragoso[m] has joined #rust-embedded
<thalesfragoso[m]> <adamgreig[m]> "that's annoying and perhaps does..." <- Sorry I'm late to the party, but what is the problem with write_volatile again ?
<jannic[m]> As I understand it, write_volatile is underspecified. It's unclear what should happen if `T` is larger than what the hardware can read/write in a single memory access. It's unclear how it should interact with regular memory accesses (pointer provenance etc.). "In particular, a race between a write_volatile and any other operation (reading or writing) on the same location is undefined behavior." may be too strict for some use cases.
<jannic[m]> (The MMIO register may actually be used to provide synchronization, like the rp2040 spinlocks. So it's intended to access the register simultaneously from multiple cores.)
<jannic[m]> While it may be possible to solve this issues by updating the specification of read_/write_volatile, it seems desirable to make it very clear that the interface is only meant for MMIO access and is not allowed to be used on "normal" memory locations covered by the rust memory model.
<JamesMunns[m]> <jannic[m]> "As I understand it, write_volati..." <- > <@jannic:matrix.org> As I understand it, write_volatile is underspecified. It's unclear what should happen if `T` is larger than what the hardware can read/write in a single memory access. It's unclear how it should interact with regular memory accesses (... (full message at <https://catircservices.org/_matrix/media/v3/download/catircservices.org/UNHTmCUxNHCCSvWcyiRmjMgE>)
jxsl has quit [Ping timeout: 260 seconds]
<thalesfragoso[m]> Hmm. Regarding tearing and ordering, I think it has been like that forever everywhere and "well understood".
<thalesfragoso[m]> Provenance I think they want to provide a concept for unbound provenance, which I think it's the case today with int -> ptr casts.
<thalesfragoso[m]> But you bring a good point regarding IO used for synchronization.
<thalesfragoso[m]> Does LLVM provide any guarantees w.r.t volatiles reads/writes when the target fits the underlying word ?
<JamesMunns[m]> It promises that the reads and writes won't be elided, and that the reads and writes won't tear
<JamesMunns[m]> that's it, AFAIK.
<JamesMunns[m]> oh, and that volatile accesses won't ever be re-ordered relative to each other, but with no promises wrt normal access or atomic access
pbsds3 has quit [Quit: The Lounge - https://thelounge.chat]
pbsds3 has joined #rust-embedded
<thalesfragoso[m]> Hmm, I'm not familiar with the "won't tear" part, but the rest seems quite standard.
<JamesMunns[m]> It'll never chop up a 32-bit read into two 16-bit reads
<thalesfragoso[m]> If it has that guarantee, then shouldn't it be enough ?
<Jonathan[m]> I assume there's a limit to how large a read it won't tear
<JamesMunns[m]> Enough for what?
<Jonathan[m]> because of hardware
<JamesMunns[m]> Yeah, sorry, it will only not-tear up to the native word width of the platform
<thalesfragoso[m]> JamesMunns[m]: General MMIO usage.
<JamesMunns[m]> (and for aligned access)
<JamesMunns[m]> yeah, the point is that MMIO is a subset of the "fuzzy set of things volatile does/doesn't do"
<JamesMunns[m]> the goal is to make the specific guarantees of MMIO usage clear, with a dedicated interface, to allow Rust to be more clear about what does and doesn't happen
<JamesMunns[m]> like, today, volatile is the most-right thing we have for MMIO
<thalesfragoso[m]> JamesMunns[m]: Can rustc even do that ? I mean, it can't promise more than LLVM
<thalesfragoso[m]> JamesMunns[m]: Why would we need inline asm ?
<Jonathan[m]> where would such a primitive live?
<Jonathan[m]> * primitive live? (excuse me if I missed earlier related discussion)
<JamesMunns[m]> the suggestion is to make a crate today that achieves this with inline asm, with the potential goal of rfc-ing it upstream to live in core::ptr or so
<Jonathan[m]> do you envision something specific to MMIO being useful except on embedded, and how does that relate to it being in core in your opinion?
<JamesMunns[m]> Jonathan[m]: desktops also use MMIO, including linux
<Jonathan[m]> fair enough, just not a lot in userspace AFAIK, but I might be wrong about that
<JamesMunns[m]> not as much in userspace, but Rust is also in the linux kernel
<JamesMunns[m]> They write drivers like we do, more or less :)
<JamesMunns[m]> thalesfragoso[m]: IIRC it was suggested we could pick reasonable asm attributes to model the things we are and are not promising, such as nomem, which means we promise we don't touch any memory in the abstract model
<Jonathan[m]> no for sure, and that all makes a lot of sense, I think my comment comes more the fact that for higher level programs this will never be useful, but I guess that's true for read/write volatile in a way too so that's all good tbh. Thanks!!
GrantM11235[m] has joined #rust-embedded
<GrantM11235[m]> Does rust-for-linux use the volatile stuff in core::ptr or do they have their own thing?
<JamesMunns[m]> I don't know, I would assume they use one or both of inline asm or core::ptr::x_volatile
Ninetoone[m] has joined #rust-embedded
<Ninetoone[m]> I'm pretty new in Rust Embedded. Yeah, I found some example for STM32F3 or F4, but actually I have bought this STM32H745i disco board. Actually I want to use the audio on it. Is there any project support this or is there any process or way can convert C driver or those BSP to support a Rust development?
<JamesMunns[m]> You could check out the embassy-stm32 examples, I'm pretty sure that board is tested in CI there, lots of examples: https://github.com/embassy-rs/embassy/tree/main/examples/stm32h7/src/bin
<JamesMunns[m]> A lot of native Rust drivers, no need to port the C code, usually: https://docs.embassy.dev/embassy-stm32/git/stm32h745ig-cm7/index.html
<Ninetoone[m]> I actually already tried the embassy one, can't make the blinky work.
<Ninetoone[m]> JamesMunns[m]: Let me try this๐Ÿ˜€
<JamesMunns[m]> Feel free to drop by #embassy-rs:matrix.org if you're having trouble getting the examples working
<Ninetoone[m]> JamesMunns[m]: ๐Ÿ‘ just joined
pbsds3 has quit [Quit: The Lounge - https://thelounge.chat]
pbsds3 has joined #rust-embedded