avrdude /w linux, using AVRISP mkII

I am developing Arduino with platform.io.

There is one problem.

platform.io does not support bootloader writing. (Maybe)

I do not think it is best to use the arduino IDE for this purpose only.

I connect avrisp mkII and arduino leonardo and try accessing from raspberry pi with avrdude.

Using avrdude attached to the arduino IDE built for raspberry pi.

type this.

$cd /opt/arduino-1.6.12/hardware/tools/avr/bin

$sudo ./avrdude -c avrisp2 usb -p m32u4 -C /opt/arduino-1.6.12/hardware/arduino/avr/bootloaders/gemma/avrdude.conf

output

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.10s

avrdude: Device signature = 0x1e9587 (probably m32u4)

avrdude: safemode: Fuses OK (E:CB, H:D8, L:FF)

avrdude done. Thank you.

Apparently it seems to be going well.

Ok.

First I will write the sketch HEX.

I confirm fuse.

This is described in boards.txt.

low_fuses=0xff

high_fuses=0xd8

extended_fuses=0xcb

Hmm.

Apparently it looks like it matches the content displayed when connecting to the trial.

Also, this too.

unlock_bits=0x3F

lock_bits=0x2F

I made a script because the command has been lengthened.

#!/bin/bash

sudo /opt/arduino-1.6.12/hardware/tools/avr/bin/avrdude \

-b 19200 \

-c avrisp2 usb \

-p m32u4 \

-C /opt/arduino-1.6.12/hardware/arduino/avr/bootloaders/gemma/avrdude.conf \

-v -e -U efuse:w:0xCB:m -U hfuse:w:0xD8:m -U lfuse:w:0xFF:m

sudo /opt/arduino-1.6.12/hardware/tools/avr/bin/avrdude \

-b 19200 \

-c avrisp2 usb \

-p m32u4 \

-C /opt/arduino-1.6.12/hardware/arduino/avr/bootloaders/gemma/avrdude.conf \

-v -e -U flash:w:firmware.hex \

-U lock:w:0x2F:m

Well ... Will it work?

... It takes more time than I thought.

finish! Alright, writing seems to be going well.

However, writing sketch HEX in this way makes it impossible to write sketches in the usual way.

Next.

Write bootloader.

Probably in the same way.

Write bootloader.hex instead of firmware.hex.

I think that I will go well with this.

Partial change.

When firmware.hex is written, the lock bit is set, so change to unlock. Also, please specify bootloader.hex instead of firmware.hex.

#!/bin/bash

sudo /opt/arduino-1.6.12/hardware/tools/avr/bin/avrdude \

-b 19200 \

-c avrisp2 usb \

-p m32u4 \

-C /opt/arduino-1.6.12/hardware/arduino/avr/bootloaders/gemma/avrdude.conf \

-v -e -U efuse:w:0xCB:m -U hfuse:w:0xD8:m -U lfuse:w:0xFF:m -U lock:w:0x3F:m

sudo /opt/arduino-1.6.12/hardware/tools/avr/bin/avrdude \

-b 19200 \

-c avrisp2 usb \

-p m32u4 \

-C /opt/arduino-1.6.12/hardware/arduino/avr/bootloaders/gemma/avrdude.conf \

-v -e -U flash:w:bootloader.hex \

-U lock:w:0x2F:m

Anyway it takes time...

I will keep on waiting. Wait, wait, wait ...

I think. It is more comfortable to use "arduino as isp".

...zzz

Well!

I confirmed that I can write sketches in the usual way.

Continue...