Skip to content

Commit 81ce513

Browse files
committed
Support AVR and megaAVR PlatformIO boards
1 parent 8007a1e commit 81ce513

File tree

3 files changed

+339
-27
lines changed

3 files changed

+339
-27
lines changed

README.md

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ Place `target()` **at the very top of your script**, immediately after imports.
9494
| ---------: | :----: | :----------: | --------------------------------------------------------------------------- |
9595
| `port` | `str` || Serial port, e.g. `"COM3"` or `"/dev/ttyACM0"`. |
9696
| `upload` | `bool` | `True` | If `True`, compile & upload via PlatformIO. If `False`, only transpile. |
97-
| `platform` | `str` | `"atmelavr"` | PlatformIO platform ID, e.g. `"espressif32"` for ESP32 boards. |
98-
| `board` | `str` | `"uno"` | PlatformIO board ID, e.g. `"esp32dev"`. Must be compatible with `platform`. |
97+
| `platform` | `str` | `"atmelavr"` | PlatformIO platform ID. Reduino currently supports `atmelavr` and `atmelmegaavr`. |
98+
| `board` | `str` | `"uno"` | PlatformIO board ID. Must be compatible with `platform`. |
9999

100100
**Returns:** `str` of the generated Arduino C++ source.
101101

@@ -149,31 +149,30 @@ print(cpp)
149149

150150
### Targeting different platforms & boards
151151

152-
Reduino validates that the requested PlatformIO platform/board pair is supported. The
153-
following combinations are available out of the box:
152+
Reduino validates that the requested PlatformIO platform/board pair is supported.
153+
At the moment two PlatformIO platforms are available:
154154

155-
| PlatformIO platform | Supported boards |
156-
| ------------------- | -------------------------------- |
157-
| `atmelavr` | `uno`, `nano` |
158-
| `atmelsam` | `due` |
159-
| `espressif32` | `esp32dev`, `esp32doit-devkit-v1` |
155+
* `atmelavr` – classic AVR-based boards (Uno, Nano, Leonardo, etc.).
156+
* `atmelmegaavr` – newer megaAVR devices (Nano Every, Uno WiFi Rev2, Curiosity Nano kits, ...).
160157

