cancel
Showing results for 
Search instead for 
Did you mean: 

Copying the running application from the bootloader/application

shijinjose
Associate II

Hi, 

Am using a STM32WL55JCix series MCU for my application. Created a custom bootloader running at 0x08000000 with size 25K and application runs at 0x08006400 with size 231K.

I was able to run the bootloader and jump to application without any issue. As part of the OTA firmware update, the downloaded image will be saved to external flash OTA sector1. Then from the bootloader, check for new firmware in the external flash. if the OTA image is there, want to save the currently running application to external flash OTA sector2 and then load the OTA image to internal flash.

The problem arise here. able to get the flash image size by 

extern int _etext;

#define IMAGE_LAST_ADDRESS (uint32_t) (& _etext)

uint32_t imageSize = IMAGE_LAST_ADDRESS - APP_BASE_ADDRESS;

and copy the image.

from the boot loader if i load this image to flash with same application at 0x08006400, it running.

But if i flash a new image at 0x08006400 and load the old image from external flash to the internal flash at 0x08006400, then its not working 

Any help on this one ? am i copying all the necessary data to the external flash ?

1 ACCEPTED SOLUTION

Accepted Solutions
shijinjose
Associate II

Hi.. its solved..

extern int _etext;

#define IMAGE_LAST_ADDRESS (uint32_t) (& _etext).it will give only the code not the complete image from the flash.

 

 

Added new variable in the linker script which will give last flash address.

.endof :

{

_flash_end_addr = .;

} >FLASH

 

From this able to get the exact size of the image and get the backup

 

View solution in original post

2 REPLIES 2
TDK
Super User

If you copy the program into flash, and the program works, it'll run.

If it doesn't run, verify that the flash was programmed successfully by loading in STM32CubeProgrammer and comparing to the target flash image. If it matches, you need to debug the program. If not, you need to debug the flashing procedure.

If you feel a post has answered your question, please click "Accept as Solution".
shijinjose
Associate II

Hi.. its solved..

extern int _etext;

#define IMAGE_LAST_ADDRESS (uint32_t) (& _etext).it will give only the code not the complete image from the flash.

 

 

Added new variable in the linker script which will give last flash address.

.endof :

{

_flash_end_addr = .;

} >FLASH

 

From this able to get the exact size of the image and get the backup