参考URL
http://arms22.blog91.fc2.com/blog-entry-286.html
http://zampoh.cocolog-nifty.com/blog/2009/03/arduino---atmeg.html
環境
Mac mini G4 OSX10.4.11
Arduino Duemilanove (FTDI BitBang mode用ピンヘッダ追加)
使用するAVRチップ
ATmega328P-PU
使用するソフトウェア
D2XX Direct Drivers
http://www.ftdichip.com/Drivers/D2XX/MacOSX/UniBin/Universal%20D2XX0.1.6.dmg
avrdude-serjtag04e
http://nmj.sumomo.ne.jp/suz-avr/serjtag/avrdude-serjtag04e.zip
avrdude-5.8
http://ftp.twaren.net/Unix/NonGNU/avrdude/avrdude-5.8.tar.gz
D2XXドライバーをインストールしておく。詳細はダウンロードしたファイルに書いてあるはず。
serjtag 0.4とavrdude 5.8をダウンロードし、適当なフォルダに解凍する。
cd avrdude-5.8
patch -p1 < ../avrdude-serjtag04e/src/avrdude-5.8-serjtag.patch
patch -p1 < ../avrdude-serjtag04e/src/avrdude-5.8-ft245r.patch
patch -p1 < ../avrdude-serjtag04e/src/avrdude-5.8-conf.patch./configure CFLAGS="-g -O2 -DSUPPORT_FT245R" LIBS="-lftd2xx"
make
sudo make install
Arduino0018.app/Contents/Resources/Java/hardware/bootloaders/atmega/ATmegaBOOT_168_atmega328.hex
または
ArduinoJ.app/Contents/Resources/Java/hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_atmega328.hex
をavrdudeと同じフォルダにコピーしておく。
FTDIドライバをアンロード
sudo kextunload /System/Library/Extensions/FTDIUSBSerialDriver.kext
Arduinoに生のAtmega328P-PUを刺し、X3とICSPを繋ぐ。(繋ぎ方は参考ページ参照)
ブートローダの書き込み
avrdude -c diecimila -P ft0 -p m328 -B 4800 -U efuse:w:0×05:m -U hfuse:w:0xda:m -U lfuse:w:0xff:m
avrdude -c diecimila -P ft0 -p m328 -U flash:w:"ATmegaBOOT_168_atmega328.hex":i
avrdude -c diecimila -P ft0 -p m328 -U lock:w:0x0f:m
使用しているのはDuemilanoveだが、FTDIの仕様が同じなので実質的には同等なはず。
FTDIドライバをロード
sudo kextload /System/Library/Extensions/FTDIUSBSerialDriver.kext
以上。
実際の表示はこんな感じ。
kkuro$ avrdude -c diecimila -P ft0 -p m328p -B 4800 -U efuse:w:0x05:m -U hfuse:w:0xda:m -U lfuse:w:0xff:m
avrdude: BitBang OK
avrdude: pin assign miso 3 sck 5 mosi 6 reset 7
avrdude: drain OKft245r: bitclk 4800 -> ft baud 2400
avrdude: AVR device initialized and ready to accept instructionsReading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e950f
avrdude: reading input file "0x05"
avrdude: writing efuse (1 bytes):Writing | ################################################## | 100% 0.07s
avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0x05:
avrdude: load data efuse data from input file 0x05:
avrdude: input file 0x05 contains 1 bytes
avrdude: reading on-chip efuse data:Reading | ################################################## | 100% 0.03s
avrdude: verifying ...
avrdude: 1 bytes of efuse verified
avrdude: reading input file "0xda"
avrdude: writing hfuse (1 bytes):Writing | ################################################## | 100% 0.06s
avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xda:
avrdude: load data hfuse data from input file 0xda:
avrdude: input file 0xda contains 1 bytes
avrdude: reading on-chip hfuse data:Reading | ################################################## | 100% 0.02s
avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xff"
avrdude: writing lfuse (1 bytes):Writing | ################################################## | 100% 0.08s
avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xff:
avrdude: load data lfuse data from input file 0xff:
avrdude: input file 0xff contains 1 bytes
avrdude: reading on-chip lfuse data:Reading | ################################################## | 100% 0.03s
avrdude: verifying ...
avrdude: 1 bytes of lfuse verifiedavrdude: safemode: Fuses OK
avrdude done. Thank you.
kkuro$ avrdude -c diecimila -P ft0 -p m328p -U flash:w:"ATmegaBOOT_168_atmega328.hex":i
avrdude: BitBang OK
avrdude: pin assign miso 3 sck 5 mosi 6 reset 7
avrdude: drain OKft245r: bitclk 230400 -> ft baud 115200
avrdude: AVR device initialized and ready to accept instructionsReading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e950f
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
ft245r: bitclk 230400 -> ft baud 115200
avrdude: reading input file "ATmegaBOOT_168_atmega328.hex"
avrdude: can't open input file ATmegaBOOT_168_atmega328.hex: No such file or directory
avrdude: write to file 'ATmegaBOOT_168_atmega328.hex' failedavrdude: safemode: Fuses OK
avrdude done. Thank you.
kkuro$ avrdude -c diecimila -P ft0 -p m328p -U flash:w:"ATmegaBOOT_168_atmega328.hex":i
avrdude: BitBang OK
avrdude: pin assign miso 3 sck 5 mosi 6 reset 7
avrdude: drain OKft245r: bitclk 230400 -> ft baud 115200
avrdude: AVR device initialized and ready to accept instructionsReading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e950f
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
ft245r: bitclk 230400 -> ft baud 115200
avrdude: reading input file "ATmegaBOOT_168_atmega328.hex"
avrdude: can't open input file ATmegaBOOT_168_atmega328.hex: No such file or directory
avrdude: write to file 'ATmegaBOOT_168_atmega328.hex' failedavrdude: safemode: Fuses OK
avrdude done. Thank you.
p6118-ipngn100103tokaisakaetozai:~/avrdude-serjtag04e/avrdude-5.8 kkuro$ avrdude -c diecimila -P ft0 -p m328p -U flash:w:"ATmegaBOOT_168_atmega328.hex":i
avrdude: BitBang OK
avrdude: pin assign miso 3 sck 5 mosi 6 reset 7
avrdude: drain OKft245r: bitclk 230400 -> ft baud 115200
avrdude: AVR device initialized and ready to accept instructionsReading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e950f
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
ft245r: bitclk 230400 -> ft baud 115200
avrdude: reading input file "ATmegaBOOT_168_atmega328.hex"
avrdude: writing flash (32670 bytes):Writing | ################################################## | 100% 19.88s
avrdude: 32670 bytes of flash written
avrdude: verifying flash memory against ATmegaBOOT_168_atmega328.hex:
avrdude: load data flash data from input file ATmegaBOOT_168_atmega328.hex:
avrdude: input file ATmegaBOOT_168_atmega328.hex contains 32670 bytes
avrdude: reading on-chip flash data:Reading | ################################################## | 100% 10.05s
avrdude: verifying ...
avrdude: 32670 bytes of flash verifiedavrdude: safemode: Fuses OK
avrdude done. Thank you.
kkuro$ avrdude -c diecimila -P ft0 -p m328p -U lock:w:0x0f:m
avrdude: BitBang OK
avrdude: pin assign miso 3 sck 5 mosi 6 reset 7
avrdude: drain OKft245r: bitclk 230400 -> ft baud 115200
avrdude: AVR device initialized and ready to accept instructionsReading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e950f
avrdude: reading input file "0x0f"
avrdude: writing lock (1 bytes):Writing | ################################################## | 100% 0.05s
avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x0f:
avrdude: load data lock data from input file 0x0f:
avrdude: input file 0x0f contains 1 bytes
avrdude: reading on-chip lock data:Reading | ################################################## | 100% 0.02s
avrdude: verifying ...
avrdude: 1 bytes of lock verifiedavrdude: safemode: Fuses OK
avrdude done. Thank you.