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
starblue has quit [Ping timeout: 248 seconds]
starblue has joined #rust-embedded
<re_irc> <boondocker> is there a "critical_section" implementation for RISC-V?
<re_irc> <boondocker> Getting the "undefined symbol: _critical_section_1_0_acquire" errors using "riscv" and "critical_section" crates
cr1901_ has joined #rust-embedded
msh has joined #rust-embedded
cr1901 has quit [Ping timeout: 244 seconds]
<re_irc> <jannic> There is one within critical_section 0.2.x, but 1.0.0 removed the implementations. They should be provided by arch specific create now. That may not be available yet.
<re_irc> But it should be easy to take the implementation from 0.2.x and use it so you can provide the implementation for 1.0.0 yourself. As long as you are on single core.
<re_irc> <jannic> * an arch specific crate
<re_irc> <jannic> Here is a pull request: https://github.com/rust-embedded/riscv/pull/110
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #rust-embedded
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #rust-embedded
starblue has quit [Ping timeout: 252 seconds]
starblue has joined #rust-embedded
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #rust-embedded
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #rust-embedded
<re_irc> <dirbaio> adamgreig: Yeah, I thought about it too
<re_irc> <dirbaio> didn't think it was worth removing it, having it doesn't hurt much (unlike the "interrupt::free" multicore unsoundness)
<re_irc> <adamgreig> yea, it's not a problem as such, but it's now not at all cortex-m specific and could be used by anyone using critical-section, I guess
<re_irc> <adamgreig> but on the other hand it really doesn't need to live in the critical-section crate
<re_irc> <dirbaio> thing is i've never been a fan of the syntax though
<re_irc> <dirbaio> so having it in c-s (which is "1.0 forever, never break it again") scares me
<re_irc> <adamgreig> yea, it feels a little bit janky
<re_irc> <adamgreig> it could be its own crate i guess.... not super enthused about the effort to benefit ratio there though
<re_irc> <dirbaio> in embassy we've been using a thing called "Forever" which does exactly the same without macros
<re_irc> <dirbaio> more boilerplate, but at least there's no macro magic going on
<re_irc> <adamgreig> I wonder how widely used cortex-m's singleton is
<re_irc> <adamgreig> yea
<re_irc> <adamgreig> not sure if it would make sense for svd2rust PACs to use it, they need updating for critical-section either way (https://github.com/rust-embedded/svd2rust/blob/master/src/generate/device.rs#L317)
<re_irc> <adamgreig> probably doesn't really make sense
<re_irc> <dirbaio> and using TAIT you can make a macro that's just "forever!(val)", the compiler infers the type, no need to write it out at all
<re_irc> <dirbaio> funny timing, I was splitting "Forever" to a separate crate just yesterday https://github.com/embassy-rs/static-cell
<re_irc> <dirbaio> not the macro though, TAIT is still not quite there. For example it ICEs if you do "let (a, b) = forever!((1, 2));" :D
<re_irc> <adamgreig> hah, nice
<re_irc> <adamgreig> a tricky case alright
<re_irc> <adamgreig> my fav compiler bug from very simple input's still when compiling "loop { continue; }" caused rustc to infinite loop
<re_irc> <dirbaio> lol
crabbedhaloablut has quit [Remote host closed the connection]
<re_irc> <dirbaio> so dunno, IMO the macro should go on another crate, not c-s itself yeah
crabbedhaloablut has joined #rust-embedded
<re_irc> <explodingwaffle101> dirbaio: i'm not fully awake yet- what's the diff between this and once_cell?
<re_irc> <dirbaio> static_cell gives "&'static mut" once
<re_irc> once_cell gives "&'static" many times
<re_irc> <explodingwaffle101> oooooh ok right
<re_irc> <adamgreig> makes perfect sense 🤣
<re_irc> <dirbaio> should name mine "really_only_once_cell" :P
<re_irc> <adamgreig> and give the "static_cell" name to "once_cell" :P
<re_irc> <dirbaio> 🤷😂
<re_irc> <James Munns> yomo
<re_irc> <James Munns> you only mut once
<re_irc> <jack-n> I am looking for some guidance on which repo would be the most appropriate to log it on. On Arm, if I include a core::arch::asm!("bkpt"); in my code, it halts the processor and raises a breakpoint exception, so the debugger knows what to do with it. On RISC-V (ESP32C3), if I include a core::arch::asm!("ebreak");, it sends the processor into riscv-rt's "pub fn DefaultExceptionHandler(trap_frame: &TrapFrame)". Any...
<re_irc> ... suggestions?
cr1901_ is now known as cr1901
<re_irc> <James Munns> Probably https://github.com/rust-embedded/riscv-rt ?
<re_irc> <James Munns> Might not be _totally_ correct, but you probably have the best chance of the right people seeing it :D
<re_irc> <James Munns> jack-n: ^
causal has quit [Quit: WeeChat 3.6]
<re_irc> <tiwalun> jack-n: On RISCV, you can configure the behaviour of the _ebreak_ instruction, using the _dcsr_ register. It's described in the debug spec. Maybe you have to change a setting there.
<re_irc> <mabez> tiwalun: Ah yes, that'll be it. 4.5.1 of the debug spec (0.13) probe-rs will need to set the ebreak bits for the respective modes
<re_irc> <mabez> Default at reset _doesn't_ put the chip in debug mode
<re_irc> <mabez> Probably because GCC (maybe LLVM) use ebreaks as "unreachable" markers in codegen
<re_irc> <ryan-summers> Anyone know what "heapless" doesn't have an unsorted linked list implementation? I want to have an ordered sequence of (large) objects that doesn't incur a ton of copying between push/pop operations
<re_irc> <ryan-summers> And/or am I missing a datastructure that does this?
<re_irc> <ryan-summers> A vec of heapless::pool::Box's does this, but I'm using this in a lib and don't know if my users can always satisfy the CAS-portability constraints of heapless::pool
<re_irc> <dirbaio> you want to insert/remove from the middle?
<re_irc> <ryan-summers> No, just at the ends
<re_irc> <ryan-summers> But need read/write throughout
<re_irc> <dirbaio> then Deque should work
<re_irc> <ryan-summers> Can you index the Deque?
<re_irc> <dirbaio> hmm, no, but there's "iter" and "as_slices"
<re_irc> <dirbaio> but indexing shouldn't be hard to add
<re_irc> <ryan-summers> That's somewhat gross :D
<re_irc> <ryan-summers> But yeah, Deque + adding index support might be the thing I want
<re_irc> <dirbaio> with a linked list indexing would be actually O(n), while deque can do it in O(1)
<re_irc> <almindor> Linked lists are rarely the thing people need.
<re_irc> <ryan-summers> Agreed. That's why I like the deque approach. Basically turns Deque into a ring-buffer
<re_irc> <ryan-summers> Actually, Deque's iteration methods look fine for my purposes. No modification necessary
<re_irc> <ryan-summers> Ugh. Deque does not work because there may be a need to reorder the list (e.g. pop in the middle). I forgot about that
<re_irc> <dirbaio> 😅
<re_irc> <ryan-summers> The MQTT spec is a beauty. The client has to maintain order, but the server (high powered PC) is free to do what it wants ;)
<re_irc> <dirbaio> maybe "Vec<atomic_pool::Box<T>>"?
<re_irc> <dirbaio> "atomic-pool" works everywhere, through "atomic-polyfill"
<re_irc> <ryan-summers> Is that not yet released? I don't see it in the 0.7.16 docs
<re_irc> <dirbaio> different crate https://github.com/embassy-rs/atomic-pool
<re_irc> <dirbaio> I wrote it because heapless's pool seemed way too complicated to me
<re_irc> <jannic> Shouldn't "heapless::pool" work for exactly the same set of architectures as "atomic-polyfill" does?
<re_irc> <ryan-summers> I think it does, but you have to enable a feature
<re_irc> <dirbaio> also "atomic-pool" has 1 bit of bookkeeping overhead per item, vs "heapless::Pool" has 32bits
<re_irc> <dirbaio> but yeah it does seem "heapless::Pool" can use "atomic-polyfill", so both should be equally portable
<re_irc> <James Munns> You could also build something on top of cordyceps::List: https://docs.rs/cordyceps/latest/cordyceps/struct.List.html
<re_irc> <James Munns> gives you a doubly linked (intrusive) list with a cursor interface
rardiol has joined #rust-embedded
<re_irc> <dirbaio> James Munns: doesn't it need alloc?
<re_irc> <James Munns> but you'll need to BYO "storage" mechanism, e.g. how/where the nodes are stored
<re_irc> <dirbaio> ah you can bring your own box/pool
<re_irc> <James Munns> doesn't _require_ alloc, but then you need to impl some glue, yeah
<re_irc> <dirbaio> but then for this usecase you might as well use "Vec<Box<T>>" directly (with "Box" from whatever no-alloc pool)
<re_irc> <James Munns> Yeah, fair :D
<re_irc> <dirbaio> as long as O(n) is fine if it's only moving pointers, not the actual data
<re_irc> <dirbaio> oh "heapless" needs upating to "atomic-polyfill 1.0", fun
<re_irc> <ryan-summers> Yeah, I will likely have a relatively short list in general, but each element is large
<re_irc> <ryan-summers> I'm trying to figure out if heapless has the atomic-polyfill stuff on-by-default. If so, that seems fine to me
<re_irc> <ryan-summers> E.g. is it smart enough to figure out polyfill or not based on the target?
<re_irc> <explodingwaffle101> isn't that the whole point of a polyfill?
<re_irc> <ryan-summers> Yeah, but others like in shared-bus require enabling a feature IIRC
<re_irc> <dirbaio> I think you have to enable "cas" feature
<re_irc> <dirbaio> which annoys me because "atomic-polyfill" IS smart enough to automatically know when to polyfill or nt
<re_irc> <dirbaio> * not
<re_irc> <dirbaio> so heapless could inconditionally use it
<re_irc> <ryan-summers> Sounds like a PR then
<re_irc> <ryan-summers> heapless does explicitly enable "cas" and thus "atomic-polyfill" by default
<re_irc> <dirbaio> was already discussed https://github.com/japaric/heapless/pull/220
<re_irc> <dirbaio> reason was "it pulls cortex-m stuff in non-cortex-m targets"
<re_irc> <dirbaio> but that's fixed with "critical-section 1.0"! :D
<re_irc> <dirbaio> so perhaps worth a 2nd try
<re_irc> <dirbaio> ah, but there's heapless structs that use atomic load/store only
<re_irc> <dirbaio> which will be a perf regression with the current "atomic-polyfill", because it polyfills load/store too if there's no native CAS
<re_irc> <dirbaio> +with a CS
<re_irc> <dirbaio> (early "atomic-polyfill" versions allowed mixing native load/store + polyfilled CAS, but that's unsound)
<re_irc> <dirbaio> There were some discussions about adding "load_store_only::AtomicXX" variants to "atomic-polyfill"
<re_irc> <dirbaio> which would still lower to native load/store, on targets with native load/store but no CAS
<re_irc> <dirbaio> 🤔
<re_irc> <chrysn (@chrysn:matrix.org)> dirbaio, I'm just giving the nrf-softdevice a test run. I'm guessing at a few steps in the middle (not having used probe-run before). Is there any kind of intro text / article that is more detailed than the nrf-softdevice README?
<re_irc> <chrysn (@chrysn:matrix.org)> No problem if there isn't any, but I'd prefer not to learn things the hard(er) way and later see that it was all in the intro.
rardiol has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
<re_irc> <dirbaio> no docs other than what's in the repo, no
<re_irc> <dirbaio> if you're stuck on something feel free to ask for help in #embassy-rs:matrix.org (https://matrix.to/#/#embassy-rs:matrix.org)
<re_irc> <chrysn (@chrysn:matrix.org)> OK, thanks!
creich has joined #rust-embedded
rardiol has joined #rust-embedded
crabbedhaloablut has quit [Write error: Connection reset by peer]
crabbedhaloablut has joined #rust-embedded
dc740 has joined #rust-embedded
<bjc> has anyone here managed to get usb working on a gd32vf103c-start board? i've been tearing my hair out for weeks and am about to give up
<bjc> at this point i assume i have to set some jumpers somehow, but there doesn't even appear to be documentation in chinese for them
<bjc> i'm currently trying with the synopsys-usb-otg crate, but i've alse tried about every enumeration of doing it by hand that i can think of. i can get as far as getting the reset interrupt, but nothing past that; like the host doesn't even see it. maybe there's a gpio pull up i have to configure like on the gd32f303 series?
dc740 has quit [Ping timeout: 256 seconds]
rardiol has quit [Ping timeout: 248 seconds]
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #rust-embedded
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #rust-embedded
rardiol has joined #rust-embedded
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #rust-embedded
<agg> bjc: sorry, the matrix->irc bridge is currently acting up and your messages don't seem to have made it through to matrix
<bjc> thanks for letting me know. i'll try again later
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #rust-embedded
bjc has left #rust-embedded [ERC 5.4 (IRC client for GNU Emacs 28.1)]
causal has joined #rust-embedded
dc740 has joined #rust-embedded
crabbedhaloablut has quit [Read error: Connection reset by peer]
crabbedhaloablut has joined #rust-embedded
dc740 has quit [Ping timeout: 256 seconds]
GenTooMan has quit [Ping timeout: 244 seconds]