diff --git a/Cargo.toml b/Cargo.toml index ca159ee2b2..ebf2a9828a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,8 @@ members = [ "examples/arduino-uno", "examples/atmega2560", "examples/nano168", + "examples/nano-328pb", + "examples/nano-every", "examples/sparkfun-promicro", "examples/sparkfun-promini-3v3", "examples/sparkfun-promini-5v", diff --git a/arduino-hal/Cargo.toml b/arduino-hal/Cargo.toml index 1f400c73f3..cbb4b31e4e 100644 --- a/arduino-hal/Cargo.toml +++ b/arduino-hal/Cargo.toml @@ -25,6 +25,7 @@ arduino-mega2560 = ["mcu-atmega", "atmega-hal/atmega2560", "board-selected"] arduino-mega1280 = ["mcu-atmega", "atmega-hal/atmega1280", "board-selected"] arduino-nano = ["mcu-atmega", "atmega-hal/atmega328p", "atmega-hal/enable-extra-adc", "board-selected"] arduino-uno = ["mcu-atmega", "atmega-hal/atmega328p", "board-selected"] +nano-every = ["mcu-atmega", "atmega-hal/atmega328p", "atmega-hal/enable-extra-adc", "board-selected"] trinket-pro = ["mcu-atmega", "atmega-hal/atmega328p", "board-selected"] sparkfun-promicro = ["mcu-atmega", "atmega-hal/atmega32u4", "board-selected"] sparkfun-promini-3v3 = ["mcu-atmega", "atmega-hal/atmega328p", "atmega-hal/enable-extra-adc", "board-selected"] diff --git a/arduino-hal/src/clock.rs b/arduino-hal/src/clock.rs index 7c53088015..35d504e38a 100644 --- a/arduino-hal/src/clock.rs +++ b/arduino-hal/src/clock.rs @@ -21,6 +21,7 @@ pub(crate) mod default { feature = "arduino-mega1280", feature = "arduino-nano", feature = "arduino-uno", + feature = "nano-every", feature = "sparkfun-promicro", feature = "sparkfun-promini-5v", feature = "trinket-pro", diff --git a/arduino-hal/src/lib.rs b/arduino-hal/src/lib.rs index 5e78dc3318..7876c3e58d 100644 --- a/arduino-hal/src/lib.rs +++ b/arduino-hal/src/lib.rs @@ -12,6 +12,7 @@ #![cfg_attr(feature = "arduino-mega1280", doc = "**Arduino Mega 1280**.")] #![cfg_attr(feature = "arduino-nano", doc = "**Arduino Nano**.")] #![cfg_attr(feature = "arduino-uno", doc = "**Arduino Uno**.")] +#![cfg_attr(feature = "nano-every", doc = "**Nano Every**.")] #![cfg_attr(feature = "sparkfun-promicro", doc = "**SparkFun ProMicro**.")] #![cfg_attr( feature = "sparkfun-promini-3v3", @@ -65,6 +66,7 @@ compile_error!( * arduino-mega2560 * arduino-mega1280 * arduino-nano + * nano-every * arduino-uno * sparkfun-promicro * sparkfun-promini-3v3 @@ -325,6 +327,7 @@ macro_rules! default_serial { /// ``` #[cfg(any( feature = "arduino-nano", + feature = "nano-every", feature = "nano168", feature = "sparkfun-promini-3v3", feature = "sparkfun-promini-5v", diff --git a/arduino-hal/src/port/mod.rs b/arduino-hal/src/port/mod.rs index 160d3f9811..e0ba079823 100644 --- a/arduino-hal/src/port/mod.rs +++ b/arduino-hal/src/port/mod.rs @@ -30,6 +30,7 @@ pub use mega::*; #[cfg(any( feature = "arduino-nano", feature = "arduino-uno", + feature = "nano-every", feature = "nano168", feature = "sparkfun-promini-3v3", feature = "sparkfun-promini-5v" @@ -38,6 +39,7 @@ mod uno; #[cfg(any( feature = "arduino-nano", feature = "arduino-uno", + feature = "nano-every", feature = "nano168", feature = "sparkfun-promini-3v3", feature = "sparkfun-promini-5v" diff --git a/avr-specs/avr-atmega328pb.json b/avr-specs/avr-atmega328pb.json new file mode 100644 index 0000000000..0def6a1863 --- /dev/null +++ b/avr-specs/avr-atmega328pb.json @@ -0,0 +1,31 @@ +{ + "arch": "avr", + "atomic-cas": false, + "cpu": "atmega328pb", + "crt-objects-fallback": "false", + "data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8", + "eh-frame-header": false, + "exe-suffix": ".elf", + "late-link-args": { + "gnu-cc": ["-lgcc"], + "gnu-lld-cc": ["-lgcc"] + }, + "linker": "avr-gcc", + "linker-flavor": "gnu-cc", + "llvm-target": "avr-unknown-unknown", + "max-atomic-width": 16, + "metadata": { + "description": null, + "host_tools": null, + "std": null, + "tier": null + }, + "no-default-libraries": false, + "pre-link-args": { + "gnu-cc": ["-mmcu=atmega328pb", "-Wl,--as-needed,--print-memory-usage"], + "gnu-lld-cc": ["-mmcu=atmega328pb", "-Wl,--as-needed,--print-memory-usage"] + }, + "relocation-model": "static", + "target-c-int-width": "16", + "target-pointer-width": "16" +} diff --git a/examples/arduino-nano/.cargo/config.toml b/examples/arduino-nano/.cargo/config.toml index 244bf7ba63..10fcdf40ef 100644 --- a/examples/arduino-nano/.cargo/config.toml +++ b/examples/arduino-nano/.cargo/config.toml @@ -2,7 +2,7 @@ target = "../../avr-specs/avr-atmega328p.json" [target.'cfg(target_arch = "avr")'] -runner = "ravedude nano -cb 57600" +runner = "../../ravedude/target/debug/ravedude" [unstable] build-std = ["core"] diff --git a/examples/nano-328pb/.cargo/config.toml b/examples/nano-328pb/.cargo/config.toml new file mode 100644 index 0000000000..d42da7c6cc --- /dev/null +++ b/examples/nano-328pb/.cargo/config.toml @@ -0,0 +1,8 @@ +[build] +target = "../../avr-specs/avr-atmega328pb.json" + +[target.'cfg(target_arch = "avr")'] +runner = "../../ravedude/target/debug/ravedude" + +[unstable] +build-std = ["core"] diff --git a/examples/nano-328pb/Cargo.toml b/examples/nano-328pb/Cargo.toml new file mode 100644 index 0000000000..3c97451543 --- /dev/null +++ b/examples/nano-328pb/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "nano-328pb-examples" +version = "0.0.0" +authors = ["Bill Wiseman "] +edition = "2018" +publish = false + +[dependencies] +panic-halt = "0.2.0" +ufmt = "0.1.0" +nb = "0.1.2" +embedded-hal = "0.2.3" + +[dependencies.arduino-hal] +path = "../../arduino-hal/" +features = ["arduino-nano"] + +[dependencies.avr-device] +version = "0.5.1" + +# The latest releases of `proc-macro2` do not support the rust toolchain that +# we use. Thus, we must fix this dependency to an older version where our +# toolchain is still supported. See https://github.com/Rahix/avr-hal/issues/537 +[build-dependencies.proc-macro2] +version = "=1.0.79" diff --git a/examples/nano-328pb/Ravedude.toml b/examples/nano-328pb/Ravedude.toml new file mode 100644 index 0000000000..22bd45ac8c --- /dev/null +++ b/examples/nano-328pb/Ravedude.toml @@ -0,0 +1,6 @@ +# Ravedude.toml +[general] +open-console = true +serial-baudrate = 115200 +board = "nano-328pb" +port = "/dev/ttyUSB0" diff --git a/examples/nano-328pb/src/main.rs b/examples/nano-328pb/src/main.rs new file mode 100644 index 0000000000..8650f1274d --- /dev/null +++ b/examples/nano-328pb/src/main.rs @@ -0,0 +1,25 @@ +#![no_std] +#![no_main] + +use panic_halt as _; + +#[arduino_hal::entry] +fn main() -> ! { + let dp = arduino_hal::Peripherals::take().unwrap(); + let pins = arduino_hal::pins!(dp); + + // Digital pin 13 is also connected to an onboard LED marked "L" + let mut led = pins.d13.into_output(); + led.set_high(); + + loop { + led.toggle(); + arduino_hal::delay_ms(100); + led.toggle(); + arduino_hal::delay_ms(100); + led.toggle(); + arduino_hal::delay_ms(100); + led.toggle(); + arduino_hal::delay_ms(800); + } +} diff --git a/examples/nano-every/.cargo/config.toml b/examples/nano-every/.cargo/config.toml new file mode 100644 index 0000000000..10fcdf40ef --- /dev/null +++ b/examples/nano-every/.cargo/config.toml @@ -0,0 +1,8 @@ +[build] +target = "../../avr-specs/avr-atmega328p.json" + +[target.'cfg(target_arch = "avr")'] +runner = "../../ravedude/target/debug/ravedude" + +[unstable] +build-std = ["core"] diff --git a/examples/nano-every/Cargo.toml b/examples/nano-every/Cargo.toml new file mode 100644 index 0000000000..e68c0c150e --- /dev/null +++ b/examples/nano-every/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "nano-every-examples" +version = "0.0.0" +authors = ["Bill Wiseman "] +edition = "2018" +publish = false + +[dependencies] +panic-halt = "0.2.0" +ufmt = "0.1.0" +nb = "0.1.2" +embedded-hal = "0.2.3" + +[dependencies.arduino-hal] +path = "../../arduino-hal/" +features = ["nano-every"] diff --git a/examples/nano-every/Ravedude.toml b/examples/nano-every/Ravedude.toml new file mode 100644 index 0000000000..a4ca3a2f44 --- /dev/null +++ b/examples/nano-every/Ravedude.toml @@ -0,0 +1,17 @@ +[general] +open-console = true +serial-baudrate = 115200 +port = "/dev/ttyACM0" +board = "nano-every" +debug-avrdude = true +reset-delay = 500 + +[avrdude] +programmer = "jtag2updi" +partno = "atmega4809" +delay-serial = true +fuse2 = 0x40 +fuse5 = 0x69 +fuse8 = 0x00 +avrdude-conf = "~/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf" +avrdude-path = "~/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude" diff --git a/examples/nano-every/src/main.rs b/examples/nano-every/src/main.rs new file mode 100644 index 0000000000..50f441ea8b --- /dev/null +++ b/examples/nano-every/src/main.rs @@ -0,0 +1,19 @@ +#![no_std] +#![no_main] + +use panic_halt as _; + +#[arduino_hal::entry] +fn main() -> ! { + let dp = arduino_hal::Peripherals::take().unwrap(); + let pins = arduino_hal::pins!(dp); + + let mut led = pins.d13.into_output(); + + loop { + led.set_high(); + arduino_hal::delay_ms(500); + led.set_low(); + arduino_hal::delay_ms(500); + } +} \ No newline at end of file diff --git a/ravedude/Cargo.lock b/ravedude/Cargo.lock index 4131ee0561..525a2d900b 100644 --- a/ravedude/Cargo.lock +++ b/ravedude/Cargo.lock @@ -70,6 +70,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + [[package]] name = "cc" version = "1.0.67" @@ -96,7 +102,7 @@ checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" dependencies = [ "ansi_term", "atty", - "bitflags", + "bitflags 1.3.2", "textwrap", "unicode-width", ] @@ -122,6 +128,26 @@ dependencies = [ "winapi", ] +[[package]] +name = "dirs" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + [[package]] name = "either" version = "1.10.0" @@ -213,6 +239,16 @@ version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a60553f9a9e039a333b4e9b20573b9e9b9c0bb3a11e201ccc48ef4283456d673" +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.6.0", + "libc", +] + [[package]] name = "libudev" version = "0.2.0" @@ -272,7 +308,7 @@ version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd0eaf8df8bab402257e0a5c17a254e4cc1f72a93588a1ddfb5d356c801aa7cb" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cc", "cfg-if 0.1.10", "libc", @@ -285,7 +321,7 @@ version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f305c2c2e4c39a82f7bf0bf65fb557f9070ce06781d4f2454295cc34b1c43188" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cc", "cfg-if 1.0.0", "libc", @@ -401,6 +437,7 @@ dependencies = [ "ctrlc", "either", "git-version", + "resolve-path", "serde", "serialport", "structopt", @@ -414,7 +451,18 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94341e4e44e24f6b591b59e47a8a027df12e008d73fd5672dbea9cc22f4507d9" dependencies = [ - "bitflags", + "bitflags 1.3.2", +] + +[[package]] +name = "redox_users" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" +dependencies = [ + "getrandom", + "libredox", + "thiserror", ] [[package]] @@ -443,6 +491,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "resolve-path" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "321e5e41b3b192dab6f1e75b9deacb6688b4b8c5e68906a78e8f43e7c2887bb5" +dependencies = [ + "dirs", +] + [[package]] name = "serde" version = "1.0.197" @@ -480,7 +537,7 @@ checksum = "22f37409d980045734250d679750bdf11bd875fec5bb5417dd21bb75d04d31a1" dependencies = [ "CoreFoundation-sys", "IOKit-sys", - "bitflags", + "bitflags 1.3.2", "cfg-if 0.1.10", "libudev", "mach 0.2.3", @@ -558,6 +615,26 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "thiserror" +version = "1.0.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] + [[package]] name = "toml" version = "0.8.11" diff --git a/ravedude/Cargo.toml b/ravedude/Cargo.toml index 3ee61459d1..05d21a6319 100644 --- a/ravedude/Cargo.toml +++ b/ravedude/Cargo.toml @@ -20,6 +20,7 @@ ctrlc = "3.2.1" serde = { version = "1.0.197", features = ["serde_derive"] } toml = "0.8.11" either = "1.10.0" +resolve-path = "0.1.0" [dependencies.structopt] version = "0.3.21" diff --git a/ravedude/src/avrdude/mod.rs b/ravedude/src/avrdude/mod.rs index 65224e4ba8..60c8e379af 100644 --- a/ravedude/src/avrdude/mod.rs +++ b/ravedude/src/avrdude/mod.rs @@ -1,3 +1,7 @@ +use resolve_path::PathResolveExt; +use std::thread; +use std::time::Duration; + use anyhow::Context as _; use std::path; use std::process; @@ -51,7 +55,18 @@ impl Avrdude { ) -> anyhow::Result { let avrdude_version = Self::get_avrdude_version()?; - let mut command = &mut process::Command::new("avrdude"); + println!("{:?}", options); + + let mut command = match options.avrdude_path.as_ref() { + Some(avrdude_path) => { + let avrdude_path = avrdude_path.resolve(); + // let avrdude_path = path::absolute(avrdude_path).unwrap(); + &mut process::Command::new(avrdude_path.as_os_str()) + } + None => &mut process::Command::new("avrdude"), // let avrdude_path = path::absolute(options.avrdude_path); + // &mut process::Command::new(avrdude_path) + // } else { + }; let config = if avrdude_version <= (7, 0) { let config = tempfile::Builder::new() @@ -72,6 +87,8 @@ impl Avrdude { }; let mut command = command + .arg("-v") + .arg("-V") .arg("-c") .arg( options @@ -87,10 +104,27 @@ impl Avrdude { .ok_or_else(|| anyhow::anyhow!("board has no part number"))?, ); - if let Some(port) = port { + if let Some(fuse2) = options.fuse2 { + command = command.arg("-U").arg(format!("fuse2:w:{:#02X}:m", fuse2)); + } + + if let Some(fuse5) = options.fuse5 { + command = command.arg("-U").arg(format!("fuse2:w:{:#02X}:m", fuse5)); + } + + if let Some(fuse8) = options.fuse8 { + command = command.arg("-U").arg(format!("fuse2:w:{:#02X}:m", fuse8)); + } + + if let Some(port) = port.as_ref() { command = command.arg("-P").arg(port.as_ref()); } + if let Some(avrdude_conf) = options.avrdude_conf.as_ref() { + let avrdude_conf = avrdude_conf.resolve(); + command = command.arg("-C").arg(avrdude_conf.as_os_str()); + } + if let Some(baudrate) = options.baudrate.flatten() { command = command.arg("-b").arg(baudrate.to_string()); } @@ -107,7 +141,27 @@ impl Avrdude { command = command.arg("-e"); } - command = command.arg("-D").arg("-U").arg(flash_instruction); + match options.curclock { + Some(curclock) => { + if curclock == true { + command = command.arg("-curclock"); + } + } + None => {} + } + + command = command.arg("-D"); + command = command.arg("-U").arg(flash_instruction); + + // Add x nometadata if no_metadata is true + match options.no_metadata { + Some(no_metadata) => { + if no_metadata == true { + command = command.arg("-x").arg("nometadata"); + } + } + None => {} + } if debug { crate::task_message!( @@ -122,6 +176,26 @@ impl Avrdude { ); } + // Reset if this is nanao-every + match options.delay_serial { + Some(delay_serial) => { + if delay_serial == true { + if let Some(port) = port.as_ref() { + // Open the port + let serial_port = serialport::new(port.as_ref().to_str().unwrap(), 1200); + serial_port.open().expect("Failed to open port"); + + // Wait for half a second + let half_second = Duration::from_millis(500); + thread::sleep(half_second); + } + } + } + None => {} + } + + println!("{:?}", command); + let process = command.spawn().context("failed starting avrdude")?; Ok(Self { config, process }) diff --git a/ravedude/src/boards.toml b/ravedude/src/boards.toml index 7609a18683..75cd23b4ef 100644 --- a/ravedude/src/boards.toml +++ b/ravedude/src/boards.toml @@ -1,240 +1,282 @@ [uno] - name = "Arduino Uno" +name = "Arduino Uno" - [uno.reset] - automatic = true +[uno.reset] +automatic = true - [uno.avrdude] - programmer = "arduino" - partno = "atmega328p" - baudrate = -1 - do-chip-erase = true +[uno.avrdude] +programmer = "arduino" +partno = "atmega328p" +baudrate = -1 +do-chip-erase = true - [uno.usb-info] - port-ids = [ - { vid = 0x2341, pid = 0x0043 }, - { vid = 0x2341, pid = 0x0001 }, - { vid = 0x2A03, pid = 0x0043 }, - { vid = 0x2341, pid = 0x0243 }, - ] +[uno.usb-info] +port-ids = [ + { vid = 0x2341, pid = 0x0043 }, + { vid = 0x2341, pid = 0x0001 }, + { vid = 0x2A03, pid = 0x0043 }, + { vid = 0x2341, pid = 0x0243 }, +] [nano] - name = "Arduino Nano" +name = "Arduino Nano" - [nano.reset] - automatic = true +[nano.reset] +automatic = true - [nano.avrdude] - programmer = "arduino" - partno = "atmega328p" - baudrate = 57600 - do-chip-erase = true +[nano.avrdude] +programmer = "arduino" +partno = "atmega328p" +baudrate = 57600 +do-chip-erase = true - [nano.usb-info] - error = "Not able to guess port" +[nano.usb-info] +error = "Not able to guess port" [nano-new] - name = "Arduino Nano (New Bootloader)" +name = "Arduino Nano (New Bootloader)" - [nano-new.reset] - automatic = true +[nano-new.reset] +automatic = true - [nano-new.avrdude] - programmer = "arduino" - partno = "atmega328p" - baudrate = 115200 - do-chip-erase = true +[nano-new.avrdude] +programmer = "arduino" +partno = "atmega328p" +baudrate = 115200 +do-chip-erase = true - [nano-new.usb-info] - error = "Not able to guess port" +[nano-new.usb-info] +error = "Not able to guess port" + + +[nano-328pb] +name = "Nano Atmega328pb" + +[nano-328pb.reset] +automatic = true + +[nano-328pb.avrdude] +programmer = "arduino" +partno = "atmega328pb" +baudrate = 115200 +do-chip-erase = true +curclock = true +no-metadata = true +avrdude-path = "~/.arduino15/packages/MiniCore/tools/avrdude/8.0-arduino.1/bin/avrdude" +avrdude-conf = "~/.arduino15/packages/MiniCore/tools/avrdude/8.0-arduino.1/etc/avrdude.conf" + +[nano-328pb.usb-info] +error = "Not able to guess port" + + +[nano-every] +name = "Nano Every" + +[nano-every.reset] +automatic = true + +[nano-every.avrdude] +programmer = "jtag2updi" +partno = "atmega4809" +baudrate = 115200 +do-chip-erase = true +delay-serial = true +fuse2 = 0x01 +fuse5 = 0x69 +fuse8 = 0x00 +avrdude-path = "~/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude" +avrdude-conf = "~/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf" + +[nano-every.usb-info] +error = "Not able to guess port" [leonardo] - name = "Arduino Leonardo" - - [leonardo.reset] - automatic = false - - [leonardo.avrdude] - programmer = "avr109" - partno = "atmega32u4" - baudrate = -1 - do-chip-erase = true - - [leonardo.usb-info] - port-ids = [ - { vid = 0x2341, pid = 0x0036 }, - { vid = 0x2341, pid = 0x8036 }, - { vid = 0x2A03, pid = 0x0036 }, - { vid = 0x2A03, pid = 0x8036 }, - ] +name = "Arduino Leonardo" + +[leonardo.reset] +automatic = false + +[leonardo.avrdude] +programmer = "avr109" +partno = "atmega32u4" +baudrate = -1 +do-chip-erase = true + +[leonardo.usb-info] +port-ids = [ + { vid = 0x2341, pid = 0x0036 }, + { vid = 0x2341, pid = 0x8036 }, + { vid = 0x2A03, pid = 0x0036 }, + { vid = 0x2A03, pid = 0x8036 }, +] [micro] - name = "Arduino Micro" - - [micro.reset] - automatic = false - - [micro.avrdude] - programmer = "avr109" - partno = "atmega32u4" - baudrate = 115200 - do-chip-erase = true - - [micro.usb-info] - port-ids = [ - { vid = 0x2341, pid = 0x0037 }, - { vid = 0x2341, pid = 0x8037 }, - { vid = 0x2A03, pid = 0x0037 }, - { vid = 0x2A03, pid = 0x8037 }, - { vid = 0x2341, pid = 0x0237 }, - { vid = 0x2341, pid = 0x8237 }, - ] +name = "Arduino Micro" + +[micro.reset] +automatic = false + +[micro.avrdude] +programmer = "avr109" +partno = "atmega32u4" +baudrate = 115200 +do-chip-erase = true + +[micro.usb-info] +port-ids = [ + { vid = 0x2341, pid = 0x0037 }, + { vid = 0x2341, pid = 0x8037 }, + { vid = 0x2A03, pid = 0x0037 }, + { vid = 0x2A03, pid = 0x8037 }, + { vid = 0x2341, pid = 0x0237 }, + { vid = 0x2341, pid = 0x8237 }, +] [mega2560] - name = "Arduino Mega 2560" - - [mega2560.reset] - automatic = true - - [mega2560.avrdude] - programmer = "wiring" - partno = "atmega2560" - baudrate = 115200 - do-chip-erase = false - - [mega2560.usb-info] - port-ids = [ - { vid = 0x2341, pid = 0x0010 }, - { vid = 0x2341, pid = 0x0042 }, - { vid = 0x2A03, pid = 0x0010 }, - { vid = 0x2A03, pid = 0x0042 }, - { vid = 0x2341, pid = 0x0210 }, - { vid = 0x2341, pid = 0x0242 }, - ] +name = "Arduino Mega 2560" + +[mega2560.reset] +automatic = true + +[mega2560.avrdude] +programmer = "wiring" +partno = "atmega2560" +baudrate = 115200 +do-chip-erase = false + +[mega2560.usb-info] +port-ids = [ + { vid = 0x2341, pid = 0x0010 }, + { vid = 0x2341, pid = 0x0042 }, + { vid = 0x2A03, pid = 0x0010 }, + { vid = 0x2A03, pid = 0x0042 }, + { vid = 0x2341, pid = 0x0210 }, + { vid = 0x2341, pid = 0x0242 }, +] [mega1280] - name = "Arduino Mega 1280" +name = "Arduino Mega 1280" - [mega1280.reset] - automatic = true +[mega1280.reset] +automatic = true - [mega1280.avrdude] - programmer = "wiring" - partno = "atmega1280" - baudrate = 57600 - do-chip-erase = false +[mega1280.avrdude] +programmer = "wiring" +partno = "atmega1280" +baudrate = 57600 +do-chip-erase = false - [mega1280.usb-info] - # This board uses a generic serial interface id 0403:6001 which is too common for auto detection. - error = "Not able to guess port" +[mega1280.usb-info] +# This board uses a generic serial interface id 0403:6001 which is too common for auto detection. +error = "Not able to guess port" [diecimila] - name = "Arduino Diecimila" +name = "Arduino Diecimila" - [diecimila.reset] - automatic = true +[diecimila.reset] +automatic = true - [diecimila.avrdude] - programmer = "arduino" - partno = "atmega168" - baudrate = 19200 - do-chip-erase = false +[diecimila.avrdude] +programmer = "arduino" +partno = "atmega168" +baudrate = 19200 +do-chip-erase = false - [diecimila.usb-info] - # No IDs known. - error = "Not able to guess port" +[diecimila.usb-info] +# No IDs known. +error = "Not able to guess port" [promicro] - name = "SparkFun Pro Micro" - - [promicro.reset] - automatic = false - - [promicro.avrdude] - programmer = "avr109" - partno = "atmega32u4" - baudrate = -1 - do-chip-erase = true - - [promicro.usb-info] - port-ids = [ - { vid = 0x1B4F, pid = 0x9205 }, # 5V - { vid = 0x1B4F, pid = 0x9206 }, # 5V - { vid = 0x1B4F, pid = 0x9203 }, # 3.3V - { vid = 0x1B4F, pid = 0x9204 }, # 3.3V - ] +name = "SparkFun Pro Micro" + +[promicro.reset] +automatic = false + +[promicro.avrdude] +programmer = "avr109" +partno = "atmega32u4" +baudrate = -1 +do-chip-erase = true + +[promicro.usb-info] +port-ids = [ + { vid = 0x1B4F, pid = 0x9205 }, # 5V + { vid = 0x1B4F, pid = 0x9206 }, # 5V + { vid = 0x1B4F, pid = 0x9203 }, # 3.3V + { vid = 0x1B4F, pid = 0x9204 }, # 3.3V +] [promini-5v] - name = "SparkFun Pro Mini 5V (16MHz)" +name = "SparkFun Pro Mini 5V (16MHz)" - [promini-5v.reset] - automatic = true +[promini-5v.reset] +automatic = true - [promini-5v.avrdude] - programmer = "arduino" - partno = "atmega328p" - baudrate = 57600 - do-chip-erase = true +[promini-5v.avrdude] +programmer = "arduino" +partno = "atmega328p" +baudrate = 57600 +do-chip-erase = true - [promini-5v.usb-info] - error = "Not able to guess port" +[promini-5v.usb-info] +error = "Not able to guess port" [trinket-pro] - name = "Trinket Pro" +name = "Trinket Pro" - [trinket-pro.reset] - automatic = false - - [trinket-pro.avrdude] - programmer = "usbtiny" - partno = "atmega328p" - baudrate = -1 - do-chip-erase = false +[trinket-pro.reset] +automatic = false - # The Trinket Pro does not have USB-Serial, thus no port is known or needed. +[trinket-pro.avrdude] +programmer = "usbtiny" +partno = "atmega328p" +baudrate = -1 +do-chip-erase = false + +# The Trinket Pro does not have USB-Serial, thus no port is known or needed. [trinket] - name = "Trinket" +name = "Trinket" + +[trinket.reset] +automatic = false - [trinket.reset] - automatic = false - - [trinket.avrdude] - programmer = "usbtiny" - partno = "atmega328p" - baudrate = -1 - do-chip-erase = true +[trinket.avrdude] +programmer = "usbtiny" +partno = "atmega328p" +baudrate = -1 +do-chip-erase = true - # The Trinket does not have USB-Serial, thus no port is known or needed. +# The Trinket does not have USB-Serial, thus no port is known or needed. [nano168] - name = "Nano Clone (ATmega168)" +name = "Nano Clone (ATmega168)" - [nano168.reset] - automatic = true +[nano168.reset] +automatic = true - [nano168.avrdude] - programmer = "arduino" - partno = "atmega168" - baudrate = 19200 - do-chip-erase = false +[nano168.avrdude] +programmer = "arduino" +partno = "atmega168" +baudrate = 19200 +do-chip-erase = false - [nano168.usb-info] - # No IDs here because the Nano 168 uses a generic USB-Serial chip. - error = "Not able to guess port" +[nano168.usb-info] +# No IDs here because the Nano 168 uses a generic USB-Serial chip. +error = "Not able to guess port" [duemilanove] - name = "Arduino Duemilanove" +name = "Arduino Duemilanove" - [duemilanove.reset] - automatic = true +[duemilanove.reset] +automatic = true - [duemilanove.avrdude] - programmer = "arduino" - partno = "atmega328p" - baudrate = 57600 - do-chip-erase = true +[duemilanove.avrdude] +programmer = "arduino" +partno = "atmega328p" +baudrate = 57600 +do-chip-erase = true - [duemilanove.usb-info] - # No IDs here because the Nano 168 uses a generic USB-Serial chip. - error = "Not able to guess port" +[duemilanove.usb-info] +# No IDs here because the Nano 168 uses a generic USB-Serial chip. +error = "Not able to guess port" diff --git a/ravedude/src/config.rs b/ravedude/src/config.rs index 8e688f22ff..be73cc77ec 100644 --- a/ravedude/src/config.rs +++ b/ravedude/src/config.rs @@ -131,6 +131,14 @@ pub struct BoardAvrdudeOptions { // Option pub baudrate: Option>, pub do_chip_erase: Option, + pub delay_serial: Option, + pub curclock: Option, + pub no_metadata: Option, + pub fuse2: Option, + pub fuse5: Option, + pub fuse8: Option, + pub avrdude_conf: Option, + pub avrdude_path: Option, } impl BoardAvrdudeOptions { pub fn merge(self, base: Self) -> Self { @@ -139,6 +147,14 @@ impl BoardAvrdudeOptions { partno: self.partno.or(base.partno), baudrate: self.baudrate.or(base.baudrate), do_chip_erase: self.do_chip_erase.or(base.do_chip_erase), + delay_serial: self.delay_serial.or(base.delay_serial), + curclock: self.curclock.or(base.curclock), + no_metadata: self.no_metadata.or(base.no_metadata), + fuse2: self.fuse2.or(base.fuse2), + fuse5: self.fuse5.or(base.fuse5), + fuse8: self.fuse8.or(base.fuse8), + avrdude_conf: self.avrdude_conf.or(base.avrdude_conf), + avrdude_path: self.avrdude_path.or(base.avrdude_path), } } }