PlatformIO Community

Upload using programmer for Arduino Uno board not working

I’m trying to set up VSC/PIO as workbench for my projects, but get stuck with a very basic problem.
Basic testing with an Arduino Uno board by uploading a simple blink is working via USB with bootloader.
But when I use a programmer AVRISP mkII or Atmel ICE it seems the devices are not recognized (see the message below). Same setup with Arduino IDE is working.
Not luck using upload_command in platform.ini. Changed USB driver (Zadig) for the programmer for testing, tried a complete new istallation. All without success.
The most weird: PIO commandline works (c:\progs\ArduinoIDE\arduino-1.8.9\hardware\tools\avr\bin\avrdude -Cc:\progs\ArduinoIDE\arduino-1.8.9\hardware\tools\avr\etc\avrdude.conf -v -patmega328p -cstk500v2 -Pusb -Uflash:w:c:\Users\thomas\Documents\PlatformIO\Projects\LED8-RGB.pio\build\uno\firmware.elf)


Configuring upload protocol…
AVAILABLE: stk500v2
CURRENT: upload_protocol = stk500v2
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//)
*** [upload] Explicit exit, status 1

The message is telling you that a parameter is missing…

Error: Please specify upload_port for environment or use global --upload-port option.

What do you actually have in your platformio.ini? Does it have the correct settings for your programmer? And are you using the program / upload with programmer option rather than the standard upload option (which for this device family is more for serial uploading).

From another post made recently, it seems that …
upload_protocol = atmelice_isp
… should work for the Atmel ICE programmer (but I haven’t tried that with mine yet, so can neither confirm or deny that! :laughing: ).

thx for reply an sorry for missing my platform.ini:

[env:myenv]
platform = atmelavr
framework = arduino
board = uno
upload_protocol = stk500v2
upload_flags =
-Pusb

and I used “upload using programmer”

I would like to concentrate on the more popular AVRISPmk2 (anybody else using this?) AtmelICE3 is even more delicate with drivers.

Try adding upload_port = custom - it shouldn’t actually do anything other than satisfy the check that upload_port has been set. It gets past the

Error: Please specify `upload_port` for environment or use global `--upload-port` option.

and hands over to avrdude to actually do the upload. Command line used then looks like it should work.

And yes… the Atmel ICE is a pain on Windoze… had to poke it with zadig to make it usable with avrdude -> ArduinoIDE/PIO/etc.

1 Like

Success! Amazing, just adding “upload_port = custom” to platform.ini did it. Thank you.
How to request this directive to be added to the doku? Can’t find it even in the docu .pdf. Would have saved me hours.
Thanks for your time and have a good day.

1 Like

Generally have a look at the platformio github repos and see what one your issue best fits… i.e.

Then there’s the various platforms, extensions, etc. In this case, I’m going to open an issue against platform-atmelavr to first ask if the behaviour can be improved, as IMO you should be able to do

upload_protocol = stk500v2
upload_port = usb

instead. Currently both that and custom fails on linux, and it would also remove the need for upload_flags = -Pusb as that is what’s setting the port. If that idea isn’t liked, I’ll then suggest a fix to the documentation page.

1 Like

Totally agree, this is quite unexpected behaviour.
Just some more information about AVR programmer/debugger with PIO for those it may concern:
Now my Atmel-ICE3 is working under PIO as well, adding “upload_port = custom” with “debug_tool = jtag3isp” and “upload_protocol = jtag3isp” defined in .ini.
However adrdude.conf has to be modied. Vendor & Product ID is 03eb/2141 for my device. In advdude.conf usbpid = 0x2110, 0x2140 is defined, so the device will not be found.
But this is common for all avrdude installations I’ve seen.
No idea if this appies to all Atemel-Ice3 devices or this is specific to whatever.

1 Like

Is it the Atmel-ICE3, or JTAGICE3? I’m not seeing anything for Atmel-ICE3? I’ve got the Atmel ICE, and don’t think I needed to change VID/PID pairs, but it has been a while since I tried it.

Well, good point. The correct naming is [ATATMEL-ICE-PCBA](([https://www.microchip.com/DevelopmentTools/ProductDetails/ATATMEL-ICE].), Same as you got.
I ordered the PCB-only version from Digikey 2 months ago. Atmel Studio shows just an ATMEL_ICE. Atmel/Microship can be pretty confusing even with names :smiley:
USBDeview shows following information ![USB%20Devices%20List|690x487]
(upload://lmZ4o8VN6zdHUS0bMIE0aiErX9H.jpeg)