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> < (@adamgreig:matrix.org)> : aah cool, I didn't know cargo-release has stuff for multi-crate repos, that will be worth checking out, thanks!
<re_irc> < (@adamgreig:matrix.org)> github's lack of support for multi-project repos like that is my main nuisance of monorepos
Amanieu has quit [Ping timeout: 255 seconds]
Amanieu has joined #rust-embedded
Socke has quit [Ping timeout: 248 seconds]
Socke has joined #rust-embedded
IlPalazzo-ojiisa has joined #rust-embedded
brazuca has joined #rust-embedded
rardiol has quit [Ping timeout: 246 seconds]
bjc has quit [Remote host closed the connection]
bjc has joined #rust-embedded
IlPalazzo-ojiisa has quit [Quit: Leaving.]
bjc has quit [Ping timeout: 255 seconds]
fabic_ has quit [Ping timeout: 246 seconds]
dc740 has joined #rust-embedded
<re_irc> < (@crzyrndm:matrix.org)> Evening all
<re_irc> I have a C lib that outputs a large (for an MCU anyway) array of floats. I don't need the precision and the post-processing happens way quicker if done with integers/fixed point (prototyped / benchmarked/ etc.)
<re_irc> However at full size, I don't have the memory to allocate the array for both f32 and u16/u32. Is there a standard pattern / crate for transforming an array in place
<re_irc> < (@crzyrndm:matrix.org)> * place?
<re_irc> < (@crzyrndm:matrix.org)> (I realise that w/e way I do this there's probably going to be plenty of unsafe and probably a few pointers)
<re_irc> < (@crzyrndm:matrix.org)> ty, transmuting the array then recreating the floats is way cleaner than what I was thinking 👍️
<re_irc> < (@grantm11235:matrix.org)> This doesn't prevent you from looking at the data as floats, which will be corrupted. I don't think that is Undefined Behavior or anything, its just weird https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=e139f89f3e439c76909f08629a36f598
crabbedhaloablut has quit [Ping timeout: 255 seconds]
crabbedhaloablut has joined #rust-embedded
fabic_ has joined #rust-embedded
lehmrob has joined #rust-embedded
<re_irc> < (@chrysn:matrix.org)> : If you want to use different sized types, you can use a union (https://doc.rust-lang.org/std/keyword.union.html), eg. "union F32orI16 { f: f32, i: i16 }" as an "[F32orI16; 2048]". This will not take "&mut [i16]" / give you a "&[i16]" ever, but using these will be tricky anyway due to alignment.
<re_irc> < (@chrysn:matrix.org)> If you build a newtype (like "struct ConversionBuffer([F32orI16; 2048]);"), you can not have an unsafe ".assume_i16(&self) -> &[i16]", but you can have a "struct I16View<'a>)(&'a ConversionBuffer)" where the ConversiionBuffer has a ".assume_i16(&self) -> I16View<'_>", and I16View could implement iteration and indexing.
<re_irc> < (@chrysn:matrix.org)> This would give you safe usability of the resulting buffer view and contain the unsafety to the ConversionBuffer.
jsolano has joined #rust-embedded
jsolano has quit [Quit: leaving]
jsolano has joined #rust-embedded
IlPalazzo-ojiisa has joined #rust-embedded
brazuca has quit [Quit: Client closed]
bjc has joined #rust-embedded
lehmrob has quit [Ping timeout: 248 seconds]
<re_irc> < (@htms:matrix.org)> Hi, I have a problem with defmt prints with custom STM32L451 board.
<re_irc> Knurling-rs app template and defmt steps:
<re_irc> - cargo generated project from main branch
<re_irc> - fullfilled TODOs (changed target, chip, memory layout, etc.)
<re_irc> < (@korken89:matrix.org)> : Have you set the env variable? Like "DEFMT_LOG=trace" ?
<re_irc> < (@htms:matrix.org)> : Yes. I was wandering over issues in defmt repo, it seems like it's a bug in defmt-rtt. Changing version of it from 0.4 to 0.3 worked for me.
<re_irc> < (@thejpster:matrix.org)> I think cortex-m-rt 0.7.3 fixed my random keyboard issue 🎉
<re_irc> < (@thejpster:matrix.org)> I would randomly get LShift instead of RAlt2. But today it's totally gone
brazuca has joined #rust-embedded
<cr1901> Pin back to 0.7.2, rebuild the firmware, and then see if the issue reappears to confirm :D?
fabic_ has quit [Ping timeout: 255 seconds]
<re_irc> < (@jamesmunns:beeper.com)> : Do you have the old offending code still around? You could probably manually audit the ASM to confirm
brazuca has quit [Quit: Client closed]
emerent has quit [Ping timeout: 252 seconds]
emerent has joined #rust-embedded
<re_irc> < (@thejpster:matrix.org)> Yes I think I do on my other laptop.
<re_irc> < (@jamesmunns:beeper.com)> arm-none-eabi-objdump -dS --demangle=rust target/thumbv7em-none-eabihf/release/test_extract > dump.txt
<re_irc> (but with your path) would be pretty enlightening
<re_irc> < (@jamesmunns:beeper.com)> (and looking at the specific function that was choosing between those two key options)
<re_irc> < (@boiethios:matrix.org)> Hello, I'm shopping to build my own keyboard, and I'm thinking about buying the rp2040. Is it well supported by Rust frameworks?
<re_irc> < (@jamesmunns:beeper.com)> yeah, pretty well: https://github.com/rp-rs
<re_irc> < (@boiethios:matrix.org)> Can I use it with RTIC or embassy?
<re_irc> < (@jamesmunns:beeper.com)> Theres also #rp-rs:matrix.org
<re_irc> < (@jamesmunns:beeper.com)> both :)
<re_irc> < (@boiethios:matrix.org)> Nice, thanks!
<re_irc> < (@dirbaio:matrix.org)> : embassy has the "embassy-rp" hal, which you'd use instead of "rp2040-hal"
<re_irc> < (@dirbaio:matrix.org)> (you can still use "rp2040-hal" with embassy, but then you can't use async uart/spi/i2c/etc)
<re_irc> < (@dirbaio:matrix.org)> * it doesn't have
<re_irc> < (@ithinuel:matrix.org)> We're a few over https://matrix.to/#/#rp-rs:matrix.org having done that (this message was written using wilskeeb (https://github.com/ithinuel/wilskeeb) an rp2040 + rust based DIY keyboard ❤️)
<re_irc> < (@ithinuel:matrix.org)> : but there are some async drivers ready to be added to rp2040-hal as soon as they won't require an unstable feature ("async_fn_in_trait")
<re_irc> < (@boiethios:matrix.org)> : Nice, I plan to build a Kyria. I'll definitely check your repo out.
<re_irc> < (@ithinuel:matrix.org)> +EDIT: Bt least 1 (i2c) 😛
<re_irc> < (@thejpster:matrix.org)> : what am I looking for to spot miscompilation?
<re_irc> < (@thejpster:matrix.org)> Compiled 12 Feb, dissassembled just now: https://gist.github.com/thejpster/ac4cce6e514109830afad4efc4605c31
<re_irc> < (@dirbaio:matrix.org)> the original miscomp was doing bitwise ops on addrs derived from SP
<re_irc> < (@dirbaio:matrix.org)> https://github.com/rust-embedded/cortex-m/pull/463
<re_irc> < (@thejpster:matrix.org)> $ cat Cargo.lock | grep -e name -e version | grep cortex-m -A1
<re_irc> name = "cortex-m"
<re_irc> name = "cortex-m-rt"
<re_irc> version = "0.7.7"
<re_irc> orr.w r1,r2,r1, lsl #0x2
<re_irc> < (@dirbaio:matrix.org)> mov r2,sp
<re_irc> < (@dirbaio:matrix.org)> that's only correct if sp is multiple of 8, otherwise it'd have to do an add
<re_irc> < (@dirbaio:matrix.org)> so perhaps there's something similar here
<re_irc> < (@thejpster:matrix.org)> That's the only stack pointer mov I can see: https://gist.github.com/thejpster/ac4cce6e514109830afad4efc4605c31#file-dump-asm-L516
<re_irc> < (@thebutlah:matrix.org)> I noticed this type of code in one of the hal drivers I'm using:
<re_irc> < (@thebutlah:matrix.org)> /// Handle any messages with a timeout
<re_irc> pub fn handle_all_messages(
<re_irc> delay: &mut impl DelayMs<u8>,
<re_irc> &mut self,
<re_irc> < (@thejpster:matrix.org)> Oh, I should dump the other image. It could be a bug in the OS.
<re_irc> < (@thebutlah:matrix.org)> Is there ever a good reason to call a blocking delay to "give time to other parts of the system"
<re_irc> < (@thebutlah:matrix.org)> * system"? I assumed that is only relevant when using async await. And this isn't
<re_irc> < (@dirbaio:matrix.org)> : no good reaason, no. Not even with async/await since that's a blocking delay
<re_irc> < (@thebutlah:matrix.org)> : right, with async await you would use "yield_now().await" I assume
<re_irc> < (@dirbaio:matrix.org)> yep
<re_irc> < (@thebutlah:matrix.org)> should I open a PR to fix it in the imu driver that im using I suppose?
<re_irc> < (@thebutlah:matrix.org)> If y'all are confident is a problem
<re_irc> < (@thebutlah:matrix.org)> +(any other reason they might have done this?_
<re_irc> < (@thebutlah:matrix.org)> * this?)
<re_irc> < (@dirbaio:matrix.org)> perhaps the imu chip itself needs it? idk
<re_irc> < (@thebutlah:matrix.org)> does doing a "delay_ms" have any effect at all on interrupts? Interrrupts will still fire as normal during a delay right?
WSalmon__ has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
<re_irc> < (@thejpster:matrix.org)> This one is a bit more spicey because it contains fmt::Debug machinery: https://gist.github.com/thejpster/6d2ccaa646c6d38a6a9e0c76bdce9a26
WSalmon has joined #rust-embedded
<re_irc> < (@jamesmunns:beeper.com)> Any hint to the functions that were making that one key vs the other decision?
<re_irc> < (@jamesmunns:beeper.com)> I'm heading out for a bit, I can peek later if you can point me where to look.
<re_irc> < (@dirbaio:matrix.org)> the pattern to trigger it was: indexing a small on-stack array with a value the compiler knows is bounded (like a "bool", or an enum variant casted as usize)
<re_irc> < (@dirbaio:matrix.org)> perhaps you have something like that in the keyboard code?
<re_irc> < (@dirbaio:matrix.org)> that's the pattern we found, nothing guarantees it's the only one though!
<re_irc> < (@dirbaio:matrix.org)> so it could be anything
<re_irc> < (@ithinuel:matrix.org)> : It might be something specific to your target. Which HAL is that from?
<re_irc> < (@thejpster:matrix.org)> oh for sure. Keyboard HID events come from the BIOS into the OS as a struct of a u8 keycode and a small enum.
<re_irc> < (@thejpster:matrix.org)> The OS I posted earlier was too old. This one has the cmd_kbtest function: https://gist.github.com/thejpster/53f931fc2cef1804fe2b29f260626058
<re_irc> < (@thejpster:matrix.org)> cmd_kbtest goes into a loop pumping the BIOS function hid_get_events, running the events through pc_keyboard EventDecoder and printing the results to the console.
<re_irc> < (@thejpster:matrix.org)> It would sometimes just print the wrong keyboard code.
<re_irc> < (@thejpster:matrix.org)> I recall that instead of pc_keyboard::KeyCode::RAlt2 it would say pc_keyboard::KeyCode::LShift, but then it would also get stuck somehow and not report all the key events. You'd press a key and then more key events would turn up, including the missing one from earlier. But not always? It was weird.
<re_irc> < (@dirbaio:matrix.org)> welp finding it in a dump of 20k asm lines is going to be impossible
<re_irc> < (@thejpster:matrix.org)> I mashed on the keys a whole bunch just now and it didn't seem to miss out anything or mis decode something. But you know, it could just be my bad programming.
brazuca has joined #rust-embedded
<re_irc> < (@adamgreig:matrix.org)> I _think_ you'd expect to see it always hit the bug and never work, rather than sometimes work and sometimes not on the same execution
<re_irc> < (@adamgreig:matrix.org)> but yea, perhaps it's some totally different manifestation of bug
IlPalazzo-ojiisa has quit [Quit: Leaving.]
dc740 has quit [Remote host closed the connection]
lehmrob has joined #rust-embedded
lehmrob has quit [Quit: Konversation terminated!]
loki_val has joined #rust-embedded
crabbedhaloablut has quit [Remote host closed the connection]
rardiol has joined #rust-embedded