-
Notifications
You must be signed in to change notification settings - Fork 55
A guinea-pig binary for bloat checks #332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
29ec94d
A dedicated executable for checking bloat
ivmarkov 409d0c6
Display runtime information for the .bss from the app itself
ivmarkov 0945798
Fix subscriptions as they always used NoopRawMutex
ivmarkov 062f215
More docu
ivmarkov 4636394
Re-target the size reports to our binary
ivmarkov 50f3314
Build bloat-check as part of the CI; disable -Zbuild-std for now (nee…
ivmarkov ce67df1
Move the clippy tasks into the size reports workflow
ivmarkov 80c1e30
Small fix in the docu
ivmarkov 115c142
Re-include the examples in the bloat report
ivmarkov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[build] | ||
#target = "thumbv7em-none-eabi" | ||
|
||
[unstable] | ||
#build-std-features = ["panic_immediate_abort"] | ||
#build-std = ["core", "std", "panic_abort"] | ||
|
||
[env] | ||
DEFMT_LOG = "info" | ||
RUST_LOG = "info" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
[package] | ||
name = "rs-matter-bloat-check" | ||
version = "0.1.0" | ||
edition = "2021" | ||
license = "MIT OR Apache-2.0" | ||
|
||
[[bin]] | ||
name = "bloat-check" | ||
|
||
[workspace] | ||
|
||
[profile.dev] | ||
debug = true | ||
opt-level = "z" | ||
|
||
[profile.release] | ||
opt-level = "z" | ||
debug = 0 | ||
debug-assertions = false | ||
codegen-units = 1 # LLVM can perform better optimizations using a single thread | ||
lto = "fat" | ||
incremental = false | ||
overflow-checks = false | ||
|
||
[features] | ||
defmt = [] | ||
log = [] | ||
|
||
[dependencies] | ||
embassy-futures = "0.1" | ||
static_cell = "1" | ||
critical-section = "1" | ||
embassy-executor = { version = "0.9", features = ["executor-thread"] } | ||
rs-matter = { path = "../rs-matter", default-features = false, features = ["rustcrypto"] } | ||
|
||
[target.'cfg(not(target_os = "none"))'.dependencies] | ||
log = { version = "0.4", features = ["max_level_info"] } | ||
simple_logger = "5" | ||
embassy-sync = { version = "0.7", features = ["log"] } | ||
embassy-time = { version = "0.5", features = ["std", "log"] } | ||
embassy-executor = { version = "0.9", features = ["arch-std", "log"] } | ||
critical-section = { version = "1", features = ["std"] } | ||
rs-matter = { path = "../rs-matter", default-features = false, features = ["log"] } | ||
|
||
[target.'cfg(target_os = "none")'.dependencies] | ||
defmt = "0.3" | ||
embassy-sync = { version = "0.7", features = ["defmt"] } | ||
embassy-time = { version = "0.5", features = ["defmt"] } | ||
embassy-executor = { version = "0.9", features = ["defmt"] } | ||
embedded-alloc = "0.6" | ||
rtt-target = { version = "0.6", features = ["defmt"] } | ||
panic-rtt-target = "0.2" | ||
rs-matter = { path = "../rs-matter", default-features = false, features = ["defmt"] } | ||
|
||
[target.'cfg(all(target_arch = "arm", target_os = "none"))'.dependencies] | ||
cortex-m = { version = "0.7.6", features = ["critical-section-single-core" ] } | ||
cortex-m-rt = "0.7" | ||
embassy-executor = { version = "0.9", features = ["arch-cortex-m"] } | ||
|
||
[target.thumbv7em-none-eabi.dependencies] | ||
hal = { package = "embassy-nrf", version = "0.8", default-features = false, features = ["defmt", "time-driver-rtc1", "time", "nrf52840"] } | ||
|
||
[target.thumbv6m-none-eabi.dependencies] | ||
hal = { package = "embassy-rp", version = "0.8", features = ["defmt", "unstable-pac", "time-driver", "rp2040"] } | ||
|
||
[target.riscv32imac-unknown-none-elf.dependencies] | ||
hal = { package = "esp-hal", version = "=1.0.0-rc.1", features = ["defmt", "exception-handler", "unstable", "esp32c6"] } | ||
esp-rtos = { version = "0.1.0", features = ["embassy", "esp32c6"] } | ||
#embassy-executor = { version = "0.9", features = ["riscv32"] } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# rs-matter-bloat-check | ||
|
||
This project builds an executable which serves as a reference for checking the code and data footprint of `rs-matter`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
//! This build script copies the `memory.x` file from the crate root into | ||
//! a directory where the linker can always find it at build time. | ||
//! For many projects this is optional, as the linker always searches the | ||
//! project root directory -- wherever `Cargo.toml` is. However, if you | ||
//! are using a workspace or have a more complicated build setup, this | ||
//! build script becomes required. Additionally, by requesting that | ||
//! Cargo re-run the build script whenever `memory.x` is changed, | ||
//! updating `memory.x` ensures a rebuild of the application with the | ||
//! new memory settings. | ||
|
||
use std::env; | ||
use std::fs::File; | ||
use std::io::Write; | ||
use std::path::PathBuf; | ||
|
||
fn main() { | ||
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap(); | ||
|
||
if target_arch == "arm" { | ||
let target = env::var("TARGET").unwrap(); | ||
cortex_m(target == "thumbv7em-none-eabi"); | ||
} else if target_arch == "riscv32" { | ||
riscv32(); | ||
} | ||
} | ||
|
||
fn cortex_m(nrf: bool) { | ||
// Put `memory.x` in our output directory and ensure it's | ||
// on the linker search path. | ||
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); | ||
File::create(out.join("memory.x")) | ||
.unwrap() | ||
.write_all(if nrf { | ||
include_bytes!("memory-nrf52.x") | ||
} else { | ||
include_bytes!("memory-rp0.x") | ||
}) | ||
.unwrap(); | ||
println!("cargo:rustc-link-search={}", out.display()); | ||
|
||
// By default, Cargo will re-run a build script whenever | ||
// any file in the project changes. By specifying `memory.x` | ||
// here, we ensure the build script is only re-run when | ||
// `memory.x` is changed. | ||
println!("cargo:rerun-if-changed=memory.x"); | ||
|
||
println!("cargo:rustc-link-arg-bins=--nmagic"); | ||
println!("cargo:rustc-link-arg-bins=-Tlink.x"); | ||
println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); | ||
} | ||
|
||
fn riscv32() { | ||
println!("cargo:rustc-link-arg=-Tdefmt.x"); | ||
// make sure linkall.x is the last linker script (otherwise might cause problems with flip-link) | ||
println!("cargo:rustc-link-arg=-Tlinkall.x"); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
MEMORY | ||
{ | ||
FLASH : ORIGIN = 0x00000000, LENGTH = 1024K | ||
RAM : ORIGIN = 0x20000000, LENGTH = 256K | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
MEMORY { | ||
BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100 | ||
FLASH : ORIGIN = 0x10000100, LENGTH = 2048K - 0x100 | ||
|
||
/* Pick one of the two options for RAM layout */ | ||
|
||
/* OPTION A: Use all RAM banks as one big block */ | ||
/* Reasonable, unless you are doing something */ | ||
/* really particular with DMA or other concurrent */ | ||
/* access that would benefit from striping */ | ||
RAM : ORIGIN = 0x20000000, LENGTH = 264K | ||
|
||
/* OPTION B: Keep the unstriped sections separate */ | ||
/* RAM: ORIGIN = 0x20000000, LENGTH = 256K */ | ||
/* SCRATCH_A: ORIGIN = 0x20040000, LENGTH = 4K */ | ||
/* SCRATCH_B: ORIGIN = 0x20041000, LENGTH = 4K */ | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.