2019-09-16 07:06 PM
Hi,
I am in the process of integrating OTA functionality into my project using the examples in STM32Cube_FW_WB_V1.2.0. With reference to AN5247, I have added the Reboot Characteristic and changed my Flash start address to 0x08007000.
I have also noticed that in the BLE_HeartRate project, that there is the "MagicKeywordValue", "MagicKeywordAddress" and "BleApplicationContext" placed in various different sections in flash ("TAG_OTA_END", "TAG_OTA_START" & "BLE_APP_CONTEXT"). I have a few questions as these do not seem to mentioned in the App Note.
Thanks,
Daniel
2019-09-18 08:02 PM
I have successfully got my applications working with the OTA. Added the following code to my app_ble.c and configured the linker file to position the "TAG_OTA_START" at 0x08007140 and "TAG_OTA_END" at the end of the application. Linker file attached. More information would be greatly appreciated.
/**
* These are the two tags used to manage a power failure during OTA
* The MagicKeywordAdress shall be mapped @0x140 from start of the binary image
* The MagicKeywordvalue is checked in the ble_ota application
*/
PLACE_IN_SECTION("TAG_OTA_END") const uint32_t MagicKeywordValue = 0x94448A29 ;
PLACE_IN_SECTION("TAG_OTA_START") const uint32_t MagicKeywordAddress = (uint32_t)&MagicKeywordValue;
2019-09-26 05:36 AM
Hello,
Here are some clarification how it works :
The section "BLE_APP_CONTEXT" is unused so you can just forget it. ( It is there for historical reason)
The Ble_Ota project implements a simple mechanism to ensure the full application has been flashed in the device. The goal was to have the exact same application code (eg Heart Rate) whether it is used alone in the device or downloaded with OTA. The only difference is the link address. A standalone application is linked @0x0800 0000 whereas an application to be downloaded by OTA is linked @0x0800 7000.
In order to check if the full firmware has been written, a magic keyword is written at the end of the firmware. At startup, the Ble_Ota application checks whether this magic keyword is there or not at the end of the application. In case a reset occurred during upload which could result on a partial image to be written, the magic keyword will not be there and the corrupted application will be ignored by the Ble_Ota startup.
As the application length information is not present, the address of the Magic Keyword is written @0x0800 7140.
In order to make the calculation transparent to the user, two constants are defined in the firmware. One is holding the address of the magic Keyword and is associated with section TAG_OTA_START and the other one is holding the magic keyword and is associated with TAG_OTA_END.
The linker file is updated with these two sections and the address of the magic keyword is calculated automatically by the linker.
Regards
2020-11-11 05:37 AM
hello @Christophe Arnal
how to update linker file according to OTA application in stm32wb55, code is generated by STM32CubeIDE(STM32Cube_FW_WB_V1.8.0).
There is two linker files for Flash(STM32WB55RGVX_FLASH.ld) and RAM(STM32WB55RGVX_RAM.ld).
2020-11-20 08:51 AM
Hello,
I would recommend to check the provided linker file of either BLE_HeartRate_ota or BLE_p2pServer_ota.
I extracted from the linker provided the important section related to OTA
You basically need to :
I would recommend to study the linker file of either IAR or KEIL which are much more easy to understand.
MEMORY
{
FLASH (rx) : ORIGIN = 0x08007000, LENGTH = 484k
RAM1 (xrw) : ORIGIN = 0x20000004, LENGTH = 191k
RAM_SHARED (xrw) : ORIGIN = 0x20030000, LENGTH = 10K
}
.ota_region 0x08007140:
{
KEEP(*(TAG_OTA_START))
. = ALIGN(4);
} >FLASH
.ota_region_end :
{
. = ALIGN(4);
KEEP(*(TAG_OTA_END))
. = ALIGN(4);
} >FLASH
MAPPING_TABLE (NOLOAD) : { *(MAPPING_TABLE) } >RAM_SHARED
MB_MEM1 (NOLOAD) : { *(MB_MEM1) } >RAM_SHARED
MB_MEM2 (NOLOAD) : { _sMB_MEM2 = . ; *(MB_MEM2) ; _eMB_MEM2 = . ; } >RAM_SHARED
TAG_OTA_END(NOLOAD) : { KEEP (*(TAG_OTA_END)) } >FLASH
Regards