<haobogu[m]>
Hi everyone, I'm wondering that is there any solution for Rust embedded to print memory usages after building a firmware? In my C project, I'm using -Wl,--gc-sections,--print-memory-usage flag for gcc and it prints something like the image
<diondokter[m]>
You can install the cargo-binutils crate which will give you the cargo size command
<haobogu[m]>
diondokter[m]: `cargo size` gives me the flash usage, but not ram usage
<diondokter[m]>
It does, just not split out over the different regions
<diondokter[m]>
data is stored in ram
IlPalazzo-ojiisa has joined #rust-embedded
<diondokter[m]>
* data and bss is stored in ram
<haobogu[m]>
Can I print the mem usage of sections defined in linker script?
<diondokter[m]>
I don't know actually
<thejpster[m]>
cargo size -- -A
<thejpster[m]>
You can also pass linker flags to the linker (see .cargo/config.toml) so any linker flags you use with gcc probably work here too.
<thejpster[m]>
(-Wl,xxx is a gcc flag which just passes the 'xxx' flag down to the linker)
<haobogu[m]>
yeah, --print-memory-usage is a gcc ld specific flag, it doesn't work for llvm
<thejpster[m]>
booo. I thought llvm lld did pretty much anything gcc ld did. Why not change the linker to use gcc then?
<thejpster[m]>
Just add linker = "arm-none-eabi-gcc" to [target.thumbv7m-none-eabi]
<haobogu[m]>
I tried but the gcc linker failed with arm-none-eabi/bin/ld: failed to merge target specific data of file error
<haobogu[m]>
haobogu[m]: it says that the compiler uses VFP register arguments, but my project doesn't not. I don't know what's that mean..
<haobogu[m]>
Anyway, `cargo size -- -A` prints what I need, thats bro thejpster
<haobogu[m]>
thanks
<thejpster[m]>
If you use gcc as a linker you possibly also need to give it "-mcpu=cortex-m4f" or something, and maybe "-nostdlib" and "-nostartfiles".
<thejpster[m]>
Otherwise it'll try and link in libc, and if Rust made a bunch of object code that used the floating point unit (and put float arguments in floating point unit registers), but the C library didn't, I could see why it might complain.
ryan-summers[m] has joined #rust-embedded
<ryan-summers[m]>
Small announcement (now that I'm back from vacation) for anyone interested - we're releasing 0.8.0 of minimq, a MQTTv5 MQTT client. This latest release makes it nearly feature-complete for the MQTTv5 stack, and it only takes up something like 17KB of flash based on my last measurements, so it's a really nice, small footprint solution for IoT projects and data analysis if you ever need it! https://crates.io/crates/minimq
<ryan-summers[m]>
Also thanks Robert Jördens for the release on it :)
<diondokter[m]>
Oh cool! Yet have to try it out. Though actually... maybe I've got an opportunity
<ryan-summers[m]>
Just did a rework on memory management on it so that everything uses user-provided buffers like smoltcp, makes it really easy on stack usage for smaller devices.
<ryan-summers[m]>
Although MQTT still needs to use ethernet, so small resource devices are probably still excluded
<ryan-summers[m]>
* use ethernet + TCP stacks, so
<ryan-summers[m]>
dirbaio: / newam re: heapless 0.8 - does it need a tag + changelog bump on Github as well? https://github.com/rust-embedded/heapless I'd PR if I knew which commit it was
<dav1d>
ryan-summers[m], I assume I cant use your lib with async/embassy?
<ryan-summers[m]>
First-class async support is on the horizon, but I don't see why you couldn't.
<ryan-summers[m]>
Right now it has a poll() function similar to smoltcp
<dav1d>
ah cool, Ill have to look into that, thanks!
korken89[m] has quit [Quit: Idle timeout reached: 172800s]
<newam[m]>
<ryan-summers[m]> "dirbaio: / newam re: heapless 0..." <- 0.8 doesn't exist yet AFAIK, someone just bumped the version in Cargo.toml preemptively after breaking changes were added to the 0.7.x series.
<ryan-summers[m]>
Oh you're right. Now I'm very confused, thanks for the clarification :)
Noah[m] has quit [Quit: Idle timeout reached: 172800s]
<firefrommoonligh>
<ryan-summers[m]> "Small announcement (now that I'm..." <- V cool. Btw, I now do programming at work and we do a lot of MQTT stuff. I have been looking for excuses to build the projects in Rust! Fail so far as there's nothing on Django's level for web backend, and the Rust bindings for ML/CV are not in a usable state but... someday
<firefrommoonligh>
> <@ryan-summers:matrix.org> Small announcement (now that I'm back from vacation) for anyone interested - we're releasing 0.8.0 of `minimq`, a MQTTv5 MQTT client. This latest release makes it nearly feature-complete for the MQTTv5 stack, and it only takes up something like 17KB of flash based on my last measurements, so it's a really nice, small footprint solution for IoT projects and data collection if you ever need it!
<firefrommoonligh>
* V cool. Btw, I now do programming at a desk job, and we do a lot of MQTT stuff. I have been looking for excuses to build the projects in Rust! Fail so far as there's nothing on Django's level for web backend, and the Rust bindings for ML/CV are not in a usable state but... someday
<firefrommoonligh>
(There are semi-official Rust OpenVINO and Tensorflow bindings, but they are out of date/high-build-friction)
<firefrommoonligh>
* of date/missing critical features/high-build-friction)
<ryan-summers[m]>
I use minimq a lot for even MQTT clients on host PCs honestly. Not the best API, but it works fine
<firefrommoonligh>
V cool. Of note the [Paho MQTT](https://docs.rs/paho-mqtt/latest/paho_mqtt/) lib is what I was experimenting with; seemed solid, and similar to the C++ and Python ones
<firefrommoonligh>
s/V cool/Nice/
<ryan-summers[m]>
Yeah that's what I'd probably go with if I weren't no_std
<Danilo[m]>
Hi folks! In https://github.com/dbrgn/embedded-hal-mock/pull/86 the maintenance question came up. Would you be interested in moving embedded-hal-mock to the rust-embedded GitHub organization? (I'd continue co-maintaining the library of course, as long as I find time to do it. But it might reduce the bus factor a bit more. ryankurte and newam are already co-maintainers.)
dsvsdveg[m] has quit [Quit: Idle timeout reached: 172800s]
andresovela[m] has quit [Quit: Idle timeout reached: 172800s]
Guest7221 has joined #rust-embedded
lulf[m]1 has quit [Quit: Idle timeout reached: 172800s]