Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions ravedude/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ in `Ravedude.toml`. It works like this:

[board]
name = "Custom Arduino Uno"
max-application-size = 32256

[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