Storing variable in Flash memory
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
