From edc43995c96f45c8d8dedf16afb1f08a903f262f Mon Sep 17 00:00:00 2001 From: Lotte Steenbrink Date: Wed, 20 Jan 2021 16:25:34 +0100 Subject: [PATCH] add tooltips; move cargo-bloat there --- embedded-workshop-book/src/SUMMARY.md | 1 + embedded-workshop-book/src/binary-size.md | 16 ----------- embedded-workshop-book/src/installation.md | 6 +---- embedded-workshop-book/src/tooltips.md | 31 ++++++++++++++++++++++ 4 files changed, 33 insertions(+), 21 deletions(-) create mode 100644 embedded-workshop-book/src/tooltips.md diff --git a/embedded-workshop-book/src/SUMMARY.md b/embedded-workshop-book/src/SUMMARY.md index 8312a61..9b9297b 100644 --- a/embedded-workshop-book/src/SUMMARY.md +++ b/embedded-workshop-book/src/SUMMARY.md @@ -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) diff --git a/embedded-workshop-book/src/binary-size.md b/embedded-workshop-book/src/binary-size.md index f1bf9bc..ffc70a7 100644 --- a/embedded-workshop-book/src/binary-size.md +++ b/embedded-workshop-book/src/binary-size.md @@ -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 ::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::::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. diff --git a/embedded-workshop-book/src/installation.md b/embedded-workshop-book/src/installation.md index 629e990..b22d44a 100644 --- a/embedded-workshop-book/src/installation.md +++ b/embedded-workshop-book/src/installation.md @@ -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` (..) diff --git a/embedded-workshop-book/src/tooltips.md b/embedded-workshop-book/src/tooltips.md new file mode 100644 index 0000000..6da99cb --- /dev/null +++ b/embedded-workshop-book/src/tooltips.md @@ -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 ::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::::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. \ No newline at end of file