add tooltips; move cargo-bloat there

This commit is contained in:
Lotte Steenbrink 2021-01-20 16:25:34 +01:00
parent 07a3386119
commit edc43995c9
4 changed files with 33 additions and 21 deletions

View file

@ -58,6 +58,7 @@
- [Getting it Configured](./getting-device-configured.md)
- [Next Steps](./advanced-next-steps.md)
- [References and Resources](./references-resources.md)
- [Tooltips](./tooltips.md)
- [Troubleshooting](./troubleshooting.md)
- [`cargo-size` is not working](./troubleshoot-cargo-size.md)
- [`cargo-flash` is not working](./troubleshoot-cargo-flash.md)

View file

@ -32,19 +32,3 @@ The first three sections are contiguously located in Flash memory -- Flash memor
* The `.rodata` section contains constants like strings literals.
The next three sections, `.data`, `.bss` and `.uninit`, are located in RAM -- RAM memory spans the address range `0x2000_0000` - `0x2004_0000` (256 KB). These sections contain statically allocated variables (`static` variables).
Another other useful tool to analyze the binary size of a program is `cargo-bloat`:
``` console
$ cargo bloat --bin hello
File .text Size Crate Name
0.7% 13.5% 1.3KiB std <char as core::fmt::Debug>::fmt
0.5% 9.6% 928B hello hello::__cortex_m_rt_main
0.4% 8.4% 804B std core::str::slice_error_fail
0.4% 8.0% 768B std core::fmt::Formatter::pad
0.3% 6.4% 614B std core::fmt::num::<impl core::fmt::Debug for usize>::fmt
(..)
5.1% 100.0% 9.4KiB .text section size, the file size is 184.5KiB
```
This breakdowns the size of the `.text` section by function. This breakdown can be used to identify the largest functions in the program; those could then be modified to make them smaller.

View file

@ -133,7 +133,7 @@ $ cargo install cargo-binutils
### Cargo subcommands
Install version v0.10.2 of the [`cargo-flash`](https://crates.io/crates/cargo-flash) and [`cargo-embed`](https://crates.io/crates/cargo-embed) subcommands, as well as the [`cargo-binutils`](https://crates.io/crates/cargo-binutils) set of subcommands and the [`cargo-bloat`](https://crates.io/crates/cargo-bloat) subcommand using the following Cargo commands:
Install version v0.10.2 of the [`cargo-flash`](https://crates.io/crates/cargo-flash) and [`cargo-embed`](https://crates.io/crates/cargo-embed) subcommands, as well as the [`cargo-binutils`](https://crates.io/crates/cargo-binutils) set of subcommands using the following Cargo commands:
``` console
$ cargo install cargo-flash --version 0.10.2 -f
@ -148,10 +148,6 @@ $ cargo install cargo-binutils
(..)
Installed package `cargo-binutils v0.3.3` (..)
$ cargo install cargo-bloat
(..)
Installed package `cargo-bloat v0.9.3` (..)
$ cargo install probe-run
(..)
Installed package `probe-run v0.1.8` (..)

View file

@ -0,0 +1,31 @@
# Tooltips
Besides the ones covered in this workshop, there are many more tools that make embedded development easier.
Here, we'd like to introduce you to some of these tools and encourage you to play around with them and adopt them if you find them helpful!
## `cargo-bloat`
`cargo-bloat` is a useful tool to analyze the binary size of a program. You can install it through cargo:
``` console
$ cargo install cargo-bloat
(..)
Installed package `cargo-bloat v0.10.0` (..)
```
Let's inspect our beginner course's `hello` program with it:
``` console
$ cd beginner/apps
$ cargo bloat --bin hello
File .text Size Crate Name
0.7% 13.5% 1.3KiB std <char as core::fmt::Debug>::fmt
0.5% 9.6% 928B hello hello::__cortex_m_rt_main
0.4% 8.4% 804B std core::str::slice_error_fail
0.4% 8.0% 768B std core::fmt::Formatter::pad
0.3% 6.4% 614B std core::fmt::num::<impl core::fmt::Debug for usize>::fmt
(..)
5.1% 100.0% 9.4KiB .text section size, the file size is 184.5KiB
```
This breakdowns the size of the `.text` section by function. This breakdown can be used to identify the largest functions in the program; those could then be modified to make them smaller.