kopia lustrzana https://github.com/skuep/AIOC
Moved flash definitions into linker file and added explicit invalidation into the programming file. This way the user configuration is lost on each firmware upgrade. Although inconvenient, it's required for now since settings might not be compatible between versions
rodzic
c0fbd8c746
commit
e853047a2c
|
@ -2,6 +2,10 @@
|
|||
#include <assert.h>
|
||||
#include "stm32f3xx_hal.h"
|
||||
|
||||
/* Define this, so that each time the AIOC is programmed, the EEPROM is cleared.
|
||||
* This is inconvenient, but settings might not be portable across versions. */
|
||||
uint32_t settingsRegMapROM[SETTINGS_REGMAP_SIZE] __attribute__ ((section (".eeprom"))) = {[0 ... (SETTINGS_REGMAP_SIZE-1)] = 0xFF};
|
||||
|
||||
uint32_t settingsRegMap[SETTINGS_REGMAP_SIZE] = {[0 ... (SETTINGS_REGMAP_SIZE-1)] = 0};
|
||||
|
||||
void Settings_Init()
|
||||
|
@ -79,7 +83,10 @@ void Settings_Store(void)
|
|||
|
||||
void Settings_Recall(void)
|
||||
{
|
||||
uint32_t wordAddress = SETTINGS_FLASH_ADDRESS;
|
||||
/* From linker script */
|
||||
extern uint32_t * _eeprom;
|
||||
|
||||
uint32_t wordAddress = (uint32_t) &_eeprom;
|
||||
uint32_t wordCount = SETTINGS_REGMAP_SIZE;
|
||||
uint32_t * wordPtr = settingsRegMap;
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include "usb_descriptors.h"
|
||||
|
||||
#define SETTINGS_REGMAP_SIZE 256
|
||||
#define SETTINGS_FLASH_ADDRESS 0x0801F000UL
|
||||
|
||||
extern uint32_t settingsRegMap[SETTINGS_REGMAP_SIZE];
|
||||
|
||||
|
|
|
@ -76,6 +76,12 @@ SECTIONS
|
|||
_etext = .; /* define a global symbols at end of code */
|
||||
} >FLASH
|
||||
|
||||
.eeprom 0x0801F000 :
|
||||
{
|
||||
_eeprom = .;
|
||||
KEEP(*(.eeprom))
|
||||
}
|
||||
|
||||
/* Constant data goes into FLASH */
|
||||
.rodata :
|
||||
{
|
||||
|
|
Ładowanie…
Reference in New Issue