Trouble uploading to ATmega328PB Xplained mini

Hello,

I have recently bought the ATmega328PB Xplained mini and am struggling to upload to it.
Here is a link to the board infomation: here

I have the environment as follows in my platformio.ini file:
[env:ATmega328PB]
platform = atmelavr
board = ATmega328PB
framework = arduino
upload_protocol = xplainedmini
upload_flags =
-p m328pb

I then run the command “pio run -t program -v” in the terminal and get the following output:

Processing ATmega328PB (platform: atmelavr; board: ATmega328PB; framework: arduino; upload_protocol: xplainedmini; upload_flags: -p m328pb)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
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.3
 - 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 8 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.4% (used 9 bytes from 2048 bytes)
Flash: [          ]   3.6% (used 1166 bytes from 32256 bytes)
.pio\build\ATmega328PB\firmware.elf  :

section                    size      addr

.data                         0   8388864

.text                      1166         0

.bss                          9   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                      6940
<lambda>(["program"], [".pio\build\ATmega328PB\firmware.hex"])
AVAILABLE: xplainedmini
CURRENT: upload_protocol = xplainedmini
avrdude "-p m328pb" -v -p atmega328pb -C C:\Users\tg0_test\.platformio\packages\tool-avrdude\avrdude.conf -c xplainedmini -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\tg0_test\.platformio\packages\tool-avrdude\avrdude.conf"

         Using Port                    : usb
         Using Programmer              : xplainedmini
avrdude: jtag3_open_common(): Did not find any device matching VID 0x03eb and PID list: 0x2145

avrdude done.  Thank you.

*** [program] Error 1
=================================================================================== [FAILED] Took 1.47 seconds ===================================================================================

Environment     Status    Duration
--------------  --------  ------------
uno             IGNORED
lightblue-bean  IGNORED
attiny13        IGNORED
digispark-pro   IGNORED
digispark-tiny  IGNORED
dwenguino       IGNORED
ATmega16        IGNORED
ATmega48        IGNORED
AT90CAN64       IGNORED
ATmega324PB     IGNORED
ATmega328PB     FAILED    00:00:01.465
nibo2           IGNORED
panStampAVR     IGNORED
attiny828       IGNORED
attiny441       IGNORED
============================================================================= 1 failed, 0 succeeded in 00:00:01.465 =============================================================================

I think that the PID and VID supplied in the error message are for the ATmega328P Xplained mini (no B). I’m not sure what settings should be applied to refocus on the ATmega328PB Xplained mini.

Any help with this would be much appreciated!
Will

This causes two -p switches to be present, avrdude "-p m328pb" -v -p atmega328pb … I think this is not needed and atmega328pb is already correct, so upload_flags should be deleted

There’s also xplainedmini_dw as a possible value, can you try that?

In the windows device manager, what’s the USB device that appears when pluggin in the Xplained mini board? In the details, what VID and PID does it have?

Thanks for your help.

Unfortunately removing the upload flags did not change the result. Also using xplainedmini_dw did not help in this case. I still see the same error of:
avrdude: jtag3_open_common(): Did not find any device matching VID 0x03eb and PID list: 0x2145
In both instances.

Interestingly in the attached image you can see that the Xplained mini does indeed appear as mEDBG device on COM142 and that the PID and VID are identical to those displayed in the error message.

Now I’m really confused!

mEDBG

Ah, you have special drivers loaded for this device. AVRDude uses libUSB to communicate with the device. Your current propretiery drivers probably come from Atmel Studio and is not libusb.

Use https://zadig.akeo.ie/ to overwrite the USB drivers for this device to like libusbK, WinUSB or libusb-win32 and see if avrdude sees the device now with your initial upload_protocol = xplainedmini.

Make sure you know what the previous drivers were to reinstall the old drivers if necessary. You can see the loaded driver files in the windows device manager in Driver → Driver Details as a list of files. But you should also be able to go back by simply uninstalling the device in the device manager, removing the libusb filter (there’s a program for that) and replugging the device.

1 Like

Thanks again for your help with this Max.

This time we do have some progress but I am still getting an error. I am using Zadig as suggested and have replaced the driver for mEDBG CDC (Interface 1). Using either libusb-win32 or libusbK I get the following:

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\tg0_test\.platformio\packages\tool-avrdude\avrdude.conf"

         Using Port                    : usb
         Using Programmer              : xplainedmini
avrdude: stk500v2_jtag3_open()
avrdude: usbdev_open(): Found mEDBG CDC, serno: ATML2523052700002124
avrdude: jtag3_getsync()
avrdude: Sending sign-on command:
avrdude: jtag3_send(): sending 3 bytes
avrdude: usbdev_send(): wrote -22 out of 7 bytes, err =
avrdude: jtag3_send(): failed to send command to serial port
avrdude: jtag3_recv():
avrdude: usbdev_recv_frame(): usb_bulk_read():
avrdude: jtag3_recv(): Timeout receiving packet

avrdude: sign-on command: timeout/error communicating with programmer (status -1)
avrdude: failed to sync with the JTAGICE3 in ISP mode

avrdude done.  Thank you.

*** [program] Error 1
=================================================================================== [FAILED] Took 2.20 seconds ===================================================================================

Using WinUSB driver I get the same error as previously, the device with matching PID and VID is not found.

Well that’s at least some progress, it now finds the programmer. Can you try upload_protocol = xplainedmini_dw now? Are there any other USB devices related to mEDBG available in Zadig?

1 Like

Success! Thanks so much for your help Max!

You were right, there was also mEDBG CMSIS-DAP (Interface 0) in Zadig, changing the driver of this to libusb-win32 and using upload_protocol = xplainedmini worked!

1 Like