Skip to content

Commit

Permalink
ravedude: Make avrdude -e optional
Browse files Browse the repository at this point in the history
It seems that actually some boards _don't_ want the -e option (which
instructs avrdude to do a chip erase before flashing).  For those
boards, make it possible to omit the flag.
  • Loading branch information
Rahix committed Mar 21, 2021
1 parent 3a472c7 commit 5c26a0f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ravedude/src/avrdude/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub struct AvrdudeOptions<'a> {
pub programmer: &'a str,
pub partno: &'a str,
pub baudrate: Option<u32>,
pub do_chip_erase: bool,
}

#[derive(Debug)]
Expand Down Expand Up @@ -56,7 +57,11 @@ impl Avrdude {
flash_instruction.push(bin);
flash_instruction.push(":e");

command = command.arg("-e").arg("-D").arg("-U").arg(flash_instruction);
if options.do_chip_erase {
command = command.arg("-e");
}

command = command.arg("-D").arg("-U").arg(flash_instruction);

let process = command.spawn().context("failed starting avrdude")?;

Expand Down
3 changes: 3 additions & 0 deletions ravedude/src/board.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ impl Board for ArduinoUno {
programmer: "arduino",
partno: "atmega328p",
baudrate: None,
do_chip_erase: true,
}
}

Expand Down Expand Up @@ -82,6 +83,7 @@ impl Board for ArduinoNano {
programmer: "arduino",
partno: "atmega328p",
baudrate: Some(57600),
do_chip_erase: true,
}
}

Expand All @@ -106,6 +108,7 @@ impl Board for ArduinoLeonardo {
programmer: "avr109",
partno: "atmega32u4",
baudrate: None,
do_chip_erase: true,
}
}

Expand Down

0 comments on commit 5c26a0f

Please sign in to comment.