I am trying to use my atmel ICE with platformIO and VS Code instead of Atmel Studio, as this software is a pain when I want to use Arduino.h with libraries.
*I posted this question on stackoverflow earlier but nobody seems to be familiar with PlatformIO enough to answer, so I decided to ask the same question on PIO community directly!
However I cannot upload with my programmer. I tried with a 32 pin ATmega328.
I first used PIO’s documentation on how to use Atmel-ICE with it on this page: debug-tools/atmel-ice
If you would like to use this tool for firmware uploading, please change upload
protocol:
[env:myenv]
platform = ...
board = ...
debug_tool = atmel-ice
upload_protocol = atmel-ice
So this is what I wrote in my file:
[env:ATmega328P]
platform = atmelavr
board = ATmega328P
framework = arduino
upload_protocol = atmel-ice
And I get this message as I run the upload command on PIO:
DATA: [ ] 0.4% (used 9 bytes from 2048 bytes)
PROGRAM: [ ] 1.4% (used 444 bytes from 32256 bytes)
Configuring upload protocol...
AVAILABLE: atmel-ice
CURRENT: upload_protocol = atmel-ice
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
At that point I am not sure what to try. I tried a couple things described below but I am not sure I am going on the right track. The atmel ICE programmer, compared to an Arduino for example, doesn’t have a USB PORT number associated with it, so I don’t know how I am supposed to specify my upload_port argument in my .ini file.
There are some options described on the platformIO documentation Redirecting... but I am completely lost. I feel like the message I get : For some development platforms it can be a USB flash drive (i.e. /media//) can be a good clue. Any Idea what should I change in my .ini file to make my atmel ICE work? thanks!
Other things I tried: I read on a post (I’m sorry I cannot find the link anymore) that adding
upload_port = usb
can solve the issue. When adding this line to my platformio.ini, I get a different error message:
avrdude: Can't find programmer id "atmel-ice"
Valid programmers are:
2232HIO = FT2232H based generic programmer
4232h = FT4232H based generic programmer
arduino = Arduino
And the list goes on…
I searched and found this post, which has the same error message!: Atmega 328 - Internal 8MHZ oscillator - Atmel ICE upload troubles
The solution here was to add
upload_flags = -e
But it didn’t change anything for me.
He also mentioned he made changes to the 328p8m.json file, which would be ATmega328P.json in my case. I don’t even know where to find it. Would that be relevant?