升级镜像(文件)的安全检测
为了保证只有兼容的固件才会被安装到芯片上,NORDIC的Bootloader提供了一种安全检测方法——在真正升级之前,Bootloader需要检测DFU init packet,它的内容如下图:
DFU init packet
- Device type: A 2-byte value specified by the developer that identifies the device type, for example Heart Rate Belt.
- Device revision: A 2-byte value that can be used to restrict the update to be accepted only on devices with a defined revision number.
- Application version: A 4-byte value identifying the version of the application that is being transferred. This value can be used to allow only software upgrades and prevent downgrades. No example code is provided for this feature.
- Supported SoftDevices: A list of 2-byte values identifying the SoftDevices that are compatible with the application, for example, S110 v7.1 or S110 v8.0.
- Checksum: A 2-byte CRC-16-CCITT for the image to transfer.
其中指定了多个关键字,也就是说你的升级镜像内的关键字也必须和这个Bootloader一一对应,否则这个升级包就会被认为不被兼容而放弃这次升级。
这也就是为什么上一篇提到需要用.zip包来升级,而不是简单的用.hex文件的原因。
Device type and revision
储存在UICR (0x10001080)地址上。如果不想检查这些信息,保证它的值是 0xFFFF就行了。
Application version
例程中的dfu_init_template.c并没有检查这个信息。用户需要自己来添加。
Supported SoftDevices
根据依赖的Softdevice版本,该字段应如下表所示:
| SoftDevice S110 | FWID |
|---|---|
| S110 v7.0.0 | 0x004F |
| S110 v7.1.0 | 0x005A |
| S110 v8.0.0 | 0x0064 |
| S120 v2.0.0 | 0x0060 |
| S130 v1.0.0 | 0x0067 |
| S310 v2.0.0 | 0x005D |
| Development/any | 0xFFFE |
最后,提一个可能会遇到的问题:升级后的应用程序不能运行。
可能的原因是:应用程序的启动地址错误,导致无法运行。
解决办法是:修改代码中的应用程序启动地址,比如 S110 SoftDevice v7.0.0 是 0x00016000. S310 SoftDevice v0.9.0是0x00020000.

没有评论:
发表评论