diff --git a/embedded-examples/stm32h7-nucleo-rtic/.cargo/config.toml.template b/embedded-examples/stm32h7-nucleo-rtic/.cargo/config.toml.template new file mode 100644 index 0000000..f01cbee --- /dev/null +++ b/embedded-examples/stm32h7-nucleo-rtic/.cargo/config.toml.template @@ -0,0 +1,29 @@ +[target.'cfg(all(target_arch = "arm", target_os = "none"))'] +runner = "probe-rs run --chip STM32H753ZITx" +# runner = ["probe-rs", "run", "--chip", "$CHIP", "--log-format", "{L} {s}"] + +rustflags = [ + "-C", "linker=flip-link", + "-C", "link-arg=-Tlink.x", + "-C", "link-arg=-Tdefmt.x", + # This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x + # See https://github.com/rust-embedded/cortex-m-quickstart/pull/95 + "-C", "link-arg=--nmagic", + # Can be useful for debugging. + # "-Clink-args=-Map=app.map" +] + +[build] +# (`thumbv6m-*` is compatible with all ARM Cortex-M chips but using the right +# target improves performance) +# target = "thumbv6m-none-eabi" # Cortex-M0 and Cortex-M0+ +# target = "thumbv7m-none-eabi" # Cortex-M3 +# target = "thumbv7em-none-eabi" # Cortex-M4 and Cortex-M7 (no FPU) +target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU) + +[alias] +rb = "run --bin" +rrb = "run --release --bin" + +[env] +DEFMT_LOG = "info" diff --git a/embedded-examples/stm32h7-nucleo-rtic/.gitignore b/embedded-examples/stm32h7-nucleo-rtic/.gitignore index c2bb1e7..54f6671 100644 --- a/embedded-examples/stm32h7-nucleo-rtic/.gitignore +++ b/embedded-examples/stm32h7-nucleo-rtic/.gitignore @@ -1,4 +1,4 @@ /target -/.cargo/config* +/.cargo/config.toml /.vscode /app.map diff --git a/embedded-examples/stm32h7-nucleo-rtic/README.md b/embedded-examples/stm32h7-nucleo-rtic/README.md index 01f842e..35bba02 100644 --- a/embedded-examples/stm32h7-nucleo-rtic/README.md +++ b/embedded-examples/stm32h7-nucleo-rtic/README.md @@ -29,15 +29,19 @@ If you have not installed it yet, you can do so with rustup target add thumbv7em-none-eabihf ``` -A default `.cargo` config file is provided for this project, but needs to be copied to have -the correct name. This is so that the config file can be updated or edited for custom needs -without being tracked by git. +A default `.cargo` config file is provided as `.cargo/config.toml.template`. The build script +copies it to `.cargo/config.toml` if that file does not exist yet. The copy is not tracked by git, +so you can change settings like the runner for your setup. + +Cargo reads the configuration before the build script runs, so the very first build on a fresh +checkout does not use it yet and might fail. Simply run the build again, or copy the file +manually beforehand: ```sh -cp def_config.toml config.toml +cp .cargo/config.toml.template .cargo/config.toml ``` -The configuration file will also set the target so it does not always have to be specified with +The configuration file also sets the target so it does not always have to be specified with the `--target` argument. ## Building diff --git a/embedded-examples/stm32h7-nucleo-rtic/build.rs b/embedded-examples/stm32h7-nucleo-rtic/build.rs index 5f7e192..93b7aa1 100644 --- a/embedded-examples/stm32h7-nucleo-rtic/build.rs +++ b/embedded-examples/stm32h7-nucleo-rtic/build.rs @@ -3,7 +3,7 @@ use std::{env, fs}; fn main() { let manifest_dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap()); - let cargo_dir = manifest_dir.parent().unwrap().join(".cargo"); + let cargo_dir = manifest_dir.join(".cargo"); let config = cargo_dir.join("config.toml"); let config_template = cargo_dir.join("config.toml.template");