cancel
Showing results for 
Search instead for 
Did you mean: 

remap routine in SRAM for Bootloader

DAUSILI
Associate II
Hi,
I need to remap my code in SRAM for my custom Bootloader.
This to be able to erase the flash dedicated to Bootloader when the Bootloader itself needs to be update.
I used __attribute__ ((section(".RamFunc"))) on the functions declaration in my code.
The functions with this attribute now are in SRAM.
But are not yet in SRAM the funcions called inside them.
 
For example:
__attribute__ ((section(".RamFunc"))) int16_t HW_FLASH_ErasePages (uint32_t firstPage, uint32_t pagesNmb);
 
"HW_FLASH_ErasePages" is in SRAM, but "HAL_FLASH_Unlock" called inside "HW_FLASH_ErasePages" is still in flash.
 
So when I execute the erase of Bootloader, i get a fault.
 
I also try to make this on linker file (I added the raw  *stm32g0xx_hal_flash.o(.text)):
 
/* Initialized data sections into "RAM" Ram type memory */
  .data :
  {
    . = ALIGN(4);
    _sdata = .;        /* create a global symbol at data start */
    *(.data)           /* .data sections */
    *(.data*)          /* .data* sections */
    *(.RamFunc)        /* .RamFunc sections */
    *(.RamFunc*)       /* .RamFunc* sections */
    
/* ADDED BY ME TO  REMAP IN SRAM HAL_FLASH_Unlock*/
    *stm32g0xx_hal_flash.o(.text)
 
    . = ALIGN(4);
    _edata = .;        /* define a global symbol at data end */
 
  } >RAM AT> FLASH
0 REPLIES 0