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"