starblue has quit [Ping timeout: 260 seconds]
starblue has joined #rust-embedded
<re_irc> <> That's nuts! I agree in your case you may wish to have an intermediate PAC-like layer.
<re_irc> <> Unfortunately, you won't be able to auto-gen it like you can with SVDs
<re_irc> <> This also depends on if you're trying to write a general driver you can use later, of if you only need to implement specific functionality for a project
<re_irc> <> (The latter is a lot easier!)
PyroPeter has quit [Ping timeout: 260 seconds]
PyroPeter has joined #rust-embedded
<re_irc> <> ( adamgreig ) there is no PR yet, but the idea of simple, let the user specify the instant and duration type of their time library (and we assert that it has the right traits implemented), then RTIC will happily use it. I needed to finish a first version of my time library so we have two to design with and make sure it works as we want :) I released the "const embedded time" lib...
<re_irc> ... yesterday, you can have a look here is you're interested:
<re_irc> <> So now we can finalize the the monotonic trait
tokomak has joined #rust-embedded
edm has quit [Ping timeout: 264 seconds]
SanchayanMaity has quit [Read error: Connection reset by peer]
SanchayanMaity has joined #rust-embedded
edm has joined #rust-embedded
fabic_ has quit [Remote host closed the connection]
fabic has joined #rust-embedded
tokomak has quit [Ping timeout: 264 seconds]
<re_irc> <> korken89: I have a stupid question about fugit. Let's say I would like to use `trait CountDown` using `fugit` Duration as `count`:
<re_irc> <> ```rust
<re_irc> <> use fugit::ExtU32;
<re_irc> <> This would allow `start` it like this:
<re_irc> <> You should select a duration
<re_irc> <> Or parameterize over `NOM / DENOM` and const generics
<re_irc> <> So eg `Time = MillisDurationU32`
<re_irc> <> Then it should work fine
<re_irc> <> Yes it works. I just missed `.into()` and that gave little bit confusing error message.
<re_irc> <> impl CountDown for SysTimer {
<re_irc> <> ```rust
<re_irc> <> type Time = fugit::Duration<u32, 1, 1000>;
<re_irc> <> What is the deal with ✂️ and 📝?
<re_irc> <> andres: Awesome!
<re_irc> <> andres: I think this is when the IRC bridge puts something in a pastebin
fabic has quit [Ping timeout: 265 seconds]
fabic has joined #rust-embedded
<re_irc> <> korken89: Let's say I have somekind of lib which has following enum. Instant is used here to timestamp for example when start was called.
<re_irc> <> use fugit::Instant;
<re_irc> <> ```rust
<re_irc> <> enum State {
<re_irc> <> To make something generic of the `Instant` I'd recommend using const generic parameters
<re_irc> <> Yes right I can do that.
<re_irc> <> enum State<const N: u32, const D: u32> {
<re_irc> <> Start(Instant<u32, N, D>);
<re_irc> <> Stop(Instant<u32, N, D>);
<re_irc> <> }
<re_irc> <> As instants generally do not have the same baseline, converting between instants is not valid
<re_irc> <> This is why these conversions are not implemented for Instant, but are for Duration
<re_irc> <> Jep that makes sense. I am converting one of the lib that is using `embedded-time` to `fugit`.
<re_irc> <> Ah nice!
<re_irc> <> Thanks for giving it a try!
<re_irc> <> I have not come that far myself yet with RTIC
<re_irc> <> Ping me if you find more issues with the interface or usability :)
<re_irc> <> It's only `0.1` so probably a lot of room for improvement
<re_irc> <> Honestly, I would desperately prefer that any `Instant` only have a single type param at most, like embedded-time
<re_irc> <> How so?
<re_irc> <> The nice part with fugit is that you can choose one, and not be generic
<re_irc> <> Then the implementation is made so it does conversions to your chosen one at compile time
<re_irc> <> So the generic is only to set your specification
<re_irc> <> Is there a generic type that any library can use?
<re_irc> <> The rest of usage will be converted to your specification
<re_irc> <> I want crates to be able to make use of various `Instant`s and they have no concept of what the underlying system time keeping mechanism is
<re_irc> <> This is why it's so heavy on the `const` side
<re_irc> <> Same as we want in RTIC
<re_irc> <> Not quite sure what you mean?
<re_irc> <> As it converts at compile time you can choose any concrete type that fits your use case
<re_irc> <> One thing I really like about embedded-time is that I can construct a `Clock` and hand it to a crate so that crate can now internally keep time on an arbitrary system
<re_irc> <> The clock part is not part of fugit
<re_irc> <> Take for example my minimq crate, where I need to periodically send out `PING` messages at a set interval
<re_irc> <> If you want a clock trait it would be a different crate
<re_irc> <> Does fugit support some `clock`-like trait?
<re_irc> <> It only defines instants and durations, if you want a clock trait that returns an instant this is fine - but up to you
<re_irc> <> E.g. if you want to make sure 2 instants are from different clocks, you would have the old interface of embedded-time
<re_irc> <> This is not the aim of fugit though, it only handles the time math very efficiently and with concrete types
<re_irc> <> Gotcha
<re_irc> <> The areas where embedded-time did not do well
<re_irc> <> ... agreed
<re_irc> <> You could on top of this make a crate like fugit-traits
<re_irc> <> And add an embedded-time like API
<re_irc> <> I've fought embedded-time so incredibly much just trying to get e.g. a `Second(1) / 2`
<re_irc> <> Indeed
<re_irc> <> Which is absurd
<re_irc> <> Plus that and expression like that should be compile time optimized
<re_irc> <> Plus another thing
<re_irc> <> As fugit uses concrete types you dont get the generic instantiation bloat that embedded-time has
<re_irc> <> If you want to write a function which takes a duration for example
<re_irc> <> Just let the compiler do the conversion for you to whatever granularity you choose
<re_irc> <> Only one impl is generated
<re_irc> <> We had quite big issues in RTIC to not get an implementation of the entire `spawn_after` system for every different duration the use hit us with in their code
<re_irc> <> And generating concrete type compression points was extremely difficult
<re_irc> <> So in `fugit` I simply removed this way of doing it
<re_irc> <> `The power of const compels you`
<re_irc> <> ryan-summers: I think something like this would be a clock interface ala embedded-time:
<re_irc> <> /// The type to hold the tick count
<re_irc> <> type Instant: fugit::Instant::<u64, 1, 1_000_000>;
<re_irc> <> pub trait Clock: Sized {
<re_irc> <> (not tested)
<re_irc> <> I assume `type instant: fugit::Instant` is supposed to be `type instant = fugit::Instant`, e.g. default instant type?
<re_irc> <> Was thinking that was some strange type trait impl shenanigans for a moment
<re_irc> <> korken89: I have only looked at fugit for a few seconds, please excuse my ignorance. But from the perspective of someone who has worked many years in time and frequency in national metrology institutes, your approach looks promising. I don't know whether the implementation is correct in detail, but I agree that `fugit` can likely solve the massive and fundamental unsoundness and the current problems with the...
<re_irc> ... existing crates.
<re_irc> <> Ah yes
<re_irc> <> I mixed implementation and definition
<re_irc> <> Only would select a `fugit::Instant` as the `Clock::Instant`
<re_irc> <> Thanks!
<re_irc> <> I stole 99% of the math from embedded-time and made them const where it was not possible originally
<re_irc> <> The only thing I do differently is that I optimize the numerator and denominator for an expression at compile time
<re_irc> <> But I'm also not 100% sure everything is correct
<re_irc> <> But the idea of a rational time base and integer ticks on that is sound.
<re_irc> <> I only have basic testing in place, including overflow/wrapping testing
<re_irc> <> But I think there are edge cases not coverted
<re_irc> <> Yeah, both embedded-time and fugit uses the same idea here :D
<re_irc> <> I'm trying to use cortex-m-rt in version 0.7.0 in my project but I'm getting loads of what I assume are linker errors:
<re_irc> <> = note: rust-lld: error: undefined symbol: PVD
<re_irc> <> I was upgrading from 0.6.13. Is there anything I'm missing here?
<re_irc> <> On the same note, has anyone ever experienced issues with the `#[entry]` macro confusing `rust-analzyer`? It doesn't seem to pick up variable names anymore once `#[entry]` is present
<re_irc> <> Have you enabled the procmacro support?
<re_irc> <> My impression was that embedded-time doesn't really follow through with it though and that's where it becomes hairy and unsound.
<re_irc> <> Basically you want to free yourself from any preference for a timescale. That includes not interpreting/coerscing anything to SI units.
<re_irc> <> Ah yeah
<re_irc> <> That's true
<re_irc> <> korken89: oh wow yeah that's a really good point. I don't think I have
<re_irc> <> I think its experimental still
<re_irc> <> It seems like it's enabled by default now
<re_irc> <> But I guess the experimental-ness of it is the reason why it doesn't work (yet)
<re_irc> <> Thanks korken89, that's definitely a good point
<re_irc> <> I had some thoughts about the whole time traits discussion and did some experiments with code on an STM32L4 Nucleo board.
<re_irc> <> I think that stuff can really be optimized when the caller of Instant::now() specifies something additional.
<re_irc> <> Like`'let instant = Instant<Milliseconds>::now()`
<re_irc> <> But I don't know if this concept is the way to go.
<re_irc> <> Something comparable would be `let d: MillisDurationU32 = Instant::now().duration_since_epoch().convert()` ?
<re_irc> <> Performancewise, the expensive stuff happens on two places: creating the instant and converting it.
<re_irc> <> If the needed precision is known at the instantiation, you can get around it.
<re_irc> <> The more general problem here is that Instants generally are not connected to a specific time unit, so the conversion is always needed
<re_irc> <> But the implementation can optimize it for common use cases like Milliseconds.
<re_irc> <> Plus that instants in their own right are barely used, only durations form a good basis for thing more can comparison
<re_irc> <> Not sure I follow your problem
<re_irc> <> Yes, but duration is mostly addition and subtraction.
<re_irc> <> Unless time base changes are needed, then muls and divs
<re_irc> <> What issue is it you are looking to solve?
<re_irc> <> When I create an instant in my app code, I decide which precision is needed. If I create it with ms, I'm quite sure I don't do conversions to µs.
<re_irc> <> What do you mean with converting an instant?
<re_irc> <> They are opaque types without fixed baseline, so you can't really convert their bases
<re_irc> <> The main issue is that embedded-hal does not have Instant types because noone knows how they should look like.
<re_irc> <> Exactly
<re_irc> <> You generally only work in durations
<re_irc> <> Instants are only a means to get durations in the end
<re_irc> <> As they have a fixed baseline of 0
<re_irc> <> In the end, I need real time units.
<re_irc> <> So you have a duration and want it in millis?
<re_irc> <> `let d: Duration::<_, 1, 1000> = old_d.convert();` seems like what you want to do?
<re_irc> <> And then only use it in millis
<re_irc> <> Yes, but the main issue is that conversions imply expensive divisions if not optimized from the start.
<re_irc> <> If they are generated from a different timebase they never will be optimized completely, you would need to select an instant timebase that has the same granularity
<re_irc> <> This is no problem on a Cortex-M4 but for smaller chips it's not a good idea.
<re_irc> <> If your timer runs at 1 MHz and you want millis, you are forced to do the / 1000 divition
<re_irc> <> Yes, but I can decide how fast my timer runs. And this is 1k in my case.
<re_irc> <> Sure, then there is no problem
<re_irc> <> E.g. in fugit that will optimize to no conversion
<re_irc> <> The checks made for "same base" are done at compile time
<re_irc> <> With a Cortex, you can still get µs precision even if the systick runs on 1k only.
<re_irc> <> ?
<re_irc> <> Sure you can link multiple timers if you want to make a dual timer with different time bases
<re_irc> <> No, i'm talking about much simpler stuff.
<re_irc> <> I'm still not following on the problem though, what is it you are trying to solve?
<re_irc> <> Do you want to make a clock abstration that minimizes conversions?
<re_irc> <> E.g. in RTIC we don't do a single time conversion for the entire scheduling framework when applying `fugit`
<re_irc> <> Again, what I need in the end is `time::millis()` and `time::micros()` and this should play together with the `embedded-hal` abstraction.
<re_irc> <> You can implement a `Clock` abstration which does that
<re_irc> <> But it seems that my concept is too simple. Even the Arduino stuff provides them.
<re_irc> <> pub trait Clock: Sized {
<re_irc> <> fn micros(&self) -> Instant::<u32, 1, 1_000_000>;
<re_irc> <> fn milllis(&self) -> Instant::<u32, 1, 1_000>;
<re_irc> <> E.g.:
<re_irc> <> }
<re_irc> <> Where is this code from?
<re_irc> <> Directly from my head :)
<re_irc> <> That is the trait I would make for your usecase
<re_irc> <> It's not the point that I can do this on my own. The point is that embedded-hal should at least provide this simple stuff so it can be used widely.
<re_irc> <> Sure, but something simple like that you can make into your own crate if you don't want it to go through the WG machinery
<re_irc> <> But I'm not that into the `embedded-hal` design decision process
<re_irc> <> But this is what the initial discussion was about.
<re_irc> <> Ah, then I misunderstood you - I though you were looking for a clock abstration
<re_irc> <> embedded-hal is lacking these traits, there's an issue open in the tracker for more than one year now.
<re_irc> <> I think the main issue is that `embedded-hal` does not want to tie itself to a specific time library
<re_irc> <> We did that error in RTIC
<re_irc> <> It does not have to
<re_irc> <> And now we are redesigning those parts
<re_irc> <> I have to leave now, cya around all
<re_irc> <> To me, embedded-hal should provide traits that define Instant and Duration in a way that does not imply a large performance drop when implementing them.
<re_irc> <> I think the reason it hasn't is because it's hard. Just look at our current discussion
<re_irc> <> I know, but a solution has to be found at some point.
<re_irc> <> But there's no reason that solution has to be the only one or that it has to be incorporated into the `embedded-hal` yet
<re_irc> <> Different approaches have different tradeoffs
<re_irc> <> I think you should tie these down with specific use cases in midn
<re_irc> <> Perhaps it would be best to start with projects you use that use time durations, or if you don't have that but still want to build infrastructure, public examples
<re_irc> <> But the amount of discussion shows that there's some interest to get this in.
<re_irc> <> A lot of it is driven by RTIC
<re_irc> <> Since RTIC has a scheduler as part of it
<re_irc> <> Then it should be easy to find concrete examples
<re_irc> <> What they choose to use will ultimately drive a lot of the ecosystem
<re_irc> <> Chicken+egg problem?
<re_irc> <> The only place I seriously need time support is in an MQTT TCP client:
<re_irc> <> There are probably some chickens around
<re_irc> <> Find code bases that use RTIC and would benefit
<re_irc> <> and see what works
<re_irc> <> I just need to manage elapsed seconds. Smoltcp has similar issues with having an `Instant` for the network stack to know when to manage TCP-related ops, DHCP, DNS etc.
<re_irc> <> I'm using it for one growing codebase, but can't comment since I only use its resource management, not scheduling
<re_irc> <> I'm using ISRs and manually managing timers, but maybe I'll look at RTIC's scheduling soon
<re_irc> <> I haven't had a need for `embedded-time` Instant support for anything more granular than e.g. 500ms
<re_irc> <> And I assume anything less will start having serious impacts on performance just due to time math
<re_irc> <> E.g. if you're working with uS durations on a 1MHz processor, just the additions have a big impact
<re_irc> <> Can you think of any examples? For background, in the WIP project I'm thinking of (The one that uses RTIC), I use tmings on the order of 48kHz (it's audio), which comes from the MCU's audio clock, via DMA transfer complete and HT complete interrupts. I also use timers with ~second order timing to let's say, start or stop playing a certain tone or sound
<re_irc> <> Would `embedded-time` etc help there? I don't know it well enough to comment
<re_irc> <> The actual timing of the 48KHz audio is almost always going to be using a hardware peripheral, so `Instant`s are irrelevant there. The only time `embedded-time` makes sense is for the sloppier, longer scale start/stop actions
<re_irc> <> You don't want a software-based time solution for any real-time constraints
<re_irc> <> Even the blinky LED needs a timebase.
<re_irc> <> Blinky LED examples are historically done with cortex-m etc delays
<re_irc> <> Yeah, but RTIC handles things like that. The reason I like embedded-time is that it gives you an application-aspecific clock for a generic crate
<re_irc> <> You could also do it with a timer + ISR
<re_irc> <> Delay needs also a timebase.
<re_irc> <> Then setting up your timer with something like
<re_irc> <> ```rust
<re_irc> <> timer.set_period(0.3).ok();
<re_irc> <> And cycling the LED in the ISR or w/e
<re_irc> <> The delay timebase would come from the systick clock
<re_irc> <> the timer timebase would come from whatever clock that uses
<re_irc> <> I'm curious where the time abstraction fits in
<re_irc> <> In any real application, you're not doing a busywait loop for blinking an LED
<re_irc> <> When I do delay_ms(), I need a ms() function first, but the trait for this is missing.
<re_irc> <> Yea - we shoudl drop the blinky thing
<re_irc> <> TBH I'm not a fan of its ubiquity as an example
<re_irc> <> I'm coding time-related stuff ATM btw
<re_irc> <> korken89: What about Rate and Duration <-> Rate conversion. Is it planned?
<re_irc> <> Interplay between DMA, ISRs, and timers
<re_irc> <> I'm making an interactive audiogram, that involves playing various combinations of noise, tones overlayed over the noise etc. Can you think of how the abstraction would work there?
<re_irc> <> Generally, I see the use case of embedded-time for generic protocol crates. I find it less useful for applications
<re_irc> <> Unless it's for task scheduling, but as I mentioned, RTIC manages that for you behind the scenes
<re_irc> <> Basically, There's a double-output buffer fed into the audio periph (SAI) using circular DMA. So it continuously plays, and we sequence which side we play from, and which we can edit using DMA ISRs on HT and TC. I use timers to control how long each tone plays among the noise, and for things like timeout on user input response to the noise, and how long the user takes
<re_irc> <> How would you fit your time abstraction in there? THere are several areas of attack
<re_irc> <> Gotcha
<re_irc> <> (ISR == RTIC task actually here)
<re_irc> <> My thoughts in summary: Think about what the use case is. Who's the user, and how will this abstraction look in code.
<re_irc> <> Even if you don't like the blinky example, I have to say that the products I develop usually use some LEDs doing that thing.
<re_irc> <> As korken89 just said, perhaps generic protocol crates. Start there and flesh it out. Find the crates and people who use them, and see how it would fit in
<re_irc> <> Yes, LEDs are often used, but they are never implemented in the trivial method of "block all other code while we blink them" because the controller has better things to do
<re_irc> <> *Sorry, you mentioned generic protocol crates
<re_irc> <> Yes, of course. LEDs should be non-blocking, that's obvious. This is what you learn as step 2 after doing step 1 with the delay function.
<re_irc> <> You don't have to!
<re_irc> <> It (can be) a few lines to do it with a timer and ISR
<re_irc> <> But this is a bit of a tangent
<re_irc> <> wherein I rant about examples that are too narrow-focused and/or unrealistic
<re_irc> <> Honestly, LED blinking, unless you're doing dimming, is generally so timing tolerant that you just do it with a software-based timing solution, so `Instant` does actually make sense there
<re_irc> <> But I don't know if that warrants some complexities of `embedded-time`
<re_irc> <> But the point here is, that you need to handle some kind of timestamp and it's a little bit ridiculous that you need a dedicated time library to do it.
<re_irc> <> Since the whole purpose of those types of crates are to make a **generic** timebase that crates can use without knowing how the underlying system works
<re_irc> <> Why? That's how it always works
<re_irc> <> Or you write it yourself
<re_irc> <> But rust is designed to make libraries small and easy to incorporate
<re_irc> <> Using a library in rust is infinitely simpler than e.g. in C
<re_irc> <> Generally I expect it to be part of the HAL. At least the simple stuff.
<re_irc> <> All C HALs from ST provide the tick function.
<re_irc> <> I buy it. I've been cracking that nut on switching between STM32 and nRF projects by using a common API
<re_irc> <> Eg that `timer.set_period(0.3).ok();` I posted earlier works the same in either
<re_irc> <> I don't think we should be looking to those as the beacon of soundness
<re_irc> <> Arduino provides millis() and micros().
<re_irc> <> Nor do I think we should look at Arduino as the "right" way
<re_irc> <> Of course not, but something like this is so common.
<re_irc> <> But they're fundamentally different things
<re_irc> <> Not yet, but should not be a problem to add I think.
<re_irc> <> An ST-HAL tick is (i presume) to drive some RTOS-based, system level timer. They define how you're using their architecture and make a lot of assumptions
<re_irc> <> Same with Arduino. The `millis()` and friends are implying busywait loops, which again are infeasible in most real apps
<re_irc> <> We're trying to provide generic, assumption-free implementations
<re_irc> <> millis() just return a value, no blocking.
<re_irc> <> But implies there
<re_irc> <> Why?
<re_irc> <> How else do you get the current wall time?
<re_irc> <> Yes, some source of time is implied.
<re_irc> <> Not all systems have a reliable way of tracking wall time
fabic has quit [Ping timeout: 258 seconds]
<re_irc> <> Micro clocks have drift, overflow, etc.
<re_irc> <> Re Duration <->Rate:
<re_irc> <> ```rust
<re_irc> <> timer.set_period(2.).ok();
<re_irc> <> timer.set_freq(0.5).ok();
<re_irc> <> And then you have to dedicate a timer to doing that
<re_irc> <> Which steals a hardware peripheral from your users
<re_irc> <> If you you need something really precise, then it's up to you as the app developer to ensure that.
<re_irc> <> STM32 HRTIM is good for that
<re_irc> <> But this is the whole point of things like embedded-time
<re_irc> <> It allows the app to determine what drives the wall clock
<re_irc> <> Without making any assumptions for the user
<re_irc> <> Hot take: Rust is awesome for embedded and we don't need to worry so much about making everything generic
<re_irc> <> The only times I care about making things generic is when I need to use the same code for two different platforms
<re_irc> <> You can crack that nut by standardizing APIs
<re_irc> <> E.g. that MQTT library is going to be on 3(?) different hardwares
<re_irc> <> Eg that timer code I posetd above works on most STM32s and all nRF52s!
<re_irc> <> (Granted, maybe your approach is better than standardizing APIs)
<re_irc> <> Maybe it should be decided at some point if embedded-hal will provide time-related traits or leave it to some other crate.
<re_irc> <> That would make things clearer because now my impression is, these traits should be provided, but noone knows how they should look like.
<re_irc> <> It has a few already btw, but people have so far found them insufficient imo
<re_irc> <> or maybe Im thinking of `Delay`?
<re_irc> <> So either address that problem seriously or drop them would be my suggestion.
cr1901 has quit [Quit: Leaving.]
cr1901 has joined #rust-embedded
fabic has joined #rust-embedded
<re_irc> <> If embedded-hal does not define the traits, then other crates will do it. This is fine until the point where you develop an application that uses driver crates and each of this crates uses a different time library. But all these libraries need a implementation of their traits and that's usually up to you.
bpye has quit [Quit: Ping timeout (120 seconds)]
bpye has joined #rust-embedded
Ekho has quit [*.net *.split]
Ekho- has joined #rust-embedded
Ekho- is now known as Ekho
<re_irc> <> Does anyone recommend a gyro + magnetometer that's 1) in stock 2) has a rust driver and 3) is decently priced?
<re_irc> <> #2 will significantly limit your options
<re_irc> <> And won't save you much work. I recommend dropping it from your requirements
fabic has quit [Ping timeout: 245 seconds]
<re_irc> <> Sure, I can always implement the gyro/mag traits manually. Do you have any recommended gyros / mags that's 1 and 3?
<re_irc> <> having some trouble with `/dev/gpiomem`; relevant code:```rust
<re_irc> <> unsafe fn transfer_bytes(
<re_irc> <> // ...
<re_irc> <> gpio: *mut u32, // Address of `/dev/gpiomem` in mapped memory.
<re_irc> <> ew sorry, how do i format a codeblock?
<re_irc> <> there
ni has quit [Quit: WeeChat 2.8]
<re_irc> <> No
<re_irc> <> *to jkelleyrtp
ni has joined #rust-embedded
ni has quit [Quit: WeeChat 3.0]
<re_irc> <> agghhhhh i got it; i always forget that `offset()` is multiplied by the size of the referent type
<re_irc> <> fixed by `0x1C` -> `0x1C / 4`
<re_irc> <> I'm looking for pointers on binary files. I'm properly confused about what I end up with after compiling (in target/thumbv7em-none-eabixx). `cargo size` reports roughly 11kb whereas the compiled file is 1.2M big. What are the steps that are magically taken for me to make it smaller? Just some reading material regarding this would be super helpful, as I'm not sure how to actually search for this.
ni has joined #rust-embedded
<re_irc> <> The ELF file is 1.2M?
<re_irc> <> That could be the case because of debug information.
<re_irc> <> But the debug information is not going to the chip, so don't worry.
<re_irc> <> Ah so that's the ELF file
<re_irc> <> The ELF file contains a lot of stuff that is not flashed.
<re_irc> <> Hm. I tried to convert it using arm-none-eabi-objcopy but it's basically still 1.2M
<re_irc> <> that will depend exactly what you tell objcopy to do
<re_irc> <> Convert it to what format?
<re_irc> <> Oh no, alright, this works: `arm-none-eabi-objcopy -O binary blinky blinky.bin`. I end up with the file size I expected
<re_irc> <> Thanks both, it's time for me to do a bit man reading on this :)
<re_irc> <> if you run `readelf -l <elf file>` you will get a dump of the "program header" which describe which parts of the binary will actually be loaded to memory
<re_irc> <> when you objcopy to `binary` you're basically doing this loading and dumping the result to a file
<re_irc> <> Thank you, that's helpful
<re_irc> <> for systems that actually use ELF binaries directly (like Linux) this is the same data the kernel or dynamic linker will use to work out how to load the program; for embedded you are just usually doing this work at build time with objcopy instead of at runtime
<re_irc> <> though some more complex embedded devices have their own mini binary formats that their bootloader understands so that you can do things like have data/code loaded into different regions of RAM
<re_irc> <> generally not ELF though as even with all the unnecessary info stripped ELF is quite complex and large
<re_irc> <> What about a runnable 45 byte ELF binary? :D
<re_irc> <> Yeah I know it isn't following the standard, but still
<re_irc> <> yeah that's carefully crafted around exactly what the linux kernel happens to accept in practise, which isn't likely to work with an embedded device bootloader even if it understands ELF :)
<re_irc> <> and definitely isn't going to be what you get by running `strip`
<re_irc> <> also 45 bytes is still pretty huge given that the code is only 7 bytes of that
<re_irc> <> 542% overhead :)
Foxyloxy_ has quit [Quit: Textual IRC Client:]
Foxyloxy has joined #rust-embedded
emerent_ has joined #rust-embedded
emerent is now known as Guest4985
emerent_ is now known as emerent
Guest4985 has quit [Killed ( (Nickname regained by services))]
<re_irc> <> Are there any tricks to preventing the compiler from optimizing out or w/e `static mut` vars? eg:
<re_irc> <> ```rust
<re_irc> <> unsafe {
<re_irc> <> defmt::info!("If we comment this out, the playback doesn't work {}", &OUT_BUF[..100]);
<re_irc> <> }
<re_irc> <> I tried compiler fences around the DMA write op that uses this buffer.