工作环境:win10 64bit, AVRDUDE.exe, 便宜的USBasp下载器
目的: 使用命令行下载hex到ATMEGA2560;
下载AVRDUDE, 在该网络链接:http://download.savannah.gnu.org/releases/avrdude/; 下载到文件 avrdude-6.3-mingw32.zip, 解压后得到avrdude.conf与avrdude.exe。
方法1:通过USBasp,下载stk500boot_v2_mega2560.hex到atmega2560芯片。
命令行如下:
avrdude.exe -C avrdude.conf -v -p atmega2560 -c usbasp -P usb -D -U flash:w:stk500boot_v2_mega2560.hex:i
avrdude.exe -C avrdude.conf -v -p atmega2560 -c usbasp -P usb -e -U lock:w:0x3F:m -U efuse:w:0xFD:m -U hfuse:w:0xD8:m -U lfuse:w:0xFF:m -D -U flash:w:stk500boot_v2_mega2560.hex:i
可以看到命令的执行过程和结果:
avrdude.exe: Version 6.3, compiled on Feb 17 2016 at 09:25:53
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "avrdude.conf"
Using Port : usb
Using Programmer : usbasp
AVR Part : ATmega2560
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PA0
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 10 8 0 no 4096 8 0 9000 9000 0x00 0x00
flash 65 10 256 0 yes 262144 256 1024 4500 4500 0x00 0x00
lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
lock 0 0 0 0 no 1 0 0 9000 9000 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.exe: auto set sck period (because given equals null)
avrdude.exe: warning: cannot set sck period. please check for usbasp firmware update.
avrdude.exe: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.02s
avrdude.exe: Device signature = 0x1e9801 (probably m2560)
avrdude.exe: safemode: hfuse reads as D8
avrdude.exe: safemode: efuse reads as FD
avrdude.exe: reading input file "stk500boot_v2_mega2560.hex"
avrdude.exe: writing flash (261406 bytes):
Writing | ################################################## | 100% 0.12s
avrdude.exe: 261406 bytes of flash written
avrdude.exe: verifying flash memory against stk500boot_v2_mega2560.hex:
avrdude.exe: load data flash data from input file stk500boot_v2_mega2560.hex:
avrdude.exe: input file stk500boot_v2_mega2560.hex contains 261406 bytes
avrdude.exe: reading on-chip flash data:
Reading | ################################################## | 100% 0.10s
avrdude.exe: verifying ...
avrdude.exe: 261406 bytes of flash verified
avrdude.exe: safemode: hfuse reads as D8
avrdude.exe: safemode: efuse reads as FD
avrdude.exe: safemode: Fuses OK (E:FD, H:D8, L:FF)
avrdude.exe done. Thank you.
方法2:通过串口COM1,就下载test.hex到atmega2560芯片(前提stk500boot_v2_mega2560.hex已经下载成功)。
avrdude.exe -C avrdude.conf -v -p atmega2560 -c wiring -P COM1 -b 115200 -D -U flash:w:test.hex:i