From 882e79f9b8cf1de95464f473db3734fff62570f5 Mon Sep 17 00:00:00 2001 From: finga Date: Fri, 8 Apr 2022 00:24:44 +0200 Subject: [PATCH 1/2] fw-rust: Update build dependencies --- firmware/rust/Cargo.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/firmware/rust/Cargo.lock b/firmware/rust/Cargo.lock index 74b8068..82a9dba 100644 --- a/firmware/rust/Cargo.lock +++ b/firmware/rust/Cargo.lock @@ -112,9 +112,9 @@ checksum = "de96540e0ebde571dc55c73d60ef407c653844e6f9a1e2fdbd40c07b9252d812" [[package]] name = "paste" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0744126afe1a6dd7f394cb50a716dbe086cb06e255e53d8d0185d82828358fb5" +checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc" [[package]] name = "proc-macro-hack" @@ -124,18 +124,18 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro2" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" +checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1" dependencies = [ "unicode-xid", ] [[package]] name = "quote" -version = "1.0.15" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" +checksum = "632d02bff7f874a36f33ea8bb416cd484b90cc66c1194b1a1110d067a7013f58" dependencies = [ "proc-macro2", ] @@ -176,9 +176,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.86" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" +checksum = "b683b2b825c8eef438b77c36a06dc262294da3d5a5813fac20da149241dcd44d" dependencies = [ "proc-macro2", "quote", From 3f19ad6ee9f8f78bd351fc0806d99a1ce3360517 Mon Sep 17 00:00:00 2001 From: finga Date: Fri, 8 Apr 2022 01:03:16 +0200 Subject: [PATCH 2/2] make: Set up release profile and update the readme Due to limiting the codegen units to 1 the size of the program memory can be reduced roughly by 10% and the data memory by a bit more than 20%. --- README.md | 3 +- firmware/rust/Makefile.toml | 60 +++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e0fb99e..d7e29d3 100644 --- a/README.md +++ b/README.md @@ -79,5 +79,6 @@ regulator is 3.3V. ### The Rust Firmware To flash the firmware, connect the ICSP pins of the board to the programmer and inside the `firmware/rust/` directory run `cargo make -all`. This burns the fuses, writes the default configuration values to +--profile release all`. This compiles the firmware with the release +profile, burns the fuses, writes the default configuration values to the EEPROM and flashes the firmware. diff --git a/firmware/rust/Makefile.toml b/firmware/rust/Makefile.toml index e47cb7d..178c8eb 100644 --- a/firmware/rust/Makefile.toml +++ b/firmware/rust/Makefile.toml @@ -6,35 +6,95 @@ HIGH_FUSE = "0xD6" LOW_FUSE = "0xE2" [tasks.size] +run_task = [ + { name = "size-development", condition = { profiles = [ "development" ] } }, + { name = "size-release", condition = { profiles = [ "release" ] } }, +] + +[tasks.size-development] description = "Print usage of memory segments" dependencies = ["build"] command = "avr-size" args = ["--format=avr", "--mcu=${MCU}", "target/avr-atmega328p/debug/clock-generator.elf"] +[tasks.size-release] +description = "Print usage of memory segments" +dependencies = ["build"] +command = "avr-size" +args = ["--format=avr", "--mcu=${MCU}", "target/avr-atmega328p/release/clock-generator.elf"] + [tasks.copy_flash] +run_task = [ + { name = "copy_flash-development", condition = { profiles = [ "development" ] } }, + { name = "copy_flash-release", condition = { profiles = [ "release" ] } }, +] + +[tasks.copy_flash-development] description = "Extract the flash" dependencies = ["build"] command = "avr-objcopy" args = ["-O", "ihex", "-j", ".text", "-j", ".data", "target/avr-atmega328p/debug/clock-generator.elf", "target/avr-atmega328p/debug/clock-generator.hex"] +[tasks.copy_flash-release] +description = "Extract the flash" +dependencies = ["build"] +command = "avr-objcopy" +args = ["-O", "ihex", "-j", ".text", "-j", ".data", "target/avr-atmega328p/release/clock-generator.elf", "target/avr-atmega328p/release/clock-generator.hex"] + [tasks.flash] +run_task = [ + { name = "flash-development", condition = { profiles = [ "development" ] } }, + { name = "flash-release", condition = { profiles = [ "release" ] } }, +] + +[tasks.flash-development] description = "Flash the firmware" dependencies = ["copy_flash", "size"] command = "avrdude" args = ["-p", "${MCU}", "-c", "${PROGRAMMER}", "-U", "flash:w:target/avr-atmega328p/debug/clock-generator.hex:a"] +[tasks.flash-release] +description = "Flash the firmware" +dependencies = ["copy_flash", "size-release"] +command = "avrdude" +args = ["-p", "${MCU}", "-c", "${PROGRAMMER}", "-U", "flash:w:target/avr-atmega328p/release/clock-generator.hex:a"] + [tasks.copy_eeprom] +run_task = [ + { name = "copy_eeprom-development", condition = { profiles = [ "development" ] } }, + { name = "copy_eeprom-release", condition = { profiles = [ "release" ] } }, +] + +[tasks.copy_eeprom-development] description = "Extract the EEPROM" dependencies = ["build"] command = "avr-objcopy" args = ["--change-section-lma", ".eeprom=0", "-O", "ihex", "-j", ".eeprom", "target/avr-atmega328p/debug/clock-generator.elf", "target/avr-atmega328p/debug/clock-generator.eep"] +[tasks.copy_eeprom-release] +description = "Extract the EEPROM" +dependencies = ["build"] +command = "avr-objcopy" +args = ["--change-section-lma", ".eeprom=0", "-O", "ihex", "-j", ".eeprom", "target/avr-atmega328p/release/clock-generator.elf", "target/avr-atmega328p/release/clock-generator.eep"] + [tasks.eeprom] +run_task = [ + { name = "eeprom-development", condition = { profiles = [ "development" ] } }, + { name = "eeprom-release", condition = { profiles = [ "release" ] } }, +] + +[tasks.eeprom-development] description = "Flash the eeprom" dependencies = ["copy_eeprom", "size"] command = "avrdude" args = ["-p", "${MCU}", "-c", "${PROGRAMMER}", "-U", "eeprom:w:target/avr-atmega328p/debug/clock-generator.eep:a"] +[tasks.eeprom-release] +description = "Flash the eeprom" +dependencies = ["copy_eeprom", "size"] +command = "avrdude" +args = ["-p", "${MCU}", "-c", "${PROGRAMMER}", "-U", "eeprom:w:target/avr-atmega328p/release/clock-generator.eep:a"] + [tasks.fuses] description = "Burn the fuses" command = "avrdude"