Built an OTA bootloader for EFR32BG12 from template bootloader-storage-internal-single-lzma. Have the latest Studio and SDK updates, SDK 2.11.3
Uncompressed gbl files update well, but cannot figure out why compressed update can fail.
The Gecko android app sends compressed gbl file successfully but then shows "gatt error" and disconnects. And the board remains in OTA state.
I've also enabled debug messages in the bootloader, but there's nothing indicating uncompress or update error.
I changed create_bl_files.bat in the main app to add lzma compression as follows:
%COMMANDER% gbl create "%PATH_GBL%\%OTA_APPLI_NAME%.gbl" --app "%PATH_GBL%\%OTA_APPLI_NAME%.srec" --compress lzma
Also, there's a compiler warning in LzmaDec.c, function LzmaDec_DecodeToBuf. This function does not return a value in some code paths.
If you use the standard Bluetooth OTA DFU, then you cannot use lzma compression. This is because the GBL files are parsed by the apploader on-the-fly (during the upload process), and lzma could be decompressed only offline (after the whole image is uploaded), see section 6.2 in UG266: https://www.silabs.com/documents/public/user-guides/ug266-gecko-bootloader-user-guide.pdf
If you need lzma compression, you can use an application level uploader, which uploads the whole image first, then uses the bootloader to decompress and load it: https://www.silabs.com/community/wireless/bluetooth/knowledge-base.entry.html/2017/09/20/uploading_imagesto-DXxD
Arnold, thank you for the explanation. I've read the UG266, but must confess, this is not obviously stated there.
Would it be possible to "fix" the standard OTA DFU to enable downloading compressed gbl?
If this is too much trouble, is source of the "standard OTA DFU" available for those who need to modify it (maybe under NDA)?
The lzma limitation comes from the fact, that the standard OTA DFU (Apploader) overwrites the actual firmware during update (i.e. while you are sending Bluetooth OTA packets) instead of storing the GBL first, and then copy the new firmware over the old one. This means that the compressed image should be being decompressed while receiving the packets. Obviously, decompression needs buffering. You cannot decompress just 1 byte, you need a whole decompressable unit. And this buffering is really challenging with the given RAM limitations. Since it couldn't run on all of our devices, we do not support it.
Since you are using a EFR32BG12 device I strongly suggest you not use the standard OTA DFU. It was designed for EFR32BG1 devices which have limited flash area, and on which overwriting the firmware on-the-fly is unavoidable. In case of EFR32BG12 devices you have enough space to store the GBL file next to your running firmware and then you can get the bootloader copy its content over the running application. This also enables lzma decompression. So please use the example code in https://www.silabs.com/community/wireless/bluetooth/knowledge-base.entry.html/2017/09/20/uploading_imagesto-DXxD
It works with your mobile phone as well as the standard OTA DFU. And it is open source, so you can modify it according to your needs.
If you need any guidenance implementing it, let me know.