diff --git a/beginner/apps/.cargo/config.toml b/beginner/apps/.cargo/config.toml index be9aeec..4b518a8 100644 --- a/beginner/apps/.cargo/config.toml +++ b/beginner/apps/.cargo/config.toml @@ -6,10 +6,13 @@ rustflags = [ ] [target.thumbv7em-none-eabihf] +# set custom cargo runner to flash & run on embedded target when we call `cargo run` +# for more information, check out https://github.com/knurling-rs/probe-run runner = "probe-run --chip nRF52840_xxAA" rustflags = [ "-C", "link-arg=-Tlink.x", ] [build] +# cross-compile to this target target = "thumbv7em-none-eabihf" # = ARM Cortex-M4 \ No newline at end of file diff --git a/beginner/apps/src/bin/hello.rs b/beginner/apps/src/bin/hello.rs index 62a8ad0..8a5605d 100644 --- a/beginner/apps/src/bin/hello.rs +++ b/beginner/apps/src/bin/hello.rs @@ -1,12 +1,20 @@ -#![no_main] +// this program does not use the standard library to avoid heap allocations. +// only the `core` library functions are available. #![no_std] +// this program uses a custom entry point instead of `fn main()` +#![no_main] use cortex_m::asm; use cortex_m_rt::entry; use panic_log as _; // the panicking behavior +// the custom entry point +// vvvvv #[entry] fn main() -> ! { + // ˆˆˆ + // ! is the 'never' type: this function never returns + // initializes the peripherals dk::init().unwrap();