Giter Site home page Giter Site logo

platformio / platform-atmelmegaavr Goto Github PK

View Code? Open in Web Editor NEW
28.0 28.0 21.0 108 KB

Atmel megaAVR: development platform for PlatformIO

Home Page: https://registry.platformio.org/platforms/platformio/atmelmegaavr

License: Apache License 2.0

Python 100.00%
arduino avr megaavr platformio platformio-platform

platform-atmelmegaavr's Introduction

PlatformIO Core

CI Build for PlatformIO Core

CI Build for Docs

CI Build for dev-platform examples

CI Build for the Community Projects

Latest Version

PlatformIO Labs

Quick Links: Homepage | PlatformIO IDE | Registry | Project Examples | Docs | Donate | Contact Us

Social: LinkedIn | Twitter | Facebook | Community Forums

image

PlatformIO: Your Gateway to Embedded Software Development Excellence.

Unlock the true potential of embedded software development with PlatformIO's collaborative ecosystem, embracing declarative principles, test-driven methodologies, and modern toolchains for unrivaled success.

  • Open source, maximum permissive Apache 2.0 license
  • Cross-platform IDE and Unified Debugger
  • Static Code Analyzer and Remote Unit Testing
  • Multi-platform and Multi-architecture Build System
  • Firmware File Explorer and Memory Inspection

Get Started

Solutions

Advanced

Registry

Contributing

See contributing guidelines.

Telemetry / Privacy Policy

Share minimal diagnostics and usage information to help us make PlatformIO better. It is enabled by default. For more information see:

License

Copyright (c) 2014-present PlatformIO <[email protected]>

The PlatformIO is licensed under the permissive Apache 2.0 license, so you can use it in both commercial and personal projects with confidence.

SWUbanner

platform-atmelmegaavr's People

Contributors

5e3 avatar brunob45 avatar ivankravets avatar jboynes avatar maxgerhardt avatar mcudude avatar valeros avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

platform-atmelmegaavr's Issues

Upload protocol "custom" still looks for AVRdude

platformio.ini has the following:

upload_protocol = custom
upload_port = COM3
upload_speed = 115200
upload_command = pymcuprog write -t uart -d attiny1616 -u $UPLOAD_PORT -c $UPLOAD_SPEED -f $SOURCE --erase --verify

a user has reported on Windows, hey had to force the installation of AVRdude, otherwise they got the following error:

Error: Processing avrcoding101 (platform: atmelmegaavr; board: ATtiny1616)
Verbose mode can be enabled via
- - verbose' option
KeyError: 'tool-avrdude'
File " /home/matteo/.platformio/penv/lib/python3.10/site-packages/platformio/builder/main.py",line187:
env.SConscript ("$BUILD SCRIPT")
File "/home/matteo/.platformio/packages/tool-scons/scons-local-4.4.0/SCons/Script/SConscript.py",line597:
return SConscript(self.fs, *files, **subst kw)
File " /home/matte/.platformio/packages/tool-scons/scons-local-4.4.0/SCons/Script/SConscript.py",line285:
exec (compile (scriptdata, scriptname, 'exec'), call stack[-1] .globals)
File " /home/matteo/.platformio/platforms/atmelmegaavr/builder/main.py", line 77:
env.PioPlatform() .get package dir
File " /home/matteo/.platformio/penv/lib/python3.10/site-packages/platformio/platform/_packages.py",line 32:
pkg = self.get package (name)
File " /home/matteo/.platformio/penv/lib/python3.10/site-packages/platformio/platform/_packages.py",line29:
return self.pm.get package(spec or self.get package spec (name))
File " /home/matteo/.platformio/penv/lib/python3.10/site-packages/platformio/platform/packages.py",line21:
owner=self.packages [name].get ("owner"),
= [FAILED] Took 0.34 seconds

I assume there should be no reason AVRdude is required in this configuration using a custom upload.

Upgrade to Avrdude 7.0

Avrdude 7.0 has been out for a while now, and Arduino has their own build with statically linked libraries that "just works".

There are lots of bug fixes and new features, but the most exciting one is probably support for SerialUPDI. It would be great if you could update Avrdude for "megaAVR's" as well as for "classic" AVRs.

Here are all the pre-compiled Arduino-build Avrdude binaries:
https://github.com/arduino/avrdude-packing

🇺🇦

DXCore uart upload with optiboot

Hello everyone

Found something that i think should be documented or fixed.

I started to play a little with the AVRxxDAxx chips using platformIO .
Using DXCore with arduinoIDE everything is working , but with plaformIO nothing worked (updi upload,bootloader burn,uart upload)

maxgerhardt on the platformIO forum helped me to find few problems,
This topic will be only about the UART upload with optiboot already on the chip

when i first started , i made a little program to tests the serial monitor and a blinking LED
I uploaded it through UART but nothing was happening

I took a look in logs from platformIO and arduinoIDE ( with verbose activated ), found some things that didn't match .
Found a flag named -DUSING_OPTIBOOT .

