troth has quit [Ping timeout: 264 seconds]
troth has joined #rust-embedded
<re_irc> <> Let's say you want to store a short sound clip into a program. (Represented as an i32 array etc). How would you do it, short of a mass copy+paste?
<re_irc> <> Perhaps onboard flash, perhaps offboard eg if it's too big
<re_irc> <> Another question: When performing multiple successive transforms on data, do you save memory by modifying a `static mut` in place, vice accepting `&[i32]`, and outputting `[i32; SIZE]` ?
<re_irc> <> I'd do the latter approach for code style in other settings and languages, but wondering if I'm "copying" etc data here unecessarily
<re_irc> <> So far, they both seem to work
<re_irc> <> `include_bytes!()` is nice for including binary data
<re_irc> <> seet
<re_irc> <> appreciate it
<re_irc> <> Looks perfect
fabic_ has joined #rust-embedded
fabic_ has quit [Ping timeout: 260 seconds]
PyroPeter has quit [Ping timeout: 258 seconds]
PyroPeter has joined #rust-embedded
fabic_ has joined #rust-embedded
tokomak has joined #rust-embedded
troth has quit [Ping timeout: 260 seconds]
troth has joined #rust-embedded
<re_irc> <> Could you theoretically use `include_bytes!()` for creating a combined bootloader + app image?
<re_irc> <> That's a fun idea. I bet you could
fabic_ has quit [Ping timeout: 265 seconds]
fabic_ has joined #rust-embedded
fabic_ has quit [Ping timeout: 260 seconds]
starblue has quit [*.net *.split]
starblue has joined #rust-embedded
<re_irc> <> I've absolutely done this :D
<re_irc> <> If I had to write a bootloader, it's what I
<re_irc> <> Better than writing some external combiner to add two ELFs/BINS/s28s
<re_irc> <> That's the bootloader, including two initial images, because I'm using it to test the behavior
<re_irc> <> Is there a way to specify a linker section for `include_bytes!`?
<re_irc> <> like, I guess I can apply a linker section to the static? I think?
<re_irc> <> Won't you just do a #[.section] above?
<re_irc> <> You just specify the linker section for the variable
<re_irc> <> Yeah, fair
<re_irc> <> I'm trying to remember how I did that for sprocket-boot again, since I think I pulled the same trick...
<re_irc> <> hmmm, maybe not.
<re_irc> <> We use this method for bundling the bootloader in RP2040.
inara` has joined #rust-embedded
inara has quit [*.net *.split]
fabic_ has joined #rust-embedded
<re_irc> <> it does have to live in user code though - i tried using using the #[link_section] directive in the HAL and that just silently fails.
<re_irc> <> it makes sense, but I still don't like it.
hifi has quit [Remote host closed the connection]
<re_irc> <> Don't we use it directly in cortex-m-rt?
hifi has joined #rust-embedded
<re_irc> <> first rustc issue popped up
<re_irc> <> uh... now it seems to be working. not sure if it's because i was holding it wrong before or if i'm holding it wrong now.
<re_irc> <> looks like i have another thing to look into on the weekend.
<re_irc> <> RTIC q: Does anyone know how to pass a resource to a function? Getting this error with the naive approach:
<re_irc> <> hearing_test::run(&[], cx.shared.dfsdm, dma, cx.shared.sai);
<re_irc> <> ```rust
<re_irc> <> | ^^^^^^^^^^^^^^^ expected mutable reference, found struct `shared_resources::dfsdm`
<re_irc> <> `&mut *cx.shared.dfsdm` maybe?
<re_irc> <> ```error[E0614]: type `shared_resources::dfsdm<'_>` cannot be dereferenced```
<re_irc> <> I'm going through [the official examples](
<re_irc> <> But they seem a bit sparse
<re_irc> <> If it’s a shared resource it’s behind a mutex (unless you declared it as lock_free?)
<re_irc> <> This case actually has both
<re_irc> <> ```rust
<re_irc> <> cx.shared.dma.lock(|dma| {
<re_irc> <> hearing_test::run(&[], &mut cx.shared.dfsdm, &mut dma, &mut cx.shared.sai);
<re_irc> <> Zoomed out a bit:
<re_irc> <> });
<re_irc> <> Note that RTIC has been working for me, but I just threw 2 curve balls at it, re the locked resource, and passing resources as fn params
<re_irc> <> There teh other 2 are lock-free
<re_irc> <> Would recommend asking in
<re_irc> <> Haha thanks. I tried to find it but didn't come up on the search
<re_irc> <> But you need to modify the type that your function is accepting. RTIC wraps shared resources in custom structs, so the type somewhat changes
<re_irc> <> But what you're trying to do is definitely possible from what I remember
<re_irc> <> TBH if that's the case I'd rather not use it
<re_irc> <> The argument of your en would have the type `impl Mutex<T = u32>` or whatever
<re_irc> <> I don't want to influence downstream code with resource logic
<re_irc> <> Ie the function should just accept a mutable ref and not care how it's managed
<re_irc> <> This is a dealbraeker
<re_irc> <> why can't you lock dfsdm like you lock dma?
<re_irc> <> Don't need to. Locking `dma` since it's used by diff tasks at diff pris
<re_irc> <> And when you call it you wrap it in `Exclusive` newtype
<re_irc> <> if dfsdm is just used in the current task then "locking" it is a noop I think (?)
<re_irc> <> Could be
<re_irc> <> like you get the lock syntax but not the overhead (?)
<re_irc> <> Well, the idea is to avoid the lock syntax unless you need it
<re_irc> <> And when you need it is described in the RTIC docs as when multiple resources of diff pri use it. This makes sense, and is enforced by RTIC using the compiler
<re_irc> <> It's pretty clever
<re_irc> <> Then you should define it as a local
<re_irc> <> But Yeah i think the lock is automatically removed by the compiler, at least it used to
<re_irc> <> Also remember you can ”multi-lock” serveral resources as a tuple
<re_irc> <> Inside the lock closure they’re just mutable references with the original type
<re_irc> <> Maybe i don’t understand your unsage to see the problem :)
<re_irc> <> Working on the RTIC channel now
<re_irc> <> I'm just learning RTIC
<re_irc> <> See you there :)
<re_irc> <> Sorted out! Appreciate it
<re_irc> <> But i can almost guarantee you there are no hidden ”dealbreakers”
<re_irc> <> The root is, you need to lock resources that are passed as params
<re_irc> <> Haha yea, this was a false alarm
<re_irc> <> I'm a big fan of RTIC from an embedded development perspective. It's everything you want from defined timing + control with none of the software overhead of an RTOS
<re_irc> <> Or at least very little overhead
<re_irc> <> I like it too! My hesitation is that from a code layout and syntax perspective, it's not much diff from cortex-m mutexes
<re_irc> <> Ie, It's effectively a syntax change from the perspective of my code bases
<re_irc> <> init function + superloop is a super common design paradigm
<re_irc> <> Granted, I use macros to wrap the ugly mutex creation and unwarpping
<re_irc> <> Just take a look at arduino
<re_irc> <> No thank you!
<re_irc> <> It removes most of the boilerplate you need for any app bigger than a blinky in a very clever way i cant imagine reinventing myself every time and lets you focus on the business logic
<re_irc> <> While still being low level to give you full control of the hardware
<re_irc> <> Sure, but you can do the same with ISRs and mutexes
<re_irc> <> It sounds like RTIC's locking is faster than mutexes
<re_irc> <> and Mutex syntax is ugly unless you macro it
<re_irc> <> it's not "faster" (except in the situations where it's a no-op), but it has a lower system-level impact
<re_irc> <> Sure I can but why bother? :)
<re_irc> <> From my experimenting so far, it's a push
<re_irc> <> I'm using RTIC in this project to learn, and get a better perspective
<re_irc> <> 🙌 for me there was no going back :)
<re_irc> <> Maybe that'll be me in a month
<re_irc> <> Ymmv :) But we’re here for you if you get stuck!
<re_irc> <> Demonstrated
<re_irc> <> You’ll love the timer queue and capacity etc
<re_irc> <> Those are probably the biggest selling points for me apart from resource handling
<re_irc> <> Oh haven't messed with that yet!
<re_irc> <> Using timers manually can be a bit clumsy for task scheduling. Looking fwd to trying
<re_irc> <> Also to have ”software task” handled by the hardware with priority etc is wonderful
<re_irc> <> `</fanboy>`
<re_irc> <> Let's say there are couple of examples under lib examples dir. Is it possible to mark that those would be built only if using `target.thumbv7em-none-eabihf`?
<re_irc> <> Essentially lib and tests can run on x86, but there are specific examples that only run on `thumbv7em-none-eabihf`.
<re_irc> <> `cargo test` tries to build aIso all examples which only build for `thumbv7em-none-eabihf` at the moment. I think it is impossible to put `#[cfg(target="thumbv7em-none-eabihf")]` or something in those example files to disable building them.
<re_irc> <> I'll tag the Stm32-HAL timers with RTIC monotimic
fabic_ has quit [Ping timeout: 260 seconds]
tokomak has quit [Ping timeout: 264 seconds]
emerent_ has joined #rust-embedded
emerent is now known as Guest3115
emerent_ is now known as emerent
Guest3115 has quit [Ping timeout: 260 seconds]