📍本论坛的相关烧录教程(通过一块Arduino UNO板作为ISP来烧录的)《为ATMega328pb芯片烧录Arduino bootloader》
📌USBasp个人相关内容《2018版USBASP烧录器改通用版教》
?本文是通过USBasp工具进行Bootloader烧录的。
?本文使用ATMega328PB-AU烧录bootloader作为研究测试对象。
👉烧录bootloader前提,必须要有一个AVR烧录器或者Arduino UNO/nano开发板。
ATMega328PB
芯片型号的支持包固件: ATMega328PB
支持包网址:https://files.pololu.com/arduino/package_pololu_index.json
https://mcudude.github.io/MiniCore/package_MCUdude_MiniCore_index.json
USBasp
进行代码上传。需要依赖bootloader
固件+串口,才能完成代码上传的工作。如果手上有AVR烧录器,那么可以通过AVR烧录器+烧录软件,完成程序烧录即可。趁目前
ATMega328PB-AU
主控芯片的价格比较便宜,购买了一片此型号芯片,刚刚完成ATMega328PB-AU
主控的开发板的设计,准备打板,先测试下一是否兼容Arduino nano开发板,于是将手上现有的Arduino nano板子上的32引脚TQFP封装的ATMega328P
更换了下来,换上ATMega328PB-AU
进行bootloader
烧录。
ATMega328PB
如果选择使用MiniCore
固件所提供的Bootloader
烧录文件,之后使用Arduino IDE程序上传都需要选择此类型的开发板的对应型号,并不能选择其他支持包下面的同型号芯片进行上传。主要是在Arduino IDE里面,采用不同支持包下的bootloader固件,调用的对象和执行的命令不相同导致。(MiniCore
支持包,在烧录时,调用的是自带支持包下面的对应的avrdude
,而pololu
调用的是Arduino IDE本地的avrdude
)"C:\Users\Administrator\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\7.2-arduino.1/bin/avrdude" "-CC:\Users\Administrator\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\3.0.1/avrdude.conf" -v -patmega328pb -curclock -PCOM9 -b9600 -D -xnometadata "-Ueeprom:w:C:\Users\Administrator\AppData\Local\Temp\arduino\sketches\D21CF4E415C37110D46815DADA9CBA76/Blink.ino.eep:i" "-Uflash:w:C:\Users\Administrator\AppData\Local\Temp\arduino\sketches\\D21CF4E415C37110D46815DADA9CBA76/Blink.ino.hex:i""
"C:\Users\Administrator\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\Administrator\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -patmega328pb -carduino "-PCOM9" -b115200 -D "-Uflash:w:C:\Users\Administrator\AppData\Local\Temp\arduino\sketches\D21CF4E415C37110D46815DADA9CBA76/Blink.ino.hex:i"
-👉 如果使用独立的烧录软件,通过加载编译好的Hex文件进行烧录不存在此问题。
USBasp slow
才行,这一点很关键!!!个人在选择USBasp
模式下,对从未使用过的新芯片,烧录了N多遍的失败经历,曾一度怀疑是不是芯片没有焊接好。
- 🔖在第一次选择
USBasp slow
模式下,烧录成功后,后面如果有需要再次烧录bootloader程序,可以直接选择USBasp
模式进行烧录。
USBasp slow
模式只有选择安装了MiniCore
固件下才有,pololu
固件不带,这一点需要注意!资料下载地址:http://pan.baidu.com/s/1i49UCOP
https://pan.baidu.com/s/1eTYTxp4
AVRDUDESS:下载地址:`https://github.com/ZakKemble/AVRDUDESS/releases
🌿AVRDUDESS
:下载地址:https://github.com/ZakKemble/AVRDUDESS/releases
🌿使用progisp软件,烧录Arduino IDE编译好的Hex文件。
🔖上面.eep为EEPROM文件,.hex为程序文件。分别通过调入Flash
和调入Eeprom
加载进来。
🌿如果想通过上面的软件顺便将带bootloader的文件烧录进去,可以选择类似Blink.ino.with_bootloader.hex
名称的合并文件。(bootloader和程序合并文件)
- 👉如果烧录了带
bootloader
程序文件,后面可以直接通过Arduino IDE,配置号串口,编程器选择AVRISP mkll
进行程序上传。
ATMega328PB
开发板。https://mcudude.github.io/MiniCore/package_MCUdude_MiniCore_index.json
https://files.pololu.com/arduino/package_pololu_index.json
👉如果对新的芯片首次进行烧录,那么推荐先选择用
MiniCore
固件,选择对应的单片机型号,进行烧录,因为可以选择USBasp slow
慢速模式。
328
,找到MiniCore
固件进行安装。1.8.1.x
版本或者使用2.2.x
版本,都是可以的。C:\Users\Administrator\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\7.2-arduino.1/bin/avrdude -CC:\Users\Administrator\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\3.0.1/avrdude.conf -v -patmega328pb -cusbasp -B32 -e -Ulock:w:0xff:m -Uefuse:w:0b11110101:m -Uhfuse:w:0xd7:m -Ulfuse:w:0b11111111:m
avrdude: Version 7.2-arduino.1
Copyright the AVRDUDE authors;
see https://github.com/avrdudes/avrdude/blob/main/AUTHORS
System wide configuration file is C:\Users\Administrator\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\3.0.1\avrdude.conf
Using Port : usb
Using Programmer : usbasp
Setting bit clk period : 32.0
AVR Part : ATmega328PB
Chip Erase delay : 10500 us
PAGEL : PD7
BS2 : PC2
RESET disposition : possible i/o
RETRY pulse : SCK
Serial program mode : yes
Parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Alias Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0x00 0x00
flash 65 10 128 0 yes 32768 128 256 4500 4500 0x00 0x00
lfuse 0 0 0 0 no 1 1 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 1 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 1 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 1 0 4500 4500 0x00 0x00
signature 0 0 0 0 no 3 1 0 0 0 0x00 0x00
calibration 0 0 0 0 no 1 1 0 0 0 0x00 0x00
Programmer Type : usbasp
Description : USBasp ISP and TPI programmer
avrdude: set SCK frequency to 16000 Hz
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9516 (probably m328pb)
avrdude: erasing chip
avrdude: set SCK frequency to 16000 Hz
avrdude: processing -U lock:w:0xff:m
avrdude: reading input file 0xff for lock
with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte lock ...
avrdude: 1 byte of lock written
avrdude: verifying lock memory against 0xff
avrdude: 1 byte of lock verified
avrdude: processing -U efuse:w:0b11110101:m
avrdude: reading input file 0b11110101 for efuse
with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte efuse ...
avrdude: 1 byte of efuse written
avrdude: verifying efuse memory against 0b11110101
avrdude: 1 byte of efuse verified
avrdude: processing -U hfuse:w:0xd7:m
avrdude: reading input file 0xd7 for hfuse
with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte hfuse ...
avrdude: 1 byte of hfuse written
avrdude: verifying hfuse memory against 0xd7
avrdude: 1 byte of hfuse verified
avrdude: processing -U lfuse:w:0b11111111:m
avrdude: reading input file 0b11111111 for lfuse
with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte lfuse ...
avrdude: 1 byte of lfuse written
avrdude: verifying lfuse memory against 0b11111111
avrdude: 1 byte of lfuse verified
avrdude done. Thank you.
C:\Users\Administrator\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\7.2-arduino.1/bin/avrdude -CC:\Users\Administrator\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\3.0.1/avrdude.conf -v -patmega328pb -cusbasp -B32 -Uflash:w:C:\Users\Administrator\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\3.0.1/bootloaders/urboot/atmega328pb/watchdog_1_s/autobaud/uart0_rxd0_txd1/led+b5/urboot_atmega328pb_pr_ee_ce.hex:i -Ulock:w:0xff:m
avrdude: Version 7.2-arduino.1
Copyright the AVRDUDE authors;
see https://github.com/avrdudes/avrdude/blob/main/AUTHORS
System wide configuration file is C:\Users\Administrator\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\3.0.1\avrdude.conf
Using Port : usb
Using Programmer : usbasp
Setting bit clk period : 32.0
AVR Part : ATmega328PB
Chip Erase delay : 10500 us
PAGEL : PD7
BS2 : PC2
RESET disposition : possible i/o
RETRY pulse : SCK
Serial program mode : yes
Parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Alias Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0x00 0x00
flash 65 10 128 0 yes 32768 128 256 4500 4500 0x00 0x00
lfuse 0 0 0 0 no 1 1 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 1 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 1 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 1 0 4500 4500 0x00 0x00
signature 0 0 0 0 no 3 1 0 0 0 0x00 0x00
calibration 0 0 0 0 no 1 1 0 0 0 0x00 0x00
Programmer Type : usbasp
Description : USBasp ISP and TPI programmer
avrdude: set SCK frequency to 16000 Hz
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9516 (probably m328pb)
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: set SCK frequency to 16000 Hz
avrdude: processing -U flash:w:C:\Users\Administrator\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\3.0.1/bootloaders/urboot/atmega328pb/watchdog_1_s/autobaud/uart0_rxd0_txd1/led+b5/urboot_atmega328pb_pr_ee_ce.hex:i
avrdude: reading input file C:\Users\Administrator\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\3.0.1/bootloaders/urboot/atmega328pb/watchdog_1_s/autobaud/uart0_rxd0_txd1/led+b5/urboot_atmega328pb_pr_ee_ce.hex for flash
with 368 bytes in 2 sections within [0x7e80, 0x7fff]
using 3 pages and 16 pad bytes
avrdude: writing 368 bytes flash ...
Writing | ################################################## | 100% 0.30s
avrdude: 368 bytes of flash written
avrdude: verifying flash memory against C:\Users\Administrator\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\3.0.1/bootloaders/urboot/atmega328pb/watchdog_1_s/autobaud/uart0_rxd0_txd1/led+b5/urboot_atmega328pb_pr_ee_ce.hex
Reading | ################################################## | 100% 0.00s
avrdude: 368 bytes of flash verified
avrdude: processing -U lock:w:0xff:m
avrdude: reading input file 0xff for lock
with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte lock ...
avrdude: 1 byte of lock written
avrdude: verifying lock memory against 0xff
avrdude: 1 byte of lock verified
avrdude done. Thank you.
"C:\Users\Administrator\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\7.2-arduino.1/bin/avrdude" "-CC:\Users\Administrator\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\3.0.1/avrdude.conf" -v -patmega328pb -cusbasp -e -Ulock:w:0xff:m -Uefuse:w:0b11110101:m -Uhfuse:w:0xd7:m -Ulfuse:w:0b11111111:m
- 🌿第二阶段是,对目标型号芯片进行bootloader下载。
"C:\Users\Administrator\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\7.2-arduino.1/bin/avrdude" "-CC:\Users\Administrator\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\3.0.1/avrdude.conf" -v -patmega328pb -cusbasp "-Uflash:w:C:\Users\Administrator\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\3.0.1/bootloaders/urboot/atmega328pb/watchdog_1_s/autobaud/uart0_rxd0_txd1/led+b5/urboot_atmega328pb_pr_ee_ce.hex:i" -Ulock:w:0xff:m
MiniCore
固件下烧录328PB
,整个烧录过程是一次进行烧录。