161-
If you pick an unsupported board, or a board that does not belong to the selected
162-
platform, `target()` raises a `ValueError` with a helpful message.
158+
Every board listed in the [PlatformIO board registry for `atmelavr`](https://docs.platformio.org/en/latest/boards/atmelavr.html)
159+
and [`atmelmegaavr`](https://docs.platformio.org/en/latest/boards/atmelmegaavr.html) can be targeted. If you choose an
160+
unsupported board, or one that does not belong to the selected platform, `target()` raises
161+
a `ValueError` with a helpful message.
163162

164163
```python
165164
from Reduino import target
166165

167-
# Build for an ESP32 dev module without uploading automatically.
166+
# Build for an Arduino Nano Every without uploading automatically.
168167
target(
169168
"COM9",
170169
upload=False,
171-
platform="espressif32",
172-
board="esp32dev",
170+
platform="atmelmegaavr",
171+
board="nano_every",
173172
)
174173

175-
# Build for an Arduino Nano and upload immediately.
176-
target("/dev/ttyUSB0", platform="atmelavr", board="nano")
174+
# Build for a classic Arduino Uno and upload immediately.
175+
target("/dev/ttyUSB0", platform="atmelavr", board="uno")
177176
```
178177

179178
> [!IMPORTANT]

src/Reduino/toolchain/pio.py

Lines changed: 318 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,322 @@
55
from pathlib import Path
66
from typing import Iterable, List
77

8+
SUPPORTED_ATMELAVR_BOARDS = frozenset(
9+
"""
10+
1284p16m
11+
1284p8m
12+
168pa16m
13+
168pa8m
14+
328p16m
15+
328p8m
16+
32u416m
17+
644pa16m
18+
644pa8m
19+
AT90CAN128
20+
AT90CAN32
21+
AT90CAN64
22+
ATmega128
23+
ATmega1280
24+
ATmega1281
25+
ATmega1284
26+
ATmega1284P
27+
ATmega16
28+
ATmega162
29+
ATmega164A
30+
ATmega164P
31+
ATmega165
32+
ATmega165P
33+
ATmega168
34+
ATmega168P
35+
ATmega168PB
36+
ATmega169A
37+
ATmega169P
38+
ATmega2560
39+
ATmega2561
40+
ATmega32
41+
ATmega324A
42+
ATmega324P
43+
ATmega324PA
44+
ATmega324PB
45+
ATmega325
46+
ATmega3250
47+
ATmega3250P
48+
ATmega325P
49+
ATmega328
50+
ATmega328P
51+
ATmega328PB
52+
ATmega329
53+
ATmega3290
54+
ATmega3290P
55+
ATmega329P
56+
ATmega48
57+
ATmega48P
58+
ATmega48PB
59+
ATmega64
60+
ATmega640
61+
ATmega644A
62+
ATmega644P
63+
ATmega645
64+
ATmega6450
65+
ATmega6450P
66+
ATmega645P
67+
ATmega649
68+
ATmega6490
69+
ATmega6490P
70+
ATmega649P
71+
ATmega8
72+
ATmega8515
73+
ATmega8535
74+
ATmega88
75+
ATmega88P
76+
ATmega88PB
77+
LilyPadUSB
78+
a-star32U4
79+
alorium_hinj
80+
alorium_sno
81+
alorium_xlr8
82+
altair
83+
ardhat
84+
arduboy
85+
arduboy_devkit
86+
at90pwm216
87+
at90pwm316
88+
atmegangatmega168
89+
atmegangatmega8
90+
attiny13
91+
attiny13a
92+
attiny1634
93+
attiny167
94+
attiny2313
95+
attiny24
96+
attiny25
97+
attiny261
98+
attiny43
99+
attiny4313
100+
attiny44
101+
attiny441
102+
attiny45
103+
attiny461
104+
attiny48
105+
attiny828
106+
attiny84
107+
attiny841
108+
attiny85
109+
attiny861
110+
attiny87
111+
attiny88
112+
blend
113+
blendmicro16
114+
blendmicro8
115+
bluefruitmicro
116+
bob3
117+
btatmega168
118+
btatmega328
119+
chiwawa
120+
circuitplay_classic
121+
controllino_maxi
122+
controllino_maxi_automation
123+
controllino_mega
124+
controllino_mini
125+
diecimilaatmega168
126+
diecimilaatmega328
127+
digispark-pro
128+
digispark-pro32
129+
digispark-pro64
130+
digispark-tiny
131+
dwenguino
132+
elektor_uno_r4
133+
emonpi
134+
engduinov3
135+
esplora
136+
ethernet
137+
feather328p
138+
feather32u4
139+
fio
140+
flora8
141+
ftduino
142+
fysetc_f6_13
143+
gemma
144+
itsybitsy32u4_3V
145+
itsybitsy32u4_5V
146+
leonardo
147+
leonardoeth
148+
lightblue-bean
149+
lightblue-beanplus
150+
lightup
151+
lilypadatmega168
152+
lilypadatmega328
153+
lora32u4II
154+
mayfly
155+
megaADK
156+
megaatmega1280
157+
megaatmega2560
158+
metro
159+
micro
160+
mightyhat
161+
miniatmega168
162+
miniatmega328
163+
miniwireless
164+
moteino
165+
moteino8mhz
166+
moteinomega
167+
nanoatmega168
168+
nanoatmega328
169+
nanoatmega328new
170+
nibo2
171+
nibobee
172+
nibobee_1284
173+
niboburger
174+
niboburger_1284
175+
one
176+
panStampAVR
177+
pinoccio
178+
pro16MHzatmega168
179+
pro16MHzatmega328
180+
pro8MHzatmega168
181+
pro8MHzatmega328
182+
protrinket3
183+
protrinket3ftdi
184+
protrinket5
185+
protrinket5ftdi
186+
prusa_mm_control
187+
prusa_rambo
188+
quirkbot
189+
raspduino
190+
reprap_rambo
191+
robotControl
192+
robotMotor
193+
sanguino_atmega1284_8m
194+
sanguino_atmega1284p
195+
sanguino_atmega644
196+
sanguino_atmega644_8m
197+
sanguino_atmega644p
198+
sanguino_atmega644p_8m
199+
seeeduino
200+
sleepypi
201+
smart7688
202+
sodaq_galora
203+
sodaq_mbili
204+
sodaq_moja
205+
sodaq_ndogo
206+
sodaq_tatu
207+
sparkfun_digitalsandbox
208+
sparkfun_fiov3
209+
sparkfun_makeymakey
210+
sparkfun_megamini
211+
sparkfun_megapro16MHz
212+
sparkfun_megapro8MHz
213+
sparkfun_promicro16
214+
sparkfun_promicro8
215+
sparkfun_qduinomini
216+
sparkfun_redboard
217+
sparkfun_satmega128rfa1
218+
sparkfun_serial7seg
219+
the_things_uno
220+
tinyduino
221+
tinylily
222+
trinket3
223+
trinket5
224+
uno
225+
uno_mini
226+
usbasp
227+
uview
228+
whispernode
229+
wildfirev2
230+
wildfirev3
231+
yun
232+
yunmini
233+
zumbt328
234+
""".split()
235+
)
236+
237+
SUPPORTED_ATMELMEGAAVR_BOARDS = frozenset(
238+
"""
239+
ATmega1608
240+
ATmega1609
241+
ATmega3208
242+
ATmega3209
243+
ATmega4808
244+
ATmega4809
245+
ATmega808
246+
ATmega809
247+
ATtiny1604
248+
ATtiny1606
249+
ATtiny1607
250+
ATtiny1614
251+
ATtiny1616
252+
ATtiny1617
253+
ATtiny1624
254+
ATtiny1626
255+
ATtiny1627
256+
ATtiny202
257+
ATtiny204
258+
ATtiny212
259+
ATtiny214
260+
ATtiny3216
261+
ATtiny3217
262+
ATtiny3224
263+
ATtiny3226
264+
ATtiny3227
265+
ATtiny402
266+
ATtiny404
267+
ATtiny406
268+
ATtiny412
269+
ATtiny414
270+
ATtiny416
271+
ATtiny417
272+
ATtiny424
273+
ATtiny426
274+
ATtiny427
275+
ATtiny804
276+
ATtiny806
277+
ATtiny807
278+
ATtiny814
279+
ATtiny816
280+
ATtiny817
281+
ATtiny824
282+
ATtiny826
283+
ATtiny827
284+
AVR128DA28
285+
AVR128DA32
286+
AVR128DA48
287+
AVR128DA64
288+
AVR128DB28
289+
AVR128DB32
290+
AVR128DB48
291+
AVR128DB64
292+
AVR32DA28
293+
AVR32DA32
294+
AVR32DA48
295+
AVR32DB28
296+
AVR32DB32
297+
AVR32DB48
298+
AVR64DA28
299+
AVR64DA32
300+
AVR64DA48
301+
AVR64DA64
302+
AVR64DB28
303+
AVR64DB32
304+
AVR64DB48
305+
AVR64DB64
306+
AVR64DD14
307+
AVR64DD20
308+
AVR64DD28
309+
AVR64DD32
310+
avr_iot_wg
311+
curiosity_nano_4809
312+
curiosity_nano_da
313+
curiosity_nano_db
314+
nano_every
315+
uno_wifi_rev2
316+
xplained_nano_416
317+
xplained_pro_4809
318+
""".split()
319+
)
320+
8321
SUPPORTED_PLATFORMS: dict[str, set[str]] = {
9-
"atmelavr": {"uno", "nano"},
10-
"atmelsam": {"due"},
11-
"espressif32": {"esp32dev", "esp32doit-devkit-v1"},
322+
"atmelavr": SUPPORTED_ATMELAVR_BOARDS,
323+
"atmelmegaavr": SUPPORTED_ATMELMEGAAVR_BOARDS,
12324
}
13325

14326
BOARD_TO_PLATFORM = {
@@ -65,9 +377,10 @@ def validate_platform_board(platform: str, board: str) -> None:
65377
)
66378

67379
if board not in BOARD_TO_PLATFORM:
68-
supported = ", ".join(sorted(BOARD_TO_PLATFORM))
69380
raise ValueError(
70-
f"Unsupported PlatformIO board '{board}'. Supported boards: {supported}."
381+
f"Unsupported PlatformIO board '{board}'. Supported boards for the AVR platforms "
382+
"are listed at https://docs.platformio.org/en/latest/boards/atmelavr.html "
383+
"and https://docs.platformio.org/en/latest/boards/atmelmegaavr.html."
71384
)
72385

73386
required_platform = BOARD_TO_PLATFORM[board]

0 commit comments

Comments
 (0)