NVRAM refactor, phase 1. (#18969)
* Rename `eeprom_stm32` to `eeprom_legacy_emulated_flash`. * Rename `flash_stm32` to `legacy_flash_ops`. * Rename `eeprom_teensy` to `eeprom_kinetis_flexram`.
This commit is contained in:
parent
bfdc761819
commit
bebfdad795
@ -222,10 +222,10 @@ else
|
|||||||
else ifeq ($(PLATFORM),CHIBIOS)
|
else ifeq ($(PLATFORM),CHIBIOS)
|
||||||
ifneq ($(filter %_STM32F072xB %_STM32F042x6, $(MCU_SERIES)_$(MCU_LDSCRIPT)),)
|
ifneq ($(filter %_STM32F072xB %_STM32F042x6, $(MCU_SERIES)_$(MCU_LDSCRIPT)),)
|
||||||
# STM32 Emulated EEPROM, backed by MCU flash (soon to be deprecated)
|
# STM32 Emulated EEPROM, backed by MCU flash (soon to be deprecated)
|
||||||
OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_STM32_FLASH_EMULATED
|
OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_LEGACY_EMULATED_FLASH
|
||||||
COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/flash
|
COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/flash
|
||||||
COMMON_VPATH += $(DRIVER_PATH)/flash
|
COMMON_VPATH += $(DRIVER_PATH)/flash
|
||||||
SRC += eeprom_driver.c eeprom_stm32.c flash_stm32.c
|
SRC += eeprom_driver.c eeprom_legacy_emulated_flash.c legacy_flash_ops.c
|
||||||
else ifneq ($(filter $(MCU_SERIES),STM32F1xx STM32F3xx STM32F4xx STM32L4xx STM32G4xx WB32F3G71xx WB32FQ95xx GD32VF103),)
|
else ifneq ($(filter $(MCU_SERIES),STM32F1xx STM32F3xx STM32F4xx STM32L4xx STM32G4xx WB32F3G71xx WB32FQ95xx GD32VF103),)
|
||||||
# Wear-leveling EEPROM implementation, backed by MCU flash
|
# Wear-leveling EEPROM implementation, backed by MCU flash
|
||||||
OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_WEAR_LEVELING
|
OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_WEAR_LEVELING
|
||||||
@ -242,8 +242,8 @@ else
|
|||||||
WEAR_LEVELING_DRIVER = rp2040_flash
|
WEAR_LEVELING_DRIVER = rp2040_flash
|
||||||
else ifneq ($(filter $(MCU_SERIES),KL2x K20x),)
|
else ifneq ($(filter $(MCU_SERIES),KL2x K20x),)
|
||||||
# Teensy EEPROM implementations
|
# Teensy EEPROM implementations
|
||||||
OPT_DEFS += -DEEPROM_TEENSY
|
OPT_DEFS += -DEEPROM_KINETIS_FLEXRAM
|
||||||
SRC += eeprom_teensy.c
|
SRC += eeprom_kinetis_flexram.c
|
||||||
else
|
else
|
||||||
# Fall back to transient, i.e. non-persistent
|
# Fall back to transient, i.e. non-persistent
|
||||||
OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_TRANSIENT
|
OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_TRANSIENT
|
||||||
@ -287,7 +287,7 @@ ifneq ($(strip $(WEAR_LEVELING_DRIVER)),none)
|
|||||||
POST_CONFIG_H += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_PATH)/wear_leveling/wear_leveling_rp2040_flash_config.h
|
POST_CONFIG_H += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_PATH)/wear_leveling/wear_leveling_rp2040_flash_config.h
|
||||||
else ifeq ($(strip $(WEAR_LEVELING_DRIVER)), legacy)
|
else ifeq ($(strip $(WEAR_LEVELING_DRIVER)), legacy)
|
||||||
COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/flash
|
COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/flash
|
||||||
SRC += flash_stm32.c wear_leveling_legacy.c
|
SRC += legacy_flash_ops.c wear_leveling_legacy.c
|
||||||
POST_CONFIG_H += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/wear_leveling/wear_leveling_legacy_config.h
|
POST_CONFIG_H += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/wear_leveling/wear_leveling_legacy_config.h
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <ch.h>
|
#include <ch.h>
|
||||||
#include <hal.h>
|
#include <hal.h>
|
||||||
|
|
||||||
#include "eeprom_teensy.h"
|
#include "eeprom_kinetis_flexram.h"
|
||||||
#include "eeconfig.h"
|
#include "eeconfig.h"
|
||||||
|
|
||||||
/*************************************/
|
/*************************************/
|
@ -22,8 +22,8 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "eeprom_stm32.h"
|
#include "eeprom_legacy_emulated_flash.h"
|
||||||
#include "flash_stm32.h"
|
#include "legacy_flash_ops.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We emulate eeprom by writing a snapshot compacted view of eeprom contents,
|
* We emulate eeprom by writing a snapshot compacted view of eeprom contents,
|
||||||
@ -132,7 +132,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "eeprom_stm32_defs.h"
|
#include "eeprom_legacy_emulated_flash_defs.h"
|
||||||
/* These bits are used for optimizing encoding of bytes, 0 and 1 */
|
/* These bits are used for optimizing encoding of bytes, 0 and 1 */
|
||||||
#define FEE_WORD_ENCODING 0x8000
|
#define FEE_WORD_ENCODING 0x8000
|
||||||
#define FEE_VALUE_NEXT 0x6000
|
#define FEE_VALUE_NEXT 0x6000
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <hal.h>
|
#include <hal.h>
|
||||||
#include "flash_stm32.h"
|
#include "legacy_flash_ops.h"
|
||||||
|
|
||||||
#if defined(STM32F1XX)
|
#if defined(STM32F1XX)
|
||||||
# define FLASH_SR_WRPERR FLASH_SR_WRPRTERR
|
# define FLASH_SR_WRPERR FLASH_SR_WRPRTERR
|
@ -24,7 +24,7 @@ extern "C" {
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifdef FLASH_STM32_MOCKED
|
#ifdef LEGACY_FLASH_OPS_MOCKED
|
||||||
extern uint8_t FlashBuf[MOCK_FLASH_SIZE];
|
extern uint8_t FlashBuf[MOCK_FLASH_SIZE];
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -5,7 +5,7 @@
|
|||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "wear_leveling.h"
|
#include "wear_leveling.h"
|
||||||
#include "wear_leveling_internal.h"
|
#include "wear_leveling_internal.h"
|
||||||
#include "flash_stm32.h"
|
#include "legacy_flash_ops.h"
|
||||||
|
|
||||||
bool backing_store_init(void) {
|
bool backing_store_init(void) {
|
||||||
bs_dprintf("Init\n");
|
bs_dprintf("Init\n");
|
||||||
|
@ -41,11 +41,11 @@ void eeprom_update_block(const void *__src, void *__dst, size_t __n);
|
|||||||
#elif defined(EEPROM_STM32_L0_L1)
|
#elif defined(EEPROM_STM32_L0_L1)
|
||||||
# include "eeprom_stm32_L0_L1.h"
|
# include "eeprom_stm32_L0_L1.h"
|
||||||
# define TOTAL_EEPROM_BYTE_COUNT (STM32_ONBOARD_EEPROM_SIZE)
|
# define TOTAL_EEPROM_BYTE_COUNT (STM32_ONBOARD_EEPROM_SIZE)
|
||||||
#elif defined(EEPROM_TEENSY)
|
#elif defined(EEPROM_KINETIS_FLEXRAM)
|
||||||
# include "eeprom_teensy.h"
|
# include "eeprom_kinetis_flexram.h"
|
||||||
# define TOTAL_EEPROM_BYTE_COUNT (EEPROM_SIZE)
|
# define TOTAL_EEPROM_BYTE_COUNT (EEPROM_SIZE)
|
||||||
#elif defined(EEPROM_STM32_FLASH_EMULATED)
|
#elif defined(EEPROM_LEGACY_EMULATED_FLASH)
|
||||||
# include "eeprom_stm32_defs.h"
|
# include "eeprom_legacy_emulated_flash_defs.h"
|
||||||
# define TOTAL_EEPROM_BYTE_COUNT (FEE_DENSITY_BYTES)
|
# define TOTAL_EEPROM_BYTE_COUNT (FEE_DENSITY_BYTES)
|
||||||
#elif defined(EEPROM_SAMD)
|
#elif defined(EEPROM_SAMD)
|
||||||
# include "eeprom_samd.h"
|
# include "eeprom_samd.h"
|
||||||
@ -59,12 +59,12 @@ void eeprom_update_block(const void *__src, void *__dst, size_t __n);
|
|||||||
#elif defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__)
|
#elif defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__)
|
||||||
# define TOTAL_EEPROM_BYTE_COUNT 4096
|
# define TOTAL_EEPROM_BYTE_COUNT 4096
|
||||||
#elif defined(EEPROM_TEST_HARNESS)
|
#elif defined(EEPROM_TEST_HARNESS)
|
||||||
# ifndef FLASH_STM32_MOCKED
|
# ifndef LEGACY_FLASH_OPS_MOCKED
|
||||||
// Normal tests
|
// Normal tests
|
||||||
# define TOTAL_EEPROM_BYTE_COUNT 32
|
# define TOTAL_EEPROM_BYTE_COUNT 32
|
||||||
# else
|
# else
|
||||||
// Flash wear-leveling testing
|
// Flash wear-leveling testing
|
||||||
# include "eeprom_stm32_tests.h"
|
# include "eeprom_legacy_emulated_flash_tests.h"
|
||||||
# define TOTAL_EEPROM_BYTE_COUNT (EEPROM_SIZE)
|
# define TOTAL_EEPROM_BYTE_COUNT (EEPROM_SIZE)
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "flash_stm32.h"
|
#include "legacy_flash_ops.h"
|
||||||
#include "eeprom_stm32.h"
|
#include "eeprom_legacy_emulated_flash.h"
|
||||||
|
|
||||||
#define EEPROM_SIZE (FEE_PAGE_SIZE * FEE_PAGE_COUNT / 2)
|
#define EEPROM_SIZE (FEE_PAGE_SIZE * FEE_PAGE_COUNT / 2)
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "flash_stm32.h"
|
#include "legacy_flash_ops.h"
|
||||||
|
|
||||||
uint8_t FlashBuf[MOCK_FLASH_SIZE] = {0};
|
uint8_t FlashBuf[MOCK_FLASH_SIZE] = {0};
|
||||||
|
|
@ -1,25 +1,25 @@
|
|||||||
eeprom_stm32_DEFS := -DEEPROM_TEST_HARNESS -DFLASH_STM32_MOCKED -DNO_PRINT -DFEE_FLASH_BASE=FlashBuf
|
eeprom_legacy_emulated_flash_DEFS := -DEEPROM_TEST_HARNESS -DLEGACY_FLASH_OPS_MOCKED -DNO_PRINT -DFEE_FLASH_BASE=FlashBuf
|
||||||
eeprom_stm32_tiny_DEFS := $(eeprom_stm32_DEFS) \
|
eeprom_legacy_emulated_flash_tiny_DEFS := $(eeprom_legacy_emulated_flash_DEFS) \
|
||||||
-DFEE_MCU_FLASH_SIZE=1 \
|
-DFEE_MCU_FLASH_SIZE=1 \
|
||||||
-DMOCK_FLASH_SIZE=1024 \
|
-DMOCK_FLASH_SIZE=1024 \
|
||||||
-DFEE_PAGE_SIZE=512 \
|
-DFEE_PAGE_SIZE=512 \
|
||||||
-DFEE_PAGE_COUNT=1
|
-DFEE_PAGE_COUNT=1
|
||||||
eeprom_stm32_large_DEFS := $(eeprom_stm32_DEFS) \
|
eeprom_legacy_emulated_flash_large_DEFS := $(eeprom_legacy_emulated_flash_DEFS) \
|
||||||
-DFEE_MCU_FLASH_SIZE=64 \
|
-DFEE_MCU_FLASH_SIZE=64 \
|
||||||
-DMOCK_FLASH_SIZE=65536 \
|
-DMOCK_FLASH_SIZE=65536 \
|
||||||
-DFEE_PAGE_SIZE=2048 \
|
-DFEE_PAGE_SIZE=2048 \
|
||||||
-DFEE_PAGE_COUNT=16
|
-DFEE_PAGE_COUNT=16
|
||||||
|
|
||||||
eeprom_stm32_INC := \
|
eeprom_legacy_emulated_flash_INC := \
|
||||||
$(PLATFORM_PATH)/chibios/drivers/eeprom/ \
|
$(PLATFORM_PATH)/chibios/drivers/eeprom/ \
|
||||||
$(PLATFORM_PATH)/chibios/drivers/flash/
|
$(PLATFORM_PATH)/chibios/drivers/flash/
|
||||||
eeprom_stm32_tiny_INC := $(eeprom_stm32_INC)
|
eeprom_legacy_emulated_flash_tiny_INC := $(eeprom_legacy_emulated_flash_INC)
|
||||||
eeprom_stm32_large_INC := $(eeprom_stm32_INC)
|
eeprom_legacy_emulated_flash_large_INC := $(eeprom_legacy_emulated_flash_INC)
|
||||||
|
|
||||||
eeprom_stm32_SRC := \
|
eeprom_legacy_emulated_flash_SRC := \
|
||||||
$(TOP_DIR)/drivers/eeprom/eeprom_driver.c \
|
$(TOP_DIR)/drivers/eeprom/eeprom_driver.c \
|
||||||
$(PLATFORM_PATH)/$(PLATFORM_KEY)/eeprom_stm32_tests.cpp \
|
$(PLATFORM_PATH)/$(PLATFORM_KEY)/eeprom_legacy_emulated_flash_tests.cpp \
|
||||||
$(PLATFORM_PATH)/$(PLATFORM_KEY)/flash_stm32_mock.c \
|
$(PLATFORM_PATH)/$(PLATFORM_KEY)/legacy_flash_ops_mock.c \
|
||||||
$(PLATFORM_PATH)/chibios/drivers/eeprom/eeprom_stm32.c
|
$(PLATFORM_PATH)/chibios/drivers/eeprom/eeprom_legacy_emulated_flash.c
|
||||||
eeprom_stm32_tiny_SRC := $(eeprom_stm32_SRC)
|
eeprom_legacy_emulated_flash_tiny_SRC := $(eeprom_legacy_emulated_flash_SRC)
|
||||||
eeprom_stm32_large_SRC := $(eeprom_stm32_SRC)
|
eeprom_legacy_emulated_flash_large_SRC := $(eeprom_legacy_emulated_flash_SRC)
|
||||||
|
@ -1 +1 @@
|
|||||||
TEST_LIST += eeprom_stm32_tiny eeprom_stm32_large
|
TEST_LIST += eeprom_legacy_emulated_flash_tiny eeprom_legacy_emulated_flash_large
|
||||||
|
Loading…
Reference in New Issue
Block a user