OTA linker script error in CubeWB 1.3.0 examples?
In the linker scripts for BLE_p2pServer_ota in CubeWB1.3.0, the ld script puts the OTA_TAG at 0x08007178:
/* Specify the memory areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08007000, LENGTH = 1k
RAM1 (xrw) : ORIGIN = 0x20000004, LENGTH = 191k
RAM_SHARED (xrw) : ORIGIN = 0x20030000, LENGTH = 10k
OTA_TAG (rx) : ORIGIN = 0x08007178 , LENGTH = 599k
}However, the BLE_ota example checks a COMPLETELY different address in CheckFwAppValidity:
static uint8_t CheckFwAppValidity( void )
{
uint8_t status;
uint32_t magic_keyword_address;
uint32_t last_user_flash_address;
magic_keyword_address = *(uint32_t*)(FLASH_BASE + (CFG_APP_START_SECTOR_INDEX * 0x1000 + 0x140));
last_user_flash_address = (((READ_BIT(FLASH->SFR, FLASH_SFR_SFSA) >> FLASH_SFR_SFSA_Pos) << 12) + FLASH_BASE) - 4;
if( (magic_keyword_address < FLASH_BASE) || (magic_keyword_address > last_user_flash_address) )
{In particular the line:
magic_keyword_address = *(uint32_t*)(FLASH_BASE + (CFG_APP_START_SECTOR_INDEX * 0x1000 + 0x140));Checks the value of 0x08007140 (since CFG_APP_START_SECTOR_INDEX is 7).
So when we compile OTA apps with the new linker script, the MCU never boots into the main FW and stays in the OTA firmware. How can we fix this? Should we change the linker script, or change the OTA firmware which is hardcoded to check 0x08007140?