atmega328pb xplained mini with Arduino IDE 1.8.5 and USBasp

Hello All,

I got an atmega328pb xplained mini board and I am trying to connect it with the USBasp programmer but I am getting errors with the Arduino IDE 1.8.5 version.

The main problem is it is looking for a COM port but this board is powered by the USBasp, no USB cables attached to the board directly and therefor no COM ports available in the system.

If someone used this combination of atmega328pb xplained mini board + Arduino IDE + USBasp before, please let me know how can I overcome this issue?

Thanks.

When you encounter an error you'll see a button on the right side of the orange bar "Copy error messages". Click that button. Paste the error in a message here USING CODE TAGS (</> button on the toolbar).

Put that USBasp away, the atmega328pb xplained board clearly has an onboard ISP tool. You just need to figure out how it talks, and see if avrdude can do that.

so looking at avrdude.conf my best guess is the programmer with id = "xplainedmini"

But I do not see it in MiniCore. I do see "atmelice_isp"

Oh... both have type = "jtagice3_isp", so I think they work the same.

So you can install MiniCore

Flash its optiboot bootloader with that ISP tool and then bootload like a normal Arduino (I've not tried any of this so if I'm wrong then hopefully someone can tell the errors).

Thanks.

I really need to get the USBasp up and running as I would move to a custom board after testing with this EVB.

So anything other than USBasp is not in my interest.
:slight_smile:

Anytime you feel like posting the mysterious error message we can get started helping you.

Maybe I'm missing something obvious here, but when using an external programmer like the USBASP you should be using Sketch>Upload Using Programmer. There is no issue with any serial port then.

The 32U4 on the Xplained looks to have a JTAG port for programming. I wonder if the firmware it uses is available?
Who knows what the 32U4 does when the target reset (it is also the debug wire) pulls low, it might be best to hold the 32U4 in reset (jumper JTAG pin 6 to pin 10) and then see if the off-board ISP works.

The 32U4 has control of a power toggle which could be a problem for optiboot. The power may toggle when the serial port connects, and it is missing the DTR trick which I forget to look for, thus optiboot is not going to work on this board.

The main problem is it is looking for a COM port but this board is powered by the USBasp, no USB cables attached to the board directly and therefor no COM ports available in the system.

Do you have the IDE's "Programmer" setting set to "USBasp" and are you using the "Upload using programmer" option? That should NOT result in the IDE "looking for a COM port"
Check the Xplained user docs to see if there's a way to "turn off" the built-in programmer so that the USBasp and the mEDBG don't "fight" controlling the pins.

Thanks for the hint on "Upload using Programmer" that resolved looking for COM port but following error is new.

avrdude: error: program enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1

I am sure that the connections are correct as it is directly connecting to the ISP header on the EVB. And USBasp I've tested with a different arduino 1284 board and it is working perfectly as well.