(As I'm a noob in this things, before i found a better solution )
I went inside of the .json board file and found same style of flags so added it there ... and voila, worked perfectly.

After few tries everything was working nicely, then google helped me a little and found that in platformio.ini, we can add something called "build_flags"

This is what looks like my settings to upload through UART, working only with optiboot already on the chip ( burned it with arduinoIDE)

[env]
platform = atmelmegaavr
board = AVR64DA32
framework = arduino
board_build.f_cpu = 24000000L

[env:Upload_UART]
build_flags = -DUSING_OPTIBOOT
upload_protocol = arduino
upload_speed = 115200

Is there a way to put it somewhere so people don't loose 2 weeks searching as i did ? or maybe put it directly in the config files .
Thanks

PS :
If interested, i uploaded the verbose logs at https://github.com/matou78/temp

avrdude: Can't find programmer id "curiosity_updi"

PlatformIO Core Version: 5.1.1
Home Version: 3.3.4
IDE: VS Code
Version: 1.60.0 (user setup)
Commit: e7d7e9a9348e6a8cc8c03f877d39cb72e5dfb1ff
Date: 2021-09-01T10:41:52.311Z
Electron: 13.1.8
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Windows_NT x64 10.0.19043

I was trying to build a sample project for AVR-IoT WG development board. PlatformIO supports the board, and builds the project using Arduino framework. My code (to blink an LED) compiles fine, but I am seeing issues while uploading. Following is the verbose output from Build command.

> Executing task: C:\Users\Vishnu Mohanan\.platformio\penv\Scripts\platformio.exe run --verbose --target upload --environment avr_iot_wg <

Processing avr_iot_wg (platform: atmelmegaavr; board: avr_iot_wg; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------------------------CONFIGURATION: https://docs.platformio.org/page/boards/atmelmegaavr/avr_iot_wg.html
PLATFORM: Atmel megaAVR (1.5.0) > AVR-IoT WG Development Board
HARDWARE: ATMEGA4808 16MHz, 6KB RAM, 48KB Flash
PACKAGES:
 - framework-arduino-megaavr-megacorex 1.0.9
 - tool-avrdude-megaavr 2.60300.210128 (6.3.0)
 - toolchain-atmelavr 2.70300.201015 (7.3.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 11 compatible libraries
Scanning dependencies...     
No dependencies
Building in release mode
MethodWrapper(["checkprogsize"], [".pio\build\avr_iot_wg\firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.1% (used 4 bytes from 6144 bytes)
Flash: [          ]   1.6% (used 792 bytes from 49152 bytes)
.pio\build\avr_iot_wg\firmware.elf  :

section                     size      addr

.data                          0   8398848

.text                        792         0

.bss                           4   8398848

.comment                      17         0

.note.gnu.avr.deviceinfo      64         0

.debug_aranges               128         0

.debug_info                 9628         0

.debug_abbrev               8466         0

.debug_line                  921         0

.debug_str                  3789         0

Total                      23809
<lambda>(["upload"], [".pio\build\avr_iot_wg\firmware.hex"])
AVAILABLE: curiosity_updi
CURRENT: upload_protocol = curiosity_updi
BeforeUpload(["upload"], [".pio\build\avr_iot_wg\firmware.hex"])
avrdude -v -p atmega4808 -C "C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf" -c curiosity_updi -P usb -U flash:w:.pio\build\avr_iot_wg\firmware.hex:i

avrdude: Version 6.3-20201216
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf"


avrdude: Can't find programmer id "curiosity_updi"

Valid programmers are:
  2232HIO          = FT2232H based generic programmer [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:413]
  4232h            = FT4232H based generic programmer [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:441]
  89isp            = Atmel at89isp cable            [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1505]
  abcmini          = ABCmini Board, aka Dick Smith HOTCHIP [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1404]
  alf              = Nightshade ALF-PgmAVR, http://nightshade.homeip.net/ [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1364]
  arduino          = Arduino                        [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:361]
  arduino-ft232r   = Arduino: FT232R connected to ISP [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:765]
  arduinoisp       = Arduino ISP Programmer         [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:893]
  arduinoisporg    = Arduino ISP Programmer         [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:902]
  atisp            = AT-ISP V1.1 programming cable for AVR-SDK1 from <http://micro-research.co.th/>  [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1460]
  atmelice         = Atmel-ICE (ARM/AVR) in JTAG mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1163]
  atmelice_dw      = Atmel-ICE (ARM/AVR) in debugWIRE mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1187]
  atmelice_isp     = Atmel-ICE (ARM/AVR) in ISP mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1195]
  atmelice_pdi     = Atmel-ICE (ARM/AVR) in PDI mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1171]
  atmelice_updi    = Atmel-ICE (ARM/AVR) in UPDI mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1179]
  avr109           = Atmel AppNote AVR109 Boot Loader [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:918]
  avr910           = Atmel Low Cost Serial Programmer [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:722]
  avr911           = Atmel AppNote AVR911 AVROSP    [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:925]
  avrftdi          = FT2232D based generic programmer [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:387]
  avrisp           = Atmel AVR ISP                  [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:609]
  avrisp2          = Atmel AVR ISP mkII             [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:629]
  avrispmkII       = Atmel AVR ISP mkII             [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:623]
  avrispv2         = Atmel AVR ISP V2               [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:616]
  bascom           = Bascom SAMPLE programming cable [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1358]
  blaster          = Altera ByteBlaster             [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1482]
  bsd              = Brian Dean's Programmer, http://www.bsdhome.com/avrdude/ [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1313]
  buspirate        = The Bus Pirate                 [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:634]
  buspirate_bb     = The Bus Pirate (bitbang interface, supports TPI) [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:641]   
  butterfly        = Atmel Butterfly Development Board [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:911]
  butterfly_mk     = Mikrokopter.de Butterfly       [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:939]
  bwmega           = BitWizard ftdi_atmega builtin programmer [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:752]
  C232HM           = FT232H based module from FTDI and Glyn.com.au [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:510]      
  c2n232i          = serial port banging, reset=dtr sck=!rts mosi=!txd miso=!cts [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1623]
  dapa             = Direct AVR Parallel Access cable [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1448]
  dasa             = serial port banging, reset=rts sck=dtr mosi=txd miso=cts [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1595]
  dasa3            = serial port banging, reset=!dtr sck=rts mosi=txd miso=cts [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1609]
  diecimila        = alias for arduino-ft232r       [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:776]
  dragon_dw        = Atmel AVR Dragon in debugWire mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1074]
  dragon_hvsp      = Atmel AVR Dragon in HVSP mode  [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1065]
  dragon_isp       = Atmel AVR Dragon in ISP mode   [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1047]
  dragon_jtag      = Atmel AVR Dragon in JTAG mode  [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1038]
  dragon_pdi       = Atmel AVR Dragon in PDI mode   [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1083]
  dragon_pp        = Atmel AVR Dragon in PP mode    [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1056]
  dt006            = Dontronics DT006               [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1348]
  ehajo-isp        = avr-isp-programmer from eHaJo, http://www.eHaJo.de [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:884] 
  ere-isp-avr      = ERE ISP-AVR <http://www.ere.co.th/download/sch050713.pdf> [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1471]
  flip1            = FLIP USB DFU protocol version 1 (doc7618) [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1297]
  flip2            = FLIP USB DFU protocol version 2 (AVR4023) [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1304]
  frank-stk200     = Frank STK200                   [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1495]
  ft232r           = FT232R Synchronous BitBang     [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:740]
  ft245r           = FT245R Synchronous BitBang     [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:729]
  futurlec         = Futurlec.com programming cable. [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1415]
  jtag1            = Atmel JTAG ICE (mkI)           [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:952]
  jtag1slow        = Atmel JTAG ICE (mkI)           [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:957]
  jtag2            = Atmel JTAG ICE mkII            [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:987]
  jtag2avr32       = Atmel JTAG ICE mkII im AVR32 mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1020]
  jtag2dw          = Atmel JTAG ICE mkII in debugWire mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1002]
  jtag2fast        = Atmel JTAG ICE mkII            [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:981]
  jtag2isp         = Atmel JTAG ICE mkII in ISP mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:993]
  jtag2pdi         = Atmel JTAG ICE mkII PDI mode   [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1029]
  jtag2slow        = Atmel JTAG ICE mkII            [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:976]
  jtag2updi        = JTAGv2 to UPDI bridge          [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1636]
  jtag3            = Atmel AVR JTAGICE3 in JTAG mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1091]
  jtag3dw          = Atmel AVR JTAGICE3 in debugWIRE mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1107]
  jtag3isp         = Atmel AVR JTAGICE3 in ISP mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1115]
  jtag3pdi         = Atmel AVR JTAGICE3 in PDI mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1099]
  jtagkey          = Amontec JTAGKey, JTAGKey-Tiny and JTAGKey2 [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:448]
  jtagmkI          = Atmel JTAG ICE (mkI)           [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:944]
  jtagmkII         = Atmel JTAG ICE mkII            [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:968]
  jtagmkII_avr32   = Atmel JTAG ICE mkII im AVR32 mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1011]
  linuxspi         = Use Linux SPI device in /dev/spidev* [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1545]
  lm3s811          = Luminary Micro LM3S811 Eval Board (Rev. A) [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:571]
  mib510           = Crossbow MIB510 programming board [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:673]
  mkbutterfly      = Mikrokopter.de Butterfly       [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:933]
  nibobee          = NIBObee                        [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:848]
  o-link           = O-Link, OpenJTAG from www.100ask.net [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:542]
  openmoko         = Openmoko debug board (v3)      [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:553]
  pavr             = Jason Kyle's pAVR Serial Programmer [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1283]
  pickit2          = MicroChip's PICkit2 Programmer [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1290]
  pickit4_isp      = MPLAB(R) PICkit 4 in ISP mode  [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1259]
  pickit4_updi     = MPLAB(R) PICkit 4 in UPDI mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1243]
  picoweb          = Picoweb Programming Cable, http://www.picoweb.net/ [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1393]  pkobn_updi       = PKOB nano (nEDBG) in UPDI mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1275]
  pony-stk200      = Pony Prog STK200               [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1341]
  ponyser          = design ponyprog serial, reset=!txd sck=rts mosi=dtr miso=cts [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1573]
  powerdebugger    = Atmel PowerDebugger (ARM/AVR) in JTAG mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1203]        
  powerdebugger_dw = Atmel PowerDebugger (ARM/AVR) in debugWire mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1227]   
  powerdebugger_isp = Atmel PowerDebugger (ARM/AVR) in ISP mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1235]        
  powerdebugger_pdi = Atmel PowerDebugger (ARM/AVR) in PDI mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1211]        
  powerdebugger_updi = Atmel PowerDebugger (ARM/AVR) in UPDI mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1219]      
  siprog           = Lancos SI-Prog <http://www.lancos.com/siprogsch.html> [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1586]
  snap_isp         = MPLAB(R) SNAP in ISP mode      [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1267]
  snap_updi        = MPLAB(R) SNAP in UPDI mode     [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1251]
  sp12             = Steve Bolt's Programmer        [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1381]
  stk200           = STK200                         [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1325]
  stk500           = Atmel STK500                   [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:659]
  stk500hvsp       = Atmel STK500 V2 in high-voltage serial programming mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:694]
  stk500pp         = Atmel STK500 V2 in parallel programming mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:687]       
  stk500v1         = Atmel STK500 Version 1.x firmware [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:666]
  stk500v2         = Atmel STK500 Version 2.x firmware [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:680]
  stk600           = Atmel STK600                   [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:701]
  stk600hvsp       = Atmel STK600 in high-voltage serial programming mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:715]
  stk600pp         = Atmel STK600 in parallel programming mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:708]
  ttl232r          = FTDI TTL232R-5V with ICSP adapter [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:812]
  tumpa            = TIAO USB Multi-Protocol Adapter [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:592]
  UM232H           = FT232H based module from FTDI and Glyn.com.au [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:483]      
  uncompatino      = uncompatino with all pairs of pins shorted [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:788]
  usbasp           = USBasp, http://www.fischl.de/usbasp/ [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:823]
  usbasp-clone     = Any usbasp clone with correct VID/PID [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:859]
  usbtiny          = USBtiny simple USB programmer, https://learn.adafruit.com/usbtinyisp [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:874]
  wiring           = Wiring                         [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:354]
  xil              = Xilinx JTAG cable              [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1434]
  xplainedmini     = Atmel AVR XplainedMini in ISP mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1139]
  xplainedmini_dw  = Atmel AVR XplainedMini in debugWIRE mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1147]
  xplainedmini_updi = Atmel AVR XplainedMini in UPDI mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1155]
  xplainedpro      = Atmel AVR XplainedPro in JTAG mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1123]
  xplainedpro_updi = Atmel AVR XplainedPro in UPDI mode [C:\Users\Vishnu Mohanan\.platformio\packages\tool-avrdude-megaavr\avrdude.conf:1131]

*** [upload] Error 1
================================================================ [FAILED] Took 0.84 seconds ================================================================
The terminal process "C:\Users\Vishnu Mohanan\.platformio\penv\Scripts\platformio.exe 'run', '--verbose', '--target', 'upload', '--environment', 'avr_iot_wg'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

As you can see, avrdude complains about not being able to find the default programmer for the target. The configuration file used by avrdude is the default one shipped with PlatformIO. I have my device connected and detected by PlatformIO as seen below.

image

Thinking this could be an issue with outdated packages, I tried updating/upgrading everything.

PS D:\Code\PlatformIO\AVR-IoT\Blink\AVR-IoT-Blink> pio update
Updating platformio/contrib-piohome           3.3.4 @ ~3.3.4                     [Up-to-date]
Updating platformio/tool-scons                4.40100.2 @ ~4.40100.2             [Incompatible 4.40200.0]
Updating platformio/tool-cppcheck             1.230.0 @ ~1.230.0                 [Incompatible 1.241.210401]

Platform Manager 
================ 
Platform atmelavr
--------
Updating platformio/atmelavr                  3.4.0                              [Up-to-date]
Updating platformio/toolchain-atmelavr        1.70300.191015 @ ~1.70300.0        [Up-to-date]

Platform atmelmegaavr
--------
Updating platformio/atmelmegaavr              1.5.0                              [Up-to-date]
Updating platformio/toolchain-atmelavr        1.70300.191015 @ ~1.70300.0        [Up-to-date]
Updating platformio/framework-arduino-megaavr-megacorex 1.0.9 @ ~1.0.7                     [Up-to-date]


Library Manager
===============
Library Storage: C:\Users\Vishnu Mohanan\.platformio\lib
PS D:\Code\PlatformIO\AVR-IoT\Blink\AVR-IoT-Blink> pio upgrade
You're up-to-date!
PlatformIO 5.1.1 is currently the newest version available.

Is it not possible to upload binary to the board via USB port? My fallback option was to drag and drop the HEX file to the mass storage device appearing as CURIOSITY.

Please look into the issue and consider updating the support or suggesting a solution.

MegaCoreX isn't up to date

The latest version of MegaCoreX, v1.0.7 brings a lot of improvements and new features that is not currently present here. Would be great if PlatformIO could be updated to support this version.

please update megaavr core from 1.8.5 to 1.8.6

