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
fabic has joined #rust-embedded
<re_irc> <firefrommoonlight> Try to_duration (https://docs.rs/embedded-time/latest/embedded_time/rate/trait.Rate.html#method.to_duration)
explore has joined #rust-embedded
<re_irc> <reitermarkus> Did anyone encounter something like this before? Compilation failure with undefined reference to "rust_begin_unwind" depends on the order or type of the "panic_*" crate's import.
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #rust-embedded
emerent_ has joined #rust-embedded
emerent is now known as Guest1991
emerent_ is now known as emerent
Guest1991 has quit [Ping timeout: 260 seconds]
gsalazar has joined #rust-embedded
fabic has quit [Ping timeout: 260 seconds]
<re_irc> <allexoll> long shot but has anybody tried some sort of defmt logging in C? it's rough going back to plain RTT...
fabic has joined #rust-embedded
<re_irc> <James Munns> There's a library I saw for C recently allexoll , it was featured on the memfault interrupt blog
<re_irc> <James Munns> It's not the same, but very similar! Let me find the post
<re_irc> <James Munns> Also I think the Zephyr RTOS has some memoized logger built in nowadays, I found it when looking for similar projects to defmt
<re_irc> <James Munns> I haven't used either, but I tend to trust the memfault folks when it comes to taste in C :)
<re_irc> <9names (@9names:matrix.org)> trice looks nice!
<re_irc> <allexoll> oh nice!
<re_irc> <allexoll> I also found postform: https://github.com/Javier-varez/Postform but that seems to only be for C++
<re_irc> <allexoll> seems you have given people ideas with defmt!
<re_irc> <James Munns> All credit to Japaric for coming up with the idea :)
explore has quit [Quit: Connection closed for inactivity]
<re_irc> <heksa> Hey we were recently dynamically constructing a RISC-V interrupt vector table in Rust, which we found slightly unergonomic. As context, Cortex-M IVT is a list of plain function pointers ("data"), while RISC-V IVT is a list of (relative) jump instructions with the target address built in. So what we ended up doing is that we bitbang the full RISC-V relative jump instruction by calculating the function pointer's relative...
<re_irc> ... offset, then constructing the 32-bit wide instruction with the address built-in. Can someone think of a smarter way to do this? Is there some sensible abstraction or a library for this?
<re_irc> <heksa> An important sub-problem there is: how would you construct an assembly instruction as data? asm! macro's great if you want to just run some assembly, but would it be possible to use existing syntax to make that into data (like, something you can place in a variable)?
<re_irc> <adamgreig> heksa: perhaps you can use global_asm to place assembly instructions/directives/data anywhere in memory?
<re_irc> <adamgreig> no stable "sym" in asm yet though so that might complicate making the interrupt table
<re_irc> <heksa> I'm getting the sense that the global_asm macro is resolved at compile-time, so it wouldn't allow creating assembly instructions as data at runtime. That would be easy to work around, we could live with that.
<Shell> yes
<re_irc> <adamgreig> the normal asm macro is also compile time, there's no runtime assembler
<XMPPwocky> no runtime assembler in rust itself, that is; obviously you can pull in various assembler libraries
<XMPPwocky> that's a lot of potential code bloat, though
<XMPPwocky> i don't trust LTO that much :P
<XMPPwocky> <re_irc> "<heksa> Hey we were recently..." <- and fwiw this is basically how everybody does it
<XMPPwocky> if you end up needing to assemble a lot of different instructions, it may make sense to build an Abstract Runtime Assembler Thingy or pull in a library
<XMPPwocky> if you need to create a jump for an IVT, you do bitmask hackery, laugh at how awful it is, and then go finish the thing you're actually trying to make :P
<XMPPwocky> a "sensible abstraction" here is a function called make_jump_instruction(instruction_address, jump_target_address), imo
<XMPPwocky> does it call a library under the hood? who knows, that's why it's an abstraction
<re_irc> <riskable> I figured it out:
<re_irc> Ok(result) => result,
<re_irc> let ir_samplerate = match Hertz(20_000_u32).to_duration() {
<re_irc> };
<re_irc> Err(_) => Microseconds(50_u32), // Fallback to 20Khz
<re_irc> <riskable> * ir_samplerate: Microseconds
<re_irc> <riskable> (in my actual code I'm using a value taken from the user configuration instead of "20_000_u32" which is why I have the "Err(_)" check and fallback)
gsalazar has quit [Ping timeout: 260 seconds]
crabbedhaloablut has quit [Quit: No Ping reply in 180 seconds.]
crabbedhaloablut has joined #rust-embedded
hwj has joined #rust-embedded
fabic has quit [Ping timeout: 246 seconds]
hwj has quit [Remote host closed the connection]