Arduino: 1.8.5 (Windows 8), Board: "ATmega328, Yes, 328PB, Disabled, Disabled (default), 16 MHz external"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Lasa\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Lasa\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\arduino\arduino-sketchbook\libraries -fqbn=MiniCore:avr:328:bootloader=true,variant=modelPB,BOD=disabled,LTO=Os,clock=16MHz_external -ide-version=10805 -build-path C:\Users\Lasa\AppData\Local\Temp\arduino_build_221655 -warnings=none -build-cache C:\Users\Lasa\AppData\Local\Temp\arduino_cache_768164 -prefs=build.warn_data_percentage=75 -verbose C:\arduino\arduino-sketchbook\sketch_sep06a\sketch_sep06a.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Lasa\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Lasa\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\arduino\arduino-sketchbook\libraries -fqbn=MiniCore:avr:328:bootloader=true,variant=modelPB,BOD=disabled,LTO=Os,clock=16MHz_external -ide-version=10805 -build-path C:\Users\Lasa\AppData\Local\Temp\arduino_build_221655 -warnings=none -build-cache C:\Users\Lasa\AppData\Local\Temp\arduino_cache_768164 -prefs=build.warn_data_percentage=75 -verbose C:\arduino\arduino-sketchbook\sketch_sep06a\sketch_sep06a.ino
Using board '328' from platform in folder: C:\Users\Lasa\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1
Using core 'MCUdude_corefiles' from platform in folder: C:\Users\Lasa\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1
Detecting libraries used...
"C:\Users\Lasa\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\5.4.0-atmel3.6.1-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328pb -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_ATmega328 -DARDUINO_ARCH_AVR   "-IC:\Users\Lasa\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1\cores\MCUdude_corefiles" "-IC:\Users\Lasa\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1\variants\pb-variant" "C:\Users\Lasa\AppData\Local\Temp\arduino_build_221655\sketch\sketch_sep06a.ino.cpp" -o "nul"
Generating function prototypes...
"C:\Users\Lasa\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\5.4.0-atmel3.6.1-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -w -x c++ -E -CC -mmcu=atmega328pb -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_ATmega328 -DARDUINO_ARCH_AVR   "-IC:\Users\Lasa\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1\cores\MCUdude_corefiles" "-IC:\Users\Lasa\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1\variants\pb-variant" "C:\Users\Lasa\AppData\Local\Temp\arduino_build_221655\sketch\sketch_sep06a.ino.cpp" -o "C:\Users\Lasa\AppData\Local\Temp\arduino_build_221655\preproc\ctags_target_for_gcc_minus_e.cpp"
"C:\Program Files (x86)\Arduino\tools-builder\ctags\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\Users\Lasa\AppData\Local\Temp\arduino_build_221655\preproc\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\Users\Lasa\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\5.4.0-atmel3.6.1-arduino2/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328pb -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_ATmega328 -DARDUINO_ARCH_AVR   "-IC:\Users\Lasa\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1\cores\MCUdude_corefiles" "-IC:\Users\Lasa\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1\variants\pb-variant" "C:\Users\Lasa\AppData\Local\Temp\arduino_build_221655\sketch\sketch_sep06a.ino.cpp" -o "C:\Users\Lasa\AppData\Local\Temp\arduino_build_221655\sketch\sketch_sep06a.ino.cpp.o"
Compiling libraries...
Compiling core...
Archiving built core (caching) in: C:\Users\Lasa\AppData\Local\Temp\arduino_cache_768164\core\core_MiniCore_avr_328_bootloader_true,variant_modelPB,BOD_disabled,LTO_Os,clock_16MHz_external_4f3506bc6fc4d696e7d15199222e7bba.a
Linking everything together...
"C:\Users\Lasa\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\5.4.0-atmel3.6.1-arduino2/bin/avr-gcc" -w -Os -Wl,--gc-sections -mmcu=atmega328pb  -o "C:\Users\Lasa\AppData\Local\Temp\arduino_build_221655/sketch_sep06a.ino.elf" "C:\Users\Lasa\AppData\Local\Temp\arduino_build_221655\sketch\sketch_sep06a.ino.cpp.o" "C:\Users\Lasa\AppData\Local\Temp\arduino_build_221655/core\core.a" "-LC:\Users\Lasa\AppData\Local\Temp\arduino_build_221655" -lm
"C:\Users\Lasa\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\5.4.0-atmel3.6.1-arduino2/bin/avr-objcopy" -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0  "C:\Users\Lasa\AppData\Local\Temp\arduino_build_221655/sketch_sep06a.ino.elf" "C:\Users\Lasa\AppData\Local\Temp\arduino_build_221655/sketch_sep06a.ino.eep"
"C:\Users\Lasa\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\5.4.0-atmel3.6.1-arduino2/bin/avr-objcopy" -O ihex -R .eeprom  "C:\Users\Lasa\AppData\Local\Temp\arduino_build_221655/sketch_sep06a.ino.elf" "C:\Users\Lasa\AppData\Local\Temp\arduino_build_221655/sketch_sep06a.ino.hex"
Sketch uses 1062 bytes (3%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: error: program enable: target doesn't answer. 1 
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.
the selected serial port          Double check connections and try again, or use -F to override
 does not exist or your board is not connected

I've encountered a similar error message when using the USBasp with the libusb-win32 driver. I solved it by installing the libusbK driver:

  • Download Zadig from http://zadig.akeo.ie/
  • Plug the USBasp into your computer
  • Start Zadig
  • Options > List all devices
  • Select USBasp from the dropdown menu
  • Select libusbK
  • Click Install
  • Try again

Note that Zadig is even recommended on the official USBasp website.

I can confirm that my USBasp also using the libusbK.

ron_sutherland:
The 32U4 on the Xplained looks to have a JTAG port for programming. I wonder if the firmware it uses is available?

My memory is a bit hazy because it has been a while since I looked into it, but I am fairly sure that the mEDBG firmware is included with Atmel Studio.

ron_sutherland:
The 32U4 has control of a power toggle which could be a problem for optiboot. The power may toggle when the serial port connects, and it is missing the DTR trick which I forget to look for, thus optiboot is not going to work on this board.

I don't think you need to make any hardware changes. There is a section in the Xmini user guide which talks about using an external programmer:

Xmini_User_Guide:
Programming the Target Using an External Programmer
How to program the target ATmega328PB using the AVR JTAGICE mkII, JTAGICE3, Atmel-ICE, or other
programmers.

  1. Connect the External Programmer USB to the PC.
  2. Connect the External Programmer to the ATmega328PB Xplained Mini board ISP connector.
  3. Go to Atmel Studio: Click the Tools tab, select Device Programming, and select the External
    Programmer connected as Tool with Device as ATmega328PB and Interface to ISP, click Apply.
  4. Select "Memories", locate the source .hex or .elf file, and click Program

That obviously covers using the board with Atmel Studio, but it shows that you shouldn't need to make any hardware changes to use an external programmer.

I wonder if the firmware [mEdbg] uses is available?

In binary form: yes. If you run Atmel Stdio for long, you'll need to upgrade the firmware at some point, using a binaries that come with/via AS.
As for source code... probably not. Atmel is very closed-mouth about the details of the AVR debugging protocols...

After number of trials, my Xplained mini seems bricked. It can no longer detected by the Device Manager (or in AS I cannot see mEDBG interface drop down to connect to the EVB.

I am thinking the mEDBG driver might corrupted or something and I was trying with removing AS and reinstalling again with no luck.

I can see the initial sketch is still there on the 328PB (push switch toggles the LED) but there's no 32U4 status LED is not coming up at all.

I am also thinking whether this is stuck in a ENDW status register enabled, but cannot verify with either via AS (mEDBG) or USBasp.

Any idea what went wrong? or How to restore Xplained mini EVB?

After number of trials, my Xplained mini seems bricked.

Seems likely that something was powered off while something else was not. On the schematic of the Xplained Mini the debug wire has a 0 Ohm jumper that connects to some of the 32U4 pins (PE6 and PD4), so that area is at risk.