diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 968e1f2..d25b2e6 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -59,6 +59,7 @@ jobs: - name: build and fmt beginner/apps working-directory: ./beginner/apps run: | + cargo install flip-link cargo build --verbose cargo fmt --all -- --check diff --git a/advanced/firmware/Cargo.toml b/advanced/firmware/Cargo.toml index f7df825..dca67df 100644 --- a/advanced/firmware/Cargo.toml +++ b/advanced/firmware/Cargo.toml @@ -25,11 +25,11 @@ usb2 = { git = "https://github.com/japaric/usb2" } # optimize code in both profiles [profile.dev] codegen-units = 1 -debug = 2 +debug = 1 debug-assertions = true # ! incremental = false lto = "fat" -opt-level = 1 # ! +opt-level = 'z' # ! overflow-checks = false [profile.release] diff --git a/advanced/firmware/src/bin/stack_overflow.rs b/advanced/firmware/src/bin/stack_overflow.rs index befc47b..e24c08f 100644 --- a/advanced/firmware/src/bin/stack_overflow.rs +++ b/advanced/firmware/src/bin/stack_overflow.rs @@ -25,6 +25,5 @@ fn spam() { log::info!("address of current `use_stack`: {:?}", &use_stack as *const u32); - log::info!("entering next recursive step"); spam(); // infinite recursion } diff --git a/beginner/apps/.cargo/config.toml b/beginner/apps/.cargo/config.toml index 1f11e40..be9aeec 100644 --- a/beginner/apps/.cargo/config.toml +++ b/beginner/apps/.cargo/config.toml @@ -1,3 +1,10 @@ +[target.'cfg(all(target_arch = "arm", target_os = "none"))'] +# (..) +rustflags = [ + "-C", "linker=flip-link", # adds stack overflow protection + # (..) +] + [target.thumbv7em-none-eabihf] runner = "probe-run --chip nRF52840_xxAA" rustflags = [ diff --git a/embedded-workshop-book/src/installation.md b/embedded-workshop-book/src/installation.md index d042a4f..f12dec0 100644 --- a/embedded-workshop-book/src/installation.md +++ b/embedded-workshop-book/src/installation.md @@ -143,6 +143,10 @@ Installed package `cargo-binutils v0.3.3` (..) $ cargo install probe-run (..) Installed package `probe-run v0.1.8` (..) + +$ cargo install flip-link +(..) +Installed package `flip-link v0.1.2` (..) ``` ### Workshop specific tools @@ -176,12 +180,6 @@ Leave the processes running in the background. #### Advanced workshop -```console -$ cargo install flip-link -(..) -Installed package `flip-link v0.1.2` (..) -``` - Change to the `tools` folder and run these commands: ```console