From eb18cc19cb392a69f8675c42776c644d1003ed89 Mon Sep 17 00:00:00 2001 From: Karl Palsson Date: Fri, 25 Jan 2013 10:13:33 +0000 Subject: [PATCH] stm32l1: Add eeprom to memory maps 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. --- lib/stm32/l1/libopencm3_stm32l1.ld | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/stm32/l1/libopencm3_stm32l1.ld b/lib/stm32/l1/libopencm3_stm32l1.ld index 3fc2ccb6..b0032e56 100644 --- a/lib/stm32/l1/libopencm3_stm32l1.ld +++ b/lib/stm32/l1/libopencm3_stm32l1.ld @@ -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++.