Atmega328pb Xplained upload problems

Hello, I found an Atmega328p Xplained board while cleaning out a closet and wanted to mess around with it on Platform IO.

I’ve spent some time reading some forum posts about uploading to it, but I’m not having any luck. I’m pretty sure I don’t have the atmel studio driver problem, but I’ve tried reinstalling drivers to libusb32 and libusbk (didn’t work). I keep getting the same error:

Processing ATmega328PB (platform: atmelavr; board: ATmega328PB; framework: arduino; upload_protocol: xplainedmini)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/ATmega328PB.html
PLATFORM: Atmel AVR (2.0.0) > ATmega328PB
HARDWARE: ATMEGA328PB 16MHz, 2KB RAM, 31.50KB Flash
PACKAGES:
 - framework-arduino-avr-minicore 2.0.7
 - tool-avrdude 1.60300.190424 (6.3.0)
 - toolchain-atmelavr 1.50400.190710 (5.4.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 9 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
MethodWrapper(["checkprogsize"], [".pio\build\ATmega328PB\firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.5% (used 11 bytes from 2048 bytes)
Flash: [          ]   3.4% (used 1110 bytes from 32256 bytes)
.pio\build\ATmega328PB\firmware.elf  :

section                    size      addr

.data                         0   8388864

.text                      1110         0

.bss                         11   8388864

.comment                     48         0

.note.gnu.avr.deviceinfo     64         0

.debug_info                2282         0

.debug_abbrev              2158         0

.debug_line                 421         0

.debug_str                  792         0

Total                      6886
<lambda>(["upload"], [".pio\build\ATmega328PB\firmware.hex"])
AVAILABLE: xplainedmini
CURRENT: upload_protocol = xplainedmini
BeforeUpload(["upload"], [".pio\build\ATmega328PB\firmware.hex"])
Auto-detected: COM22
avrdude -v -p atmega328pb -C C:\Users\email\.platformio\packages\tool-avrdude\avrdude.conf -c xplainedmini -b 115200 -D -P "COM22" -U flash:w:.pio\build\ATmega328PB\firmware.hex:i

avrdude: Version 6.3, compiled on Sep 12 2016 at 17:24:16
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

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

         Using Port                    : COM22
         Using Programmer              : xplainedmini
         Overriding Baud Rate          : 115200
avrdude: jtag3_open_common(): JTAGICE3/EDBG port names must start with "usb"

avrdude done.  Thank you.

*** [upload] Error 

Here is my platformio.ini with a few options I have commented out, none of the upload protocols are working for me:

[env:ATmega328PB]
platform = atmelavr
board = ATmega328PB
framework = arduino
upload_protocol = xplainedmini
;upload_protocol = xplainedmini_dw
;upload_protocol = xplainedpro
;upload_flags = -P usb

When changing the drivers didn’t work I let windows locate and install the “best drivers”:

Any help would be apreciated!

This command still contains the auto-detected COM22 port which avrdude doesn’t seem to like. Please try the following:

In VScode, open a PIO terminal. Then try each of the commands until one one works or throws some other error:

C:\Users\email\.platformio\packages\tool-avrdude\avrdude.exe -v -p atmega328pb -C C:\Users\email\.platformio\packages\tool-avrdude\avrdude.conf -c xplainedmini -b 115200 -D -Pusb -U flash:w:.pio\build\ATmega328PB\firmware.hex:i

C:\Users\email\.platformio\packages\tool-avrdude\avrdude.exe -v -p atmega328pb -C C:\Users\email\.platformio\packages\tool-avrdude\avrdude.conf -c xplainedmini -b 115200 -D -U flash:w:.pio\build\ATmega328PB\firmware.hex:i

C:\Users\email\.platformio\packages\tool-avrdude\avrdude.exe -v -p atmega328pb -C C:\Users\email\.platformio\packages\tool-avrdude\avrdude.conf -c xplainedmini_dw -b 115200 -D -Pusb -U flash:w:.pio\build\ATmega328PB\firmware.hex:i

C:\Users\email\.platformio\packages\tool-avrdude\avrdude.exe -v -p atmega328pb -C C:\Users\email\.platformio\packages\tool-avrdude\avrdude.conf -c xplainedpro -b 115200 -D -Pusb -U flash:w:.pio\build\ATmega328PB\firmware.hex:i

I also note that -e (erase) is not contained in any flags – so if some other partial verification shows up, try adding -e at the end.

Hopefully that revelas what the correct upload command is and if the -P "COM22" is the problem here.

1 Like

@maxgerhardt Port 22 is the CDC virtual com port (interface 1). It looks like PIO automatically wants to use that port to upload.

Here are the results of the commands.

With these drivers:
mEDBG CSMIS-DAP (Interface 0): WinUSB (v6.1.7600.16385)
mEDBG CDC (Interface 1): usbser (v7.3.0.0)

Every command gives me this response:

avrdude.exe: Version 6.3, compiled on Sep 12 2016 at 17:24:16
             Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
             Copyright (c) 2007-2014 Joerg Wunsch

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

             Using Port                    : usb
             Using Programmer              : xplainedmini
             Overriding Baud Rate          : 115200
avrdude.exe: jtag3_open_common(): Did not find any device matching VID 0x03eb and PID list: 0x2145

avrdude.exe done.  Thank you.

If I switch to libusb-win32 drivers (unplug and plug back in after driver switches):
mEDBG CSMIS-DAP (Interface 0): libusb0 (v1.2.6.0)
mEDBG CDC (Interface 1): libusb0 (v1.2.6.0)

I lose the ability to communicate with the CDC virtual com port (port 22) that you believe was causing the problem when I attempt to upload using the platform IO button. When I attempt to upload using the PIO upload button, PIO tries to upload to COM 8 which is one of my RS232 adapters. So… Since COM 22 goes away when I use libusb drivers on the CDC interface 1 device, PIO just grabs the next available com port?

So I reinstall the windows driver for that interface (right click in device manager and “update driver”) and now my drivers are listed in Zadig as:
mEDBG CSMIS-DAP (Interface 0): libusb0 (v1.2.6.0)
mEDBG CDC (Interface 1): usbser (v7.3.0.0)

image

Which allows me to communicate with the CDC interface via a terminal.

I just want to stress that I needed to unplug the board and plug it back in after updating my drivers, if you don’t you get errors and freezes.

C:\Users\email\.platformio\packages\tool-avrdude\avrdude.exe -v -p atmega328pb -C C:\Users\email\.platformio\packages\tool-avrdude\avrdude.conf -c xplainedmini -b 115200 -D -Pusb -U flash:w:.pio\build\ATmega328PB\firmware.hex:i

avrdude.exe: Version 6.3, compiled on Sep 12 2016 at 17:24:16
             Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
             Copyright (c) 2007-2014 Joerg Wunsch

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

             Using Port                    : usb
             Using Programmer              : xplainedmini
             Overriding Baud Rate          : 115200
avrdude.exe: usbdev_open(): Found mEDBG CMSIS-DAP, serno: ATML2323020200001354
avrdude.exe: max packet size expected 512, but found 64 due to EP 0x81's wMaxPacketSize
avrdude.exe: Found CMSIS-DAP compliant device, using EDBG protocol
             AVR Part                      : ATmega328PB
             Chip Erase delay              : 9000 us
             PAGEL                         : PD7
             BS2                           : PC2
             RESET disposition             : dedicated
             RETRY pulse                   : SCK
             serial program mode           : yes
             parallel program mode         : yes
             Timeout                       : 200
             StabDelay                     : 100
             CmdexeDelay                   : 25
             SyncLoops                     : 32
             ByteDelay                     : 0
             PollIndex                     : 3
             PollValue                     : 0x53
             Memory Detail                 :
                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
               flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
               lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
               signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

             Programmer Type : JTAG3_ISP
             Description     : Atmel AVR XplainedMini in ISP mode
             Vtarget         : 5.0 V
             SCK period      : 8.00 us

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.06s

avrdude.exe: Device signature = 0x1e950f (probably m328p)
avrdude.exe: Expected signature for ATmega328PB is 1E 95 16
             Double check chip, or use -F to override this check.

avrdude.exe done.  Thank you.

Doh! My board is a 328p Xplained Mini, not the 328pb. I edit that argument in the command.

PS C:\Users\email\Documents\PlatformIO\Projects\328pXplained_test> C:\Users\email\.platformio\packages\tool-avrdude\avrdude.exe -v -p atmega328p -C C:\Users\email\.platformio\packages\tool-avrdude\avrdude.conf -c xplainedmini -b 115200 -D -Pusb -U flash:w:.pio\build\ATmega328PB\firmware.hex:i 

avrdude.exe: Version 6.3, compiled on Sep 12 2016 at 17:24:16
             Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
             Copyright (c) 2007-2014 Joerg Wunsch

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

             Using Port                    : usb
             Using Programmer              : xplainedmini
             Overriding Baud Rate          : 115200
avrdude.exe: usbdev_open(): Found mEDBG CMSIS-DAP, serno: ATML2323020200001354
avrdude.exe: max packet size expected 512, but found 64 due to EP 0x81's wMaxPacketSize
avrdude.exe: Found CMSIS-DAP compliant device, using EDBG protocol
             AVR Part                      : ATmega328P
             Chip Erase delay              : 9000 us
             PAGEL                         : PD7
             BS2                           : PC2
             RESET disposition             : dedicated
             RETRY pulse                   : SCK
             serial program mode           : yes
             parallel program mode         : yes
             Timeout                       : 200
             StabDelay                     : 100
             CmdexeDelay                   : 25
             SyncLoops                     : 32
             ByteDelay                     : 0
             PollIndex                     : 3
             PollValue                     : 0x53
             Memory Detail                 :

                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
               flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
               lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
               signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

             Programmer Type : JTAG3_ISP
             Description     : Atmel AVR XplainedMini in ISP mode
             Vtarget         : 5.0 V
             SCK period      : 8.00 us

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.06s
avrdude.exe: Device signature = 0x1e950f (probably m328p)
avrdude.exe: safemode: hfuse reads as DF
avrdude.exe: safemode: efuse reads as FF
avrdude.exe: reading input file ".pio\build\ATmega328PB\firmware.hex"
avrdude.exe: writing flash (1110 bytes):

Writing | ################################################## | 100% 1.04s

avrdude.exe: 1110 bytes of flash written
avrdude.exe: verifying flash memory against .pio\build\ATmega328PB\firmware.hex:
avrdude.exe: load data flash data from input file .pio\build\ATmega328PB\firmware.hex:
avrdude.exe: input file .pio\build\ATmega328PB\firmware.hex contains 1110 bytes
avrdude.exe: reading on-chip flash data:

Reading | ################################################## | 100% 1.07s

avrdude.exe: verifying ...
avrdude.exe: verification error, first mismatch at byte 0x0006
             0x8a != 0xae
avrdude.exe: verification error; content mismatch

avrdude.exe: safemode: hfuse reads as DF
avrdude.exe: safemode: efuse reads as FF
avrdude.exe: safemode: Fuses OK (E:FF, H:DF, L:E0)

avrdude.exe done.  Thank you.

And like you mentioned, It looks like I need the erase argument, so I add the -e to the end of the command.

PS C:\Users\email\Documents\PlatformIO\Projects\328pXplained_test> C:\Users\email\.platformio\packages\tool-avrdude\avrdude.exe -v -p atmega328p -C C:\Users\email\.platformio\packages\tool-avrdude\avrdude.conf -c xplainedmini -b 115200 -D -Pusb -U flash:w:.pio\build\ATmega328PB\firmware.hex:i -e

avrdude.exe: Version 6.3, compiled on Sep 12 2016 at 17:24:16
             Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
             Copyright (c) 2007-2014 Joerg Wunsch

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

             Using Port                    : usb
             Using Programmer              : xplainedmini
             Overriding Baud Rate          : 115200
avrdude.exe: usbdev_open(): Found mEDBG CMSIS-DAP, serno: ATML2323020200001354
avrdude.exe: max packet size expected 512, but found 64 due to EP 0x81's wMaxPacketSize
avrdude.exe: Found CMSIS-DAP compliant device, using EDBG protocol
             AVR Part                      : ATmega328P
             Chip Erase delay              : 9000 us
             PAGEL                         : PD7
             BS2                           : PC2
             RESET disposition             : dedicated
             RETRY pulse                   : SCK
             serial program mode           : yes
             parallel program mode         : yes
             Timeout                       : 200
             StabDelay                     : 100
             CmdexeDelay                   : 25
             SyncLoops                     : 32
             ByteDelay                     : 0
             PollIndex                     : 3
             PollValue                     : 0x53
             Memory Detail                 :

                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
               flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
               lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
               signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

             Programmer Type : JTAG3_ISP
             Description     : Atmel AVR XplainedMini in ISP mode
             Vtarget         : 5.0 V
             SCK period      : 8.00 us

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.06s

avrdude.exe: Device signature = 0x1e950f (probably m328p)
avrdude.exe: safemode: hfuse reads as DF
avrdude.exe: safemode: efuse reads as FF
avrdude.exe: erasing chip
avrdude.exe: reading input file ".pio\build\ATmega328PB\firmware.hex"
avrdude.exe: writing flash (1908 bytes):

Writing | ################################################## | 100% 1.78s

avrdude.exe: 1908 bytes of flash written
avrdude.exe: verifying flash memory against .pio\build\ATmega328PB\firmware.hex:
avrdude.exe: load data flash data from input file .pio\build\ATmega328PB\firmware.hex:
avrdude.exe: input file .pio\build\ATmega328PB\firmware.hex contains 1908 bytes
avrdude.exe: reading on-chip flash data:

Reading | ################################################## | 100% 1.77s

avrdude.exe: verifying ...
avrdude.exe: 1908 bytes of flash verified

avrdude.exe: safemode: hfuse reads as DF
avrdude.exe: safemode: efuse reads as FF
avrdude.exe: safemode: Fuses OK (E:FF, H:DF, L:E0)

avrdude.exe done.  Thank you.

This successfully runs my program that blinks the LED and prints hello world to port 22.

Just to check I ran the other commands you suggested, and here are the results:

It looks like it works fine without the -Pusb argument.

C:\Users\email\.platformio\packages\tool-avrdude\avrdude.exe -v -p atmega328p -C C:\Users\email\.platformio\packages\tool-avrdude\avrdude.conf -c xplainedmini -b 115200 -D -U flash:w:.pio\build\ATmega328PB\firmware.hex:i -e

avrdude.exe: Version 6.3, compiled on Sep 12 2016 at 17:24:16
             Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
             Copyright (c) 2007-2014 Joerg Wunsch

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

             Using Port                    : usb
             Using Programmer              : xplainedmini
             Overriding Baud Rate          : 115200
avrdude.exe: usbdev_open(): Found mEDBG CMSIS-DAP, serno: ATML2323020200001354
avrdude.exe: max packet size expected 512, but found 64 due to EP 0x81's wMaxPacketSize
avrdude.exe: Found CMSIS-DAP compliant device, using EDBG protocol
             AVR Part                      : ATmega328P
             Chip Erase delay              : 9000 us
             PAGEL                         : PD7
             BS2                           : PC2
             RESET disposition             : dedicated
             RETRY pulse                   : SCK
             serial program mode           : yes
             parallel program mode         : yes
             Timeout                       : 200
             StabDelay                     : 100
             CmdexeDelay                   : 25
             SyncLoops                     : 32
             ByteDelay                     : 0
             PollIndex                     : 3
             PollValue                     : 0x53
             Memory Detail                 :

                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
               flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
               lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
               signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

             Programmer Type : JTAG3_ISP
             Description     : Atmel AVR XplainedMini in ISP mode
             Vtarget         : 5.0 V
             SCK period      : 8.00 us

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.06s

avrdude.exe: Device signature = 0x1e950f (probably m328p)
avrdude.exe: safemode: hfuse reads as DF
avrdude.exe: safemode: efuse reads as FF
avrdude.exe: erasing chip
avrdude.exe: reading input file ".pio\build\ATmega328PB\firmware.hex"
avrdude.exe: writing flash (1908 bytes):

Writing | ################################################## | 100% 1.80s

avrdude.exe: 1908 bytes of flash written
avrdude.exe: verifying flash memory against .pio\build\ATmega328PB\firmware.hex:
avrdude.exe: load data flash data from input file .pio\build\ATmega328PB\firmware.hex:
avrdude.exe: input file .pio\build\ATmega328PB\firmware.hex contains 1908 bytes
avrdude.exe: reading on-chip flash data:

Reading | ################################################## | 100% 1.77s

avrdude.exe: verifying ...
avrdude.exe: 1908 bytes of flash verified

avrdude.exe: safemode: hfuse reads as DF
avrdude.exe: safemode: efuse reads as FF
avrdude.exe: safemode: Fuses OK (E:FF, H:DF, L:E0)

avrdude.exe done.  Thank you.

xplainedmini_dw fails.

 C:\Users\email\.platformio\packages\tool-avrdude\avrdude.exe -v -p atmega328p -C C:\Users\email\.platformio\packages\tool-avrdude\avrdude.conf -c xplainedmini_dw -b 115200 -D -Pusb -U flash:w:.pio\build\ATmega328PB\firmware.hex:i -e

avrdude.exe: Version 6.3, compiled on Sep 12 2016 at 17:24:16
             Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
             Copyright (c) 2007-2014 Joerg Wunsch

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

             Using Port                    : usb
             Using Programmer              : xplainedmini_dw
             Overriding Baud Rate          : 115200
avrdude.exe: usbdev_open(): Found mEDBG CMSIS-DAP, serno: ATML2323020200001354
avrdude.exe: max packet size expected 512, but found 64 due to EP 0x81's wMaxPacketSize
avrdude.exe: Found CMSIS-DAP compliant device, using EDBG protocol
             AVR Part                      : ATmega328P
             Chip Erase delay              : 9000 us
             PAGEL                         : PD7
             BS2                           : PC2
             RESET disposition             : dedicated
             RETRY pulse                   : SCK
             serial program mode           : yes
             parallel program mode         : yes
             Timeout                       : 200
             StabDelay                     : 100
             CmdexeDelay                   : 25
             SyncLoops                     : 32
             ByteDelay                     : 0
             PollIndex                     : 3
             PollValue                     : 0x53
             Memory Detail                 :

                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
               flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
               lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
               signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

             Programmer Type : JTAGICE3_DW
             Description     : Atmel AVR XplainedMini in debugWIRE mode
             ICE hardware version: 0
             ICE firmware version: 1.00 (rel. 0)
             Serial number   : ATML2323020200001354
             Vtarget         : 5.00 V
             JTAG clock megaAVR/program: 0 kHz
             JTAG clock megaAVR/debug:   0 kHz
             JTAG clock Xmega: 0 kHz
             PDI clock Xmega : 0 kHz

avrdude.exe: bad response to AVR sign-on command: 0xa0
avrdude.exe: retrying with external reset applied
avrdude.exe: bad response to AVR sign-on command: 0xa0
avrdude.exe: retrying with external reset applied
avrdude.exe: JTAGEN fuse disabled?
avrdude.exe: initialization failed, rc=-1
             Double check connections and try again, or use -F to override
             this check.


avrdude.exe done.  Thank you.

xplainedpro fails.

 C:\Users\email\.platformio\packages\tool-avrdude\avrdude.exe -v -p atmega328p -C C:\Users\email\.platformio\packages\tool-avrdude\avrdude.conf -c xplainedpro -b 115200 -D -Pusb -U flash:w:.pio\build\ATmega328PB\firmware.hex:i

avrdude.exe: Version 6.3, compiled on Sep 12 2016 at 17:24:16
             Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
             Copyright (c) 2007-2014 Joerg Wunsch

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

             Using Port                    : usb
             Using Programmer              : xplainedpro
             Overriding Baud Rate          : 115200
avrdude.exe: jtag3_open_common(): Did not find any device matching VID 0x03eb and PID list: 0x2111

avrdude.exe done.  Thank you.

Thanks a lot for the help so far. Any suggestions on correcting the PIO update behavior and getting debugging working?

Could you try this platformio.ini

[env:ATmega328P]
platform = atmelavr
board = ATmega328P
framework = arduino
upload_protocol = custom
upload_flags =
    -C
    $PROJECT_PACKAGES_DIR/tool-avrdude/avrdude.conf
    -p
    atmega328p
    -Pusb
    -c
    xplainedmini
    -e
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i

This should correct the used board and straight up inject the correct upload command instead of attempting to fix that PlatformIO injects -P"COM22" in the commands (didn’t have a play but maybe modifying upload_port = usb or something works too?)

If it can’t find avrdude then please replace the last line with

upload_command = $PROJECT_PACKAGES_DIR\tool-avrdude\avrdude.exe $UPLOAD_FLAGS -U flash:w:$SOURCE:i
1 Like

That works for uploads.

Attempting to debug gives me this:

Error: Currently, PlatformIO does not support debugging for `ATmega328P/PA`.
Please request support at https://github.com/platformio/platformio-core/issues
or visit -> https://docs.platformio.org/page/plus/debugging.html
The terminal process "C:\Users\email\.platformio\penv\Scripts\platformio.exe 'debug'" terminated with exit code: 1.

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

I am just messing around with this board, if you don’t feel like figuring out the debugging I won’t take it personally. I see in the documentation a fuse might need to be set:

http://ww1.microchip.com/downloads/en/devicedoc/50002659a.pdf#page=8

I know the board has an ATmega32U4 that is used to debug / upload. I don’t know much about different debugging protocols or basically anything beyond pressing debug on an IDE/

Indeed, PlatformIO has no native support for debugging real AVR hardware. Only simavr as a simulator. You might want to see if avarice can connect to the chip and open a GDB server, as in Atmega32 debugging with avarice and avr-gdb - #2 by mate910327. This is all relatively unchartered territory though.

1 Like

Thanks for the help Max.

The avarice / GDB stuff looks fun to learn about. While I was reading about GDB I came across this github issue Support for other development tools · Issue #11 · jdolinay/avr_debug · GitHub which is discussing the code in these two repos GitHub - jdolinay/avr_debug: Source level debugger for Arduino - GDB stub for Atmega328 microcontroller used in Arduino Uno. and GitHub - msquirogac/avr-debugger-bootloader: avr-debugger bootloader to enable Flash breakpoints, built throught PlatformIO.

Which also looks fun.

Just wanted to mention it for anyone that might land on this post and wanted to try it out.

Thanks again!

1 Like

The avr-debug project with its GDB stub are now officially supported in PlatformIO! Atmel AVR dev/platform v3.0.0: updated Arduino cores, support for AVR GDB stub

1 Like

That’s awesome!

This program / community is the best.