[L476RG]could not assign flash memory address to functions for the purpose of upgrade firmware
In the firmware we have some upgrade functions/data, if we want to update the firmware, we have to make sure those upgrade functions/data will not be erased . So I edit Debug_STM32L476RG_FLASH.ld file, and change
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 96K
RAM2 (rw) : ORIGIN = 0x10000000, LENGTH = 32K
MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0Kto
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 768K
UPGRADE_VAR (rx) : ORIGIN = 0x080C0000, LENGTH = 128K
UPGRADE_FUN (rx): ORIGIN = 0x080E0000, LENGTH = 128K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 96K
RAM2 (rw) : ORIGIN = 0x10000000, LENGTH = 32K
MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K, I just inserted two memory regions for the upgrade use.
then I also added the following sections in this file.
.crc_table :
{
PROVIDE_HIDDEN (__crc_table_start = .);
KEEP (*(SORT(.crc_table.*)))
KEEP (*(.crc_table*))
PROVIDE_HIDDEN (__crc_table_end = .);
} >UPGRADE_VAR
.upgrade :
{
PROVIDE_HIDDEN (__upgrade_start = .);
KEEP (*(SORT(.upgrade.*)))
KEEP (*(.upgrade*))
PROVIDE_HIDDEN (__upgrade_end = .);
} > UPGRADE_FUNalso, in my firmware I added attribute for this flash memory distribution:
__attribute__((section(".crc_table"))) static const unsigned int crctable[]={
...
}
__attribute__((section(".upgrade"))) unsigned int crc_cal(unsigned int msg[],int len){
...
}
__attribute__((section(".upgrade"))) short upgrade_firmware(__uint8_t *input){
...
}Now the problem is: the build on Atollic TrueStudio is succesfull: please see the following build analyzer results
However, when you run the firmware code on TrueStudio, it will show you :
Failure at line:13 in 'Target Software Startup Scripts'. Please edit the debug configuration setting.
I googled and some people mentioned it is a version problem, https://forum.atollic.com/viewtopic.php?t=1382, I downgraded TrueStudio to 9.0.0 tried this but it has "error in initializing st-link device" error.....