From c44163d6799e449a7b76972b63944fd7207b2ced Mon Sep 17 00:00:00 2001 From: Jesus Hernandez Date: Tue, 5 Dec 2023 15:37:48 +0800 Subject: [PATCH] Simplify instructions using current Cargo features and reduce size Configure Rust toolchain to nightly channel, simplify steps in usage section of README.md as now Cargo configuration works and onfigure release for smaller size --- Cargo.toml | 2 ++ README.md | 10 ++-------- rust-toolchain.toml | 2 ++ 3 files changed, 6 insertions(+), 8 deletions(-) create mode 100644 rust-toolchain.toml diff --git a/Cargo.toml b/Cargo.toml index 1067020..b816d42 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,4 +8,6 @@ edition = '2018' ruduino = { git = "https://github.com/avr-rust/ruduino", branch = "master" } [profile.release] +opt-level = 'z' lto = true +strip = true diff --git a/README.md b/README.md index 4bbb792..a08a05c 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Designed for the ATmega328p. * A recent version of the nightly Rust compiler. Anything including or greater than `rustc 1.63.0-nightly (fee3a459d 2022-06-05)` can be used. + * A recent version of Cargo. At least 1.52.0 or greater. * The rust-src rustup component - `$ rustup component add rust-src` * AVR-GCC on the system for linking * AVR-Libc on the system for support libraries @@ -22,18 +23,11 @@ Designed for the ATmega328p. Now to build, run: ```bash -rustup override set nightly - # Ensure time delays are consistent with a 16MHz microcontroller. export AVR_CPU_FREQUENCY_HZ=16000000 # Compile the crate to an ELF executable. -cargo build -Z build-std=core --target avr-atmega328p.json --release - -# Note: there is work in progress to make that easier -# peeking in .cargo/config.tom will show that -# cargo build --release -# is the short version +cargo build --release ``` There should now be an ELF file at `target/avr-atmega328p/release/blink.elf`. It can be flashed directly to an AVR microcontroller or ran inside a simulator. diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..5d56faf --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "nightly"