This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Scatter load question (STM32L152)

I'm trying to place a variable in EEPROM such that the address of the variable shows up at the EEPROM's address but the linker does not try to initialize the var. The idea is that when code reads the variable it's reading from EEPROM and any writes are done via EEPROM_xxx() functions.

I realize this would be easier done with a pointer to a structure that has all the EEPROM-backed values but it's kind of nice to just have the compiler and linker take care of everything.

Here's what I have in my C code:

__attribute ((section ("EEPROM"))) uint8_t Bias_Current;
__attribute ((section ("EEPROM"))) bool Auto_test;

I set up sections in the "Target" dialog and I'm using the following scatter load file:

LR_IROM1 0x08000000 0x00020000  {    ; load region size_region
  ER_IROM1 0x08000000 0x00020000  {  ; load address = execution address
   *.o (RESET, +First)
   *(InRoot$$Sections)
   .ANY (+RO)
  }
  RW_IRAM1 0x20000000 0x00004000  {  ; RW data
    icc_measure_Ram.o (+RO)
   .ANY (+RW +ZI)
  }
  ER_ROM1 0x00808000 UNINIT 0x00001000 {  ; load address = execution address
   *(EEPROM)
  }
  
}

However, when I run the code the scatter load algorithm crashes because it's trying to initialize the target address (0x808000), even though I marked it as "UNINIT".

What's the best way to use scatter loading to place variables at a target address but make sure the target address doesn't get written to by the scatter loader?

Thanks,
Andrew