Skip to content

Commit

Permalink
stm32l1: Add eeprom to memory maps
Browse files Browse the repository at this point in the history
By adding an "eep" memory section, and a NOLOAD step into the linker
scripts, you can now let gcc allocate variables in eeprom for you.
However, as fitting for eeprom, they cannot be initialized, and will not
be loaded at any time.  This simply lets you get place variables in the
eeprom space.

Example:

struct whatever __attribute__((section(".eeprom"))) blah;
struct another __attribute__((section(".eeprom"))) wop;
printf("%#x", &blah); // ==> 0x08080000
printf("%#x", &wop); // ==> 0x08080000 +  sizeof(blah)

You can read directly out of these variables, but need to use the
eeprom_ routines for writing to them.
  • Loading branch information
karlp committed Sep 22, 2015
1 parent 15a6103 commit eb18cc1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/stm32/l1/libopencm3_stm32l1.ld
Expand Up @@ -92,6 +92,11 @@ SECTIONS
_ebss = .;
} >ram

.eeprom (NOLOAD) : {
. = ALIGN(4);
*(.eeprom*)
} >eep

/*
* The .eh_frame section appears to be used for C++ exception handling.
* You may need to fix this if you're using C++.
Expand Down

0 comments on commit eb18cc1

Please sign in to comment.