the new core version has some important bufixes, also in the API.I know at least two libraries (DMXSerial, Automation) that should work with the new version without manual bugfixes (I couldn't get DMXSerial to work at all, because of some nasty definition collisions (but it compiles with Arduino IDE and v1.8.6)).

Pre-defined fuses ... can't set UPDI pin mode or MVIO mode fuses on AVR64DD28

i think the pre-defined fuses for the AVR64DD28 leave the UPDI pin in gpio mode and set the MVIO register bit in a reserved configuration, neither yes or no. I could change the reset pin mode and bod level so that works.

perused fuses.py and didn't see an updi pin associated with the dxcore. Also, MVIO seems to be associated with DB series only.

Selected fuses:
-------------------------
[fuse0 / wdtcfg   = 0x00]
[fuse1 / bodcfg   = 0x00]
[fuse2 / osccfg   = 0x00]
[fuse4 / tcd0cfg  = 0x00]
[fuse5 / syscfg0  = 0xC9]
[fuse6 / syscfg1  = 0x06]
[fuse7 / codesize = 0x00]
[fuse8 / bootsize = 0x00]
[lock  / lockbit  = 0x5CC5C55C]
-------------------------

threw these into microchip studio and compared them against the datasheet.

toolchain info ...

PLATFORM: Atmel megaAVR (1.9.0) > AVR64DD28
HARDWARE: AVR64DD28 24MHz, 8KB RAM, 64KB Flash
PACKAGES:
 - framework-arduino-megaavr-dxcore @ 1.5.6
 - tool-avrdude @ 1.70100.0 (7.1.0)
 - toolchain-atmelavr @ 3.70300.220127 (7.3.0)

socket.py import error DLL load failed (DxCore)

Hello,

I have a fresh PlatformIO installation with current DxCore 1.4.10 and would like to transfer a blink test via USB. USB > FTDI232RL > Bootloader > USART Controller.

pymcuprog I have installed after. The error is fixed. Python 3.10.6 is also fresh installed.

But now socket.py is not found. But the file is present in the path. What to do?

platformio.ini

[platformio]
default_envs = Upload_USB

[env]
platform = atmelmegaavr
framework = arduino
board = AVR128DB64

[env:Upload_USB]
upload_protocol = custom
upload_command = pymcuprog erase && pymcuprog write -f $SOURCE

Output:

Executing task in folder DxCoreAVR128DB64_001: C:\Users\Worker\.platformio\penv\Scripts\platformio.exe run --target upload --environment Upload_USB 

Processing Upload_USB (platform: atmelmegaavr; framework: arduino; board: AVR128DB64)
----------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelmegaavr/AVR128DB64.html
PLATFORM: Atmel megaAVR (1.6.0) > AVR128DB64     
HARDWARE: AVR128DB64 24MHz, 16KB RAM, 128KB Flash
PACKAGES:
 - framework-arduino-megaavr-dxcore @ 1.4.10     
 - tool-avrdude-megaavr @ 3.60300.220118 (6.3.0) 
 - toolchain-atmelavr @ 3.70300.220127 (7.3.0)   
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 17 compatible libraries
Scanning dependencies...
Dependency Graph
|-- SPI @ 1.0.2 
|-- Wire @ 2.0.6
Building in release mode
Compiling .pio\build\Upload_USB\src\main.cpp.o
Compiling .pio\build\Upload_USB\libe1e\SPI\SPI.cpp.o
Compiling .pio\build\Upload_USB\lib8e9\Wire\Wire.cpp.o
Compiling .pio\build\Upload_USB\lib8e9\Wire\twi.c.o
Compiling .pio\build\Upload_USB\lib8e9\Wire\twi_pins.c.o
Compiling .pio\build\Upload_USB\FrameworkArduino\Tone.cpp.o
Compiling .pio\build\Upload_USB\FrameworkArduino\UART.cpp.o
Compiling .pio\build\Upload_USB\FrameworkArduino\UART0.cpp.o
Compiling .pio\build\Upload_USB\FrameworkArduino\UART1.cpp.o
Archiving .pio\build\Upload_USB\libe1e\libSPI.a
Compiling .pio\build\Upload_USB\FrameworkArduino\UART2.cpp.o
Compiling .pio\build\Upload_USB\FrameworkArduino\UART3.cpp.o
Archiving .pio\build\Upload_USB\lib8e9\libWire.a
Compiling .pio\build\Upload_USB\FrameworkArduino\UART4.cpp.o
Compiling .pio\build\Upload_USB\FrameworkArduino\UART5.cpp.o
Indexing .pio\build\Upload_USB\libe1e\libSPI.a
Compiling .pio\build\Upload_USB\FrameworkArduino\WInterrupts.c.o
Indexing .pio\build\Upload_USB\lib8e9\libWire.a
Compiling .pio\build\Upload_USB\FrameworkArduino\WInterrupts_PA.c.o
Compiling .pio\build\Upload_USB\FrameworkArduino\WInterrupts_PB.c.o
Compiling .pio\build\Upload_USB\FrameworkArduino\WInterrupts_PC.c.o
Compiling .pio\build\Upload_USB\FrameworkArduino\WInterrupts_PD.c.o
Compiling .pio\build\Upload_USB\FrameworkArduino\WInterrupts_PE.c.o
Compiling .pio\build\Upload_USB\FrameworkArduino\WInterrupts_PF.c.o
Compiling .pio\build\Upload_USB\FrameworkArduino\WInterrupts_PG.c.o
Compiling .pio\build\Upload_USB\FrameworkArduino\WMath.cpp.o
Compiling .pio\build\Upload_USB\FrameworkArduino\abi.cpp.o
Compiling .pio\build\Upload_USB\FrameworkArduino\api\Common.cpp.o
Compiling .pio\build\Upload_USB\FrameworkArduino\api\IPAddress.cpp.o
Compiling .pio\build\Upload_USB\FrameworkArduino\api\PluggableUSB.cpp.o
Compiling .pio\build\Upload_USB\FrameworkArduino\api\Print.cpp.o
Compiling .pio\build\Upload_USB\FrameworkArduino\api\RingBuffer.cpp.o
Compiling .pio\build\Upload_USB\FrameworkArduino\api\Stream.cpp.o
Compiling .pio\build\Upload_USB\FrameworkArduino\api\String.cpp.o
Compiling .pio\build\Upload_USB\FrameworkArduino\hooks.c.o
Compiling .pio\build\Upload_USB\FrameworkArduino\main.cpp.o
Compiling .pio\build\Upload_USB\FrameworkArduino\new.cpp.o
Compiling .pio\build\Upload_USB\FrameworkArduino\pinswap.c.o
Compiling .pio\build\Upload_USB\FrameworkArduino\wiring.c.o
Compiling .pio\build\Upload_USB\FrameworkArduino\wiring_analog.c.o
Compiling .pio\build\Upload_USB\FrameworkArduino\wiring_digital.c.o
Compiling .pio\build\Upload_USB\FrameworkArduino\wiring_pulse.S.o
Compiling .pio\build\Upload_USB\FrameworkArduino\wiring_pulse.c.o
Compiling .pio\build\Upload_USB\FrameworkArduino\wiring_shift.c.o
Archiving .pio\build\Upload_USB\libFrameworkArduino.a
Indexing .pio\build\Upload_USB\libFrameworkArduino.a
Linking .pio\build\Upload_USB\firmware.elf
Checking size .pio\build\Upload_USB\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   2.2% (used 367 bytes from 16384 bytes)
Flash: [          ]   2.1% (used 2794 bytes from 131072 bytes)
Building .pio\build\Upload_USB\firmware.hex
Configuring upload protocol...
AVAILABLE: custom
CURRENT: upload_protocol = custom
Uploading .pio\build\Upload_USB\firmware.hex
Traceback (most recent call last):
  File "C:\Users\Worker\.platformio\python3\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\Worker\.platformio\python3\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\Worker\AppData\Local\Programs\Python\Python310\Scripts\pymcuprog.exe\__main__.py", line 4, in <module>
  File "C:\Users\Worker\AppData\Local\Programs\Python\Python310\lib\site-packages\pymcuprog\pymcuprog.py", line 
12, in <module>
    from logging.config import dictConfig
  File "C:\Users\Worker\.platformio\python3\lib\logging\config.py", line 30, in <module>
    import logging.handlers
  File "C:\Users\Worker\.platformio\python3\lib\logging\handlers.py", line 26, in <module>
    import logging, socket, os, pickle, struct, time, re
  File "C:\Users\Worker\.platformio\python3\lib\socket.py", line 51, in <module>
    import _socket
ImportError: DLL load failed while importing _socket: Das angegebene Modul wurde nicht gefunden.
*** [upload] Error 1
========================================== [FAILED] Took 4.68 seconds ==========================================
Environment    Status    Duration
-------------  --------  ------------
Upload_USB     FAILED    00:00:04.677
==================================== 1 failed, 0 succeeded in 00:00:04.677 ==================================== 

megaTinyCore has no CLOCKSOURCE

Spence Konde's cores use a compiler switch -DCLOCK_SOURCE. (See i.e.: .platformio\packages\framework-arduino-megaavr-megatinycore\cores\megatinycore\wiring.c:552)
In platform-atmelmegaavr/builder/frameworks/arduino.py:77 there is a typo: it's called CLOCKSOURCE instead of CLOCK_SOURCE.

Include errors with ATTINY3227

Hi,

I am facing an issue with setting up a project using an attiny3227. I am using an attiny1626 in another project, what works perfectly.

What I have done:

  • I downloaded the board information from your repo and put it to the boards folder in .platformio
  • I used the platformio wizard in vscode to create a new project using the attiny3227 at a non-default location
  • I edit the platformio.ini to my needs (see below)
  • vscode already shows an include error of the main.cpp, but I hit "build". It finds the Arduino.h file, but this cannot include avr/pgmspace.h, avr/io.h, avr/interrupt.h files
  • I compared the auto-generated cpp-files in .vscode folder with that from the attiny1626 project. It differs in the project names, in the tx-variants (txy6/txy7) and the mcu declaration, so nothing unexpected
  • I checked the board files, but cannot see any issue
[env:ATtiny3227]
platform = atmelmegaavr
# board = ATtiny1626
board = ATtiny3227
framework = arduino

board_build.f_cpu = 20000000L
board_build.mcu = attiny3227
board_hardware.oscillator = internal ; internal or external
board_build.extra_flags = 
    -D $BOARD_MCU
    -D MILLIS_USE_TIMERA0

Could someone point me to the right direction? If you need further information, please do not hesitate to ask, I am happy to provide them as good as I can.

Best wishes,
Marius

Use pyupdi for UPDI uploads

I'll just leave this here.

There is another way of uploading to UPDI-compatible AVR microcontrollers that don't include Avrdude and is open source. It's called pyupdi, and it is developed by Microchip themselves. The actual hardware is dead simple.
https://github.com/mraardvark/pyupdi

 From the pyupdi repo

                        Vcc                     Vcc
                        +-+                     +-+
                         |                       |
 +---------------------+ |                       | +--------------------+
 | Serial port         +-+                       +-+  AVR device        |
 |                     |      +----------+         |                    |
 |                  TX +------+   4k7    +---------+ UPDI               |
 |                     |      +----------+    |    |                    |
 |                     |                      |    |                    |
 |                  RX +----------------------+    |                    |
 |                     |                           |                    |
 |                     +--+                     +--+                    |
 +---------------------+  |                     |  +--------------------+
                         +-+                   +-+
                         GND                   GND

As the name implies, it's Python based, and PlatformIO is Python's best friend. Would it be possible to add support for pyupdi, if so as something one could call in upload_command? I can help out with testing!

[env:Upload_using_pyupdi]
upload_protocol = custom
upload_flags =
    -d 
    $BOARD_MCU 
    -C 
    $UPLOAD_PORT 
    -b 
    $UPLOAD_SPEED
upload_command = pyupdi.py $UPLOAD_FLAGS -f $SOURCE

Fuse programming doesn't work

Per https://community.platformio.org/t/set-fuses-on-atmega4809/24681.

When using the standard platformio.ini

[env:nano_every]
platform = atmelmegaavr
board = nano_every
framework = arduino

with a Nano Every board, normal uploading works:

>pio run -t upload -v
[...]
Auto-detected: COM11
Forcing reset using 1200bps open/close on port COM11
avrdude -v -p atmega4809 -C C:\Users\Max\.platformio\packages\[email protected]\avrdude.conf -c jtag2updi -b 115200 -V -e -D -P "COM11" -U flash:w:.pio\build\nano_every\firmware.hex:i
avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\Max\.platformio\packages\[email protected]\avrdude.conf"

         Using Port                    : COM11
         Using Programmer              : jtag2updi
         Overriding Baud Rate          : 115200
JTAG ICE mkII sign-on message:
Communications protocol version: 1
M_MCU:
  boot-loader FW version:        1
  firmware version:              6.00
  hardware version:              1
S_MCU:
  boot-loader FW version:        1
  firmware version:              6.00
  hardware version:              1
Serial number:                   00:00:00:00:00:00
Device ID:                       JTAGICE mkII
[..]
avrdude: 254 bytes of flash written

avrdude: safemode: Fuses OK (E:FF, H:FF, L:FF)

avrdude done.  Thank you.

============================================= [SUCCESS] Took 3.44 seconds =============================================

However, programming fuses per documentation, it does not work

>pio run -t fuses -v
[...]
Selected fuses:
------------------------
[fuse2 / OSCCFG  = 0x01]
[fuse5 / SYSCFG0 = 0xC9]
[fuse8 / BOOTEND = 0x00]
[lfuse / LOCKBIT = 0xC5]
------------------------

avrdude -p atmega4809 -C C:\Users\Max\.platformio\packages\[email protected]\avrdude.conf -v -P usb -c jtag2updi -Ufuse2:w:0x01:m -Ufuse5:w:0xC9:m -Ufuse8:w:0x00:m -Ulock:w:0xC5:m

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\Max\.platformio\packages\[email protected]\avrdude.conf"

         Using Port                    : usb
         Using Programmer              : jtag2updi
avrdude: usbdev_open(): did not find any USB device "usb" (0x03eb:0x2103)

avrdude done.  Thank you.

*** [fuses] Error 1
============================================== [FAILED] Took 1.12 seconds ==============================================

The firmware upload used a 1200bps reset and the avrdude invocation has -P "COM11" in it. The fuses setting does not do such a reset and uses -P usb.

I think it should be generally possible to set the fuses of the underlying ATMega4809 on the Nano Every using the on-board programmer (jtag2updi), but PlatformIO invokes avrdude in a wrong way.

Additionally, in the non-verbose mode (pio run -t fuses), the critical error message did not find any USB device does not appear.

Setting fuses...

avrdude done.  Thank you.

*** [fuses] Error 1
============================================== [FAILED] Took 1.14 seconds ==============================================

Leaving the user extremely confused why the task failed although avrdude says avrdude done. Thank you..

Garbled serial output from ATtiny1616 when using Platformio IDE, OK on Arduino IDE

Code in PlatformIO IDE:

#include <Arduino.h>
void setup() {
  Serial.swap(1);       // Switch to alternate serial port.
  Serial.begin(115200);
  while (!Serial);
}
void loop() {
  Serial.println("Hello world!");
  delay(1000);
}

platformio.ini:

[env:ATtiny1616]
platform = atmelmegaavr
board = ATtiny1616
framework = arduino
upload_port = COM24
monitor_port = COM10
monitor_speed = 115200
  • When I build and upload this from PlatformIO IDE the serial output on alternate USART pins (PA1, PA2) is garbled (output looks like wrong baud rate):
    image
  • If I use primary USART (delete Serial.swap(1) or replace it with Serial.swap(0)) the same output continues on alternate USART, nothing on primary USART. I tried Serial.pins() instead of Serial.swap() -> same result.
  • Same code built on Arduino IDE (except first #include line) works as expected, both on primary and alternate USART.

In both cases I program via UPDI / jtag2updi.

Any advise on what is going on here would be highly appreciated, as I prefer working in PlatformIO IDE.

Error seen when using platform_packages

major, minor, patch = package_version.split(".")

probably needs to be

major, minor, patch = package_version.split(".",maxsplit=2)

to allow package numbers with gitsha references to work. See SpenceKonde/megaTinyCore#877 for more details.

currently:

PACKAGES:

  • framework-arduino-megaavr-megatinycore @ 2.6.4+sha.9025674
  • tool-avrdude-megaavr @ 3.60300.220118 (6.3.0)
  • toolchain-atmelavr @ 3.70300.220127 (7.3.0)
    2.6.4+sha.9025674
    ValueError: too many values to unpack (expected 3):

running upstream versions

Hi

I would love to get started trying out the new support for avr-2, i see there has been some activity in adding support thanks @MCUdude

so as per the readme, i add

[env:development]
platform = https://github.com/platformio/platform-atmelmegaavr.git
board = ...
...

to try and build a project for the 1624

fist thing i get hit with is package_version is too big as its got a +sha.(whatever) put on the end, so i edit that bit

now im getting the timer0 problem

so im just wondering if anyone could help me out with a bit more info on what i need to do to get the build button to work

sorry for the noob question but very keen to try this and its just not working for me

TIA

Update MegaCoreX to v1.0.8

Is it possible to update MegaCoreX to v1.0.7?
I would like to use the new Optiboot Flash Library.
Thanks.

Add support for new UPDI programmers + extended UPDI protocol

Someone mentioned at the Avrfreaks forum that an Avrdude patch from one of the Atmel/Microchip developers has been published.

It adds support for the PICKit4 and Microchip SNAP. But more importantly, it adds extended UPDI addressing support for devices with more than 64kB flash. This means that the AVR DA/DB/DD/EA series now can be used with official Microchip UPDI programmers and not just jtag2updi.

@valeros can you merge this patch so the next release of platform-atmelmegaavr will have this new functionality? Thanks!

MegaCoreX dynamic fuses and bootloader

Hi!
After you @valeros released the latest atmelmegaavr package I started working on the fuses/bootloader script, and it wasn't that much work really. As mentioned earlier, I am NOT a (professional) Python programmer. The scrips work, but they are probably terrible because I'm happy as long as they just do what I want.

First, here is the fuses script I've come up with:

import sys
import os

from SCons.Script import ARGUMENTS, COMMAND_LINE_TARGETS, Import, Return

Import("env")

def get_WDTCFG_fuse():
    return 0x00

def get_BODCFG_fuse(bod):
    if bod == "4.3v":
        return 0xF4
    elif bod == "2.6v":
        return 0x54
    elif bod == "1.8v":
        return 0x14
    else: # bod disabled
        return 0x00

def get_OSCCFG_fuse(f_cpu, oscillator):
    if (f_cpu == "20000000L" or f_cpu == "10000000L" or f_cpu == "5000000L") and oscillator == "internal":
        return 0x02
    else:
        return 0x01

def get_TCD0CFG_fuse():
    return 0x00

def get_SYSCFG0_fuse(eesave, rstpin, uart):
    eesave_bit = 1 if eesave == "yes" else 0
    if rstpin == "gpio":
        if uart == "no_bootloader":
            rstpin_bit = 0
        else:
            rstpin_bit = 1
    else:
        rstpin_bit = 1
    return 0xC0 | rstpin_bit << 3 | eesave_bit

def get_SYSCFG1_fuse():
    return 0x06

def get_APPEND_fuse():
    return 0x00

def get_BOOTEND_fuse(uart):
    if uart == "no_bootloader":
        return 0x00
    else:
        return 0x02

def get_LOCKBIT_fuse():
    return 0xC5

def print_fuses_info(fuse_values, fuse_names, lock_fuse):
    print("\nSelected fuses:")
    print("------------------------")
    for idx, value in enumerate(fuse_values):
        if value:
            print("[fuse%d / %s = 0x%s]" % (idx, fuse_names[idx], value))
    if lock_fuse:
        print("[lfuse / LOCKBIT = %s]" % lock_fuse)
    print("------------------------\n")

board = env.BoardConfig()
platform = env.PioPlatform()
core = board.get("build.core", "")

target = (
    board.get("build.mcu").lower()
    if board.get("build.mcu", "")
    else env.subst("$BOARD").lower()
)

fuses_section = "fuse_values"
if "bootloader" in COMMAND_LINE_TARGETS or "UPLOADBOOTCMD" in env:
    fuses_section = "bootloader"

board_fuses = board.get(fuses_section, {})

# Note: the index represents the fuse number
fuse_values = [
    board_fuses.get("WDTCFG", ""),
    board_fuses.get("BODCFG", ""),
    board_fuses.get("OSCCFG", ""),
    "",  # reserved
    board_fuses.get("TCD0CFG", ""),
    board_fuses.get("SYSCFG0", ""),
    board_fuses.get("SYSCFG1", ""),
    board_fuses.get("APPEND", ""),
    board_fuses.get("BOOTEND", ""),
]

fuse_names = (
    "WDTCFG ",
    "BODCFG ",
    "OSCCFG ",
    "       ",
    "TCD0CFG",
    "SYSCFG0",
    "SYSCFG1",
    "APPEND ",
    "BOOTEND",
    "LOCKBIT"
)

lock_fuse = board_fuses.get("LOCKBIT", "0xC5")


if not board_fuses and "FUSESFLAGS" not in env and core not in ("MegaCoreX"):
    sys.stderr.write(
        "Error: Dynamic fuses generation for %s / %s is not supported."
        " Please specify fuses in platformio.ini\n" % (target, env.subst("$BOARD"))
    )
    env.Exit(1)

if core in ("MegaCoreX"):
    f_cpu = board.get("build.f_cpu", "16000000L").upper()
    oscillator = board.get("hardware.oscillator", "internal").lower()
    bod = board.get("hardware.bod", "2.6v").lower()
    uart = board.get("hardware.uart", "no_bootloader").lower()
    eesave = board.get("hardware.eesave", "yes").lower()
    rstpin = board.get("hardware.rstpin", "reset").lower()

    # Guard that prevents the user from turning the reset pin
    # into a GPIO while using a bootloader
    if uart != "no_bootloader":
        rstpin = "reset"

    print("\nTARGET CONFIGURATION:")
    print("------------------------")
    print("Target = %s" % target)
    print("Clock speed = %s" % f_cpu)
    print("Oscillator = %s" % oscillator)
    print("BOD level = %s" % bod)
    print("Save EEPROM = %s" % eesave)
    print("Reset pin mode = %s" % rstpin)
    print("------------------------")

    fuse_values[0] = fuse_values[0] or '%.2X' % get_WDTCFG_fuse()
    fuse_values[1] = fuse_values[1] or '%.2X' % get_BODCFG_fuse(bod)
    fuse_values[2] = fuse_values[2] or '%.2X' % get_OSCCFG_fuse(f_cpu, oscillator)
    fuse_values[4] = fuse_values[4] or '%.2X' % get_TCD0CFG_fuse()
    fuse_values[5] = fuse_values[5] or '%.2X' % get_SYSCFG0_fuse(eesave, rstpin, uart)
    fuse_values[6] = fuse_values[6] or '%.2X' % get_SYSCFG1_fuse()
    fuse_values[7] = fuse_values[7] or '%.2X' % get_APPEND_fuse()
    fuse_values[8] = fuse_values[8] or '%.2X' % get_BOOTEND_fuse(uart)

env.Append(
    FUSESUPLOADER="avrdude",
    FUSESUPLOADERFLAGS=[
        "-p",
        "$BOARD_MCU",
        "-C",
        '"%s"'
        % os.path.join(env.PioPlatform().get_package_dir(
            "tool-avrdude-megaavr") or "", "avrdude.conf"),
    ],
    SETFUSESCMD="$FUSESUPLOADER $FUSESUPLOADERFLAGS $UPLOAD_FLAGS $FUSESFLAGS",
)

env.Append(
    FUSESFLAGS=[
        "-Ufuse%d:w:0x%s:m" % (idx, value) for idx, value in enumerate(fuse_values) if value
    ]
)

if lock_fuse:
    env.Append(FUSESFLAGS=["-Ulock:w:%s:m" % lock_fuse])

if int(ARGUMENTS.get("PIOVERBOSE", 0)):
    env.Append(FUSESUPLOADERFLAGS=["-v"])

if not env.BoardConfig().get("upload", {}).get("require_upload_port", False):
    # upload methods via USB
    env.Append(FUSESUPLOADERFLAGS=["-P", "usb"])
else:
    env.AutodetectUploadPort()
    env.Append(FUSESUPLOADERFLAGS=["-P", '"$UPLOAD_PORT"'])

if env.subst("$UPLOAD_PROTOCOL") != "custom":
    env.Append(FUSESUPLOADERFLAGS=["-c", "$UPLOAD_PROTOCOL"])
else:
    print(
        "Warning: The `custom` upload protocol is used! The upload and fuse flags may "
        "conflict!\nMore information: "
        "https://docs.platformio.org/en/latest/platforms/atmelavr.html"
        "#overriding-default-fuses-command\n"
    )

print_fuses_info(fuse_values, fuse_names, lock_fuse)

fuses_action = env.VerboseAction("$SETFUSESCMD", "Setting fuses...")

Return("fuses_action")

Note that many of the functions are empty and only return a constant. This is on purpose so it's easier to extend the functionality later (other megaavr cores etc.).

Here is the bootloader script:

# Copyright 2019-present PlatformIO <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import os

from SCons.Script import Import, Return

Import("env")

board = env.BoardConfig()
platform = env.PioPlatform()
core = board.get("build.core", "")


def get_suitable_optiboot_binary(framework_dir, board_config):
    uart = board_config.get("hardware.uart", "no_bootloader").upper()
    if uart == "UART0":
      uart = "UART0_DEF"
    elif uart == "UART1":
      uart = "UART1_DEF"
    elif uart == "UART2":
      uart = "UART2_DEF"
    elif uart == "UART3":
      uart = "UART3_DEF"

    bootloader_led = board_config.get("bootloader.led_pin", "A7").upper()
    bootloader_speed = board_config.get("bootloader.speed", env.subst("$UPLOAD_SPEED"))
    bootloader_file = "Optiboot_mega0_%s_%s_%s.hex" % (
        uart, bootloader_speed, bootloader_led)

    bootloader_path = os.path.join(
        framework_dir, "bootloaders", "optiboot", "bootloaders", "mega0",
        bootloader_speed, bootloader_file
    )

    return bootloader_path


framework_dir = ""
if env.get("PIOFRAMEWORK", []):
    framework_dir = platform.get_package_dir(platform.frameworks[env.get(
        "PIOFRAMEWORK")[0]]["package"])

#
# Bootloader processing
#

bootloader_path = board.get("bootloader.file", "")
if core == "MegaCoreX":
    if not os.path.isfile(bootloader_path):
        bootloader_path = get_suitable_optiboot_binary(framework_dir, board)
else:
    if not os.path.isfile(bootloader_path):
        bootloader_path = os.path.join(framework_dir, "bootloaders", bootloader_path)

    if not board.get("bootloader", {}):
        sys.stderr.write("Error: missing bootloader configuration!\n")
        env.Exit(1)

if not os.path.isfile(bootloader_path):
    bootloader_path = os.path.join(framework_dir, "bootloaders", bootloader_path)

if board.get("hardware.uart", "no_bootloader").lower() == "no_bootloader":
    sys.stderr.write("Error: board_hardware.bootloader = no bootloader selected! \n")
    env.Exit(1)

if not os.path.isfile(bootloader_path) and "BOOTFLAGS" not in env:
    sys.stderr.write("Error: Couldn't find bootloader image %s\n" % bootloader_path)
    env.Exit(1)

env.Append(
    BOOTUPLOADER="avrdude",
    BOOTUPLOADERFLAGS=[
        "-p",
        "$BOARD_MCU",
        "-C",
        '"%s"'
        % os.path.join(env.PioPlatform().get_package_dir(
            "tool-avrdude-megaavr") or "", "avrdude.conf"),
    ],
    BOOTFLAGS=['-Uflash:w:"%s":i' % bootloader_path],
    UPLOADBOOTCMD="$BOOTUPLOADER $BOOTUPLOADERFLAGS $UPLOAD_FLAGS $BOOTFLAGS",
)

if not env.BoardConfig().get("upload", {}).get("require_upload_port", False):
    # upload methods via USB
    env.Append(BOOTUPLOADERFLAGS=["-P", "usb"])
else:
    env.AutodetectUploadPort()
    env.Append(FUSESUPLOADERFLAGS=["-P", '"$UPLOAD_PORT"'])

if env.subst("$UPLOAD_PROTOCOL") != "custom":
    env.Append(BOOTUPLOADERFLAGS=["-c", "$UPLOAD_PROTOCOL"])
else:
    print(
        "Warning: The `custom` upload protocol is used! The upload and fuse flags may "
        "conflict!\nMore information: "
        "https://docs.platformio.org/en/latest/platforms/atmelavr.html"
        "#overriding-default-bootloader-command\n"
    )

fuses_action = env.SConscript("fuses.py", exports="env")

bootloader_actions = [
    fuses_action,
    env.VerboseAction("$UPLOADBOOTCMD", "Uploading bootloader"),
]

Return("bootloader_actions")

I removed the board_bootloard.pinsparameter to make the setup procedure more similar to my other cores. You can instead use board_hardware.uart = uart0 #or uart0_def or uart0_alt

There are some minor issues we need to work out though.

  • First, on the megaAVR-0 microcontrollers, the internal/external oscillator option is no longer done in the fuse bits, but rather by writing to a register in the user application setup procedure. In Arduino IDE, this is triggered by a macro in the boards.txt file; completely invisible for the user. It would be great if PlatformIO could do the same thing: Define USE_EXTERNAL_OSCILLATOR somewhere if board_hardware.oscillator = external is present in platformio.ini. I know this could be added to the build flags, but it would be slightly more elegant if it could be hidden just like in the Arduino IDE. This will harmonize with the way my other cores work and behave.
  • Second, We need to figure out a way to give the generated hex file an offset of 0x200 (512 bytes) when the bootloader is in use (board_hardware.uart != no_bootloader present in platformio.ini). If not, it won't be possible to use the bootloader to upload new programs.
  • Third, it is currently no possibility to upload using the bootloader. Even though I specify upload_protocol = arduino, PlatformIO forces the USB flag and mutes the provided upload port.
    I think this can be fixed by adding arduino as a programmer here:
    if upload_protocol == "jtag2updi":

    However arduino does not require use_1200bps_touch or wait_for_upload_port. Below is the error I'm getting with an umodified main.py file:
[env:ATmega3209_optiboot]
platform = atmelmegaavr
framework = arduino
board = ATmega3209
board_build.f_cpu = 16000000L
board_hardware.bod = 4.3v
board_build.variant = 48pin-standard
upload_protocol = arduino
upload_port = /dev/cu.usbserial-1420
$ pio run -t upload -e ATmega3209_optiboot -v
...
avrdude -v -p atmega3209 -C "/Users/hans/.platformio/packages/tool-avrdude-megaavr/avrdude.conf" -c arduino -b 115200 -P usb -U flash:w:.pio/build/ATmega3209_optiboot/firmware.hex:i

...

         Using Port                    : usb
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: ser_open(): can't open device "usb": No such file or directory

avrdude done.  Thank you.

*** [upload] Error 1

However, Modifying the main.py file by replacing line 200 - 203 with the following code works:

    # jtag2updi and arduino are the only protocols that requires serial port
    if upload_protocol == "jtag2updi":
        upload_options = env.BoardConfig().get("upload", {})
        for opt in ("require_upload_port", "use_1200bps_touch", "wait_for_upload_port"):
            upload_options[opt] = True
    elif upload_protocol == "arduino":
        upload_options = env.BoardConfig().get("upload", {})
        upload_options["require_upload_port"] = True
        upload_options["use_1200bps_touch"] = False
        upload_options["wait_for_upload_port"] = False
        env.Append(UPLOADERFLAGS=["-D"])

Note that I've added the -D flag because this is required if you're using the arduino protocol. If not, you're getting an erase error.

ATMega4808 and bootloader with UPDI

If one uses the Arduino IDE to load a bootloader (or hex including a bootloader) into a 4808 (perhaps also other chips as well) by default it places the bootload at0x0 and the main program at 0x200.

If you now try to load a program via platformio/vscode using UPDI, it loads this into memory at 0x0 and not 0x200, unfortunately the chip still looks for the start of the code at 0x200 therefore when trying to upload code from platformio it does not work (although it does upload successfully - it doesn't direct the chip to start in the correct place).

The workaround (a bit unreliable) is to upload blink or similar from Arduino IDE with the nobootloader option selected - a few times, at which point platformio can now be used to upload code via UPDI, it does mean platformio needs Arduino IDE to configure the chip first.

Options:

  1. Enable the user to select the start point as 0x0 or 0x200 - ideal as this retains the bootloader for serial upload and UPDI, or at 0x0 when there is no bootloader
  2. Ensure that when uploading it configures the chip to start at 0x0 (noting that normal serial loads on a bootloader still need to start at 0x200)

2-series ATTiny support release date

Looks like the support for 2-series ATTiny mcus has been sitting on the development branch for a few months now #36.

When can we expect a release for it?
Or am I just missing something?

DXcore bootloader burn and updi uploading

Hello everyone,

I'm trying to get the program upload through updi and bootloader burn to work
Using DXCore with arduinoIDE works as intended .

I did a small program to tests things that make a led blink and send "test ok" through UART
Uploading this program through UPDI does nothing, the chip does nothing .
Compiles correctly and uploads successfully too , but nothing happens .

here is my platformio.ini

[env]
platform = atmelmegaavr
board = AVR64DA32
framework = arduino
board_build.f_cpu = 24000000L

[env:Upload_using_pyupdi]
upload_protocol = custom
upload_speed = 230340
upload_port = COM4
upload_flags =
  -t
  uart
  -d
  $BOARD_MCU
  -u
  $UPLOAD_PORT
  -c
  $UPLOAD_SPEED
upload_command = pymcuprog write $UPLOAD_FLAGS -f $SOURCE

Tried to change few things that i found on google but i don't know much about this things, still learning .

I wanted to burn the bootloader too, hitting the option " Burn Bootloader " but all i get is "Error: missing bootloader configuration!"

I'm looking inside the bootloader.py file that maxgerhardt linked on forum
image
But as i don't understand much there , not sure what needs to be done, will try to play with it a little, maybe by miracle i can get it working lol as i did with the UART upload i my other post x)

Thanks for your time and have a nice day

Feature Request: Please support DxCore by SpenceKonde

  • Feature Request.
    https://github.com/SpenceKonde/DxCore This is a "board" of bare chips perfect for people like me who make custom hardware. I made a board with the AVR128DA28 only to find out that the Microchip software support is all but broken for things like I2C. Arduino is a great hardware/software standard but their IDE is horribly basic. Their imports are all broken for any 3rd party core. PlatformIO would be a perfect IDE.

Atmelavr toolchain iom4808.h file missing USART3?

This is a copy of the discourse thread on the same topic, I was asked to make an issue here.

Hello, I would just like to preface this with: I have no idea what I am doing and used my monkey brain pattern recognition to fix a bug. That being said, I wanted to find some closure with the bug I found and fixed (I mean it at least programs now when it didn't before).

I'll try to be as detailed as possible, but again, not sure what I'm doing so I might miss something.

What I did was create a new platformio project by selecting atmega4808 as the board.
When this project was created I then copied the jtag2updi platformio.ini from the megacorex platformio docs here.
After doing this, compiling the default sketch generated by platformio I got the following error:

In file included from C:\Users\ffejs\.platformio\packages\framework-arduino-megaavr-megacorex\cores\MegaCoreX\UART.h:28:0,
                 from C:\Users\ffejs\.platformio\packages\framework-arduino-megaavr-megacorex\cores\MegaCoreX\Arduino.h:127,
                 from C:\Users\ffejs\.platformio\packages\framework-arduino-megaavr-megacorex\cores\MegaCoreX\UART3.cpp:25:
C:\Users\ffejs\.platformio\packages\framework-arduino-megaavr-megacorex\variants\48pin-standard/pins_arduino.h:204:42: error: 'USART3' was not declared in this scope
 #define HWSERIAL3                       &USART3
                                          ^

There was a bit more but it was all USART3 stuff.
Control clicking through the files it listed (I'm not sure how I got to it as its not directly one listed) I got to the iom4808.h file which comes with the atmelavr toolchain. (the path is C:\Users\ffejs\.platformio\packages\toolchain-atmelavr\avr\include\avr\iom4808.h)
This file was missing:

  • The memory mapping for USART3
    • #define USART3              (*(USART_t *) 0x0860)
      
  • The interrupt vectors for USART3
    • #define USART3_RXC_vect_num  37
      #define USART3_RXC_vect      _VECTOR(37)
      #define USART3_DRE_vect_num  38
      #define USART3_DRE_vect      _VECTOR(38)
      #define USART3_TXC_vect_num  39
      #define USART3_TXC_vect      _VECTOR(39)
      

After adding that to the file on my machine everything compiles and uploads fine.
(Yes, I checked the values with the datasheet and they are correct)

I've scoured the github repo's looking for this file and was not able to locate it, as I wanted to make a github issue about this topic, so instead I've resorted to this.

Is there any reason it was missing or was it just a mistake and a bug that should be fixed?
Or am I messing with something I'm not supposed to be messing with and there was a really simple solution to my problem.

Can't upload to nano every

I'm having a similar issue to #6.
Uploading from Arduino IDE works fine but PlatformIO hangs forever.
I tried using the develop branch, to no avail.
Following is my verbose shell.

PS C:\Users\gurgh\OneDrive\Documents\PlatformIO\Projects\Audiuino> pio run -t upload -v
Processing nano_every (platform: atmelmegaavr; board: nano_every; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------

CONFIGURATION: https://docs.platformio.org/page/boards/atmelmegaavr/nano_every.html
PLATFORM: Atmel megaAVR (1.3.0) > Arduino Nano Every
HARDWARE: ATMEGA4809 16MHz, 6KB RAM, 47.50KB Flash
PACKAGES:
 - framework-arduino-megaavr 1.8.6
 - tool-avrdude-megaavr 1.60300.191015 (6.3.0) 
 - toolchain-atmelavr 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 5 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Auto-detected: COM8
MethodWrapper(["checkprogsize"], [".pio\build\nano_every\firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.4% (used 26 bytes from 6144 bytes)
Flash: [          ]   3.0% (used 1456 bytes from 48640 bytes)
.pio\build\nano_every\firmware.elf  :

section                     size      addr

.data                          6   8398848

.text                       1346         0

.rodata                      104     17730

.bss                          20   8398854

.comment                      17         0

.note.gnu.avr.deviceinfo      64         0

.debug_aranges               192         0

.debug_info                10525         0

.debug_abbrev               8992         0

.debug_line                 1303         0

.debug_str                  3979         0

Total                      26548
<lambda>(["upload"], [".pio\build\nano_every\firmware.hex"])
AVAILABLE: jtag2updi
CURRENT: upload_protocol = jtag2updi
BeforeUpload(["upload"], [".pio\build\nano_every\firmware.hex"])
Use manually specified: COM8
Forcing reset using 1200bps open/close on port COM8
Waiting for the new upload port...

After a few minutes it will print

avrdude -v -p atmega4809 -C "C:\Users\gurgh\.platformio\packages\tool-avrdude-megaavr\avrdude.conf" -c jtag2updi -Ufuse2:w:0x01:m -Ufuse5:w:0xC9:m -Ufuse8:w:0x00:m -Ulock:w:0xc5:m -b 115200 -V -e -D -P "COM8" -U flash:w:.pio\build\nano_every\firmware.hex:i

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\gurgh\.platformio\packages\tool-avrdude-megaavr\avrdude.conf"

         Using Port                    : COM8
         Using Programmer              : jtag2updi
         Overriding Baud Rate          : 115200

After that it will print continuously

avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
....

Platform atmelmegaavr installs old gcc by default

atmelmegaavr installs [email protected] instead of platformio/[email protected] by default. The old version of gcc lacks the spec files, includes, and libraries needed for the new AVR Dx parts and many of the newer ATtiny parts. This can be worked around by adding the following line to platformio.ini:

platform_packages = platformio/toolchain-atmelavr@^3.70300.220127

But why isn't it installing the latest version by default?

BTW, if platformio.ini includes framework = arduino, then both versions of GCC will get installed and it will use the new one by default, so you may not notice the issue. But if you are doing native development (e.g., using the native-blink example), it won't compile for newer parts without explicitly specifying the newer gcc version. See this thread for more details.

Debug Not Supported For ATmega4808

  • Feature Request.
    You know, all I want is a normal IDE that lets me step through my code. I was excited to find PlatformIO, got it all set up, brought over a sample project for my custom ATmega4808 board. Run->Debug and wham, ATmega4808 debug not supported. The suggestion was to open an issue. Here it is. It would be nice to be able to debug.

Natively support pymcuprogram

The microchip-pic-avr-tools/pymcuprog tool has emerged and per https://github.com/microchip-pic-avr-tools/pymcuprog/blob/main/pypi.md#serial-port-updi-pyupdi is capable of uploading to a MegaAVR device via UPDI via a serial adapter, in the same way pyupdi can.

One might think integrating PyUPDI should be done, but as of 3 days a deprecation notice was posted pointing to the pymcuprog program as its successor. The serialupdi subfolder is PyUPDI slightly adapted.

As of now, PlatformIO only supported PyUPDI via upload_protocol = custom configurations anyways, not natively (see here).

Programming "raw" MegaAVR chips via a simple serial adapter is a common use-case for hobbyists bying the chips directly (such as the convienent DIP form the ATMega4809) and as such, PlatformIO should support uploading the firmware and setting fuses natively through using only a serial adapter and the new pymcuprog program.

For CLI docuentation, see https://github.com/microchip-pic-avr-tools/pymcuprog/issues/7 and https://github.com/microchip-pic-avr-tools/pymcuprog/blob/main/pypi.md.

Update DXCore to 1.5.11

Hey,

could you add the actual DXCore version.
Or could I do this somehow local for me by myself?

Thanks

delay() not working on Atmega808

I've encountered an issue with the delay() function on the ATMEGA808 microcontroller. When I run the following code, the uC freezes, and no signal is detected on the TEST_PIN:

`#include <Arduino.h>

#define TEST_PIN 24

void setup() {
pinMode(TEST_PIN, OUTPUT); // debug pin
}

void loop() {
digitalWrite(TEST_PIN, HIGH);
delay(10);
digitalWrite(TEST_PIN, LOW);
delay(10);
}`

However, when I replace 'delay(10)'; with 'delayMicroseconds(10000);', the code runs smoothly. Additionally, when I run this code on an ATMEGA4809, it works without any issues.

I noticed there's a similar issue reported here [https://github.com/MCUdude/MegaCoreX/issues/43], but I'm unsure if it applies to PlatformIO as well.

Could you please help me verify if this issue is specific to PlatformIO and provide guidance on how to address it?

Users can't upload to Uno WiFi Rev2 because of argument escaping problem

Initially reported in the community forum.

With the platformio.ini

[env:uno_wifi_rev2]
platform = atmelmegaavr
board = uno_wifi_rev2
framework = arduino

Users with a space in their name experience a failure in uploading.

<lambda>(["upload"], [".pio\build\uno_wifi_rev2\firmware.hex"])
AVAILABLE: xplainedmini_updi
CURRENT: upload_protocol = xplainedmini_updi
BeforeUpload(["upload"], [".pio\build\uno_wifi_rev2\firmware.hex"])
avrdude -v -p atmega4809 -C "C:\Users\Wong Zhi Wei\.platformio\packages\tool-avrdude-megaavr\avrdude.conf" -c xplainedmini_updi -Ufuse2:w:0x01:m -Ufuse5:w:0xC9:m -Ufuse8:w:0x02:m -Ulock:w:0xC5:m "-Uflash:w:"C:\Users\Wong Zhi Wei\.platformio\packages\framework-arduino-megaavr\bootloaders\atmega4809_uart_bl.hex":i" -b 115200 -V -e -D -P usb -U flash:w:.pio\build\uno_wifi_rev2\firmware.hex:i
avrdude: invalid file format '\Users\Wong' in update specifier
avrdude: error parsing update operation 'flash:w:C:\Users\Wong'
*** [upload] Error 1

The problem looks to me like there's a double-qupting of the flashing argument for the bootloader

"-Uflash:w:"C:\Users\Wong Zhi Wei.platformio\packages\framework-arduino-megaavr\bootloaders\atmega4809_uart_bl.hex":i"

Per this the argument should have been just

-Uflash:w:"C:\Users\Wong Zhi Wei.platformio\packages\framework-arduino-megaavr\bootloaders\atmega4809_uart_bl.hex":i

I however don't see where those quotes for the complete command get added..

if board == "uno_wifi_rev2":
# uno_wifi_rev2 requires bootloader to be uploaded in any case
env.SConscript("bootloader.py", exports="env")
env.Append(UPLOADERFLAGS=env["FUSESFLAGS"])
env.Append(UPLOADERFLAGS=env["BOOTFLAGS"])

BOOTFLAGS=['-Uflash:w:"%s":i' % bootloader_path],

only add quotes for the bootloader path, which is correct. There must be some auto-escaping that is not in the platform code screwing things up here -- possible quoting any argument which has a space in it, although in this special case only a part of the argument is to be escaped.

problem with uart on attiny1624

Hi,

i wanted to use the new implemented attiny1624, but i have issues with the two UARTs.
I tried the code in PlatformIO and in the Arduino IDE. In the Arduino IDE the UARTs are sending and receiving. In PlatformIO at least on UART dont work, i didnt check wich UART dont work or if both dont work.

I hope somone can help.

tool-avrdude not installed correctly if needed

Although there is

if any(t in targets for t in ("fuses", "bootloader")):
if build_core in ("MegaCoreX", "megatinycore"):
self.packages["tool-avrdude"]["optional"] = False
else:
self.packages["tool-avrdude-megaavr"]["optional"] = False

there is tool-avrdude package definition in the platform.json

"packages": {
"toolchain-atmelavr": {
"type": "toolchain",
"owner": "platformio",
"version": "~1.70300.0",
"optionalVersions": ["~3.70300.0"]
},
"framework-arduino-megaavr": {
"type": "framework",
"optional": true,
"owner": "platformio",
"version": "~1.8.7"
},
"framework-arduino-megaavr-megacorex": {
"type": "framework",
"optional": true,
"owner": "platformio",
"version": "~1.1.1"
},
"framework-arduino-megaavr-megatinycore": {
"type": "framework",
"optional": true,
"owner": "platformio",
"version": "~2.6.5"
},
"framework-arduino-megaavr-dxcore": {
"type": "framework",
"optional": true,
"version": "~1.4.5"
},
"tool-avrdude-megaavr": {
"type": "uploader",
"optional": true,
"owner": "platformio",
"version": "~1.60300.0",
"optionalVersions": ["~3.60300.0"]
}
}

which I think leads to the problem posted about in

https://community.platformio.org/t/tool-avrdude-error-cannot-build-example-hello-world-code-due-to-the-tool-failing/32645?u=maxgerhardt

Unable to flash Arduino Uno WiFi Rev2

What kind of issue is this?

  • PlatformIO ATmelAVR.
    If you’ve found a bug, please provide an information below.

Configuration

Operating system:
Mac OS 10.14.6

PlatformIO Version (platformio --version):
PlatformIO, version 5.0.2

Description of problem

Flashing the MCU with Platformio causes the built-in LED to simply keep flashing, and the flashed code has no effect.

Steps to Reproduce

Here's the code used to flash to the board, named as src/main.cpp:

#include "Arduino.h"

#define BUILT_IN_LED LED_BUILTIN
#define PULSE_DELAY 500

void setupPulseLED(void)
{
  pinMode(BUILT_IN_LED, OUTPUT);
  digitalWrite(BUILT_IN_LED, LOW);
}

void pulse(void)
{
  digitalWrite(BUILT_IN_LED, HIGH);
  delay(PULSE_DELAY);
  digitalWrite(BUILT_IN_LED, LOW);
  delay(PULSE_DELAY);
}

void setup()
{
  setupPulseLED();
  Serial.begin(115200);
}

void loop()
{
  pulse();
  Serial.print("loop...");
}

Here's the upload:

Processing uno_wifi_rev2 (platform: atmelmegaavr; board: uno_wifi_rev2; framework: arduino)
---------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelmegaavr/uno_wifi_rev2.html
PLATFORM: Atmel megaAVR (1.2.0) > Arduino Uno WiFi Rev2
HARDWARE: ATMEGA4809 16MHz, 6KB RAM, 47.50KB Flash
PACKAGES:
 - framework-arduino-megaavr 1.8.6
 - tool-avrdude-megaavr 1.60300.191015 (6.3.0)
 - toolchain-atmelavr 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 6 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Selected fuses:
[fuse2 = 0x01]
[fuse5 = 0xc9]
[fuse8 = 0x02]
Compiling .pio/build/uno_wifi_rev2/src/main.cpp.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduinoVariant/variant.c.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/CDC.cpp.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/NANO_compat.cpp.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/Tone.cpp.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/UART.cpp.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/UART0.cpp.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/UART1.cpp.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/UART2.cpp.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/UART3.cpp.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/UNO_compat.cpp.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/USBCore.cpp.o
Archiving .pio/build/uno_wifi_rev2/libFrameworkArduinoVariant.a
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/WInterrupts.cpp.o
Indexing .pio/build/uno_wifi_rev2/libFrameworkArduinoVariant.a
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/WMath.cpp.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/abi.cpp.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/api/Common.cpp.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/api/IPAddress.cpp.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/api/PluggableUSB.cpp.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/api/Print.cpp.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/api/Stream.cpp.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/api/String.cpp.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/hooks.c.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/main.cpp.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/new.cpp.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/wiring.c.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/wiring_analog.c.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/wiring_digital.c.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/wiring_pulse.S.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/wiring_pulse.c.o
Compiling .pio/build/uno_wifi_rev2/FrameworkArduino/wiring_shift.c.o
Archiving .pio/build/uno_wifi_rev2/libFrameworkArduino.a
Indexing .pio/build/uno_wifi_rev2/libFrameworkArduino.a
Linking .pio/build/uno_wifi_rev2/firmware.elf
Checking size .pio/build/uno_wifi_rev2/firmware.elf
Building .pio/build/uno_wifi_rev2/firmware.hex
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   2.8% (used 175 bytes from 6144 bytes)
Flash: [=         ]   5.8% (used 2840 bytes from 48640 bytes)
Configuring upload protocol...
AVAILABLE: xplainedmini_updi
CURRENT: upload_protocol = xplainedmini_updi
Looking for upload port...
Uploading .pio/build/uno_wifi_rev2/firmware.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.04s

avrdude: Device signature = 0x1e9651 (probably m4809)
avrdude: erasing chip
avrdude: reading input file ".pio/build/uno_wifi_rev2/firmware.hex"
avrdude: writing flash (3352 bytes):

Writing | ################################################## | 100% 0.78s

avrdude: 3352 bytes of flash written

avrdude: safemode: Fuses OK (E:FF, H:FF, L:FF)

avrdude done.  Thank you.

Setting fuses

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.04s

avrdude: Device signature = 0x1e9651 (probably m4809)
avrdude: reading input file "0x01"
avrdude: writing fuse2 (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of fuse2 written
avrdude: verifying fuse2 memory against 0x01:
avrdude: load data fuse2 data from input file 0x01:
avrdude: input file 0x01 contains 1 bytes
avrdude: reading on-chip fuse2 data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ...
avrdude: 1 bytes of fuse2 verified
avrdude: reading input file "0xc9"
avrdude: writing fuse5 (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of fuse5 written
avrdude: verifying fuse5 memory against 0xc9:
avrdude: load data fuse5 data from input file 0xc9:
avrdude: input file 0xc9 contains 1 bytes
avrdude: reading on-chip fuse5 data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ...
avrdude: WARNING: invalid value for unused bits in fuse "fuse5", should be set to 1 according to datasheet
This behaviour is deprecated and will result in an error in future version
You probably want to use 0xcd instead of 0xc9 (double check with your datasheet first).
avrdude: 1 bytes of fuse5 verified
avrdude: reading input file "0x02"
avrdude: writing fuse8 (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of fuse8 written
avrdude: verifying fuse8 memory against 0x02:
avrdude: load data fuse8 data from input file 0x02:
avrdude: input file 0x02 contains 1 bytes
avrdude: reading on-chip fuse8 data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ...
avrdude: 1 bytes of fuse8 verified

avrdude: safemode: Fuses OK (E:FF, H:FF, L:FF)

avrdude done.  Thank you.

Uploading bootloader

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.04s

avrdude: Device signature = 0x1e9651 (probably m4809)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "/Users/mdesilva/.platformio/packages/framework-arduino-megaavr/bootloaders/atmega4809_uart_bl.hex"
avrdude: writing flash (280 bytes):

Writing | ################################################## | 100% 0.12s

avrdude: 280 bytes of flash written
avrdude: verifying flash memory against /Users/mdesilva/.platformio/packages/framework-arduino-megaavr/bootloaders/atmega4809_uart_bl.hex:
avrdude: load data flash data from input file /Users/mdesilva/.platformio/packages/framework-arduino-megaavr/bootloaders/atmega4809_uart_bl.hex:
avrdude: input file /Users/mdesilva/.platformio/packages/framework-arduino-megaavr/bootloaders/atmega4809_uart_bl.hex contains 280 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.10s

avrdude: verifying ...
avrdude: 280 bytes of flash verified

avrdude: safemode: Fuses OK (E:FF, H:FF, L:FF)

avrdude done.  Thank you.

Actual Results

The built in L led keeps blinking.

Expected Results

Works when flashed using the Arduino IDE.

If problems with PlatformIO Build System:

The content of platformio.ini:

[env:uno_wifi_rev2]
platform = atmelmegaavr
board = uno_wifi_rev2
framework = arduino

Source file to reproduce issue:

#include "Arduino.h"

#define BUILT_IN_LED LED_BUILTIN
#define PULSE_DELAY 500

void setupPulseLED(void)
{
  pinMode(BUILT_IN_LED, OUTPUT);
  digitalWrite(BUILT_IN_LED, LOW);
}

void pulse(void)
{
  digitalWrite(BUILT_IN_LED, HIGH);
  delay(PULSE_DELAY);
  digitalWrite(BUILT_IN_LED, LOW);
  delay(PULSE_DELAY);
}

void setup()
{
  setupPulseLED();
  Serial.begin(115200);
}

void loop()
{
  pulse();
  Serial.print("loop...");
}

Additional info

Updated PIO, build now fails with "KeyError: 'tool-avrdude," but I'm not even using avrdude

[ Moved this issue from platform-atmelavr#306 ]

Versions:

Appears to be similar to platform-atmelavr#269

My project is here: https://gitlab.com/nuance-systems/dragonfly-can-expander

To re-create error, simply enter the firmware subdirectory and do make or pio run

I was trying to solve a …relocation truncated to fit: R_AVR_13_PCREL against symbol…" error, when I decided to do pio pkg update, which is when this new KeyError error began.

This project doesn't even use avrdude, since it's a TINY0 project, which uses pymcuprog

Full CLI dump:

(base) epoulsen@strawberry:~/workspaces/dragonfly-can-expander/firmware$ pio run
Processing attinyx06 (platform: atmelmegaavr; board: ATtiny806)
-----------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
KeyError: 'tool-avrdude':
  File "/home/epoulsen/miniconda3/lib/python3.8/site-packages/platformio/builder/main.py", line 188:
    env.SConscript("$BUILD_SCRIPT")
  File "/home/epoulsen/.platformio/packages/tool-scons/scons-local-4.4.0/SCons/Script/SConscript.py", line 597:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/home/epoulsen/.platformio/packages/tool-scons/scons-local-4.4.0/SCons/Script/SConscript.py", line 285:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/home/epoulsen/.platformio/platforms/atmelmegaavr/builder/main.py", line 77:
    env.PioPlatform().get_package_dir(
  File "/home/epoulsen/miniconda3/lib/python3.8/site-packages/platformio/platform/_packages.py", line 32:
    pkg = self.get_package(name)
  File "/home/epoulsen/miniconda3/lib/python3.8/site-packages/platformio/platform/_packages.py", line 29:
    return self.pm.get_package(spec or self.get_package_spec(name))
  File "/home/epoulsen/miniconda3/lib/python3.8/site-packages/platformio/platform/_packages.py", line 21:
    owner=self.packages[name].get("owner"),
====================================================== [FAILED] Took 0.23 seconds ======================================================
(base) epoulsen@strawberry:~/workspaces/dragonfly-can-expander/firmware$ 

Support for MegaCoreX

A support of the MegaCoreX will helpful because there are other boards with MegaAvr0 chips,
(Curiosity Nano, ATmega4809 Xplained Pro ...) which are not supported by Arduino directly.
https://github.com/MCUdude/MegaCoreX
Thank you for support of the original Arduino boards.

Unable to upload to Nano_Every

I have been having persistent issues uploading to the Nano_Every from PIO with the atmelmegaavr platform (sample verbose at bottom).

It seems to be that the upload hangs as it forces a board reset and then waits for the upload port which I don't think is needed (I am no expert here). I have not had these issues with the Arduino IDE which is using the same version of avrdude (at this moment in time on my machine) so am fairly certain it's due to how PIO is handling uploads to this board.

I have managed to successfully program the board by modifying the nano_every.json so these two lines are false:
"require_upload_port": false,
"wait_for_upload_port": false

Verbose output for non modified json is consistently as follows:

<lambda>(["upload"], [".pio\build\nano_every\firmware.hex"])
AVAILABLE: jtag2updi
CURRENT: upload_protocol = jtag2updi
BeforeUpload(["upload"], [".pio\build\nano_every\firmware.hex"])
Auto-detected: COM23
Forcing reset using 1200bps open/close on port COM23
Waiting for the new upload port...
avrdude -v -p atmega4809 -C C:\Users\nocma4\.platformio\packages\tool-avrdude-megaavr\avrdude.conf -c jtag2updi -D -V -b 115200 -e -P "COM23" -U flash:w:.pio\build\nano_every\firmware.hex:i -Ufuse2:w:0x01:m -Ufuse5:w:0xC9:m -Ufuse8:w:0x00:m

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\nocma4\.platformio\packages\tool-avrdude-megaavr\avrdude.conf"

         Using Port                    : COM23
         Using Programmer              : jtag2updi
         Overriding Baud Rate          : 115200
avrdude: ser_open(): can't open device "\\.\COM23": Access is denied.



avrdude done.  Thank you.

*** [upload] Error 1

Board macros have different name than expected

See https://community.platformio.org/t/impossible-to-build-adafruit-gfx-with-platformio/21009/5?u=maxgerhardt.

Situation: Attempt to compile a Adafruit GFX Sketch with the platformio.ini

[env:ATmega4809]
platform = atmelmegaavr
board = ATmega4809
framework = arduino
lib_ldf_mode = chain+
lib_deps =
     adafruit/Adafruit GFX Library @ ^1.10.7
     adafruit/Adafruit BusIO @ ^1.7.3
     SPI
     Wire

The Adafruit GFX Core tries to detect the ATMega4809 with the code

..  defined(ARDUINO_AVR_ATmega4809) || ...

However this core defines

"extra_flags": "-DARDUINO_AVR_ATMEGA4809",

Notice the different upper/lowercase spelling.

This causes a compile failure for Adafruit GFX sketches which rely on this check to activate the definition of certain types (BitOrder).

It should be double-checked whether PlatformIO makes a spelling mistake here and if the behavior in the MegaCoreX is the same.

The sketch compiles with board = nano_every correctly, but that's also a different Arduino core.

Update MegaCoreX to the latest version

Already been discussed in platformio/platform-atmelavr#301, so this is just a reminder.

@valeros it would be great if you could update MegaCoreX to the latest version, v1.1.1? Avrdude can also be updated to v7.1. If all targets in this repo are using the same avrdude.conf file as the one shipped with the Avrdude binary, The entire repo could be configured to use Avrdude 7.1, which is a huge improvement over the current 6.3.

millis() not working: Incorrect hardware timer defined for 14 and 20 pin devices in arduino.py

On DD-series with 14 or 20 pins, TCB1 is the default millis timer (see https://github.com/SpenceKonde/DxCore/blob/master/megaavr/extras/Ref_Timers.md).
But in arduino.py the timer TCB2 is defined for all DxCore dvices.
ref: https://github.com/platformio/platform-atmelmegaavr/blob/aae69d4c9d317ef2e63e2e7ca89ba8ac5b85c6fb/builder/frameworks/arduino.py#L137C25-L137C25

One workaround is to define the millis()-timer in platformio.ini:

[env:AVR64DD20] 
board = AVR64DD20
board_hardware.millistimer = B1
...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.