Burn MegaCore Bootloader through Atmel ICE (AVR)

Hi

I am trying to burn MegaCore ATmega2560 bootloader on my board with the following settings:

  • BOD: 2.7V
  • Pinout: AVR pinout
  • Clock: 20MHz external
  • Compiler LTO: Disabled
  • Programmer: Atmel-ICE (AVR)

I have already downloaded the MegaCore files to my “~/Documents/Arduino/hardware” folder, and changed the resonator from 16MHz to 20MHz. However, when I click on Burn Bootloader I get the following error message (I have deleted the directories in front of each line):

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is “***/avrdude.conf”

avrdude: Can’t find programmer id “atmelice_isp”

Valid programmers are:
2232HIO = FT2232H based generic programmer
4232h = FT4232H based generic programmer
arduino = Arduino
arduino-ft232r = Arduino: FT232R connected to ISP
arduinoisp =
avr109 = Atmel AppNote AVR109 Boot Loader
avr910 = Atmel Low Cost Serial Programmer
avr911 = Atmel AppNote AVR911 AVROSP
avrftdi = FT2232D based generic programmer
avrisp = Atmel AVR ISP
avrisp2 = Atmel AVR ISP mkII
avrispmkII = Atmel AVR ISP mkII
avrispv2 = Atmel AVR ISP V2
buspirate = The Bus Pirate
buspirate_bb = The Bus Pirate (bitbang interface, supports TPI)
butterfly = Atmel Butterfly Development Board
butterfly_mk = Mikrokopter.de Butterfly
bwmega = BitWizard ftdi_atmega builtin programmer
c2n232i = serial port banging, reset=dtr sck=!rts mosi=!txd miso=!cts
dasa = serial port banging, reset=rts sck=dtr mosi=txd miso=cts
dasa3 = serial port banging, reset=!dtr sck=rts mosi=txd miso=cts
diecimila = alias for arduino-ft232r
dragon_dw = Atmel AVR Dragon in debugWire mode
dragon_hvsp = Atmel AVR Dragon in HVSP mode
dragon_isp = Atmel AVR Dragon in ISP mode
dragon_jtag = Atmel AVR Dragon in JTAG mode
dragon_pdi = Atmel AVR Dragon in PDI mode
dragon_pp = Atmel AVR Dragon in PP mode
ft232r = FT232R Synchronous BitBang
ft245r = FT245R Synchronous BitBang
jtag1 = Atmel JTAG ICE (mkI)
jtag1slow = Atmel JTAG ICE (mkI)
jtag2 = Atmel JTAG ICE mkII
jtag2avr32 = Atmel JTAG ICE mkII im AVR32 mode
jtag2dw = Atmel JTAG ICE mkII in debugWire mode
jtag2fast = Atmel JTAG ICE mkII
jtag2isp = Atmel JTAG ICE mkII in ISP mode
jtag2pdi = Atmel JTAG ICE mkII PDI mode
jtag2slow = Atmel JTAG ICE mkII
jtag3 = Atmel AVR JTAGICE3 in JTAG mode
jtag3dw = Atmel AVR JTAGICE3 in debugWIRE mode
jtag3isp = Atmel AVR JTAGICE3 in ISP mode
jtag3pdi = Atmel AVR JTAGICE3 in PDI mode
jtagkey = Amontec JTAGKey, JTAGKey-Tiny and JTAGKey2
jtagmkI = Atmel JTAG ICE (mkI)
jtagmkII = Atmel JTAG ICE mkII
jtagmkII_avr32 = Atmel JTAG ICE mkII im AVR32 mode
lm3s811 = Luminary Micro LM3S811 Eval Board (Rev. A)
mib510 = Crossbow MIB510 programming board
mkbutterfly = Mikrokopter.de Butterfly
nibobee = NIBObee
o-link = O-Link, OpenJTAG from www.100ask.net
openmoko = Openmoko debug board (v3)
pavr = Jason Kyle’s pAVR Serial Programmer
pickit2 = MicroChip’s PICkit2 Programmer
ponyser = design ponyprog serial, reset=!txd sck=rts mosi=dtr miso=cts
siprog = Lancos SI-Prog http://www.lancos.com/siprogsch.html
stk500 = Atmel STK500
stk500hvsp = Atmel STK500 V2 in high-voltage serial programming mode
stk500pp = Atmel STK500 V2 in parallel programming mode
stk500v1 = Atmel STK500 Version 1.x firmware
stk500v2 = Atmel STK500 Version 2.x firmware
stk600 = Atmel STK600
stk600hvsp = Atmel STK600 in high-voltage serial programming mode
stk600pp = Atmel STK600 in parallel programming mode
usbasp = USBasp, http://www.fischl.de/usbasp/
usbasp-clone = Any usbasp clone with correct VID/PID
usbtiny = USBtiny simple USB programmer, USBtinyISP - Inexpensive USB AVR Programmer
wiring = Wiring

