書き込みアプリケーション avrdudeを実行します
sudo avrdude -p m88 -c usbasp -P usb
-p m88 デバイスはatmega88pa
-c usbasp 書き込み器はusbasp
-P usb インターフェイスはUSB経由
usbaspを接続しないで実行すると
sudo avrdude -p m88 -c usbasp -P usb
avrdude: error: could not find USB device "USBasp" with vid=0x16c0 pid=0x5dc
avrdude done. Thank you.
って、怒られます^^
usbaspを接続して再実行
sudo avrdude -p m88 -c usbasp -P usb
avrdude: Warning: Found USB device "USBasp" with old VID/PID! Please update firmware of USBasp!
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: error: programm enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.
avrdude done. Thank you.
フォームウェアのアップデートが必要ですっていわれます
これは、のちに更新します
ターゲットケーブルがおかしいですよ っていられます
ターゲットに接続します。
ーFコマンドが必要みたいです。
ということで、マイコンに接続して、最後コマンドを発行してみます
sudo avrdude -p m88 -c usbasp -P usb
avrdude: Warning: Found USB device "USBasp" with old VID/PID! Please update firmware of USBasp!
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 = 0x1e930f
avrdude: Expected signature for ATMEGA88 is 1E 93 0A
Double check chip, or use -F to override this check.
avrdude done. Thank you.
マイコンの接続はできたみたいです。
コンパイルしてできた hexファイルを書き込んでみましょう
sudo avrdude -v -p m88 -c usbasp -P usb -F -e -U flash:w:led_test.hex
コマンドが増えてます
-F このフラグがないと書き込みできません
-e イレーズします
-U flash:w:led_test.hex led_test.hexをフラッシュメモリ領域に書き込みます
avrdude: Version 5.11.1, compiled on Oct 30 2011 at 10:41:10
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch
System wide configuration file is "/etc/avrdude.conf"
User configuration file is "/home/rika/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port : usb
Using Programmer : usbasp
avrdude: Warning: Found USB device "USBasp" with old VID/PID! Please update firmware of USBasp!
AVR Part : ATMEGA88
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 512 4 0 3600 3600 0xff 0xff
flash 65 6 64 0 yes 8192 64 128 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : usbasp
Description : USBasp, http://www.fischl.de/usbasp/
avrdude: auto set sck period (because given equals null)
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 = 0x1e930f
avrdude: Expected signature for ATMEGA88 is 1E 93 0A
avrdude: safemode: lfuse reads as 62
avrdude: safemode: hfuse reads as DF
avrdude: safemode: efuse reads as 1
avrdude: erasing chip
avrdude: auto set sck period (because given equals null)
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: reading input file "led_test.hex"
avrdude: input file led_test.hex auto detected as Intel Hex
avrdude: writing flash (176 bytes):
Writing | ################################################## | 100% 0.72s
avrdude: 176 bytes of flash written
avrdude: verifying flash memory against led_test.hex:
avrdude: load data flash data from input file led_test.hex:
avrdude: input file led_test.hex auto detected as Intel Hex
avrdude: input file led_test.hex contains 176 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.44s
avrdude: verifying ...
avrdude: 176 bytes of flash verified
avrdude: safemode: lfuse reads as 62
avrdude: safemode: hfuse reads as DF
avrdude: safemode: efuse reads as 1
avrdude: safemode: Fuses OK
avrdude done. Thank you.
書き込みが終了すると、リセットが解除されて、LEDが点滅します。