相关知识
The offset of the new image is set in the properties of plugin “OTA Simple Storage EEPROM Driver”. There are two typical settings.
- Using slot-manager:
The slot offset is defined in the bootloader. In the application, set “Gecko Bootloader Storage Support” to specify the slot. In this case, the “OTA Storage Start Offset” and “OTA Storage End Offset” will not be used.
- Using absolute offset:
In the application, you must set “Gecko Bootloader Storage Support” to “Do not use slot”. In this case the “Storage Slot To Save Images To” will not be used. The “OTA Storage Start Offset” and “OTA Storage End Offset” must be set correctly. The “OTA Storage Start Offset” must equal the start offset of a slot defined in the bootloader. The “OTA Storage End Offset” must equal the start offset plus the slot size of that slot.
- Memory Space For Bootloading
The first stage of the Gecko Bbootloader on Series 1 devices takes up a single flash page. On devices with 2 kB flash pages, like
EFR32MG1, this means that the first stage takes 2 kB.
The size of the main bootloader is dependent on the functionality required. With a typical bootloader configuration, the main bootloader
for Series 1 devices takes up 14 kB of flash, bringing the total bootloader size to 16 kB.
Silicon Labs recommends reserving 16 kB for the bootloader for Series 1 and EFR32xG21 devices and 24 kB for EFR32xG22 devices.
On EFR32xG1 devices (Mighty Gecko, Flex Gecko, and Blue Gecko families), the bootloader resides in main flash.
• First stage bootloader @ 0x0
• Main bootloader @ 0x800
• Application @ 0x4000
On EFR32xG12 and later Series 1 devices, the bootloader resides in the bootloader area in the Information Block
• Application @ 0x0
• First stage bootloader @ 0x0FE10000
• Main bootloader @ 0x0FE10800
On EFR32xG21, the main bootloader resides in main flash:
• Main bootloader @ 0x0
• Application @ 0x4000
On EFR32xG22, the main bootloader resides in main flash:
• Main bootloader @ 0x0
• Application @ 0x6000
相关文章:
Zigbee Understanding OTA Storage
Zigbee Understanding OTA Storage-CSDN
AN728: Over-the-Air Bootload Server and Client Setup
遇到的问题
Query next image response: New image is available for download.
Starting download, Version 0x0000000C
Bootload state:
Query next image response: New image is available for download.
ERROR: Next Image is too big to store (0x0003476E > 0x0002F800)
Error: failed parsing OTA cmd 0x02
解决
App,使用local storage,
Bootloader
APP 与 OTA 分区大小
- 无压缩:APP 占用的 Flash 大小应该与 OTA 的 Flash 大小一致。
- 压缩:使用 LZ4 或者 LZMA 算法生成压缩gbl文件,LZ4压缩率为 10% 左右,LZMA 压缩率为 30% 左右;所以存放 OAT 文件的Flash 大小应为存放 APP 文件的Flash 的大小的 0.7 左右;也就是 APP 区域为 100k 时,OTA 的分区大小应为 70k 左右。
问题
ASSERT:ota-storage-eeprom-page-erase.c:181
解决方法:OTA的开始地址必须为MCU page大小的整数倍,因为擦写的最小单位是 1 page。
Code:
assert(isMultipleOfPageSize(otaStorageEepromGetStorageStartAddress()));
OTA failed:需要修改SDK,Gecko boot loader 1.10 or newer
- “sdks\gecko_sdk_suite\v3.2\platform\base\hal\micro\cortexm3\efm32\bootloader-interface-app.c” 的 Line 181
// Static state allocation for bootloader verification
uint8_t bootloaderValidationContext[BOOTLOADER_STORAGE_VERIFICATION_CONTEXT_SIZE] __attribute((aligned(4)));
- “sdks\gecko_sdk_suite\v3.2\platform\bootloader\api\btl_interface_storage…c” 的 Line 282, Line 312
int32_t bootloader_verifyImage(uint32_t slotId, BootloaderParserCallback_t metadataCallback)
{
int32_t retval;
uint8_t context [BOOTLOADER_STORAGE_VERIFICATION_CONTEXT_SIZE] __attribute((aligned(4)));
...
}
int32_t bootloader_getImageInfo(uint32_t slotId,
ApplicationData_t *appInfo,
uint32_t *bootloaderVersion)
{
int32_t retval;
uint8_t context[BOOTLOADER_STORAGE_VERIFICATION_CONTEXT_SIZE] __attribute((aligned(4)));
...
}
- In "sdks\gecko_sdk_suite\v3.2\util\plugin\slot-manager\slot-manager.h " Line 36
#define SLOT_MANAGER_VERIFICATION_CONTEXT_SIZE BOOTLOADER_STORAGE_VERIFICATION_CONTEXT_SIZE //384
Image Upgrade Status Values
Image Upgrade Status Values | Description |
---|---|
0x00 | Normal |
0x01 | Download in progress |
0x02 | Download complete |
0x03 | Waiting to upgrade |
0x04 | Count down |
0x05 | Wait for more |
0x06 | Waiting to Upgrade via External Event |
下载完成状态表示客户端已收到所需的所有数据块,并且已验证 OTA 升级映像签名(如果已应用),并且已将映像写入其额外的内存空间。 一旦客户端从服务器接收到升级结束响应命令,状态将被修改。
倒计时状态表示服务器已通知客户端倒计时到它应升级其映像的时间。
正常日志
[15:08:17:942]
[15:08:18:418]-+媮pass
[15:08:18:418]UM>Reset info: 0x04 (PWR)
[15:08:18:422]UM>Extended Reset info: 0x0401 (HV )
[15:08:18:426]UM>EUI64: 30 30 30 32 47 6E 33 7A
[15:08:18:427]UM>
[15:08:18:427]IO-OUT> 0, off
[15:08:18:431]IO-OUT> 1, off
[15:08:18:431]SW>ep 1, mode 0: MM_NULL
[15:08:18:436]OTA>attributeId 0x5000
[15:08:18:436]BL>BallastConfig: ep 1, attr 0x0010
[15:08:18:439]BL>backLightLevel 6, setOn 0
[15:08:18:446]BL>BallastConfig: ep 1, attr 0x0011
[15:08:18:446]BL>headLightLevel 60, setOn 0
[15:08:18:449]EEPROM init: 0x00
[15:08:18:449]BC>endpoint 1
[15:08:18:449]BC>Sw ver 0x0001
[15:08:18:457]BC>dateCodeBuff(12):202203111458
[15:08:18:458]OTA>attributeId 0x0003
[15:08:18:463]OTA>CURRENT_ZIGBEE_STACK_VERSION: 0x0002
[15:08:18:463]OTA>attributeId 0x0007
[15:08:18:466]OTA>MANUFACTURER_ID: 0xACCA
[15:08:18:470]OTA>attributeId 0x0008
[15:08:18:473]OTA>IMAGE_TYPE_ID: 0xFFFF
[15:08:18:479]OTA>attributeId 0x0002
[15:08:18:479]OTA>CURRENT_FILE_VERSION: 0x01006A30
[15:08:18:480]OTA>attributeId 0x0005
[15:08:18:480]OTA>DOWNLOADED_ZIGBEE_STACK_VERSION: 0xFFFF
[15:08:18:485]NWK Steering stack status 0x90
[15:08:18:488]Report>report after 7798 ms
[15:08:18:490]AF>Channel 21, PanId 0xD626, ParentId 0xD17A, NodeId 0x01BC, RadioPower 19 dBm
[15:08:28:327]
[15:08:57:803]Processing message: len=7 profile=0104 cluster=0019
[15:08:57:808]OTA>attributeId 0x0006
[15:08:57:810]OTA>IMAGE_UPGRADE_STATUS: 0x00
[15:08:57:816]OTA>attributeId 0x0006
[15:08:57:816]OTA>IMAGE_UPGRADE_STATUS: 0x00
[15:08:57:818]OTA>attributeId 0x0006
[15:08:57:818]OTA>IMAGE_UPGRADE_STATUS: 0x00
[15:08:57:824]
[15:08:57:858]Processing message: len=6 profile=0000 cluster=8006
[15:08:57:865]
[15:08:59:844]OTA>attributeId 0x0006
[15:08:59:844]OTA>IMAGE_UPGRADE_STATUS: 0x00
[15:08:59:849]OTA>attributeId 0x0000
[15:08:59:851]OTA>Server eui64: 63 C6 91 FE FF CC CC CC
[15:08:59:857]OTA>
[15:08:59:857]OTA>attributeId 0x0006
[15:08:59:857]OTA>IMAGE_UPGRADE_STATUS: 0x00
[15:08:59:865]
[15:08:59:919]Processing message: len=16 profile=0104 cluster=0019
[15:08:59:923]OTA>attributeId 0x0004
[15:08:59:927]OTA>Ota start: downloadVersion 0x02006A30
[15:08:59:930]OTA>DOWNLOADED_FILE_VERSION: 0x02006A30
[15:08:59:934]OTA>attributeId 0x0001
[15:08:59:934]OTA>attributeId 0x0006
[15:08:59:948]OTA>IMAGE_UPGRADE_STATUS: 0x01
[15:08:59:952]
[15:09:00:899]OTA>attributeId 0x0006
[15:09:00:899]OTA>IMAGE_UPGRADE_STATUS: 0x01
[15:09:00:903]OTA>attributeId 0x0005
[15:09:00:905]OTA>DOWNLOADED_ZIGBEE_STACK_VERSION: 0xFFFF
[15:09:00:911]
[15:09:01:034]Processing message: len=78 profile=0104 cluster=0019
[15:09:01:038]OTA>attributeId 0x0008
[15:09:01:040]OTA>IMAGE_TYPE_ID: 0x4254
[15:09:01:046]OTA>attributeId 0x0001
[15:09:01:046]Download: 0% complete
[15:09:01:046]OTA>attributeId 0x0006
[15:09:01:052]OTA>IMAGE_UPGRADE_STATUS: 0x01
[15:09:01:052]
[15:09:01:136]Processing message: len=78 profile=0104 cluster=0019
[15:09:01:140]OTA>attributeId 0x0001
[15:09:01:142]OTA>attributeId 0x0006
[15:09:01:149]OTA>IMAGE_UPGRADE_STATUS: 0x01
[15:09:45:420]Processing message: len=78 profile=0104 cluster=0019
[15:09:45:424]OTA>attributeId 0x0001
[15:09:45:429]OTA>FILE_OFFSET: 0x0000473F
[15:09:45:429]OTA>attributeId 0x0006
[15:09:45:436]OTA>IMAGE_UPGRADE_STATUS: 0x01
[15:09:52:042]Processing message: len=78 profile=0104 cluster=0019
[15:09:52:047]OTA>attributeId 0x0001
[15:09:52:052]OTA>FILE_OFFSET: 0x0000567F
[15:09:52:052]OTA>attributeId 0x0006
[15:09:52:057]OTA>IMAGE_UPGRADE_STATUS: 0x01
[15:10:03:808]Processing message: len=78 profile=0104 cluster=0019
[15:10:03:813]OTA>attributeId 0x0001
[15:10:03:815]OTA>FILE_OFFSET: 0x000065BF
[15:10:03:820]OTA>attributeId 0x0006
[15:10:03:822]OTA>IMAGE_UPGRADE_STATUS: 0x01
[15:10:30:268]Processing message: len=80 profile=0104 cluster=0019
[15:10:30:272]OTA>attributeId 0x0001
[15:10:30:275]OTA>attributeId 0x0006
[15:10:30:281]OTA>IMAGE_UPGRADE_STATUS: 0x01
[15:10:42:447]Processing message: len=80 profile=0104 cluster=0019
[15:10:42:452]OTA>attributeId 0x0001
[15:10:42:455]OTA>attributeId 0x0006
[15:10:42:461]OTA>IMAGE_UPGRADE_STATUS: 0x01
[15:16:07:088]Processing message: len=78 profile=0104 cluster=0019
[15:16:07:099]OTA>attributeId 0x0001
[15:16:07:099]OTA>attributeId 0x0006
[15:16:07:099]OTA>IMAGE_UPGRADE_STATUS: 0x01
[15:16:07:099]
[15:16:07:176]Processing message: len=78 profile=0104 cluster=0019
[15:16:07:187]OTA>attributeId 0x0001
[15:16:07:187]OTA>attributeId 0x0006
[15:16:07:187]OTA>IMAGE_UPGRADE_STATUS: 0x01
[15:16:07:202]
[15:16:07:308]Processing message: len=78 profile=0104 cluster=0019
[15:16:07:318]OTA>attributeId 0x0001
[15:16:07:318]OTA>attributeId 0x0006
[15:16:07:318]OTA>IMAGE_UPGRADE_STATUS: 0x01
[15:16:07:330]
[15:16:07:423]Processing message: len=78 profi
[15:16:07:438]le=0104 cluster=0019
[15:16:07:438]OTA>attributeId 0x0001
[15:16:07:438]OTA>attributeId 0x0006
[15:16:07:438]OTA>IMAGE_UPGRADE_STATUS: 0x01
[15:16:07:438]
[15:16:07:503]Processing message: len=43 profile=0104 cluster=0019
[15:16:07:512]OTA>attributeId 0x0001
[15:16:07:512]Download: 100% complete
[15:16:07:512]OTA>attributeId 0x0006
[15:16:07:512]OTA>IMAGE_UPGRADE_STATUS: 0x02
[15:16:07:527]OTA>attributeId 0x0006
[15:16:07:527]OTA>IMAGE_UPGRADE_STATUS: 0x02
[15:16:07:527]OTA>attributeId 0x0006
[15:16:07:538]OTA>IMAGE_UPGRADE_STATUS: 0x02
[15:16:26:065]OTA>attributeId 0x0006
[15:16:26:065]OTA>IMAGE_UPGRADE_STATUS: 0x02
[15:16:26:078]OTA>attributeId 0x0006
[15:16:26:078]OTA>IMAGE_UPGRADE_STATUS: 0x02
[15:16:26:078]OTA>attributeId 0x0006
[15:16:26:090]OTA>IMAGE_UPGRADE_STATUS: 0x03
[15:16:26:090]OTA>attributeId 0x0005
[15:16:26:090]OTA>DOWNLOADED_ZIGBEE_STACK_VERSION: 0x0002
[15:16:26:090]
[15:16:26:152]Processing message: len=19 profile=0104 cluster=0019
[15:16:26:162]OTAC>PreBootload,srcEndpoint 1,serverEndpoint 1,serverNodeId 0x0000
[15:16:26:162]OTA>attributeId 0x0006
[15:16:26:174]OTA>IMAGE_UPGRADE_STATUS: 0x04
[15:16:26:174]
[15:16:32:689]-+媮pass
[15:16:32:689]UM>Reset info: 0x02 (BTL)
[15:16:32:700]UM>Extended Reset info: 0x0201 (GO )
[15:16:32:700]UM>EUI64: 30 30 30 32 47 6E 33 7A
[15:16:32:700]UM>
[15:16:32:700]IO-OUT> 0, off
[15:16:32:700]IO-OUT> 1, off
[15:16:32:700]SW>ep 1, mode 0: MM_NULL
[15:16:32:714]OTA>attributeId 0x5000
[15:16:32:714]BL>BallastConfig: ep 1, attr 0x0010
[15:16:32:714]BL>backLightLevel 6, setOn 0
[15:16:32:714]BL>BallastConfig: ep 1, attr 0x0011
[15:16:32:714]BL>headLightLevel 60, setOn 0
[15:16:32:724]EEPROM init: 0x00
[15:16:32:724]BC>endpoint 1
[15:16:32:724]BC>Sw ver 0x0002
[15:16:32:739]BC>dateCodeBuff(12):202203111506
[15:16:32:739]OTA>attributeId 0x0003
[15:16:32:739]OTA>CURRENT_ZIGBEE_STACK_VERSION: 0x0002
[15:16:32:739]OTA>attributeId 0x0007
[15:16:32:739]OTA>MANUFACTURER_ID: 0xACCA
[15:16:32:739]OTA>attributeId 0x0008
[15:16:32:751]OTA>IMAGE_TYPE_ID: 0xFFFF
[15:16:32:751]OTA>attributeId 0x0002
[15:16:32:751]OTA>CURRENT_FILE_VERSION: 0x02006A30
[15:16:32:751]OTA>attributeId 0x0005
[15:16:32:751]OTA>DOWNLOADED_ZIGBEE_STACK_VERSION: 0xFFFF
[15:16:32:766]NWK Steering stack status 0x90
[15:16:32:766]Report>report after 3589 ms
[15:16:32:766]AF>Channel 21, PanId 0xD626, ParentId 0xD17A, NodeId 0x01BC, RadioPower 19 dBm
[15:16:32:777]
下载中断
[17:21:52:001]-+媮pass
[17:21:52:001]UM>Reset info: 0x04 (PWR)
[17:21:52:004]UM>Extended Reset info: 0x0401 (HV )
[17:21:52:009]UM>EUI64: 30 30 30 32 47 6E 33 7A
[17:21:52:015]OTA>attributeId 0x5000
[17:21:52:021]OTA>Mgf fileVersion: 0xFFFFFFFF
[17:21:52:035]EEPROM init: 0x00
[17:21:52:035]BC>endpoint 1
[17:21:52:035]BC>Sw ver 0x0007
[17:21:52:040]BC>Hw ver 0x0000
[17:21:52:046]OTA>attributeId 0x0003
[17:21:52:047]OTA>CURRENT_ZIGBEE_VERSION: 0x0002
[17:21:52:050]OTA>attributeId 0x0007
[17:21:52:052]OTA>MANUFACTURER_ID: 0xACCA
[17:21:52:056]OTA>attributeId 0x0008
[17:21:52:058]OTA>IMAGE_TYPE_ID: 0xFFFF
[17:21:52:061]OTA>Mgf fileVersion: 0xFFFFFFFF
[17:21:52:062]OTA>attributeId 0x0002
[17:21:52:062]OTA>CURRENT_FILE_VERSION: 0x07006A30
[17:21:52:069]OTA>attributeId 0x0005
[17:21:52:069]OTA>DOWNLOADED_ZIGBEE_VERSION: 0xFFFF
[17:21:52:076]NWK Steering stack status 0x90
[17:21:52:076]Report>report after 3330 ms
[17:21:52:076]AF>Channel 21, PanId 0xD626, ParentId 0xD17A, NodeId 0x085B, RadioPower 19 dBm
[17:27:47:349]Processing message: len=7 profile=0104 cluster=0019
[17:27:47:354]OTA>attributeId 0x0006
[17:27:47:356]OTA>UPGRADE_STATUS: 0x00
[17:27:47:361]OTA>attributeId 0x0006
[17:27:47:361]OTA>UPGRADE_STATUS: 0x00
[17:27:47:361]OTA>attributeId 0x0006
[17:27:47:363]OTA>UPGRADE_STATUS: 0x00
[17:27:47:369]
[17:27:47:392]Processing message: len=6 profile=0000 cluster=8006
[17:27:47:395]
[17:27:49:389]OTA>attributeId 0x0006
[17:27:49:389]OTA>UPGRADE_STATUS: 0x00
[17:27:49:394]OTA>attributeId 0x0000
[17:27:49:396]OTA>Server eui64: 63 C6 91 FE FF CC CC CC
[17:27:49:402]OTA>
[17:27:49:402]OTA>attributeId 0x0006
[17:27:49:402]OTA>UPGRADE_STATUS: 0x00
[17:27:49:407]
[17:27:49:482]Processing message: len=16 profile=0104 cluster=0019
[17:27:49:486]OTA>attributeId 0x0004
[17:27:49:488]OTA>Ota start: downloadVersion 0x08006A30
[17:27:49:493]OTA>attributeId 0x5000
[17:27:49:497]OTA>Mgf fileVersion: 0x08006A30
[17:27:49:497]OTA>DOWNLOADED_FILE_VERSION: 0x08006A30
[17:27:49:500]OTA>attributeId 0x0001
[17:27:49:507]OTA>FILE_OFFSET: 0x00000000
[17:27:49:507]OTA>Ota blink led
[17:27:49:507]OTA>
[17:27:49:519]attributeId 0x0006
[17:27:49:519]OTA>UPGRADE_STATUS: 0x01
[17:27:49:523]
[17:27:50:470]OTA>attributeId 0x0006
[17:27:50:470]OTA>UPGRADE_STATUS: 0x01
[17:27:50:474]OTA>attributeId 0x0005
[17:27:50:476]OTA>DOWNLOADED_ZIGBEE_VERSION: 0xFFFF
[17:27:50:481]
[17:27:50:566]Processing message: len=78 profile=0104 cluster=0019
[17:27:50:570]OTA>attributeId 0x0008
[17:27:50:574]OTA>IMAGE_TYPE_ID: 0x4254
[17:27:50:574]OTA>Mgf fileVersion: 0x08006A30
[17:27:50:581]OTA>attributeId 0x0001
[17:27:50:581]Download: 0% complete
[17:27:50:581]OTA>attributeId 0x0006
[17:27:50:583]OTA>UPGRADE_STATUS: 0x01
[17:27:50:590]
[17:28:05:046]Processing message: len=78 profile=0104 cluster=0019
[17:28:05:049]OTA>attributeId 0x0001
[17:28:05:052]OTA>attributeId 0x0006
[17:28:05:056]OTA>UPGRADE_STATUS: 0x01
[17:28:05:056]
[17:28:05:130]Processing message: len=78 profile=0104 cluster=0019
[17:28:05:134]OTA>attributeId 0x0001
[17:28:05:138]OTA>attributeId 0x0006
[17:28:05:140]OTA>UPGRADE_STATUS: 0x01
[17:28:05:140]
[17:28:10:110]OTA>attributeId 0x0006
[17:28:10:110]OTA>UPGRADE_STATUS: 0x01
[17:28:10:115]
[17:28:15:081]OTA>attributeId 0x0006
[17:28:15:081]OTA>UPGRADE_STATUS: 0x01
[17:28:15:089]
[17:28:20:055]OTA>attributeId 0x0006
[17:28:20:055]OTA>UPGRADE_STATUS: 0x01
[17:28:20:061]
[17:28:25:027]OTA>attributeId 0x0006
[17:28:25:027]OTA>UPGRADE_STATUS: 0x01
[17:28:25:032]
[17:28:30:000]OTA>attributeId 0x0006
[17:28:30:000]OTA>UPGRADE_STATUS: 0x01
[17:28:30:005]
[17:28:34:973]OTA>attributeId 0x0006
[17:28:34:973]OTA>UPGRADE_STATUS: 0x01
[17:28:34:978]
[17:28:39:946]OTA>attributeId 0x0006
[17:28:39:946]OTA>UPGRADE_STATUS: 0x01
[17:28:39:951]
[17:28:44:918]OTA>attributeId 0x0006
[17:28:44:918]OTA>UPGRADE_STATUS: 0x01
[17:28:44:923]
[17:28:49:891]OTA>attributeId 0x0006
[17:28:49:891]OTA>UPGRADE_STATUS: 0x01
[17:28:49:897]
[17:28:54:865]OTA>attributeId 0x0006
[17:28:54:878]
[17:28:54:878]OTA>UPGRADE_STATUS: 0x01
[17:28:54:878]OTA>attributeId 0x0005
[17:28:54:885]OTA>DOWNLOADED_ZIGBEE_VERSION: 0xFFFF
[17:28:54:885]OTA>attributeId 0x0006
[17:28:54:887]OTA>UPGRADE_STATUS: 0x00
[17:28:54:890]OTA>attributeId 0x0008
[17:28:54:892]OTA>IMAGE_TYPE_ID: 0xFFFF
[17:28:54:892]OTA>Mgf fileVersion: 0x08006A30
[17:28:54:898]OTA>Ota failed!
[17:28:54:898]OTA>attributeId 0x5000
[17:28:54:911]OTA>Mgf fileVersion: 0xFFFFFFFF
[17:28:54:913]
[17:28:55:841]OTA>attributeId 0x0005
[17:28:55:841]OTA>DOWNLOADED_ZIGBEE_VERSION: 0xFFFF
[17:28:55:845]