以arduino Uno當isp,接線方式請參閱coopermaa大的把 Arduino 當成一個 AVR ISP(In-System Programmer) 使用(2)
avr的fuse設定查詢http://www.engbedded.com/fusecalc/
①讀取ATmega8之hfuse,lfuse
avrdude -c avrisp -b 19200 -p ATmega8 -P /dev/ttyACM0 -U hfuse:r:-:h -U lfuse:r:-:h
-P後加的是arduino接電腦的com port位置,所以要視情況調整。
執行結果如下:
avrdude: AVR device initialized and ready to accept instructions Reading | ################################################## | 100% 0.06s avrdude: Device signature = 0x1e9307 avrdude: reading hfuse memory: Reading | ################################################## | 100% 0.02s avrdude: writing output file "<stdout>" 0xca avrdude: reading lfuse memory: Reading | ################################################## | 100% 0.02s avrdude: writing output file "<stdout>" 0xdf avrdude: safemode: Fuses OK avrdude done. Thank you.
所以hfuse是Oxca,lfuse是0xdf
②
avrdude -c avrisp -b 19200 -p ATmega8 -P /dev/ttyACM0 -v
結果顯示如下
avrdude: Version 5.10, compiled on Jun 27 2010 at 00:38:29 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 "/root/.avrduderc" User configuration file does not exist or is not a regular file, skipping Using Port : /dev/ttyACM0 Using Programmer : avrisp Overriding Baud Rate : 19200 AVR Part : ATMEGA8 Chip Erase delay : 10000 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 4 20 128 0 no 512 4 0 9000 9000 0xff 0xff flash 33 10 64 0 yes 8192 64 128 4500 4500 0xff 0x00 lfuse 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00 hfuse 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00 lock 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00 calibration 0 0 0 0 no 4 0 0 0 0 0x00 0x00 signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00 Programmer Type : STK500 Description : Atmel AVR ISP Hardware Version: 2 Firmware Version: 1.18 Topcard : Unknown Vtarget : 0.0 V Varef : 0.0 V Oscillator : Off SCK period : 0.1 us avrdude: AVR device initialized and ready to accept instructions Reading | ################################################## | 100% 0.06s avrdude: Device signature = 0x1e9307 avrdude: safemode: lfuse reads as DF avrdude: safemode: hfuse reads as CA avrdude: safemode: lfuse reads as DF avrdude: safemode: hfuse reads as CA avrdude: safemode: Fuses OK avrdude done. Thank you.
③寫入fuse,下列這行指令會將atmega8的lfuse設為0xe4,hfuse設為0xd9
avrdude -c avrisp -b 19200 -p ATmega8 -P /dev/ttyACM0 -U lfuse:w:0xe4:m -U hfuse:w:0xd9:m
avrdude: AVR device initialized and ready to accept instructions Reading | ################################################## | 100% 0.06s avrdude: Device signature = 0x1e9307 avrdude: reading input file "0xe4" avrdude: writing lfuse (1 bytes): Writing | ################################################## | 100% 0.06s avrdude: 1 bytes of lfuse written avrdude: verifying lfuse memory against 0xe4: avrdude: load data lfuse data from input file 0xe4: avrdude: input file 0xe4 contains 1 bytes avrdude: reading on-chip lfuse data: Reading | ################################################## | 100% 0.02s avrdude: verifying ... avrdude: 1 bytes of lfuse verified avrdude: reading input file "0xd9" avrdude: writing hfuse (1 bytes): Writing | ################################################## | 100% 0.06s avrdude: 1 bytes of hfuse written avrdude: verifying hfuse memory against 0xd9: avrdude: load data hfuse data from input file 0xd9: avrdude: input file 0xd9 contains 1 bytes avrdude: reading on-chip hfuse data: Reading | ################################################## | 100% 0.02s avrdude: verifying ... avrdude: 1 bytes of hfuse verified avrdude: safemode: Fuses OK avrdude done. Thank you.
O