让optiboot支持atmega168pa@8Mhz
zcbzjx 于 2012-12-18 20:00 编辑
此贴有毛病,请看更新帖
有同学已经发过使Arduino支持ATmega168PA,现在我发的这个是用optiboot的bootloader,而且让他工作在8MHz,这样我们就可以用3.3V电源供电,好处?。
以下均在arduino1.01 测试通过,而且能稳定运行。
第一步,下载optiboot-with-168p.zip,拷贝到<path-where-you-installed-arduino-1.0>\hardware\arduino\bootloaders,替换原来的optiboot目录。
第二步,修改makefile文件,建议大家下载Notepad++,这样编辑就不会乱行。
找到这个位置ARDUINO 代码复制打印
pro8: TARGET = pro_8MHzpro8: MCU_TARGET = atmega168pro8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'pro8: AVR_FREQ = 8000000Lpro8: $(PROGRAM)_pro_8MHz.hexpro8: $(PROGRAM)_pro_8MHz.lstpro8_isp: pro8pro8_isp: TARGET = pro_8MHz# 2.7V brownoutpro8_isp: HFUSE = DD# Full swing xtal (20MHz) 258CK/14CK+4.1mspro8_isp: LFUSE = C6# 512 byte bootpro8_isp: EFUSE = 04pro8_isp: isp
pro8: TARGET = pro_8MHz
pro8: MCU_TARGET = atmega168
pro8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
pro8: AVR_FREQ = 8000000L
pro8: $(PROGRAM)_pro_8MHz.hex
pro8: $(PROGRAM)_pro_8MHz.lst
pro8_isp: pro8
pro8_isp: TARGET = pro_8MHz
2.7V brownout
pro8_isp: HFUSE = DD
Full swing xtal (20MHz) 258CK/14CK+4.1ms
pro8_isp: LFUSE = C6
512 byte boot
pro8_isp: EFUSE = 04
pro8_isp: isp
在这个位置之后加ARDUINO 代码复制打印
# Atmega168p target 8Mhz added by zcbzjxatmega168p_pro8: TARGET = Atmega168p_pro_8MHzatmega168p_pro8: MCU_TARGET = atmega168patmega168p_pro8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'atmega168p_pro8: AVR_FREQ = 8000000Latmega168p_pro8: $(PROGRAM)_Atmega168p_pro_8MHz.hexatmega168p_pro8: $(PROGRAM)_Atmega168p_pro_8MHz.lstatmega168p_pro8_isp: Atmega168p_pro8atmega168p_pro8_isp: TARGET = Atmega168p_pro_8MHz# 2.7V brownoutatmega168p_pro8_isp: HFUSE = DD# Full swing xtal (20MHz) 258CK/14CK+4.1msatmega168p_pro8_isp: LFUSE = C6# 512 byte bootatmega168p_pro8_isp: EFUSE = 04atmega168p_pro8_isp: isp
# Atmega168p target 8Mhz added by zcbzjx
atmega168p_pro8: TARGET = Atmega168p_pro_8MHz
atmega168p_pro8: MCU_TARGET = atmega168p
atmega168p_pro8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
atmega168p_pro8: AVR_FREQ = 8000000L
atmega168p_pro8: $(PROGRAM)_Atmega168p_pro_8MHz.hex
atmega168p_pro8: $(PROGRAM)_Atmega168p_pro_8MHz.lst
atmega168p_pro8_isp: Atmega168p_pro8
atmega168p_pro8_isp: TARGET = Atmega168p_pro_8MHz
# 2.7V brownout
atmega168p_pro8_isp: HFUSE = DD
# Full swing xtal (20MHz) 258CK/14CK+4.1ms
atmega168p_pro8_isp: LFUSE = C6
# 512 byte boot
atmega168p_pro8_isp: EFUSE = 04
atmega168p_pro8_isp: isp
大家可以看,基本上就是改了个MCU_TARGET,atmega168变成了atmega168p。
第三步,生成bootloader
1,启动命令提示符
按Win + R,输入cmd,回车键
2,改变工作目录,
cd "<path-where-you-installed-arduino-1.0>\hardware\arduino\bootloaders\optiboot\"
Enter
3,启动编译器输入
omake atmega168p_pro8
Enter
现在,文件夹"<path-where-you-installed-arduino-1.0>\hardware\arduino\bootloaders\optiboot\"中,就可以找到你为ATmega168p(8MHz)编译optiboot引导程序:optiboot_atmega168p_pro8.hex
第四步,修改boards.txt
在最后加入ARDUINO 代码复制打印
##############################################################micromagician168pa.name= optiboot (3.3V, 8 MHz) w/ ATmega168PAmicromagician168pa.upload.protocol=arduinomicromagician168pa.upload.maximum_size=15872micromagician168pa.upload.speed=19200micromagician168pa.bootloader.low_fuses=0xc6micromagician168pa.bootloader.high_fuses=0xddmicromagician168pa.bootloader.extended_fuses=0x04micromagician168pa.bootloader.path=optibootmicromagician168pa.bootloader.file=optiboot_Atmega168p_pro_8MHz.hexmicromagician168pa.bootloader.unlock_bits=0x3Fmicromagician168pa.bootloader.lock_bits=0x0Fmicromagician168pa.build.mcu=atmega168pmicromagician168pa.build.f_cpu=8000000Lmicromagician168pa.build.core=arduinomicromagician168pa.build.variant=standard
##############################################################重新启动arduino,就可以在板卡找到"optiboot (3.3V, 8 MHz) w/ ATmega168PA"
micromagician168pa.name= optiboot (3.3V, 8 MHz) w/ ATmega168PA
micromagician168pa.upload.protocol=arduino
micromagician168pa.upload.maximum_size=15872
micromagician168pa.upload.speed=19200
micromagician168pa.bootloader.low_fuses=0xc6
micromagician168pa.bootloader.high_fuses=0xdd
micromagician168pa.bootloader.extended_fuses=0x04
micromagician168pa.bootloader.path=optiboot
micromagician168pa.bootloader.file=optiboot_Atmega168p_pro_8MHz.hex
micromagician168pa.bootloader.unlock_bits=0x3F
micromagician168pa.bootloader.lock_bits=0x0F
micromagician168pa.build.mcu=atmega168p
micromagician168pa.build.f_cpu=8000000L
micromagician168pa.build.core=arduino
micromagician168pa.build.variant=standard
希望大家举一反三,生成自己需要的bootloader。
参考:
Add support for ATmega168P in optiboot
ATMega8 Arduino Bootloader (Optiboot)
via - 极客工坊