查看Arduino bootloader 的烧写的源代码
←
Arduino bootloader 的烧写
跳转到:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您刚才请求的操作只有这个用户组中的用户才能使用:
用户
您可以查看并复制此页面的源代码:
== AVR Fuse&Lock (熔丝位) == AVR Fuse&Lock (熔丝位) 可看作可编程控制的跳线,用于配置单片机的基础状态 共有 4 个字节,分别为:hfuse, lfuse, efuse, lock ATMEGA 的各型号 MCU 这些位的定义都不同,像 ATMEGA 168 和 ATMEGA328p 也不同,具体可参考手册页 以下只讨论 328p 的情形 <br><br> === hfuse,熔丝高位 === {| border="0" width=100% cellspacing="1" cellpadding="5" align="center" bgcolor=#0066bb ! style="background:#eeeeee" width=50| HFuse Bit ! style="background:#eeeeee" | [7] ! style="background:#eeeeee" | [6] ! style="background:#eeeeee" | [5] ! style="background:#eeeeee" | [4] ! style="background:#eeeeee" | [3] ! style="background:#eeeeee" | [2] ! style="background:#eeeeee" | [1] ! style="background:#eeeeee" | [0] |- ! style="background:#eeeeee" width=50| Bit Name | style="background:#ffffff" | RSTDISBL | style="background:#ffffff" | DWEN | style="background:#ffffff" | SPIEN | style="background:#ffffff" | WDTON | style="background:#ffffff" | EESAVE | style="background:#ffffff" | BOOTSZ1 | style="background:#ffffff" | BOOTSZ0 | style="background:#ffffff" | BOOTRST |- ! style="background:#eeeeee" | Description | style="background:#ffffff" | External Reset Disable | style="background:#ffffff" | Debug Wire Enable | style="background:#ffffff" | SPI programming Enable | style="background:#ffffff" | Watch Dog Timer always ON | style="background:#ffffff" | EEPROM memory is preserved through the chip erase | style="background:#ffffff" | Select bootloader area size | style="background:#ffffff" | Select bootloader area size | style="background:#ffffff" | Select Reset Vector |- ! style="background:#eeeeee" | Default Value | style="background:#ffffff" | 1 (external reset enable) | style="background:#ffffff" | 1 (debug wire disable) | style="background:#ffffff" | 0 (SPI enable) | style="background:#ffffff" | 1 (WDT always off) | style="background:#ffffff" | 1 (EEPROM not reserved) | style="background:#ffffff" | 0 | style="background:#ffffff" | 0 | style="background:#ffffff" | 1 (Reset Vector = 0x0) |} AVR 系列寄存器的值,一般 0 为真 对于 BOOTSZ1 BOOTSZ0 其对应为: [[文件:M328p-bootsz.jpg]] 表中的 Boot Reset Address (Start Boot Loader Section) 要将 hfuse 的 BOOTRST 置为 0 时,才有效 !特别注意:表中的地址都是为字为单位,换算成常用的字节单位要乘以 2 可见:BOOTSZ 为 00 时,boot area size = 4KB (2048 words,一个 words 是 16bit,两个字节) ; 01 时为 2KB; 10 时为 1KB; 11 时为 512B BOOTSZ 为 01 时,boot area 地址为 0x3C00 ~ 0x3FFF (字为单位),则以字节为单位的地址范围为:0x7800 ~ 0x7FFF Arduino 使用 ATmega 328p 一般将 hfuse 设置为 0xDA,对应二进制值为 1101 1010,低三位与默认值不同,指示 boot area size 为 2KB,地址范围 0x7800 ~ 0x7FFF,Reset Vector = 0x7800 0x7800 这个值,也与 Arduino 使用的 bootloader 文件 ATmegaBOOT_168_atmega328.hex 的起始地址一致 <br><br> === lfuse,熔丝低位 === {| border="0" width=100% cellspacing="1" cellpadding="5" align="center" bgcolor=#0066bb ! style="background:#eeeeee" width=50| LFuse Bit ! style="background:#eeeeee" | [7] ! style="background:#eeeeee" | [6] ! style="background:#eeeeee" | [5] ! style="background:#eeeeee" | [4] ! style="background:#eeeeee" | [3] ! style="background:#eeeeee" | [2] ! style="background:#eeeeee" | [1] ! style="background:#eeeeee" | [0] |- ! style="background:#eeeeee" width=50| Bit Name | style="background:#ffffff" | CKDIV8 | style="background:#ffffff" | CKOUT | style="background:#ffffff" | SUT1 | style="background:#ffffff" | SUT0 | style="background:#ffffff" | CKSEL3 | style="background:#ffffff" | CKSEL2 | style="background:#ffffff" | CKSEL1 | style="background:#ffffff" | CKSEL0 |- ! style="background:#eeeeee" | Description | style="background:#ffffff" | Divide clock by 8 | style="background:#ffffff" | Clock Output | style="background:#ffffff" | Select start-Up Time | style="background:#ffffff" | Select start-Up Time | style="background:#ffffff" | Seleck Clock source | style="background:#ffffff" | Seleck Clock source | style="background:#ffffff" | Seleck Clock source | style="background:#ffffff" | Seleck Clock source |- ! style="background:#eeeeee" | Default Value | style="background:#ffffff" | 0 | style="background:#ffffff" | 1 | style="background:#ffffff" | 1 | style="background:#ffffff" | 0 | style="background:#ffffff" | 0 | style="background:#ffffff" | 0 | style="background:#ffffff" | 1 | style="background:#ffffff" | 0 |} Arduino 使用 ATmega 328p 一般将 lfuse 设置为 0xFF,对应二进制值为 1111 1111 <br><br> === efuse,扩展熔丝位 === {| border="0" width=100% cellspacing="1" cellpadding="5" align="center" bgcolor=#0066bb ! style="background:#eeeeee" width=50| EFuse Bit ! style="background:#eeeeee" | [7] ! style="background:#eeeeee" | [6] ! style="background:#eeeeee" | [5] ! style="background:#eeeeee" | [4] ! style="background:#eeeeee" | [3] ! style="background:#eeeeee" | [2] ! style="background:#eeeeee" | [1] ! style="background:#eeeeee" | [0] |- ! style="background:#eeeeee" width=50| Bit Name | style="background:#ffffff" | NA | style="background:#ffffff" | NA | style="background:#ffffff" | NA | style="background:#ffffff" | NA | style="background:#ffffff" | NA | style="background:#ffffff" | BODLEVEL2 | style="background:#ffffff" | BODLEVEL1 | style="background:#ffffff" | BODLEVEL0 |- ! style="background:#eeeeee" | Description | style="background:#ffffff" | NA | style="background:#ffffff" | NA | style="background:#ffffff" | NA | style="background:#ffffff" | NA | style="background:#ffffff" | NA | style="background:#ffffff" | Brown-out Detector trigger level | style="background:#ffffff" | Brown-out Detector trigger level | style="background:#ffffff" | Brown-out Detector trigger level |- ! style="background:#eeeeee" | Default Value | style="background:#ffffff" | 1 | style="background:#ffffff" | 1 | style="background:#ffffff" | 1 | style="background:#ffffff" | 1 | style="background:#ffffff" | 1 | style="background:#ffffff" | 1 (false) | style="background:#ffffff" | 1 (false) | style="background:#ffffff" | 1 (false) |} Arduino 使用 ATmega 328p 一般将 efuse 设置为 0x05,对应二进制值为 0000 0101 <br><br> === lock,加密位 === {| border="0" width=100% cellspacing="1" cellpadding="5" align="center" bgcolor=#0066bb ! style="background:#eeeeee" width=50| lock Bit ! style="background:#eeeeee" | [7] ! style="background:#eeeeee" | [6] ! style="background:#eeeeee" | [5] ! style="background:#eeeeee" | [4] ! style="background:#eeeeee" | [3] ! style="background:#eeeeee" | [2] ! style="background:#eeeeee" | [1] ! style="background:#eeeeee" | [0] |- ! style="background:#eeeeee" width=50| Bit Name | style="background:#ffffff" | NA | style="background:#ffffff" | NA | style="background:#ffffff" | BLB12 | style="background:#ffffff" | BLB11 | style="background:#ffffff" | BLB02 | style="background:#ffffff" | BLB01 | style="background:#ffffff" | LB2 | style="background:#ffffff" | LB1 |- ! style="background:#eeeeee" | Description | style="background:#ffffff" | NA | style="background:#ffffff" | NA | style="background:#ffffff" | Boot Lock Bit | style="background:#ffffff" | Boot Lock Bit | style="background:#ffffff" | Boot Lock Bit | style="background:#ffffff" | Boot Lock Bit | style="background:#ffffff" | Lock Bit | style="background:#ffffff" | Lock Bit |- ! style="background:#eeeeee" | Default Value | style="background:#ffffff" | 1 | style="background:#ffffff" | 1 | style="background:#ffffff" | 1 | style="background:#ffffff" | 1 | style="background:#ffffff" | 1 | style="background:#ffffff" | 1 | style="background:#ffffff" | 1 | style="background:#ffffff" | 1 |} BLB12/BLB11, BLB02/BLB01 针对的是 Application Section 和 Bootloader Section 的访问控制。其中 BLB12/BLB11 用于从 Application Section 到 Bootloader Section 的访问控制。BLB02/BLB01 则用于从 Bootloader Section 到 Application Section 的访问控制 BLB12 BLB11 (Application 到 Bootloader): <pre> 11 --> 无限制 10 --> 不可写 Bootloader Section 01 --> 不可读 Bootloader Section 00 --> 不可写不可读 Bootloader Section </pre> BLB02 BLB01 (Bootloader 到 Application): <pre> 11 --> 无限制 10 --> 不可写 Application Section 01 --> 不可读 Application Section 00 --> 不可写不可读 Application Section </pre> !对于 Lock Bit 位 LB2 LB1,应引起高度重视,此二位用于对 Flash, EEPROM, Fuse (hfuse, lfuse, efuse) 和 Boot Lock Bit 的访问控制 LB2 LB1: <pre> 11 --> 无限制 10 --> 禁止对 Flash 和 EEPROM 通过并口和串口编程;Fuse 也被锁(不可读不可写) 00 --> 禁止对 Flash 和 EEPROM 通过并口和串口编程及验证;Fuse 和 Boot Lock Bit 也被锁(不可读不可写) </pre> 由此可见,对 LB2 LB1 的操作应放在最后,一旦操作提交,将不可更改 Arduino 使用 ATmega 328p,bootloader area 不可访问时 lfuse 设置为 0x0F,对应二进制值为 0000 1111 bootloader area 可读可写时 lfuse 设置为 0x3F,对应二进制值为 0011 1111 <br><br> <br><br> <br><br> <br><br> <br><br> <br><br>
返回到
Arduino bootloader 的烧写
。
个人工具
登录
名字空间
页面
讨论
变换
查看
阅读
查看源代码
查看历史
操作
搜索
导航
首页
社区专页
新闻动态
最近更改
随机页面
帮助
工具箱
链入页面
相关更改
特殊页面