From bebfdad795add9fbc8c6c1393d1b817d542474ed Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Wed, 23 Nov 2022 19:50:19 +1100 Subject: [PATCH] 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`. --- builddefs/common_features.mk | 10 ++++---- ...prom_teensy.c => eeprom_kinetis_flexram.c} | 2 +- ...prom_teensy.h => eeprom_kinetis_flexram.h} | 0 ...stm32.c => eeprom_legacy_emulated_flash.c} | 6 ++--- ...stm32.h => eeprom_legacy_emulated_flash.h} | 0 ....h => eeprom_legacy_emulated_flash_defs.h} | 0 .../{flash_stm32.c => legacy_flash_ops.c} | 2 +- .../{flash_stm32.h => legacy_flash_ops.h} | 2 +- .../wear_leveling/wear_leveling_legacy.c | 2 +- platforms/eeprom.h | 12 +++++----- ...=> eeprom_legacy_emulated_flash_tests.cpp} | 0 ...h => eeprom_legacy_emulated_flash_tests.h} | 4 ++-- ...h_stm32_mock.c => legacy_flash_ops_mock.c} | 2 +- platforms/test/rules.mk | 24 +++++++++---------- platforms/test/testlist.mk | 2 +- 15 files changed, 34 insertions(+), 34 deletions(-) rename platforms/chibios/drivers/eeprom/{eeprom_teensy.c => eeprom_kinetis_flexram.c} (99%) rename platforms/chibios/drivers/eeprom/{eeprom_teensy.h => eeprom_kinetis_flexram.h} (100%) rename platforms/chibios/drivers/eeprom/{eeprom_stm32.c => eeprom_legacy_emulated_flash.c} (99%) rename platforms/chibios/drivers/eeprom/{eeprom_stm32.h => eeprom_legacy_emulated_flash.h} (100%) rename platforms/chibios/drivers/eeprom/{eeprom_stm32_defs.h => eeprom_legacy_emulated_flash_defs.h} (100%) rename platforms/chibios/drivers/flash/{flash_stm32.c => legacy_flash_ops.c} (99%) rename platforms/chibios/drivers/flash/{flash_stm32.h => legacy_flash_ops.h} (97%) rename platforms/test/{eeprom_stm32_tests.cpp => eeprom_legacy_emulated_flash_tests.cpp} (100%) rename platforms/test/{eeprom_stm32_tests.h => eeprom_legacy_emulated_flash_tests.h} (69%) rename platforms/test/{flash_stm32_mock.c => legacy_flash_ops_mock.c} (98%) diff --git a/builddefs/common_features.mk b/builddefs/common_features.mk index c6a67ee87d..63814bbfae 100644 --- a/builddefs/common_features.mk +++ b/builddefs/common_features.mk @@ -222,10 +222,10 @@ else else ifeq ($(PLATFORM),CHIBIOS) ifneq ($(filter %_STM32F072xB %_STM32F042x6, $(MCU_SERIES)_$(MCU_LDSCRIPT)),) # 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 += $(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),) # Wear-leveling EEPROM implementation, backed by MCU flash OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_WEAR_LEVELING @@ -242,8 +242,8 @@ else WEAR_LEVELING_DRIVER = rp2040_flash else ifneq ($(filter $(MCU_SERIES),KL2x K20x),) # Teensy EEPROM implementations - OPT_DEFS += -DEEPROM_TEENSY - SRC += eeprom_teensy.c + OPT_DEFS += -DEEPROM_KINETIS_FLEXRAM + SRC += eeprom_kinetis_flexram.c else # Fall back to transient, i.e. non-persistent 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 else ifeq ($(strip $(WEAR_LEVELING_DRIVER)), legacy) 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 endif endif diff --git a/platforms/chibios/drivers/eeprom/eeprom_teensy.c b/platforms/chibios/drivers/eeprom/eeprom_kinetis_flexram.c similarity index 99% rename from platforms/chibios/drivers/eeprom/eeprom_teensy.c rename to platforms/chibios/drivers/eeprom/eeprom_kinetis_flexram.c index c8777febde..6468cbf3fa 100644 --- a/platforms/chibios/drivers/eeprom/eeprom_teensy.c +++ b/platforms/chibios/drivers/eeprom/eeprom_kinetis_flexram.c @@ -1,7 +1,7 @@ #include #include -#include "eeprom_teensy.h" +#include "eeprom_kinetis_flexram.h" #include "eeconfig.h" /*************************************/ diff --git a/platforms/chibios/drivers/eeprom/eeprom_teensy.h b/platforms/chibios/drivers/eeprom/eeprom_kinetis_flexram.h similarity index 100% rename from platforms/chibios/drivers/eeprom/eeprom_teensy.h rename to platforms/chibios/drivers/eeprom/eeprom_kinetis_flexram.h diff --git a/platforms/chibios/drivers/eeprom/eeprom_stm32.c b/platforms/chibios/drivers/eeprom/eeprom_legacy_emulated_flash.c similarity index 99% rename from platforms/chibios/drivers/eeprom/eeprom_stm32.c rename to platforms/chibios/drivers/eeprom/eeprom_legacy_emulated_flash.c index 1a354dc213..a81fe3353c 100644 --- a/platforms/chibios/drivers/eeprom/eeprom_stm32.c +++ b/platforms/chibios/drivers/eeprom/eeprom_legacy_emulated_flash.c @@ -22,8 +22,8 @@ #include #include "util.h" #include "debug.h" -#include "eeprom_stm32.h" -#include "flash_stm32.h" +#include "eeprom_legacy_emulated_flash.h" +#include "legacy_flash_ops.h" /* * 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 */ #define FEE_WORD_ENCODING 0x8000 #define FEE_VALUE_NEXT 0x6000 diff --git a/platforms/chibios/drivers/eeprom/eeprom_stm32.h b/platforms/chibios/drivers/eeprom/eeprom_legacy_emulated_flash.h similarity index 100% rename from platforms/chibios/drivers/eeprom/eeprom_stm32.h rename to platforms/chibios/drivers/eeprom/eeprom_legacy_emulated_flash.h diff --git a/platforms/chibios/drivers/eeprom/eeprom_stm32_defs.h b/platforms/chibios/drivers/eeprom/eeprom_legacy_emulated_flash_defs.h similarity index 100% rename from platforms/chibios/drivers/eeprom/eeprom_stm32_defs.h rename to platforms/chibios/drivers/eeprom/eeprom_legacy_emulated_flash_defs.h diff --git a/platforms/chibios/drivers/flash/flash_stm32.c b/platforms/chibios/drivers/flash/legacy_flash_ops.c similarity index 99% rename from platforms/chibios/drivers/flash/flash_stm32.c rename to platforms/chibios/drivers/flash/legacy_flash_ops.c index 72c41b8b78..fe5ad64764 100644 --- a/platforms/chibios/drivers/flash/flash_stm32.c +++ b/platforms/chibios/drivers/flash/legacy_flash_ops.c @@ -17,7 +17,7 @@ */ #include -#include "flash_stm32.h" +#include "legacy_flash_ops.h" #if defined(STM32F1XX) # define FLASH_SR_WRPERR FLASH_SR_WRPRTERR diff --git a/platforms/chibios/drivers/flash/flash_stm32.h b/platforms/chibios/drivers/flash/legacy_flash_ops.h similarity index 97% rename from platforms/chibios/drivers/flash/flash_stm32.h rename to platforms/chibios/drivers/flash/legacy_flash_ops.h index 6c66642ec5..ef80764055 100644 --- a/platforms/chibios/drivers/flash/flash_stm32.h +++ b/platforms/chibios/drivers/flash/legacy_flash_ops.h @@ -24,7 +24,7 @@ extern "C" { #include -#ifdef FLASH_STM32_MOCKED +#ifdef LEGACY_FLASH_OPS_MOCKED extern uint8_t FlashBuf[MOCK_FLASH_SIZE]; #endif diff --git a/platforms/chibios/drivers/wear_leveling/wear_leveling_legacy.c b/platforms/chibios/drivers/wear_leveling/wear_leveling_legacy.c index 87126c4467..7c6fd2d808 100644 --- a/platforms/chibios/drivers/wear_leveling/wear_leveling_legacy.c +++ b/platforms/chibios/drivers/wear_leveling/wear_leveling_legacy.c @@ -5,7 +5,7 @@ #include "timer.h" #include "wear_leveling.h" #include "wear_leveling_internal.h" -#include "flash_stm32.h" +#include "legacy_flash_ops.h" bool backing_store_init(void) { bs_dprintf("Init\n"); diff --git a/platforms/eeprom.h b/platforms/eeprom.h index 8cb7e342dc..fbfef20334 100644 --- a/platforms/eeprom.h +++ b/platforms/eeprom.h @@ -41,11 +41,11 @@ void eeprom_update_block(const void *__src, void *__dst, size_t __n); #elif defined(EEPROM_STM32_L0_L1) # include "eeprom_stm32_L0_L1.h" # define TOTAL_EEPROM_BYTE_COUNT (STM32_ONBOARD_EEPROM_SIZE) -#elif defined(EEPROM_TEENSY) -# include "eeprom_teensy.h" +#elif defined(EEPROM_KINETIS_FLEXRAM) +# include "eeprom_kinetis_flexram.h" # define TOTAL_EEPROM_BYTE_COUNT (EEPROM_SIZE) -#elif defined(EEPROM_STM32_FLASH_EMULATED) -# include "eeprom_stm32_defs.h" +#elif defined(EEPROM_LEGACY_EMULATED_FLASH) +# include "eeprom_legacy_emulated_flash_defs.h" # define TOTAL_EEPROM_BYTE_COUNT (FEE_DENSITY_BYTES) #elif defined(EEPROM_SAMD) # 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__) # define TOTAL_EEPROM_BYTE_COUNT 4096 #elif defined(EEPROM_TEST_HARNESS) -# ifndef FLASH_STM32_MOCKED +# ifndef LEGACY_FLASH_OPS_MOCKED // Normal tests # define TOTAL_EEPROM_BYTE_COUNT 32 # else // Flash wear-leveling testing -# include "eeprom_stm32_tests.h" +# include "eeprom_legacy_emulated_flash_tests.h" # define TOTAL_EEPROM_BYTE_COUNT (EEPROM_SIZE) # endif #else diff --git a/platforms/test/eeprom_stm32_tests.cpp b/platforms/test/eeprom_legacy_emulated_flash_tests.cpp similarity index 100% rename from platforms/test/eeprom_stm32_tests.cpp rename to platforms/test/eeprom_legacy_emulated_flash_tests.cpp diff --git a/platforms/test/eeprom_stm32_tests.h b/platforms/test/eeprom_legacy_emulated_flash_tests.h similarity index 69% rename from platforms/test/eeprom_stm32_tests.h rename to platforms/test/eeprom_legacy_emulated_flash_tests.h index 35ed885e52..467ec96d74 100644 --- a/platforms/test/eeprom_stm32_tests.h +++ b/platforms/test/eeprom_legacy_emulated_flash_tests.h @@ -2,7 +2,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #pragma once -#include "flash_stm32.h" -#include "eeprom_stm32.h" +#include "legacy_flash_ops.h" +#include "eeprom_legacy_emulated_flash.h" #define EEPROM_SIZE (FEE_PAGE_SIZE * FEE_PAGE_COUNT / 2) diff --git a/platforms/test/flash_stm32_mock.c b/platforms/test/legacy_flash_ops_mock.c similarity index 98% rename from platforms/test/flash_stm32_mock.c rename to platforms/test/legacy_flash_ops_mock.c index b6ab170f95..b9d805cb47 100644 --- a/platforms/test/flash_stm32_mock.c +++ b/platforms/test/legacy_flash_ops_mock.c @@ -16,7 +16,7 @@ #include #include -#include "flash_stm32.h" +#include "legacy_flash_ops.h" uint8_t FlashBuf[MOCK_FLASH_SIZE] = {0}; diff --git a/platforms/test/rules.mk b/platforms/test/rules.mk index a2baa283d0..43898db07e 100644 --- a/platforms/test/rules.mk +++ b/platforms/test/rules.mk @@ -1,25 +1,25 @@ -eeprom_stm32_DEFS := -DEEPROM_TEST_HARNESS -DFLASH_STM32_MOCKED -DNO_PRINT -DFEE_FLASH_BASE=FlashBuf -eeprom_stm32_tiny_DEFS := $(eeprom_stm32_DEFS) \ +eeprom_legacy_emulated_flash_DEFS := -DEEPROM_TEST_HARNESS -DLEGACY_FLASH_OPS_MOCKED -DNO_PRINT -DFEE_FLASH_BASE=FlashBuf +eeprom_legacy_emulated_flash_tiny_DEFS := $(eeprom_legacy_emulated_flash_DEFS) \ -DFEE_MCU_FLASH_SIZE=1 \ -DMOCK_FLASH_SIZE=1024 \ -DFEE_PAGE_SIZE=512 \ -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 \ -DMOCK_FLASH_SIZE=65536 \ -DFEE_PAGE_SIZE=2048 \ -DFEE_PAGE_COUNT=16 -eeprom_stm32_INC := \ +eeprom_legacy_emulated_flash_INC := \ $(PLATFORM_PATH)/chibios/drivers/eeprom/ \ $(PLATFORM_PATH)/chibios/drivers/flash/ -eeprom_stm32_tiny_INC := $(eeprom_stm32_INC) -eeprom_stm32_large_INC := $(eeprom_stm32_INC) +eeprom_legacy_emulated_flash_tiny_INC := $(eeprom_legacy_emulated_flash_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 \ - $(PLATFORM_PATH)/$(PLATFORM_KEY)/eeprom_stm32_tests.cpp \ - $(PLATFORM_PATH)/$(PLATFORM_KEY)/flash_stm32_mock.c \ - $(PLATFORM_PATH)/chibios/drivers/eeprom/eeprom_stm32.c -eeprom_stm32_tiny_SRC := $(eeprom_stm32_SRC) -eeprom_stm32_large_SRC := $(eeprom_stm32_SRC) + $(PLATFORM_PATH)/$(PLATFORM_KEY)/eeprom_legacy_emulated_flash_tests.cpp \ + $(PLATFORM_PATH)/$(PLATFORM_KEY)/legacy_flash_ops_mock.c \ + $(PLATFORM_PATH)/chibios/drivers/eeprom/eeprom_legacy_emulated_flash.c +eeprom_legacy_emulated_flash_tiny_SRC := $(eeprom_legacy_emulated_flash_SRC) +eeprom_legacy_emulated_flash_large_SRC := $(eeprom_legacy_emulated_flash_SRC) diff --git a/platforms/test/testlist.mk b/platforms/test/testlist.mk index 51a9638bb9..b8ec68e7d3 100644 --- a/platforms/test/testlist.mk +++ b/platforms/test/testlist.mk @@ -1 +1 @@ -TEST_LIST += eeprom_stm32_tiny eeprom_stm32_large +TEST_LIST += eeprom_legacy_emulated_flash_tiny eeprom_legacy_emulated_flash_large