Skip to main content
aonsquared
Associate III
December 29, 2019
Solved

OTA linker script error in CubeWB 1.3.0 examples?

  • December 29, 2019
  • 3 replies
  • 1332 views

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?

This topic has been closed for replies.
Best answer by Remi QUINTIN

​Indeed!

the linker file of the BLE_p2pServer_ota application in the V1.4.0 package  is attached.

The OTA tag location is not defined as a region but as a section (see bellow):

/* Specify the memory areas */

MEMORY

{

FLASH (rx)                : ORIGIN = 0x08007000, LENGTH = 484k

RAM1 (xrw)                : ORIGIN = 0x20000004, LENGTH = 191k

RAM_SHARED (xrw)          : ORIGIN = 0x20030000, LENGTH = 10K

}

/* Define output sections */

SECTIONS

{

 /* The startup code goes first into FLASH */

 .isr_vector :

 {

   . = ALIGN(4);

   KEEP(*(.isr_vector)) /* Startup code */

   . = ALIGN(4);

 } >FLASH

   .ota_region 0x08007140:

 {

 KEEP(*(TAG_OTA_START))

 . = ALIGN(4);

 } >FLASH

3 replies

aonsquared
Associate III
December 29, 2019

Just to clarify, for a previous version of CubeWB we were using (1.1.1), the linker script for BLE_p2pServer_ota points to the correct address:

/* 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 = 0x08007140 , LENGTH = 1k
OTA_TAG2(rx) : ORIGIN = 0x08007144 , LENGTH = 483k
}

Remi QUINTIN
Technical Moderator
January 6, 2020

These errors have been corrected on the release V1.4.0 of the CubeWB FW package.

For sure you should not modify any files of the ble-ota application.

aonsquared
Associate III
January 6, 2020

As V1.4.0 is not on the website yet, just to confirm the change is with OTA_TAG like this?

 /* 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 = 0x08007140 , LENGTH = 599k
 }

Thanks!

Remi QUINTIN
Technical Moderator
January 6, 2020

​Indeed!

the linker file of the BLE_p2pServer_ota application in the V1.4.0 package  is attached.

The OTA tag location is not defined as a region but as a section (see bellow):

/* Specify the memory areas */

MEMORY

{

FLASH (rx)                : ORIGIN = 0x08007000, LENGTH = 484k

RAM1 (xrw)                : ORIGIN = 0x20000004, LENGTH = 191k

RAM_SHARED (xrw)          : ORIGIN = 0x20030000, LENGTH = 10K

}

/* Define output sections */

SECTIONS

{

 /* The startup code goes first into FLASH */

 .isr_vector :

 {

   . = ALIGN(4);

   KEEP(*(.isr_vector)) /* Startup code */

   . = ALIGN(4);

 } >FLASH

   .ota_region 0x08007140:

 {

 KEEP(*(TAG_OTA_START))

 . = ALIGN(4);

 } >FLASH