From 66f13178353c25c2d76ac3774ce1b6c6e3160671 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Tue, 4 Oct 2022 08:11:52 +1100 Subject: [PATCH 1/7] Move wear-leveling to be default for F4xx. --- builddefs/common_features.mk | 23 ++++++++++++++----- builddefs/mcu_selection.mk | 4 ---- keyboards/acheron/apollo/87h/delta/rules.mk | 2 -- keyboards/acheron/apollo/87h/gamma/rules.mk | 2 -- keyboards/acheron/apollo/87htsc/rules.mk | 2 -- keyboards/acheron/apollo/88htsc/rules.mk | 3 --- .../wear_leveling/wear_leveling_efl_config.h | 4 +++- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/builddefs/common_features.mk b/builddefs/common_features.mk index e597924469a0..c6a67ee87d78 100644 --- a/builddefs/common_features.mk +++ b/builddefs/common_features.mk @@ -177,7 +177,7 @@ ifeq ($(strip $(QUANTUM_PAINTER_ENABLE)), yes) include $(QUANTUM_DIR)/painter/rules.mk endif -VALID_EEPROM_DRIVER_TYPES := vendor custom transient i2c spi wear_leveling +VALID_EEPROM_DRIVER_TYPES := vendor custom transient i2c spi wear_leveling legacy_stm32_flash EEPROM_DRIVER ?= vendor ifeq ($(filter $(EEPROM_DRIVER),$(VALID_EEPROM_DRIVER_TYPES)),) $(call CATASTROPHIC_ERROR,Invalid EEPROM_DRIVER,EEPROM_DRIVER="$(EEPROM_DRIVER)" is not a valid EEPROM driver) @@ -204,6 +204,12 @@ else OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_SPI QUANTUM_LIB_SRC += spi_master.c SRC += eeprom_driver.c eeprom_spi.c + else ifeq ($(strip $(EEPROM_DRIVER)), legacy_stm32_flash) + # STM32 Emulated EEPROM, backed by MCU flash (soon to be deprecated) + OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_STM32_FLASH_EMULATED + COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/flash + COMMON_VPATH += $(DRIVER_PATH)/flash + SRC += eeprom_driver.c eeprom_stm32.c flash_stm32.c else ifeq ($(strip $(EEPROM_DRIVER)), transient) # Transient EEPROM implementation -- no data storage but provides runtime area for it OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_TRANSIENT @@ -214,20 +220,25 @@ else ifeq ($(PLATFORM),AVR) # Automatically provided by avr-libc, nothing required else ifeq ($(PLATFORM),CHIBIOS) - ifneq ($(filter STM32F3xx_% STM32F1xx_% %_STM32F401xC %_STM32F401xE %_STM32F405xG %_STM32F411xE %_STM32F072xB %_STM32F042x6 %_GD32VF103xB %_GD32VF103x8, $(MCU_SERIES)_$(MCU_LDSCRIPT)),) - # Emulated EEPROM + 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 COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/flash COMMON_VPATH += $(DRIVER_PATH)/flash SRC += eeprom_driver.c eeprom_stm32.c flash_stm32.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 + SRC += eeprom_driver.c eeprom_wear_leveling.c + WEAR_LEVELING_DRIVER = embedded_flash else ifneq ($(filter $(MCU_SERIES),STM32L0xx STM32L1xx),) # True EEPROM on STM32L0xx, L1xx OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_STM32_L0_L1 SRC += eeprom_driver.c eeprom_stm32_L0_L1.c else ifneq ($(filter $(MCU_SERIES),RP2040),) - # Wear-leveling EEPROM implementation, backed by RP2040 flash - OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_WEAR_LEVELING - SRC += eeprom_driver.c eeprom_wear_leveling.c + # Wear-leveling EEPROM implementation, backed by RP2040 flash + OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_WEAR_LEVELING + SRC += eeprom_driver.c eeprom_wear_leveling.c WEAR_LEVELING_DRIVER = rp2040_flash else ifneq ($(filter $(MCU_SERIES),KL2x K20x),) # Teensy EEPROM implementations diff --git a/builddefs/mcu_selection.mk b/builddefs/mcu_selection.mk index 0ea9630d598e..7f3f80159b85 100644 --- a/builddefs/mcu_selection.mk +++ b/builddefs/mcu_selection.mk @@ -348,8 +348,6 @@ ifneq ($(findstring STM32F401, $(MCU)),) # or /ld/ ifeq ($(strip $(BOOTLOADER)), tinyuf2) MCU_LDSCRIPT ?= STM32F401xC_tinyuf2 - EEPROM_DRIVER ?= wear_leveling - WEAR_LEVELING_DRIVER ?= legacy else MCU_LDSCRIPT ?= STM32F401xC endif @@ -465,8 +463,6 @@ ifneq ($(findstring STM32F411, $(MCU)),) # or /ld/ ifeq ($(strip $(BOOTLOADER)), tinyuf2) MCU_LDSCRIPT ?= STM32F411xE_tinyuf2 - EEPROM_DRIVER ?= wear_leveling - WEAR_LEVELING_DRIVER ?= legacy else MCU_LDSCRIPT ?= STM32F411xE endif diff --git a/keyboards/acheron/apollo/87h/delta/rules.mk b/keyboards/acheron/apollo/87h/delta/rules.mk index 814a3f15f031..4fa4db545039 100644 --- a/keyboards/acheron/apollo/87h/delta/rules.mk +++ b/keyboards/acheron/apollo/87h/delta/rules.mk @@ -19,8 +19,6 @@ RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow AUDIO_ENABLE = no # Audio output RGB_MATRIX_ENABLE = yes RGB_MATRIX_DRIVER = WS2812 -EEPROM_DRIVER = wear_leveling -WEAR_LEVELING_DRIVER = legacy # Enter lower-power sleep mode when on the ChibiOS idle thread OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE -DDEBUG_EEPROM_OUTPUT=TRUE diff --git a/keyboards/acheron/apollo/87h/gamma/rules.mk b/keyboards/acheron/apollo/87h/gamma/rules.mk index c05ab3c41ab7..5b419929d5a1 100644 --- a/keyboards/acheron/apollo/87h/gamma/rules.mk +++ b/keyboards/acheron/apollo/87h/gamma/rules.mk @@ -20,8 +20,6 @@ AUDIO_ENABLE = no # Audio output RGB_MATRIX_ENABLE = yes RGB_MATRIX_DRIVER = IS31FL3741 KEYBOARD_SHARED_EP = yes -EEPROM_DRIVER = wear_leveling -WEAR_LEVELING_DRIVER = legacy # Enter lower-power sleep mode when on the ChibiOS idle thread OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE -DDEBUG_EEPROM_OUTPUT=TRUE diff --git a/keyboards/acheron/apollo/87htsc/rules.mk b/keyboards/acheron/apollo/87htsc/rules.mk index f2becf4db459..4fa4db545039 100644 --- a/keyboards/acheron/apollo/87htsc/rules.mk +++ b/keyboards/acheron/apollo/87htsc/rules.mk @@ -20,7 +20,5 @@ AUDIO_ENABLE = no # Audio output RGB_MATRIX_ENABLE = yes RGB_MATRIX_DRIVER = WS2812 -EEPROM_DRIVER = wear_leveling -WEAR_LEVELING_DRIVER = legacy # Enter lower-power sleep mode when on the ChibiOS idle thread OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE -DDEBUG_EEPROM_OUTPUT=TRUE diff --git a/keyboards/acheron/apollo/88htsc/rules.mk b/keyboards/acheron/apollo/88htsc/rules.mk index 18e8b33b0713..4fa4db545039 100644 --- a/keyboards/acheron/apollo/88htsc/rules.mk +++ b/keyboards/acheron/apollo/88htsc/rules.mk @@ -20,8 +20,5 @@ AUDIO_ENABLE = no # Audio output RGB_MATRIX_ENABLE = yes RGB_MATRIX_DRIVER = WS2812 -EEPROM_DRIVER = wear_leveling -WEAR_LEVELING_DRIVER = legacy - # Enter lower-power sleep mode when on the ChibiOS idle thread OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE -DDEBUG_EEPROM_OUTPUT=TRUE diff --git a/platforms/chibios/drivers/wear_leveling/wear_leveling_efl_config.h b/platforms/chibios/drivers/wear_leveling/wear_leveling_efl_config.h index 244c87cb7fad..e74cf85efd55 100644 --- a/platforms/chibios/drivers/wear_leveling/wear_leveling_efl_config.h +++ b/platforms/chibios/drivers/wear_leveling/wear_leveling_efl_config.h @@ -20,7 +20,9 @@ # if defined(STM32_FLASH_LINE_SIZE) // from some family's stm32_registry.h file # define BACKING_STORE_WRITE_SIZE (STM32_FLASH_LINE_SIZE) # else -# if defined(QMK_MCU_SERIES_STM32F1XX) +# if defined(QMK_MCU_SERIES_STM32F0XX) +# define BACKING_STORE_WRITE_SIZE 2 // from hal_efl_lld.c +# elif defined(QMK_MCU_SERIES_STM32F1XX) # define BACKING_STORE_WRITE_SIZE 2 // from hal_efl_lld.c # elif defined(QMK_MCU_SERIES_STM32F3XX) # define BACKING_STORE_WRITE_SIZE 2 // from hal_efl_lld.c From 7d8cbc0a91ba0dfea82edb6c9cb678c7a1e7f9d3 Mon Sep 17 00:00:00 2001 From: zvecr Date: Fri, 11 Nov 2022 18:07:13 +0000 Subject: [PATCH 2/7] fix yugo_m/model_m_101 --- keyboards/yugo_m/model_m_101/config.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/keyboards/yugo_m/model_m_101/config.h b/keyboards/yugo_m/model_m_101/config.h index c22bc610c334..0a9349aac1a0 100644 --- a/keyboards/yugo_m/model_m_101/config.h +++ b/keyboards/yugo_m/model_m_101/config.h @@ -91,5 +91,6 @@ along with this program. If not, see . //#define NO_ACTION_TAPPING //#define NO_ACTION_ONESHOT -/* redefine available (emulated) EEPROM as 4 kB rather than the default 1 kB to let VIA use more of the 8 kB of on-chip Flash of the STM32F303 to store 4 layers (since 4 layers * 8 rows * 16 columns * 2 = 1024 bytes but the default max available is 1023 bytes due to ATMEGA32U4 etc. only having 1 kB of EEPROM) */ -#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 4095 +/* redefine available (emulated) EEPROM as 4 kB rather than the default 2 kB to let VIA use more of the on-chip Flash of the STM32F303 to store 4 layers (since 4 layers * 8 rows * 16 columns * 2 = 1024 bytes but the default max available is 1023 bytes due to ATMEGA32U4 etc. only having 1 kB of EEPROM) */ +#define WEAR_LEVELING_BACKING_SIZE 4096 +#define WEAR_LEVELING_LOGICAL_SIZE 2048 From 241580b5d3bcc0275e9787888a168841b166e648 Mon Sep 17 00:00:00 2001 From: zvecr Date: Fri, 11 Nov 2022 19:21:04 +0000 Subject: [PATCH 3/7] fix rgbkb/sol3 --- keyboards/rgbkb/sol3/config.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/keyboards/rgbkb/sol3/config.h b/keyboards/rgbkb/sol3/config.h index 1ab4cddc9ba3..195953f7ae37 100644 --- a/keyboards/rgbkb/sol3/config.h +++ b/keyboards/rgbkb/sol3/config.h @@ -172,3 +172,6 @@ #define AUDIO_CLICKY #define AUDIO_DAC_SAMPLE_WAVEFORM_SQUARE #define AUDIO_DAC_OFF_VALUE 0 + +#define WEAR_LEVELING_BACKING_SIZE 4096 +#define WEAR_LEVELING_LOGICAL_SIZE 2048 From e9f294dced3c7056d94fe732518474405ae77c92 Mon Sep 17 00:00:00 2001 From: zvecr Date: Fri, 11 Nov 2022 19:37:52 +0000 Subject: [PATCH 4/7] fix mechlovin/hex6c --- keyboards/mechlovin/hex6c/config.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/keyboards/mechlovin/hex6c/config.h b/keyboards/mechlovin/hex6c/config.h index c3125f217fa0..5f88d8ee7021 100644 --- a/keyboards/mechlovin/hex6c/config.h +++ b/keyboards/mechlovin/hex6c/config.h @@ -54,4 +54,6 @@ along with this program. If not, see . #define ENCODER_RESOLUTION 4 #define TAP_CODE_DELAY 10 -#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 2047 \ No newline at end of file + +#define WEAR_LEVELING_BACKING_SIZE 4096 +#define WEAR_LEVELING_LOGICAL_SIZE 2048 From 0f6eff7579a9ae4a43dc541d352f41678071090c Mon Sep 17 00:00:00 2001 From: zvecr Date: Fri, 11 Nov 2022 19:45:40 +0000 Subject: [PATCH 5/7] fix rgbkb/mun --- keyboards/rgbkb/mun/config.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/keyboards/rgbkb/mun/config.h b/keyboards/rgbkb/mun/config.h index bcf4c59b6550..345f701e7f4a 100644 --- a/keyboards/rgbkb/mun/config.h +++ b/keyboards/rgbkb/mun/config.h @@ -154,3 +154,6 @@ #define TOUCH_UPDATE_INTERVAL 33 #define OLED_UPDATE_INTERVAL 33 #define TAP_CODE_DELAY 5 + +#define WEAR_LEVELING_BACKING_SIZE 4096 +#define WEAR_LEVELING_LOGICAL_SIZE 2048 From 7701021038ca9d33bbf1c38fdc2febf1630241cc Mon Sep 17 00:00:00 2001 From: zvecr Date: Fri, 11 Nov 2022 22:09:49 +0000 Subject: [PATCH 6/7] transient defaults for STM32F446 --- builddefs/mcu_selection.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/builddefs/mcu_selection.mk b/builddefs/mcu_selection.mk index 7f3f80159b85..de919bd26373 100644 --- a/builddefs/mcu_selection.mk +++ b/builddefs/mcu_selection.mk @@ -516,6 +516,9 @@ ifneq ($(findstring STM32F446, $(MCU)),) # Bootloader address for STM32 DFU STM32_BOOTLOADER_ADDRESS ?= 0x1FFF0000 + + # Default as no chibios efl config + EEPROM_DRIVER ?= transient endif ifneq ($(findstring STM32G431, $(MCU)),) From 6de41d723c35d54641f79e5eac71ee8d6617b2b3 Mon Sep 17 00:00:00 2001 From: zvecr Date: Fri, 11 Nov 2022 22:59:51 +0000 Subject: [PATCH 7/7] matrix/m12og/rev1 oversized --- keyboards/matrix/m12og/rev1/rules.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/keyboards/matrix/m12og/rev1/rules.mk b/keyboards/matrix/m12og/rev1/rules.mk index d9733e8c5eb6..136d07cbaad3 100644 --- a/keyboards/matrix/m12og/rev1/rules.mk +++ b/keyboards/matrix/m12og/rev1/rules.mk @@ -20,6 +20,7 @@ NKRO_ENABLE = no # Enable N-Key Rollover BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality RGBLIGHT_ENABLE = yes # HAS TO BE ON! Otherwise the custom matrix doesn't work AUDIO_ENABLE = no # Audio output +LTO_ENABLE = yes CUSTOM_MATRIX = lite SRC += matrix.c