Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ravedude/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- Added the `board.max-application-size` option and populated it for the
built-in boards. Firmware that would overlap the bootloader region is now
rejected before flashing instead of bricking the board ([#709]).

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't update the changelog yourself, I will take care of that once merged. Otherwise, we will often run into unnecessary merge conflicts in this file when other PRs get merged first.


### Changed
- General improvements to error handling and reporting ([#690]).
- Updated dependencies ([#690]).
Expand All @@ -16,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#690]).

[#690]: https://github.com/Rahix/avr-hal/pull/690
[#709]: https://github.com/Rahix/avr-hal/issues/709


## [0.2.2] - 2025-10-26
Expand Down
4 changes: 4 additions & 0 deletions ravedude/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ in `Ravedude.toml`. It works like this:

[board]
name = "Custom Arduino Uno"
# Maximum size of the application image in bytes. ravedude measures the
# linked firmware and refuses to flash it if it would overlap the bootloader.
# Omit this option to disable the check.
# max-application-size = 32256

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop comment and make the option not commented out.


[board.reset]
# The board automatically resets when attempting to flash
Expand Down
18 changes: 18 additions & 0 deletions ravedude/src/board.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ mod tests {
board.reset.is_some(),
"Board {name:?} doesn't have a `reset` key"
);
if let Some(max_size) = board.max_application_size {
assert!(
max_size > 0,
"Board {name:?} has a zero `max-application-size`"
);
}
assert!(
board.avrdude.is_some(),
"Board {name:?} doesn't have an `avrdude` key"
Expand All @@ -114,4 +120,16 @@ mod tests {

Ok(())
}

#[test]
fn bootloader_limits_match_arduino_board_definitions() -> anyhow::Result<()> {
let all_boards = get_all_boards()?;

assert_eq!(all_boards["nano"].max_application_size, Some(30720));
assert_eq!(all_boards["nano-new"].max_application_size, Some(30720));
assert_eq!(all_boards["uno"].max_application_size, Some(32256));
assert_eq!(all_boards["mega2560"].max_application_size, Some(253952));

Ok(())
}
}
27 changes: 27 additions & 0 deletions ravedude/src/boards.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[uno]
name = "Arduino Uno"
# 32 KiB flash minus the 512-byte optiboot bootloader.
max-application-size = 32256

[uno.reset]
automatic = true
Expand All @@ -20,6 +22,8 @@

[nano]
name = "Arduino Nano"
# 32 KiB flash minus the 2 KiB bootloader of the classic Nano.
max-application-size = 30720

[nano.reset]
automatic = true
Expand All @@ -35,6 +39,9 @@

[nano-new]
name = "Arduino Nano (New Bootloader)"
# 32 KiB flash minus the 2 KiB bootloader, matching Arduino's board
# definition for both Nano bootloader variants.
max-application-size = 30720

[nano-new.reset]
automatic = true
Expand All @@ -50,6 +57,8 @@

[leonardo]
name = "Arduino Leonardo"
# 32 KiB flash minus the 4 KiB Caterina bootloader.
max-application-size = 28672

[leonardo.reset]
automatic = false
Expand All @@ -70,6 +79,8 @@

[micro]
name = "Arduino Micro"
# 32 KiB flash minus the 4 KiB Caterina bootloader.
max-application-size = 28672

[micro.reset]
automatic = false
Expand All @@ -92,6 +103,8 @@

[mega2560]
name = "Arduino Mega 2560"
# 256 KiB flash minus the 8 KiB bootloader.
max-application-size = 253952

[mega2560.reset]
automatic = true
Expand All @@ -114,6 +127,8 @@

[mega1280]
name = "Arduino Mega 1280"
# 128 KiB flash minus the 4 KiB bootloader.
max-application-size = 126976

[mega1280.reset]
automatic = true
Expand All @@ -130,6 +145,8 @@

[diecimila]
name = "Arduino Diecimila"
# 16 KiB flash minus the 2 KiB bootloader.
max-application-size = 14336

[diecimila.reset]
automatic = true
Expand All @@ -146,6 +163,8 @@

[promicro]
name = "SparkFun Pro Micro"
# 32 KiB flash minus the 4 KiB Caterina bootloader.
max-application-size = 28672

[promicro.reset]
automatic = false
Expand All @@ -166,6 +185,8 @@

[promini-5v]
name = "SparkFun Pro Mini 5V (16MHz)"
# 32 KiB flash minus the 2 KiB bootloader.
max-application-size = 30720

[promini-5v.reset]
automatic = true
Expand All @@ -181,6 +202,8 @@

[promini-3v3]
name = "SparkFun Pro Mini 3v3 (8MHz)"
# 32 KiB flash minus the 2 KiB bootloader.
max-application-size = 30720

[promini-3v3.reset]
automatic = true
Expand Down Expand Up @@ -224,6 +247,8 @@

[nano168]
name = "Nano Clone (ATmega168)"
# 16 KiB flash minus the 2 KiB bootloader.
max-application-size = 14336

[nano168.reset]
automatic = true
Expand All @@ -240,6 +265,8 @@

[duemilanove]
name = "Arduino Duemilanove"
# 32 KiB flash minus the 2 KiB bootloader.
max-application-size = 30720

[duemilanove.reset]
automatic = true
Expand Down
2 changes: 2 additions & 0 deletions ravedude/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ impl RavedudeGeneralConfig {
pub struct BoardConfig {
pub name: Option<String>,
pub inherit: Option<String>,
pub max_application_size: Option<u32>,
pub reset: Option<ResetOptions>,
pub avrdude: Option<BoardAvrdudeOptions>,
pub usb_info: Option<BoardUSBInfo>,
Expand All @@ -156,6 +157,7 @@ impl BoardConfig {
name: self.name.or(base.name),
// inherit is used to decide what BoardConfig to inherit and isn't used anywhere else
inherit: None,
max_application_size: self.max_application_size.or(base.max_application_size),
reset: self.reset.or(base.reset),
avrdude: match self.avrdude {
Some(avrdude) => base.avrdude.map(|base_avrdude| avrdude.merge(base_avrdude)),
Expand Down
Loading
Loading