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> < (@jamesmunns:beeper.com)> Does anyone know if relocatable code works on the bare metal RISC-V targets?
<re_irc> < (@jamesmunns:beeper.com)> I know (think?) cortex m still has problems with pic/pie/ropi stuff
<re_irc> < (@dirbaio:matrix.org)> it works if you have a loader that applies relocations somehow, same as cortex-m
<re_irc> < (@dirbaio:matrix.org)> cortex-m's ropi/rwpi is an attempt to not need a loader, that's what's broken
<re_irc> < (@dirbaio:matrix.org)> +such
<re_irc> < (@jamesmunns:beeper.com)> Oh, I thought cortex m was missing something that properly generated relocation symbols or something
<re_irc> < (@dirbaio:matrix.org)> (and I don't think there's a rwpi/ropi equivalent for riscv)
<re_irc> < (@dirbaio:matrix.org)> afaik "normal" PIC/PIE works for cortex-m
<re_irc> < (@dirbaio:matrix.org)> I've never used it myself so don't quote me on that tho
<re_irc> < (@jamesmunns:beeper.com)> Oh huh.
<re_irc> < (@adamgreig:matrix.org)> yea, the problem is that ropi/rwpi requires specialist codegen to use a sort of platform ABI to agree on a relocation base
<re_irc> < (@adamgreig:matrix.org)> afaik there's no equivalent for r-v?
<re_irc> < (@jamesmunns:beeper.com)> Huh. Seems like I need to go learn how all the pic/pie stuff actually works, and what it would take to write a loader
<re_irc> < (@adamgreig:matrix.org)> oh hey https://github.com/riscv-non-isa/riscv-elf-psabi-doc/issues/128
<re_irc> < (@adamgreig:matrix.org)> of course oxide/cliff are asking about it :p
<re_irc> < (@adamgreig:matrix.org)> his comment there seems like a good summary of ropi/rwpi too
<re_irc> < (@jamesmunns:beeper.com)> Yeah, that helped!
<re_irc> < (@jamesmunns:beeper.com)> And tock gets a mention
IlPalazzo-ojiisa has quit [Quit: Leaving.]
genpaku has quit [Remote host closed the connection]
genpaku has joined #rust-embedded
genpaku has quit [Quit: leaving]
genpaku has joined #rust-embedded
bjc has quit [Ping timeout: 260 seconds]
starblue has quit [Ping timeout: 252 seconds]
starblue has joined #rust-embedded
<re_irc> <Charles ⚡️> i'm trying to set up a project for my nrf52840 devboard and "cargo embed" is telling me this:
<re_irc> $ cargo embed
<re_irc> Config default
<re_irc> Finished dev [unoptimized + debuginfo] target(s) in 0.02s
<re_irc> <Charles ⚡️> * I'm
<re_irc> <Charles ⚡️> ah i appear to be dumb
<re_irc> 2. i hadn't actually "use"d the hal in the code yet
<re_irc> doing both of those things fixed it
bjc has joined #rust-embedded
<re_irc> <Charles ⚡️> why does rust-analyzer complain about "#[cortex_m_rt::entry]"?
<re_irc> processing crate: spectra, module: /home/charles/science/freecad/spectra_keyboard/rust/src/main.rs
<re_irc> Diagnostic { code: DiagnosticCode("unresolved-proc-macro"), message: "proc macro `entry` not expanded: proc-macro expansion is disabled", range: 1020..1041, severity: WeakWarning, unused: false, experimental: false, fixes: None }
<re_irc> $ rust-analyzer diagnostics .
<re_irc> <Charles ⚡️> bug i guess: https://github.com/rust-lang/rust-analyzer/issues/14047
<re_irc> <Charles ⚡️> gotta say, embedded rust tooling has improved massively since the last time i tried things several years ago, this is great
<re_irc> <Sean Lyons> I actually had the same problem when making my first pac a few days ago, sorry I wasn’t online to help!
<re_irc> Maybe we should update the svd2rust docs with a sample snippet of how to configure the generated pac.
<re_irc> <Sean Lyons> I got some help from this group when making my first pac a while back. Now I’ve gotten a few created.
<re_irc> Thanks for the guidance, any advice is welcome :)
lehmrob has joined #rust-embedded
madb_ has joined #rust-embedded
<re_irc> < (@wucke13:matrix.org)> With regard to this, I have a new confusion: "static AtomicUsize" and "static Cell<...>" initialized with 0 both are put after the ebss, not in the ebss. If any other number than 0 is used for intialization, they are correctly placed in the data section.
madb_ has quit [Changing host]
madb_ has joined #rust-embedded
madb_ is now known as madb
IlPalazzo-ojiisa has joined #rust-embedded
starblue has quit [Ping timeout: 268 seconds]
starblue has joined #rust-embedded
brazuca has joined #rust-embedded
<re_irc> < (@korken89:matrix.org)> Looks like a shitposts but that is serious (trying to solve the N+1 limit in const generics):
<re_irc> #[repr(C)]
<re_irc> buf: [T; N],
<re_irc> struct Test<const N: usize, T> {
<re_irc> < (@korken89:matrix.org)> * shitpost
<re_irc> < (@korken89:matrix.org)> Turns out that the codegen for this is surprisingly good
<re_irc> < (@korken89:matrix.org)> (when you use it that is)
<re_irc> < (@dirbaio:matrix.org)> wow, cursed! :D
<re_irc> < (@dirbaio:matrix.org)> fails miri because "self.buf.as_ptr()" has provenance for only "buf"
<re_irc> < (@dirbaio:matrix.org)> using "self as *const _ as *const T" instead passes
brazuca has quit [Quit: Client closed]
<re_irc> < (@dirbaio:matrix.org)> I think this trick is similar to what "generic_array" does? engineer a struct that has the right layout for X items, then cast it to a slice
<re_irc> < (@korken89:matrix.org)> Probably
<re_irc> < (@korken89:matrix.org)> It's just annoying that const generics are so limited
<re_irc> < (@korken89:matrix.org)> If it looks like a slice, quacks like a slice, walks like a slice ... is it a slice? :D
<re_irc> < (@dirbaio:matrix.org)> Python says yes
<re_irc> < (@korken89:matrix.org)> xD
brazuca has joined #rust-embedded
emerent has quit [Ping timeout: 264 seconds]
emerent has joined #rust-embedded
<re_irc> < (@jamesmunns:beeper.com)> btw, the "right" way to do this is (and pass provenance) is to use "*mut Test"/"NonNull<Test>" and "addr_of_mut"
<re_irc> < (@jamesmunns:beeper.com)> oh, yeah, what dirbaio said. A little less cursed:
<re_irc> impl<const N: usize, T> Test<N, T> {
<re_irc> unsafe {
<re_irc> fn as_slice(&self) -> &[T] {
<re_irc> < (@jamesmunns:beeper.com)> you could also just cast like dirbaio said tho, since you're already saying "fuck it, I control the layout" lol
<re_irc> < (@korken89:matrix.org)> :D
lehmrob has quit [Remote host closed the connection]
lehmrob has joined #rust-embedded
lehmrob has quit [Quit: Konversation terminated!]
brazuca has quit [Quit: Client closed]
brazuca has joined #rust-embedded
brazuca has quit [Quit: Client closed]
brazuca has joined #rust-embedded
IlPalazzo-ojiisa has quit [Quit: Leaving.]
<re_irc> <Charles ⚡️> error: invalid instruction
<re_irc> |
<re_irc> 105 | "vsqrt.f32 {y}, {x}",
<re_irc> --> src/main.rs:105:14
<re_irc> <Charles ⚡️> alternatively, how do i get "f32::sqrt()" or equivalent on that target?
<re_irc> <Stephen D> Charles ⚡️: Would micromath work for your usecase? https://docs.rs/micromath/latest/micromath/index.html
<re_irc> <Stephen D> It's what I use
<re_irc> <Charles ⚡️> this thing has an FPU so it'd be nice if i could use it
<re_irc> <Stephen D> hmm
<re_irc> <Stephen D> Yeah that would be ideal
<re_irc> <Charles ⚡️> also this is hardware xy-problem anyway i think
<re_irc> <Charles ⚡️> i think i really just need more sensitive sensors
Abhishek_ has quit [Quit: Connection closed for inactivity]
brazuca has quit [Ping timeout: 260 seconds]
seds_ has joined #rust-embedded
cyrozap_ has joined #rust-embedded
a2800276_ has joined #rust-embedded
<re_irc> < (@dkhayes117:matrix.org)> I have a "&[u8]" that I'm feeding into "serde_json::from_slice(&packet.payload[..])?" and I'm getting an error which I've tried to debug but haven't had any luck. Any Ideas?
<re_irc> Json(Error("invalid type: map, expected unit"))
<re_irc> < (@dirbaio:matrix.org)> what type are you trying to deserialize it into?
<re_irc> < (@dkhayes117:matrix.org)> Function signature
<re_irc> &mut self,
<re_irc> path: &str,
<re_irc> ) -> Result<T, Error>
<re_irc> pub async fn lightdb_read_state<T: DeserializeOwned>(
cyrozap has quit [*.net *.split]
seds has quit [*.net *.split]
a2800276 has quit [*.net *.split]
seds_ is now known as seds
<re_irc> < (@dirbaio:matrix.org)> yea but what's the actual "T" that causes the error?
<re_irc> < (@dirbaio:matrix.org)> I think the error means it found a "map" (a JSON object I guess? ie"{}") and it expected "unit"
<re_irc> < (@dirbaio:matrix.org)> I think "unit" is a Rust struct like "struct Foo;", with no fields
<re_irc> < (@dirbaio:matrix.org)> so maybe it doesn't allow deserializing a "{}" into that?
<re_irc> < (@dkhayes117:matrix.org)> Ohhh, I think I see the problem. I didn't define the type when I call that function, so it was unknown. Below shows the added type, which I will try now.
<re_irc> let read : TempSensor = golioth.lightdb_read_state(device_id.await?;
<re_irc> < (@dirbaio:matrix.org)> ahh "unit" is "()"
<re_irc> < (@dirbaio:matrix.org)> makes sense then :D
<re_irc> < (@dkhayes117:matrix.org)> So simple, but needed someone to ask me an obvious question to see it :P
<re_irc> < (@dkhayes117:matrix.org)> Thanks!
<re_irc> < (@dirbaio:matrix.org)> nothing like a rubber duck :P
<re_irc> < (@dirbaio:matrix.org)> 🔔 "smoltcp" 0.9.0 is now out! Adds support for DNS and fragmentation, includes a cleaner API and many fixes. Changelog -> https://github.com/smoltcp-rs/smoltcp/blob/master/CHANGELOG.md
brazuca has joined #rust-embedded
<re_irc> < (@halfbit:matrix.org)> : oh, using golioth with rust on embedded? neat!
<re_irc> < (@halfbit:matrix.org)> or is this something entirely different hah
crabbedhaloablut has quit [Quit: No Ping reply in 180 seconds.]
crabbedhaloablut has joined #rust-embedded
<re_irc> < (@dkhayes117:matrix.org)> Yep, I've already got one project working with the nrf9160. Now I'm porting `golioth-rs` to use `Embassy` and `nrf-modem`
<re_irc> < (@halfbit:matrix.org)> Interesting
IlPalazzo-ojiisa has joined #rust-embedded
crabbedhaloablut has quit [Remote host closed the connection]
crabbedhaloablut has joined #rust-embedded
madb has quit [Ping timeout: 260 seconds]
<re_irc> <harcrow> Hi everyone. I'm a hardware person trying to keep up with the embedded FW world, so bear with me. I have an STM32F4 and am trying to understand how to derive some of the syntax from the stm32f4xx-hal documentation. To declare a type alias for a peripheral, I've seen in this example
<re_irc> pub type I2c1Handle = I2CMasterDma<
<re_irc> (PB8<AF4<OpenDrain>>, PB9<AF4<OpenDrain>>), // Pins
<re_irc> I2C1, // Instance of I2C
<re_irc> <Pranav Athreya> Hi everybody!! New to Rust; can't wait to start writing embedded apps in the language!!!
<re_irc> < (@dkhayes117:matrix.org)> Pranav Athreya: Welcome!