stm32keil

How to stock data in the specific place of flash memory stm32 and keil?


I wanna store some variable in specific place of FLASH memory on stm32, so i changed the scatter file in keil. but anytime i checked the map file, the variable doesn't in the true place in Flash memory. my scatter file:

LR_IROM1 0x08000000 0x00007800  {    ; load region size_region
  ER_IROM1 0x08000000 0x00007800  {  ; load address = execution address
   *.o (RESET, +First)
   *(InRoot$$Sections)
   .ANY (+RO)
   .ANY (+XO)
  }
  user_flash 0x08007800 0x00000800  { 
   .ANY (+RO)
  }
  RW_IRAM1 0x20000000 0x00001000  {  ; RW data
   .ANY (+RW +ZI)
  }
}

and my variable:

__IO float  EE_Myvariable __attribute__((section(".user_flash"))) = 21.0;

how can i cope with this issue? thanks in advance


Solution

  • I chenged to this:

    LR_IROM1 0x08000000 0x00007800  {    ; load region size_region
      ER_IROM1 0x08000000 0x00007800  {  ; load address = execution address
       *.o (RESET, +First)
       *(InRoot$$Sections)
       .ANY (+RO)
       .ANY (+XO)
      }
      RW_IRAM1 0x20000000 0x00001000  {  ; RW data
       .ANY (+RW +ZI)
      }
    }
    LR_IROM2 0x08007800 0x00000800 {
      My_flash 0x08007800 0x00000800  {  ; load address = execution address
        ;.ANY (+RW)
        *.o(.user_flash)
      }
    }
    

    and that worked truly