This does work on Linux with the Atmel ICE and ‘Upload using Programmer’ as it is the correct name that avrdude is looking for. For some reason it isn’t working for me on Window, but I can see mention of it on other forums as being related to driver changes by Atmel. :-/
btw, there’s a semicolon on the end of custom-upload-tool link that shouldn’t be there
The following also worked fine for me on linux - use the upload command, not upload with programmer - so I would expect to work just fine on Windows with a change to the correct path for avrdude. I didn’t use the $UPLOADERFLAGS
and specify the avrdude flags in the platformio.ini file as I had an issue with the platformio default flags being appended also.
=== platformio.ini ===
[env:nanoatmega328]
platform = atmelavr
board = nanoatmega328
framework = arduino
extra_scripts = upload_atmel-ice.py
upload_protocol = custom
=== upload_atmel-ice.py ===
Import("env")
env.Replace(UPLOADHEXCMD='$UPLOADER -p atmega328p -C /home/pfeerick/.platformio/packages/tool-avrdude/avrdude.conf -c atmelice_isp -U flash:w:$SOURCES:i')
Edit: Well, Windows is ‘working’ in as far as it’s trying to do the upload, but until I work out how to sort out the driver (will be poking with zadig to see if that can break something) it doesn’t help me. However, for some reason, I had to add upload_port = none
to the platformio.ini
for the Windows upload to not fail flat on its face with:
Configuring upload protocol...
AVAILABLE: custom
CURRENT: upload_protocol = custom
Looking for upload port...
Error: Please specify `upload_port` for environment or use global `--upload-port` option.
For some development platforms it can be a USB flash drive (i.e. /media/<user>/<device name>)
*** [upload] Explicit exit, status 1
=== Windows upload_atmel-ice.py ===
Import("env")
env.Replace(UPLOADHEXCMD='$UPLOADER -p atmega328p -C C:/Users/Peter/.platformio/packages/tool-avrdude/avrdude.conf -c atmelice_isp -U flash:w:$SOURCES:i')
Note: I used forward instead of backslashes as normal for the path in windows to avoid escaping…
Later edit: Zadig fixed the issue on windows with avrdude not detecting the atmel-ice - just replaced the “Atmel-ICE CMSIS-DAP” WinUSB driver with libusb-win32, and it works fine. Atmel studio doesn’t like it, but it will be just a matter of swapping the drivers back if I want to use it.
I also removed both the upload_port and upload_protocol commands from platformio.ini on windows, as since I’m complete replacing the avrdude call, it wasn’t needed. I’d probably keep the upload_port
in the platformio.ini in future though, and set it to custom
, just to make it a bit more obvious what’s happening. It just seems that you need to set upload_port if you have upload_protocol set though (one windows).