<esden[cis]>
hi, is there a better size reporting tool to cargo size? Something that shows how much rom vs ram the particular program uses? Mainly rom aka flash.
brazuca has quit [Quit: Client closed]
<M9names[m]>
<Jonas[m]1> "I want the logging anyway, right..." <- there's also https://crates.io/crates/cargo-hf2, in case you're still having problems
Charles[m] has joined #rust-embedded
<Charles[m]>
(don't you have to solve the halting problem (among other things) to know the amount of ram a program will use?)
crabbedhaloablut has joined #rust-embedded
<esden[cis]>
I am mainly interested in flash usage...
<esden[cis]>
not dynamic ram usage
<esden[cis]>
at most static and predictable without heap or stack
<esden[cis]>
Charles ⚡️: but maybe you are just trying to be funny?
<Charles[m]>
well you asked for a tool that can tell you how much ram a binary will use but i'm pretty sure that's impossible
<Charles[m]>
and what's wrong with cargo size?
<esden[cis]>
gcc has -Wl,--print-memory-usage which has much easier to read output... that is what I am seeking at least
<esden[cis]>
size is just the same as gcc size which is pretty annoying to read
jannic[m] has quit [Quit: Idle timeout reached: 172800s]
GenTooMan has quit [Ping timeout: 248 seconds]
GenTooMan has joined #rust-embedded
<JamesMunns[m]>
<esden[cis]> "hi, is there a better size..." <- The main binutil is `nm`, `nm -nSC path/to/elf` shows you every ram and rom symbol known at link time
<JamesMunns[m]>
`cargo bloat` is good for "vibes", it's less precise but gives a better overview
Noah[m] has quit [Quit: Idle timeout reached: 172800s]
GenTooMan has quit [Ping timeout: 260 seconds]
cybernaut has joined #rust-embedded
mburton[m] has quit [Quit: Idle timeout reached: 172800s]
<therealprof[m]>
<esden[cis]> "hi, is there a better size..." <- cargo bloat
<therealprof[m]>
Doesn't show full RAM usage though. Only static variable RAM usage. There's also https://github.com/japaric/cargo-call-stack which can compute the actual RAM usage by the stack. Not sure how well that still works...
<FreeKill[m]>
Puncover can also report stack usage
<mabez[m]>
I also like that it doesn't try and build the project, you pass it a path to the elf
<mabez[m]>
Works quite well for me
cybernaut has joined #rust-embedded
cybernaut has quit [Quit: Leaving]
cybernaut has joined #rust-embedded
adinack[m] has joined #rust-embedded
<adinack[m]>
i've noticed there seems to not really be any abstraction of flash for the stm32f0xx-hal, do i just have to write to registers manually? 😭
cybernaut has quit [Read error: Connection reset by peer]
GenTooMan has joined #rust-embedded
brazuca has quit [Quit: Client closed]
<FreeKill[m]>
<mabez[m]> "I also like that it doesn't..." <- My tool uses the elf and map file output 😁 so hopefully will work as well
brazuca has joined #rust-embedded
ErlandLewin[m] has quit [Quit: Idle timeout reached: 172800s]
<esden[cis]>
<FreeKill[m]> "image.png" <- Wow that looks great! 🤩
<esden[cis]>
<xiretza[cis]> "zephyr also has a neat script..." <- ahh right, should add it to the list and try it out
<esden[cis]>
<JamesMunns[m]> "`cargo bloat` is good for "vibes..." <- ahh yes, just tried it out, it is definitely useful to get a "feel"
<esden[cis]>
<therealprof[m]> "Doesn't show full RAM usage..." <- That sounds useful when I have to figure out ram usage. My main current issue is flash usage that I am trying to get a grip of.
<FreeKill[m]>
Try puncover
<FreeKill[m]>
Interface is fantastic, though not terse
<FreeKill[m]>
Very good for understanding the size of your linked symbols, and how they get linked in
<esden[cis]>
yes will check that out too. Saw the recommendation above. I think I used it already for another project to find places to optimize.
<FreeKill[m]>
And does static stack usage analysis!
<esden[cis]>
It is not bad.
<FreeKill[m]>
FreeKill[m]: Though you need to make sure your compiler spits out .su files
<esden[cis]>
I am looking forward to seeing more of these analysis tools to be integrated into the rust ecosystem better. Or similar tools to sprout within the ecosystem. But of course this will work in the mean time.
<esden[cis]>
Especially for embedded being able to profile flash and ram usage is quite important.
<esden[cis]>
That said, thank you all for the suggestions. All very useful. :)
<FreeKill[m]>
Unfortunately it's extremely hard to do generically. But we could definitely do better
<FreeKill[m]>
The IAR C compiler - for all its faults - has some amazing utility here
<esden[cis]>
There is always space for improvement. :)
<FreeKill[m]>
You can mark functions as roots for stack usage analysis. You can declare what dynamic dispatch routes should be considered. You can instruct it to ignore recursion
<esden[cis]>
Even the horrendous M16 compiler I used ages ago had some fantastic memory location and usage visualization. It provided it quite out of the box.
<FreeKill[m]>
And you can annotate your functions "do not pass the link stage if this function has >X worst case stack usage"
<FreeKill[m]>
I hate that embedded compilers are so technically phenomenal and then terrible in every other way
<esden[cis]>
Yeah it is a lot of specialized work unfortunately. One can only hope it will get better. But there is a good trajectory. :)
<therealprof[m]>
I find cargo bloat insanely useful for profiling applications. Usually people are not just interested in learning whether the application will fit the flash but also which parts of the application are contributing the most to the size. I'm using it to track and compare the code generation abilities of the rust compiler...
<esden[cis]>
Ohh yeah I agree. The output is very informative. I am playing with it right now.
<adinack[m]>
<GrantM11235[m]> "It looks like embassy-stm32..." <- thanks, i'm trying to *not* use embassy for this board but maybe i can learn how to add flash to the stm32f0xx-hal from this
<therealprof[m]>
adinack: stm32f0xx-hal could use some more maintainers 😉
<adinack[m]>
i know! i've had 3 PRs in line for weeks! 🤣
<therealprof[m]>
I just remembered... Looking at them now. 😉
<adinack[m]>
oh haha i didn't mean that, take your time :)
d3zd3z[m] has quit [Quit: Idle timeout reached: 172800s]
<therealprof[m]>
It's all good. I think I even told you to nudge me after you made the changes... I get like 400 (mostly drive-by) mail messages every week from GH; SNR is really bad there.
<adinack[m]>
oh god
<therealprof[m]>
Yeah. So feel free to tag me here or via PM whenever you need me.
<adinack[m]>
ok therealprof my PR has too much "sausage making" as you call it and I'm not good enough at git to fix it and now the CI is failing on code that I didn't even touch so I'm gonna close this one and open a new one where aaalllll the changes are in just one commit :)
<therealprof[m]>
adinack[m]: Don't need to close this. Create a new branch with the changes and force push it over that one.
<adinack[m]>
ok i'll try that thanks lol
<therealprof[m]>
adinack[m]: Preserves the history and discussion. 😉
<yruama_lairba[m]>
hi, i'm trying to design a "safe" abstraction for a dma buffer that can be read or written while a dma is running, but it's seems very tricky and i'm not sure about property or constrain to uphold safety. Does anyone tryiong to design such thing ?
<yruama_lairba[m]>
s/tryiong/tryed/
<yruama_lairba[m]>
at first, i think i need a Sync + Send type with shared mutability. I think this can be assumed ok if each element of my buffer can be atomically read from or written to the buffer, and i think this can be guaranteed by the hardware ( dma and MCU)
<yruama_lairba[m]>
* and MCU), Am i correct ?
<yruama_lairba[m]>
second point, the buffer need to have a static lifetime to be safe. Because of memory forget, you can bypass safety mechanism that could disable dma stream when dropping a object.
<yruama_lairba[m]>
and the next point get me trouble, i think i need to use "read_volatile" and "write_volatile" but i read it's unsound when reference to that data exist because compiler can generate spurious read. I think i need to use a custom pointer, but i don't know how to have safe abstraction to build this pointer
Tommy_plug[m] has left #rust-embedded [#rust-embedded]
<GrantM11235[m]>
yruama_lairba: Use `&[AtomicU8]` (or u16/u32) instead of volatile
<GrantM11235[m]>
Is it possible for the moderator bot to also delete the spam?
brazuca has quit [Quit: Client closed]
<adinack[m]>
therealprof: sorry i had to leave but i'm back and i think i cleaned up the PR properly, but is CI broken? the error is in `spi.rs` which i didn't touch?
<adamgreig[m]>
lol, the bot wasn't quite quick enough there huh