I can store variables in flash memory location successfully but what is happening is updating that variable in main.c file not happening.I'm posted code what i have done below.
Linker script file :
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 153
MY_VARS (xrw) : ORIGIN = 0x08005000, LENGTH = 1K // storing in flash memory
}
.my_vars :
{
*(.MY_VARS*);
} >MY_VARS
In main.c file :
__attribute__((section(".MY_VARS"),myvars)) uint32_t *value=8;
int main()
{
int a =sum(); //i have a sum function of two numbers and storing in variable 'a'
value =&a; // value should updated to sum but it is not updating
readaddress=(const volatile uint32_t *)0x08005000;// reading flash memory
printf("Read flash address %lu\n",*readaddress);// printing the data which is stored in value ,it is printing everytime 8 but it should print variable data which stored in 'a'.
}
int sum(int a)
{
int a=1, b= 34 ;
a=a+b;
return a;
}
Can anybody help me to figure this out,i hope u understood what im asking.
Thank you
Storing variable in Flash memory
Moderators: Markus Girdland, Mattias Norlander
Re: Storing variable in Flash memory
Hello,
The variable "value" cannot be loaded the address of "a" because "value" is constant. Data in flash has to be erased and reprogrammed which can be done using the HAL flash library. From the debugger, do you get the initial value of 8 for the "value"?
The variable "value" cannot be loaded the address of "a" because "value" is constant. Data in flash has to be erased and reprogrammed which can be done using the HAL flash library. From the debugger, do you get the initial value of 8 for the "value"?
Re: Storing variable in Flash memory
Hello,
See my post about constant tables in flash.
See my post about constant tables in flash.
Return to “TrueSTUDIO for STM32 discussions”
Who is online
Users browsing this forum: No registered users and 1 guest