How does the STM32F0 EEPROM emulation library allocate pages in FLASH?
I am new to the STM32. I am starting a project that requires just one byte of EEPROM.
I am using the STM32F072RBT6 on a Nucleo board.
I have been successful in getting the eeprom emulation code from the stm32cubef0 examples incorporated into code that compiles for the STM32F072RB using the eeprom.h and eeprom.c files included with the example under the STM32F091RC Applications folder.
My confusion is about how or where the Page 0 and Page 1 in this example are being allocated in FLASH, such that it is not overwriting code.
From my understanding of the example, Page 0 and Page 1 start at the beginning of FLASH (below is from the eeprom.h file):
/* Base address of the Flash sectors */
#define ADDR_FLASH_PAGE_0 ((uint32_t)0x08000000) /* Base @ of Page 0, 2 Kbytes */
#define ADDR_FLASH_PAGE_1 ((uint32_t)0x08000800) /* Base @ of Page 1, 2 Kbytes */
According the linker file (STM32F091RCTx_FLASH.ld) that came with the example for the F091RC, there did not seem to be any provision made for the EEPROM data on these pages:
/* Specify the memory areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 256K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
}
/* Define output sections */
SECTIONS
{
/* The startup code goes first into FLASH */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >FLASH
/* The program code and other data goes into FLASH */
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >FLASH
/* Constant data goes into FLASH */
.rodata :
{
. = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
} >FLASH
When I compiled my code for the F09 or F07 in Atollic TrueStudio, I checked the linker files, and they are the same.
From what I have researched, it seems to be that the linker script should be altered to account for this allocation. However, the Application note for the EEPROM emulation on the STM32F0 (AN4061) does not mention anything about this allocation. Neither does the README.txt that comes with the example code. Also, I cannot find any comments in the code related to this.
This makes me think that is is somehow being taken care of, but I cannot find out how or where.
Any assistance is appreciated.