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> < (@adamgreig:matrix.org)> has the room icon disappeared for anyone else 🤔
<re_irc> < (@jessebraham:matrix.org)> I still see it
tafama has joined #rust-embedded
tafa has quit [Ping timeout: 268 seconds]
richardeoin has quit [Ping timeout: 240 seconds]
richardeoin has joined #rust-embedded
hwj has joined #rust-embedded
hwj has quit [Ping timeout: 240 seconds]
hwj has joined #rust-embedded
Shell is now known as Shellhound
<re_irc> < (@yuhanliin:matrix.org)> cr1901: I've been trying to update my MSP430 HAL to the latest ecosystem crates and I've been running into some link errors when building the examples. I used the "-lmul_32" link flag, because my chip uses a 32-bit multiplier. However, I've been getting the following linker error:
<re_irc> = note: /home/yuhan/ti/msp430-gcc/bin/../lib/gcc/msp430-elf/8.3.1/430/libmul_f5.a(lib2hw_mul_f5.o): In function '__muldi3':
<re_irc> (.text.__muldi3+0x0): multiple definition of '__muldi3'
<re_irc> /home/yuhan/projects/rust/embedded/msp430fr2x5x-hal/target/msp430-none-elf/debug/deps/libcompiler_builtins-b8a7118326f0a1f6.rlib(compiler_builtins-b8a7118326f0a1f6.compiler_builtins.03021f45-cgu.0.rcgu.o):compiler_builtins.03021f45-cgu.0:(.text.__muldi3+0x0): first defined here
<re_irc> In addition, I also get "undefined reference to 'abort'". This error seems to originate from PAC reads/writes.
<cr1901> undefined reference to abort can be solved by adding your own abort function for debug mode: https://github.com/rust-embedded/msp430-quickstart/blob/master/src/main.rs#L26-L32
<cr1901> I've never used an msp430 w/ the hardware multiplier... interesting there's a conflict when anything besides -lmul_none is supplied
<cr1901> yuhanliin: I'm about to call it quits for the night. Lemme know if you figure anything else out re: the multiplier. I'm not sure what's wrong
<re_irc> < (@yuhanliin:matrix.org)> I added "-Wl,--allow-duplicate-definition" to sidestep the multiplier error. IDK if that's a good idea though.
m5zs7k has quit [Ping timeout: 250 seconds]
m5zs7k has joined #rust-embedded
hwj has quit [Ping timeout: 250 seconds]
hwj has joined #rust-embedded
Socke has quit [Ping timeout: 250 seconds]
Socke has joined #rust-embedded
Socke has quit [Ping timeout: 250 seconds]
Socke has joined #rust-embedded
hwj has quit [Ping timeout: 240 seconds]
<re_irc> < (@diondokter:matrix.org)> Hey so, there is an existing device driver out there I want to use. But I'm writing async code and the driver is blocking.
<re_irc> How do I proceed? (Because every path has different pros and cons)
<re_irc> 2. Add a separate async module to the current driver and make a PR. This will duplicate >50% of code!
<re_irc> 1. Fork and create a new repo "drivername-async" and just make the entire driver async
<re_irc> < (@diondokter:matrix.org)> Hey so, there is an existing device driver out there I want to use. But I'm writing async code and the driver is blocking.
<re_irc> How do I proceed? (Because every path has different pros and cons)
<re_irc> 1. Fork and create a new repo "drivername-async" and just make the entire driver async
<re_irc> 2. Add a separate async module to the current driver and make a PR. This will duplicate >50% of code!
<re_irc> < (@diondokter:matrix.org)> Hmmm, there is a library already for the last one: https://github.com/fMeow/maybe-async-rs
<re_irc> < (@dirbaio:matrix.org)> "maybe-async" is cursed
<re_irc> < (@diondokter:matrix.org)> Ah good to know haha
<re_irc> < (@xiretza:xiretza.xyz)> : all the best things are
<re_irc> < (@dirbaio:matrix.org)> I mean yes, it does work
<re_irc> < (@dirbaio:matrix.org)> but you have to "stick" to the lowest common denominator of both blocking+async
<re_irc> < (@dirbaio:matrix.org)> you lose the best of async: you can't use "with_timeout", join/select, or multiple tasks to coordinate stuff
<re_irc> < (@diondokter:matrix.org)> Basically it's just that there's a read_register and a write_register function. Those must be made async and anything that uses it must become async
<re_irc> < (@dirbaio:matrix.org)> and you still have to deal with the bad parts of async, like cancelation
<re_irc> < (@dirbaio:matrix.org)> user might call one of your functions inside "with_timeout", canceling it halfway and leaving the device in an inconsistent state, etc
<re_irc> < (@diondokter:matrix.org)> True
<re_irc> < (@diondokter:matrix.org)> Hmmm, yeah so that would require a critical section between every read and write in a modify at least
<re_irc> < (@dirbaio:matrix.org)> critical sections can't prevent async cancelation
<re_irc> < (@dirbaio:matrix.org)> they prevent concurrency, but you can already forbid that by exclusively owning the spi/i2c device
<re_irc> < (@diondokter:matrix.org)> Ah yes I see
<re_irc> < (@dirbaio:matrix.org)> also you might want to have a different public API for blocking vs async...
<re_irc> < (@dirbaio:matrix.org)> for xample, for devices using pin interrupts. in async you can just "wait for high", in blocking you want the user to do it by using irqs manually and call a callback..
<re_irc> < (@diondokter:matrix.org)> Ok so, there will be code duplication. So no option 3
<re_irc> < (@diondokter:matrix.org)> What then? Option 1 or 2?
<re_irc> < (@dirbaio:matrix.org)> it might work for a simple device that's just "read reg, write reg" and has no pin irqs nor concurrency
<re_irc> < (@dirbaio:matrix.org)> but you can't just slap maybe-async on any driver and have it magically support blocking+async
<re_irc> < (@diondokter:matrix.org)> Well, it has some simple irq stuff. It's an accelerometer
<re_irc> < (@dirbaio:matrix.org)> : or just support async :D
<re_irc> < (@dirbaio:matrix.org)> +only
<re_irc> < (@diondokter:matrix.org)> I'm not the author of the crate :)
<re_irc> < (@diondokter:matrix.org)> So you're saying to just make a new crate?
<re_irc> < (@dirbaio:matrix.org)> ah.. then I dunno, ask the author
<re_irc> < (@dirbaio:matrix.org)> supporting only async is not that bad
<re_irc> < (@dirbaio:matrix.org)> if the user's HAL doesn't support async, they can use an adapter like BlockingAsync to 'convert" from blocking i2c/spi to async i2c/spi emedded-hal
<re_irc> < (@dirbaio:matrix.org)> and if the user doesn't have an executor they can use "block_on()" to call into the driver
<re_irc> < (@diondokter:matrix.org)> Well yeah, but that'd be a very annoying change for existing users
<re_irc> < (@dirbaio:matrix.org)> the only downside is code size
<re_irc> < (@dirbaio:matrix.org)> but yeah if the existing driver is already blocking it'll be a tough sell to the maintainer D:
<re_irc> < (@diondokter:matrix.org)> It is
<re_irc> < (@mabez:matrix.org)> : You can add a blocking module that keeps the blocking interface but under the hood will use "block_on()"
<re_irc> < (@diondokter:matrix.org)> That's also true
<re_irc> < (@mabez:matrix.org)> I suggested this approach for the fatfs library: https://github.com/rafalh/rust-fatfs/issues/71 but the maintainer doesn't seems interested... dont blame him tbh!
<re_irc> < (@mabez:matrix.org)> Keywork generics would be nice :)
<re_irc> < (@mabez:matrix.org)> * Keyword
<re_irc> < (@diondokter:matrix.org)> But then the user must also provide an async I2C implementation which their current HAL probably doesn't have
<re_irc> < (@dirbaio:matrix.org)> keyword generics will run into the same problems as maybe-async
<re_irc> < (@dirbaio:matrix.org)> you can't abstract over blocking+async, they're just too different
hwj has joined #rust-embedded
hwj has quit [Ping timeout: 272 seconds]
<re_irc> < (@eldruin:matrix.org)> PSA: embedded-hal-async 0.1.0-alpha.3 (https://crates.io/crates/embedded-hal-async/0.1.0-alpha.3) is out! thanks goes to and 🎉
conplan has left #rust-embedded [Leaving.]
hwj has joined #rust-embedded
dc740 has joined #rust-embedded
WSalmon has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
WSalmon has joined #rust-embedded
conplan has joined #rust-embedded
WSalmon has quit [Remote host closed the connection]
WSalmon has joined #rust-embedded
conplan has quit [Quit: Leaving.]
conplan has joined #rust-embedded
hwj has quit [Ping timeout: 252 seconds]
hwj has joined #rust-embedded
causal has joined #rust-embedded
<cr1901> >you can't abstract over blocking+async, they're just too different <-- I don't have an opinion either way, but the ppl who are working on keyword generics explicitly don't think this is true and in the cases where it is, they will provide "some sort of" escape hatch
hwj has quit [Ping timeout: 272 seconds]
<cr1901> It's in the proposal for keyword generics, which I am too lazy to look up rn :P
causal has quit [Ping timeout: 260 seconds]
causal has joined #rust-embedded
<re_irc> < (@dirbaio:matrix.org)> cr1901: keyword generics can work to avoid duplication like "get/get_mut", "map/map_async" etc
<re_irc> < (@dirbaio:matrix.org)> like, "map" taking a blocking closure, "map_async" taking an async closure
<re_irc> < (@dirbaio:matrix.org)> so you do a generic "map" instead that can take both kinds of closures, and is async itself if the closure is
<re_irc> < (@dirbaio:matrix.org)> I see the value in that
<re_irc> < (@dirbaio:matrix.org)> but not for a whole driver...
<cr1901> I would have to see the whole proposal to determine for myself whether it's feasible to write a single HAL driver for blocking, async, and maybe even nonblocking
<re_irc> < (@dirbaio:matrix.org)> single HAL yes, embassy kinda does that
<re_irc> < (@dirbaio:matrix.org)> you can share quite a bit of code between async+blocking, like "setup transfer" and "cleanup transfer"
<re_irc> < (@dirbaio:matrix.org)> while "wait for transfer done" is different
<re_irc> < (@dirbaio:matrix.org)> and it becomes quite annoying for more complex periphs where you do lots of "wait for" (looking at you stm32 i2c >_>)
<re_irc> < (@dirbaio:matrix.org)> so it's more like "2 HALs in one" sometimes :D
hwj has joined #rust-embedded
conplan has quit [Ping timeout: 276 seconds]
hwj has quit [Ping timeout: 240 seconds]
<re_irc> < (@simon:delire.party)> anyone doing RISC-V things, have you tried doing lock-step simulation with Spike? I’m running into this: https://github.com/riscv-software-src/riscv-isa-sim/issues/1134
emerent_ has joined #rust-embedded
emerent is now known as Guest424
emerent_ is now known as emerent
<re_irc> < (@oop584:matrix.org)> I'm not in RTL, but my company is the one that wrote Hammer (https://github.com/rivosinc/hammer), so we just use that. Is there a reason you want to use a subprocess as opposed to something like that?
<re_irc> < (@simon:delire.party)> I just didn’t know something like that existed, thanks!
<re_irc> < (@simon:delire.party)> (and making it in C++ didn’t sound fun)
<re_irc> < (@simon:delire.party)> though I might still need so more glue code to use that one from rust
<re_irc> < (@simon:delire.party)> using a subprocess means I don’t need to make Cargo link to C++ code and mess with bindgen
bjc has joined #rust-embedded
<re_irc> < (@oop584:matrix.org)> : Ah, it was linked in the most recent comment of the PR you mentioned so I figured you were referring to that.
dc740 has quit [Remote host closed the connection]
conplan has joined #rust-embedded
<re_irc> < (@simon:delire.party)> ah indeed, I only read the start of that thread
bjc has quit [Remote host closed the connection]
bjc` has joined #rust-embedded
bjc` is now known as bjc