Error while burning bootloader.

I have used Atmel ICE in Atmel Studio before, so I know my wiring is correct.

Does anybody know how can I use my Atmel ICE programmer to burn MegaCore bootloader on my board?

Thanks

The problem is that MegaCore is using an outdated avrdude.conf file that doesn’t have the programmer definition for the Atmel ICE programmer. Here’s how to fix it:

  • Open ~/Documents/Arduino/hardware/MegaCore/avr/avrdude.conf with a text editor
  • Add the following:
programmer
  id    = "atmelice_isp";
  desc  = "Atmel-ICE (ARM/AVR) in ISP mode";
  type  = "jtagice3_isp";
  connection_type = usb;
  usbpid = 0x2141;
;
  • Save the file.

After doing that you should be able to burn the bootloader.

1 Like

Thanks Pert.

I actually copied my Arudino IDE 1.8.1 avrdude.conf file and overwrote the avrdude.conf file in MegaCore folder. Now the error message is reduced down to the following:

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is “***/avrdude.conf”

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

avrdude done. Thank you.

Error while burning bootloader.

What am I doing wrong this time?!!!

markwright041: I actually copied my Arudino IDE 1.8.1 avrdude.conf file and overwrote the avrdude.conf file in MegaCore folder

That's where I got the Atmel-ICE programmer definition from. That should probably be fine. The reason that MCUdude includes avrdude.conf with his hardware packages is that for some reason the stock avrdude.conf is missing definitions for some microcontrollers and he has to add them. I'm not sure if that was actually the case for MegaCore specifically or if he just did it for consistency with his other cores. Certainly the ATmega2560 is defined in the stock avrdude.conf so that is no problem but it's possible one of the less common parts supported by MegaCore is missing.

markwright041: What am I doing wrong this time?!!!

I'm not sure, it's certainly progress. I get that same exact error when I try to burn bootloader using Atmel ICE (AVR) programmer with no ICE connected to my computer. I don't own an ICE so I don't know what it would do without.

Can you check the VID/PID of the ICE on your computer to make sure it matches the ones expected? I know you can do this via Device Manager in Windows. I'm not sure what the equivalent is for other operating systems.

It's possible it could be a driver issue. I seem to remember I got a similar error when I was trying to use my Atmel AVRISP mkII after installing the Jungo driver for it that is used by Atmel Studio. I had to install a different driver to get it working with AVRDUDE/Arduino.

pert:
Can you check the VID/PID of the ICE on your computer to make sure it matches the ones expected? I know you can do this via Device Manager in Windows. I’m not sure what the equivalent is for other operating systems.

So I found my Atmel ICE in Device Manager and it has exactly the same VID that Arduino expects but cannot find it!!!

Is it safe to do what rx8pilot did in this post?

