Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for nano every uploading #420

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions arduino-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
1 change: 1 addition & 0 deletions arduino-hal/src/clock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions arduino-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -65,6 +66,7 @@ compile_error!(
* arduino-mega2560
* arduino-mega1280
* arduino-nano
* nano-every
* arduino-uno
* sparkfun-promicro
* sparkfun-promini-3v3
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions arduino-hal/src/port/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
31 changes: 31 additions & 0 deletions avr-specs/avr-atmega328pb.json
Original file line number Diff line number Diff line change
@@ -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"
}
2 changes: 1 addition & 1 deletion examples/arduino-nano/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
8 changes: 8 additions & 0 deletions examples/nano-328pb/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -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"]
25 changes: 25 additions & 0 deletions examples/nano-328pb/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "nano-328pb-examples"
version = "0.0.0"
authors = ["Bill Wiseman <[email protected]>"]
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"
6 changes: 6 additions & 0 deletions examples/nano-328pb/Ravedude.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Ravedude.toml
[general]
open-console = true
serial-baudrate = 115200
board = "nano-328pb"
port = "/dev/ttyUSB0"
25 changes: 25 additions & 0 deletions examples/nano-328pb/src/main.rs
Original file line number Diff line number Diff line change
@@ -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);
}
}
8 changes: 8 additions & 0 deletions examples/nano-every/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -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"]
16 changes: 16 additions & 0 deletions examples/nano-every/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "nano-every-examples"
version = "0.0.0"
authors = ["Bill Wiseman <[email protected]>"]
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"]
17 changes: 17 additions & 0 deletions examples/nano-every/Ravedude.toml
Original file line number Diff line number Diff line change
@@ -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"
19 changes: 19 additions & 0 deletions examples/nano-every/src/main.rs
Original file line number Diff line number Diff line change
@@ -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);
}
}
Loading