cancel
Showing results for 
Search instead for 
Did you mean: 

STM32WB55RG - STM_OTA BLE don't update firmware, how change mbed linker

PawelM
Associate III

How change mbed linker for STM32WB55 to used STM_OTA bootloader (need to add TAG_OTA_START, TAG_OTA_END ...). This is my code but don't work, mbed given my error:

; #if !defined(MBED_APP_START)
; #define MBED_APP_START 0x08000000
#define MBED_APP_START 0x08007000
; #endif
 
; #if !defined(MBED_APP_SIZE)
; 768KB FLASH
; #define MBED_APP_SIZE 0xC0000
; 768KB FLASH - 0x7000 = 0xB9000
#define MBED_APP_SIZE 0xB9000
; #endif
 
#if !defined(MBED_BOOT_STACK_SIZE)
  #define MBED_BOOT_STACK_SIZE 0x400
#endif
 
#define Stack_Size MBED_BOOT_STACK_SIZE
 
; 768KB FLASH (0xC0000) + 192KB SRAM (0x30000) +  Shared mem
LR_IROM1 MBED_APP_START 0x184  {    ; load region size_region
 
  ER_IROM1_LOW MBED_APP_START 0x184  {  ; load address = execution address
   *.o (RESET, +First)
   *.o(TAG_OTA_START) 
  }
 
  ; Total: 79 vectors = 316 bytes (0x13C) to be reserved in RAM
  ; RW_IRAM1 (0x20000000+0x13C) (0x30000-0x13C-Stack_Size)  {  ; RW data
  RW_IRAM1 (0x20000004+0x13C) (0x30000-0x13C-Stack_Size-0x4)  {  ; RW data -< new value
  .ANY (+RW +ZI)
  }
 
  ARM_LIB_STACK (0x20000000+0x30000) EMPTY -Stack_Size { ; stack
  }
 
  ; SRAM2 - Shared memory
  RW_IRAM2a 0x20030000 0x00002800  {  ; RW data
    *(MAPPING_TABLE)
    *(MB_MEM1)
  }
  RW_IRAM2b 0x20038000 0x00005000  {  ; RW data
   *(MB_MEM2)
  }
}
LR_IROM3 (MBED_APP_START + 0x184) (MBED_APP_SIZE - 0x184) {
  ER_IROM1_HIGH (MBED_APP_START + 0x184) (MBED_APP_SIZE - 0x184) {  ; load address = execution address   
 
    *(InRoot$$Sections)
    .ANY (+RO)  
    *.o(TAG_OTA_END)       
  }
  }

error:

"BUILD/NUCLEO_WB55RG/ARMC6/.link_script.sct", line 61 (column 8): Warning: L6314W: No section matches pattern *.o(TAG_OTA_START).
"BUILD/NUCLEO_WB55RG/ARMC6/.link_script.sct", line 87 (column 9): Warning: L6314W: No section matches pattern *.o(TAG_OTA_END).
Error: L6220E: Load region LR_IROM1 size (488 bytes) exceeds limit (388 bytes). Region contains 75 bytes of padding and 0 bytes of veneers (total 75 bytes of linker generated content).
Error: L6221E: Load region LR_IROM1 with Load range [0x08007000,0x080071e8) overlaps with Load region LR_IROM3 with Load range [0x08007184,0x0802dc84).
Finished: 0 information, 13 warning and 2 error messages.

When I rewrite linker I use uVision linker in "en.stm32cubewb\STM32Cube_FW_WB_V1.2.0\Projects\P-NUCLEO-WB55.Nucleo\Applications\BLE\BLE_HeartRate_ota" package with a few example but not to mbed :( 

I written about this problem at mbed forum on github. I written there many details and describe what i did till now.

I don't wont duplicate all my posts - sorry for that, please go to the link https://github.com/ARMmbed/mbed-os/issues/11864

Thanks for help.

3 REPLIES 3
Vyacheslav
Senior II

Hi,

Linker remove unused sections.

If you code contains  (and it should contain it):

PLACE_IN_SECTION("TAG_OTA_END") const uint32_t MagicKeywordValue = 0x94448A29 ;

PLACE_IN_SECTION("TAG_OTA_START") const uint32_t MagicKeywordAddress = (uint32_t)&MagicKeywordValue;

but these variables are not used anywhere in the code, so the linker remove it out.

In order to remain them, you need to write a linker options

--keep *.o(TAG_OTA_START)

--keep *.o(TAG_OTA_END)

but I dont know where to do in Mbed studio .

About overlap error - look at the scatter file in SDK 1.3.0, maybe it will help you.

Regards,

Vyacheslav.

Remi QUINTIN
ST Employee

For example in the STM32Cube_FW_WB_V1.3.0\Projects\P-NUCLEO-WB55.Nucleo\Applications\BLE\BLE_HeartRate_ota directory, under the /STM32_WPAN\App you can find in the app_ble.c file the placement of these 2 values

PLACE_IN_SECTION("TAG_OTA_END") const uint32_t MagicKeywordValue = 0x94448A29 ;

PLACE_IN_SECTION("TAG_OTA_START") const uint32_t MagicKeywordAddress = (uint32_t)&MagicKeywordValue;

Have also a look in the scatter file .ld in the SW4STM32\BLE_HeartRate_ota directory where the 2 sections are logged in 2 different memory areas FALSH and OTA_TAG.

TAG_OTA_START         : { KEEP (*(TAG_OTA_START)) } >FLASH

T AG_OTA_END           : { KEEP (*(TAG_OTA_END)) } >OTA_TAG

These 2 MEMORY areas are defined at the beginning of this scatter file by

/* 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

}

You have to replicate this declaration scheme with mbed IDE.

Remi QUINTIN
ST Employee

​Regarding the second error, The size of the data you located inside the LR_IROM1 section (488bytes = 0x1e8) is exceeding the reserved size (388 bytes = 0x184). Hence it overlaps with the next LR_IRPM3 section. Check the data size of the (Reset, + First) area.