Arduino IDE and Atmel ICE programmer in ICSP mode

I am trying to use an Atmel ICE programmer and the Arduino IDE (version 1.8.13) to flash a bootloader onto a board via the ICSP header. The board is a Prusa 3d printer MMU board which has an ATmega32U chip on it and instructions from Prusa are to add their board definitions into the Arduino IDE, connect the programmer, and use the Tools->Burn bootloader command. However, they assume that the programmer is a usbasp, USBtiny, or an Arduino as ISP. I happen to own an Atmel-ICE.

I believe the hardware connections are all correct, I'm getting the correct LEDs from the ICE (left is green, showing target power is ok, middle is red, showing programmer power is ok, right is off, since the chip isn't running).

In the tools menu of the IDE, I have selected the correct board, under Programmer I have "Atmel-ICE (AVR)", and nothing in the Ports section, as it appears that this programmer doesn't create a serial port to attach to (in Windows device manager it appears under "Microchip Tools" as "Atmel-ICE Data Gateway", but not as a COM port).

However, the flashing itself fails. The error message is very long, so rather than posting it here in full I put it into a pastebin: Arduino: 1.8.13 (Windows 10), Board: "Original Prusa i3 MK3 Multi Material 2.0 u - Pastebin.com

From the looks of it, it seems that it is trying to program in JTAG mode, which is not supported by this board, it has to be done in ICSP mode. I don't see how the programmer mode can be selected in the Arduino IDE. I tried selecting other programmers, like the "Atmel JTAGICE3 (ISP mode)" but those fail in other ways - generally with just a "device not found"-type error. I know that I can change the mode between ICSP and JTAG in Atmel Studio, but I haven't found a way to do it in Arduino IDE.

Any advice would be appreciated,

Juliean.

If you have Atmel Studio already installed, why not just compile it in Arduino IDE, and burn it using Atmel Studio

The compiled binary in Arduino is usually inside the user directory under AppData/Local/Temp/

You can find the actual location of the binary from the compilation window of Arduino IDE, towards the last few lines

I’m not really compiling anything in Arduino, at least not that I can tell, just clicking “Burn Bootloader”. Does that trigger compiling something behind the scenes? Not really sure how it works. If I can get the hex file out of it, I can definitely burn it with Atmel Studio.

Looking in %appdata%/local/temp, I’m not seeing any .hex files, or any other files recognizable to me as a burnable binary.

It's a folder inside the temp directory

Here's an example

C:\Users\hzrnb\AppData\Local\Temp*arduino_build_10789*

The folder name is random but it shows at the end of the compilation window

The bootloader file is probably somehwre in the Arduino folder directory

The error message is very long, so rather than posting it here in full I put it into a pastebin: Arduino: 1.8.13 (Windows 10), Board: "Original Prusa i3 MK3 Multi Material 2.0 u - Pastebin.com

Unfortunately, it's not "long enough" and is missing the avrdude command and info at the beginning of the burn attempt.
When I try to burn an AVR bootloader through my Atmel ICE, I get this:

/Applications/Arduino-1.8.12.app/Contents/Java/portable/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude -C/Applications/Arduino-1.8.12.app/Contents/Java/portable/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf -v -patmega32u4[b] -catmelice_isp[/b] -Pusb -e -Ulock:w:0x3F:m -Uefuse:w:0xcb:m -Uhfuse:w:0xd8:m -Ulfuse:w:0xff:m 

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/Applications/Arduino-1.8.12.app/Contents/Java/portable/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf"
         User configuration file is "/Volumes/MacOS/HD-Users/BillW/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : usb
         Using Programmer              [color=red][b]: atmelice_isp[/b][/color]
avrdude: usbhid_open(): No device found
avrdude: usbdev_open(): Found Atmel-ICE CMSIS-DAP, serno: J41800069697
avrdude: Found CMSIS-DAP compliant device, using EDBG protocol
         AVR Part                      : ATmega32U4
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
    :
         Programmer Type : JTAG3_ISP
         Description     : Atmel-ICE (ARM/AVR) in ISP mode
         Vtarget         : 3.3 V
         SCK period      : 1.00 us

avrdude: stk500v2_command(): command failed
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.

Error while burning bootloader.

(The errors are rather expected in this case, since the ICE is currently connected to a SAMD chip! But you can see it specifically requesting ISP mode.)