PlatformIO Community

Upload code to ATMEGA64 using JtagICE MKII on custom board

Is it possbible to upload my code to the microcontroller using JTAG pins and a JtagICE MK II? I have a custom board I made and I use this tool to debug and write on it when using AS7 on baremetal. I’m giving Arduino a try and I really don’t know how to upload my code.

Yes, since the used upload program avrdude supports the JtagIce MKII (source), and PlatformIO is fully configurable, you should be able to upload the code to the MCU through this programmer (using the ICSP/SPI connections of your ATMega64).

One can also use avarice to setup debugging, though this curently requires you to obtain and compile avarice yourself.

As a first step, you should use the platformio.ini

[env:ATmega64]
platform = atmelavr
board = ATmega64
framework = arduino
upload_protocol = custom
upload_flags =
    -C
    ${platformio.packages_dir}/tool-avrdude/avrdude.conf
    -p
    $BOARD_MCU
    -c
    jtag2isp
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i

and we’ll see how it goes from there when you try to upload.

1 Like

It worked very well. I had to change jtag2isp to jtag2 since I’m using JTAG and not ISP. For further use, if someone is having trouble with avrdude not being able to detect the programmer on USB port I would recommend to use Zadig and change the driver to libusb-win32.

1 Like