Replacing arduino bootloader

Posted at 2014-09-09.

I overwrote the bootloader on a Pro Mini. I wanted to see if I can replace that.

I downloaded the package linked and looked around. It seemed the 168 version might work, depending on the oscillator. I used testing hooks to wire up an USBAsp and used avrdude to flash the chip:

% avrdude -p m168p -c usbasp -U flash:w:ADABoot_168.hex

avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e940b
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: reading input file "ADABoot_168.hex"
avrdude: input file ADABoot_168.hex auto detected as Intel Hex
avrdude: writing flash (16358 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 16358 bytes of flash written
avrdude: verifying flash memory against ADABoot_168.hex:
avrdude: load data flash data from input file ADABoot_168.hex:
avrdude: input file ADABoot_168.hex auto detected as Intel Hex
avrdude: input file ADABoot_168.hex contains 16358 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 16358 bytes of flash verified

avrdude: safemode: Fuses OK (E:00, H:DD, L:FF)

avrdude done.  Thank you.

Then I pulled the wires and used (another set of) hooks to wire in a CP2102 bridge.

% avrdude -p m168 -c arduino -P /dev/ttyUSB0 -b 19200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9406

avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done.  Thank you.

% avrdude -p m168 -c arduino -P /dev/ttyUSB0 -b 19200

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9406

avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done.  Thank you.

Looks nice and seems to work at 19200. The sync messages come from me missing the manual reset. I should try some firmware:

% avrdude -p m168 -c arduino -P /dev/ttyUSB0 -b 19200 -U flash:w:myproject.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9406
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "myproject.hex"
avrdude: input file myproject.hex auto detected as Intel Hex
avrdude: writing flash (350 bytes):

Writing | ################################################## | 100% 0.26s

avrdude: 350 bytes of flash written
avrdude: verifying flash memory against myproject.hex:
avrdude: load data flash data from input file myproject.hex:
avrdude: input file myproject.hex auto detected as Intel Hex
avrdude: input file myproject.hex contains 350 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.23s

avrdude: verifying ...
avrdude: 350 bytes of flash verified

avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done.  Thank you.

A dumb blinker that seems to run. I expanded it to print some characters to UART instead of lights. Apart from having to shuffle between avrdude and picocom for the tty, it seems to work nice as well.