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
<re_irc> < (@jaxter184:matrix.org)> are there some stm chips where RTT doesn't work?
<re_irc> < (@jaxter184:matrix.org)> i've got an stm32f042, and i'm getting a "Error: A ARM specific error occured. \n Caused by: \n Timeout occured during operation.", and i dont get this when running the same sketch on my f303
<re_irc> < (@jaxter184:matrix.org)> is there maybe some configuration that i need to change?
<re_irc> < (@jaxter184:matrix.org)> the sketch im running is basically copied from here: https://github.com/knurling-rs/probe-run#4-run
<re_irc> < (@jaxter184:matrix.org)> and im also swapping out the "memory.x"
<re_irc> < (@adamgreig:matrix.org)> nope, it should work fine on everything, it's probably that the debugger isn't able to connect to your stm32 in some way
<re_irc> < (@adamgreig:matrix.org)> perhaps the bkpt() call is to blame, or you're accidentally putting it in sleep mode (wfi() or similar), or disabling debug access, or other
<re_irc> < (@adamgreig:matrix.org)> does it program OK?
<re_irc> < (@jaxter184:matrix.org)> yeah, im making it blink an APA102
<re_irc> < (@jaxter184:matrix.org)> i'll look into it and mess with it some more, thanks for the pointers
<re_irc> < (@jaxter184:matrix.org)> oh, but when i program it, it seems like i need to cycle power to the chip, so maybe its not resetting properly?
<re_irc> < (@adamgreig:matrix.org)> hm, that does sound weird, it just should run right away
<re_irc> <dngrs (spookyvision@{github,cohost})> might be the dreaded wfi issue
<re_irc> <dngrs (spookyvision@{github,cohost})> been bitten by it many times
<re_irc> <dngrs (spookyvision@{github,cohost})> ah already mentioned by "@adamgreig"
starblue has quit [Ping timeout: 248 seconds]
starblue has joined #rust-embedded
<re_irc> < (@jaxter184:matrix.org)> figured it out! i was just being a fool
<re_irc> < (@jaxter184:matrix.org)> turns out the boot0 pin is actually very important
<re_irc> < (@jaxter184:matrix.org)> i also failed to mention that my f042 is on a custom pcb while my f303 is a nucleo dev board; that was probably important information that someone else would need to solve my problem
<re_irc> < (@jaxter184:matrix.org)> but regardless, it was useful to know that it was a hardware issue and not software, so thanks again!
IlPalazzo-ojiisa has joined #rust-embedded
<re_irc> < (@therealprof:matrix.org)> : Yep, BOOT pin on the F0s is really a trap for players of any age.
<re_irc> <dngrs (spookyvision@{github,cohost})> How is it different from other boot pins?
starblue has quit [Ping timeout: 248 seconds]
starblue has joined #rust-embedded
<re_irc> < (@therealprof:matrix.org)> Well, for starters, there're two of them which are also regular GPIO pins and can be reconfigured using a flag in the option byte flash (not sure which other series use the same complex approach). They're also super sensitive so if you forget (or are accustomed to) leaving unused pins floating then any stray capacitances can randomly influence them causing all kinds of spurious errors, like the one ...
<re_irc> ... was mentioning.
<re_irc> <schphil> hello! does the does the can-loopback example from stm32f1xx-hal (https://github.com/stm32-rs/stm32f1xx-hal) work for anyone? i'm not receiving any can message back.
<re_irc> <dngrs (spookyvision@{github,cohost})> : Whoopsie. Good to know, thanks!
xnor has quit [Ping timeout: 246 seconds]
xnor has joined #rust-embedded
<re_irc> < (@jamesmunns:beeper.com)> is that something they just didn't carry over to the g0? I don't think I've given a boot pin any special attention before, and haven't had it bit me, but wondering if I should go read the RMs a bit closer...
<re_irc> < (@jamesmunns:beeper.com)> Ah, looks like yeah, it's different on the G0s: BOOT0 is shared with SWCLK, and isn't active by default unless you change some nonvol options bytes: https://community.st.com/s/question/0D50X0000ARQLq2SQH/has-anyone-gotten-the-boot0-pin-to-work-on-an-stm32g071-solved
<re_irc> < (@jamesmunns:beeper.com)> (I've designed a LOT of G0 boards, and always left SWCLK/SWDIO floating/brought out to a header, but haven't designed any other stm32 boards in recent history)
emerent has quit [Ping timeout: 248 seconds]
emerent has joined #rust-embedded
<re_irc> < (@diondokter:matrix.org)> Hey all, does anybody know if there's a way to create a struct type that can only be used as a static variable? I'm making a wrapper around a stupid C API that has this requirement for some data the struct must hold
<re_irc> < (@jamesmunns:beeper.com)> Macro probably? I don't think there's any syntax that can force a type to be static.
<re_irc> < (@diondokter:matrix.org)> Yeah, I didn't know of any way to do it. Guess it's not possible
<re_irc> < (@diondokter:matrix.org)> Macro only helps so much
<re_irc> < (@jamesmunns:beeper.com)> I'd probably look at the "singleton!()" macro as an example
<re_irc> < (@jamesmunns:beeper.com)> but if you need a type defined in your crate, you might just need to make a "doc(hidden)" type and say "don't use this", or make something offensive like:
<re_irc> #[doc(hidden)]
<re_irc> pub struct ImplDetail {}
<re_irc> impl ImplDetail {
<re_irc> < (@diondokter:matrix.org)> No, it's an exposed type
<re_irc> < (@jamesmunns:beeper.com)> You can still "hide" the constructor like that tho, even if the type itself isn't hidden
<re_irc> < (@diondokter:matrix.org)> So I can't force the type to be static, but I can force all use of it to static references
<re_irc> < (@jamesmunns:beeper.com)> That's one way I can think of, yeah
<re_irc> < (@diondokter:matrix.org)> Ok, thanks for sparring with me!
<re_irc> < (@jamesmunns:beeper.com)> Since the constructor is unsafe, if they REALLY want to use it, they can, but you can put all the "human oriented requirements", like "must exist only as a static" on there if you'd like, and provide a "safe" macro interface
<re_irc> < (@jamesmunns:beeper.com)> Or: just use "fn(&'static self, ...) -> ..." as the signature of all the functions
<re_irc> < (@jamesmunns:beeper.com)> that way you know any reference you use of the struct to call a method requires that the struct must have the static lifetime (not sure if "Box::leak()" is "static enough" for your use case, but this approach would also allow that)
<re_irc> < (@jamesmunns:beeper.com)> That doesn't guarantee all INSTANCES of that struct will be static, but if it doesn't have private fields, it means basically all USAGE of it must be with statics (or leaked items, or whatever)
<re_irc> < (@jamesmunns:beeper.com)> err, "doesn't have public", but you get what I meant hopefully :D
<re_irc> <Charles ⚡️> I'm looking to build a split wireless hall effect analog keyboard (many adjectives) and I'm a little stuck on which microcontroller to use. Obviously I'd like to use Rust to program it. I need at least two ADC channels. Not sure whether it would be best/easiest to use BLE for both halves to communicate with each other and the host, or some custom thing (maybe based on an nRF24l01) and a dongle that can do USB...
<re_irc> ... 2.0. A couple chips I'm looking at right now are the nRF52480 and the ESP32-C3 (which lacks USB but that could be okay if the all-BLE connectivity idea would work). I'd prefer RISC-V, but I guess it's not that important. Any recommendations?
<re_irc> <Charles ⚡️> * nRF24L01)
IlPalazzo-ojiisa has quit [Remote host closed the connection]
<re_irc> <Félix the Newbie> Is there a no-std crate that allows to create a map at compile time?
<re_irc> <Félix the Newbie> I mean, not really at compile time, but without allocating. I guess it's roughly the same.
<re_irc> < (@dirbaio:matrix.org)> heapless IndexMap maybe?
<re_irc> or LinearMap if you have few entries and prefer saving code size
<re_irc> < (@dirbaio:matrix.org)> it's an allocation-free map, with the max size set at compile time
<re_irc> < (@dirbaio:matrix.org)> (you can't actually create one at compile time though, like in a "const fn")
<re_irc> <Félix the Newbie> I merely want to map a C-like enum to a struct. So, there the number of entries is the number of variants.
<re_irc> <Félix the Newbie> I could do that with a function, but I think it's easier to read with a dedicated structure.
<re_irc> < (@dirbaio:matrix.org)> if the enum values are "0..n" then you could use an array of length N?
<re_irc> <Félix the Newbie> Mmh, that's true, I didn't think about that 🤔
<re_irc> <Félix the Newbie> Meh, the function I need isn't stable https://doc.rust-lang.org/stable/std/mem/fn.variant_count.html, I'll have to add a library for such a trivial thing only
<re_irc> < (@grantm11235:matrix.org)> Can you just "match" on the enum?
<re_irc> <Peter Hansen> Félix the Newbie: I've used enum-iterator to get its "cardinality()" function which does the same, more or less, along with other generally more interesting things. Note though that (I think) cardinality() is not const, while variant_count() is.
<re_irc> <Peter Hansen> No, I'm wrong.. cardinality() is const too. (Yay... will want that here soon.)