OK, then look into the driver thing. That seems quite likely since you were previously using it with Atmel Studio. I think it's the libusb driver you need. Traditionally that was libusb-win32 but I've been using libusbK lately and it seems to be better. I use this program to install either: http://zadig.akeo.ie/ The way I ended up doing it was uninstalling Jungo and installing libusb so it's an either avrdude or Atmel Studio sort of thing but there is a way to allow both drivers to be installed and the correct one used for each program. It's explained here: http://www.avrfreaks.net/forum/atmel-ice-avrdude-cannot-find-device and you'll notice they had the same error message.

markwright041: Is it safe to do what rx8pilot did in this post?

I haven't done that because I had decided I didn't want to use Atmel Studio anymore because I was only using it for Visual Micro and didn't like it very much so I had no reason to keep the Jungo driver installed but if I was to be switching back and forth between AVRDUDE and Atmel Studio regularly I would definitely figure out how to do that filter thing.

Please let me know when you get MegaCore working with the Atmel ICE and I'll submit a pull request to get the definition added to the avrdude.conf on all his repositories in addition to an arduinoISP definition that's also missing. I'm sure it will work but I don't have the hardware to test so I'd rather have confirmation first.

I tired Zadig with both libusbK and libusb-win32, and they both produce the same results. Using either driver Arduino starts burning the bootloader, but shows a warning at the end!

avrdude: WARNING: invalid value for unused bits in fuse "lock", should be set to 1 according to datasheet This behaviour is deprecated and will result in an error in future version You probably want to use 0xcf instead of 0x0f (double check with your datasheet first).

Is that a serious warning, or can I ignore it?

That should be fine. AVRDUDE changed their handling of unused fuse bits in the 6.3 release, which was a big problem because it broke backwards compatibility with settings that previously worked. So Arduino patched it so that it would correctly handle the old values and print that warning message. It's possible that fix will eventually be dropped but when that happens we'll figure out how to make MegaCore handle it correctly.

I tried to upload a sketch and it didn't work! I am using an Adafruit FTDI Friend to upload sketches onto my board.

So I cut the trace to RTS and bridged DTR and added a 100n cap between it and Reset line. Also wired GND, VCC, RX, and TX according to the pinout diagram, but still cannot upload sketches, and board seems to be stuck in bootloader mode! I even swapped the RX,TX lines but still no luck.

Any idea why I cannot upload a sketch?

Thanks alot for your help.

Oh, never mind, I got it working. My bad. I thought I could change my board back to Arduino MEGA2560, and upload sketches like before, and that is why it wasn’t working.

I just kept my board same as MegaCore2560 with AVRISP mkII as my programmer, and everything works now.

Thanks alot Pert for your help. :slight_smile:

Glad to hear you are up and running. Enjoy!

I have submitted a pull request for adding Atmel-ICE programmer support to MegaCore: https://github.com/MCUdude/MegaCore/pull/59 as well as to the other MCUdude hardware packages.

Hello everyone, I'm in the same situation, I want to restore the bootloader of my Mega through the Atmel-ICE. I updated the IDE to 1.8.5 and I use AS7 without too much trouble. But unfortunately after selecting the Atmel-ICE ISPmode I have the following message:

Arduino: 1.8.5 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

avrdude: jtag3_open_common(): Did not find any device matching VID 0x03eb and PID list: 0x2110, 0x2140
Error while burning bootloader.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Verifying the card driver, however, I find that the VID 0x03eb and PID 0x2140 are correct. :o

I belive Avrdude can't recognize the Atmel ICE because of incorrect USB drivers. You can use Zadig to switch between libusb and winusb drivers.

Parallel discussion happening here: https://github.com/arduino/Arduino/issues/4368#issuecomment-387094130

@Simone72 if you're going to do that please add links to the other places you posted so we can avoid wasting time due to duplicate effort and also so others with the same problem can easily find all the relevant information.

I managed with Zadig to select a driver that allowed Avrdude to place the bootloader, the problem is to go back ... now AS7 fails to use the ICE Zadig does not do the reverse and Windows does not restore the right one ... what a mess! >:(

I want to keep AS7 in order to study it and make it debugging via JTAG, now I can not use the ICE.

@Pert I also asked the guys from Avrfreaks here