summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common_features.mk9
-rw-r--r--keyboards/kabedon/kabedon980/config.h10
-rw-r--r--keyboards/kabedon/kabedon980/keymaps/via/keymap.c20
-rw-r--r--keyboards/mechlovin/olly/jf/keymaps/via/config.h4
-rw-r--r--keyboards/mechlovin/olly/jf/keymaps/via/keymap.c25
-rw-r--r--platforms/arm_atsam/eeprom_samd.c (renamed from platforms/arm_atsam/eeprom.c)6
-rwxr-xr-xplatforms/arm_atsam/eeprom_samd.h8
-rw-r--r--platforms/chibios/eeprom_stm32.c66
-rw-r--r--platforms/chibios/eeprom_stm32_defs.h62
-rw-r--r--platforms/chibios/eeprom_teensy.c15
-rwxr-xr-xplatforms/chibios/eeprom_teensy.h22
-rw-r--r--platforms/eeprom.h49
-rw-r--r--platforms/test/eeprom.c4
-rw-r--r--platforms/test/eeprom_stm32_tests.cpp3
-rw-r--r--platforms/test/eeprom_stm32_tests.h8
-rw-r--r--platforms/test/rules.mk2
-rw-r--r--quantum/dynamic_keymap.c25
17 files changed, 185 insertions, 153 deletions
diff --git a/common_features.mk b/common_features.mk
index d3da487e69..5c5e6a9a25 100644
--- a/common_features.mk
+++ b/common_features.mk
@@ -186,20 +186,21 @@ else
else ifeq ($(PLATFORM),CHIBIOS)
ifneq ($(filter STM32F3xx_% STM32F1xx_% %_STM32F401xC %_STM32F401xE %_STM32F405xG %_STM32F411xE %_STM32F072xB %_STM32F042x6 %_GD32VF103xB %_GD32VF103x8, $(MCU_SERIES)_$(MCU_LDSCRIPT)),)
# Emulated EEPROM
- OPT_DEFS += -DEEPROM_DRIVER
+ OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_STM32_FLASH_EMULATED
COMMON_VPATH += $(DRIVER_PATH)/eeprom
SRC += eeprom_driver.c
SRC += $(PLATFORM_COMMON_DIR)/eeprom_stm32.c
SRC += $(PLATFORM_COMMON_DIR)/flash_stm32.c
else ifneq ($(filter $(MCU_SERIES),STM32L0xx STM32L1xx),)
# True EEPROM on STM32L0xx, L1xx
- OPT_DEFS += -DEEPROM_DRIVER
+ OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_STM32_L0_L1
COMMON_VPATH += $(DRIVER_PATH)/eeprom
COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/eeprom
SRC += eeprom_driver.c
SRC += eeprom_stm32_L0_L1.c
else ifneq ($(filter $(MCU_SERIES),KL2x K20x),)
# Teensy EEPROM implementations
+ OPT_DEFS += -DEEPROM_TEENSY
SRC += eeprom_teensy.c
else
# Fall back to transient, i.e. non-persistent
@@ -209,9 +210,11 @@ else
endif
else ifeq ($(PLATFORM),ARM_ATSAM)
# arm_atsam EEPROM
- SRC += $(PLATFORM_COMMON_DIR)/eeprom.c
+ OPT_DEFS += -DEEPROM_SAMD
+ SRC += $(PLATFORM_COMMON_DIR)/eeprom_samd.c
else ifeq ($(PLATFORM),TEST)
# Test harness "EEPROM"
+ OPT_DEFS += -DEEPROM_TEST_HARNESS
SRC += $(PLATFORM_COMMON_DIR)/eeprom.c
endif
endif
diff --git a/keyboards/kabedon/kabedon980/config.h b/keyboards/kabedon/kabedon980/config.h
index 5dc70dfebf..db93dfcf85 100644
--- a/keyboards/kabedon/kabedon980/config.h
+++ b/keyboards/kabedon/kabedon980/config.h
@@ -32,21 +32,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MATRIX_COLS 13
/* Keyboard Matrix Assignments */
-#define MATRIX_ROW_PINS {D0,D2,F7,B1,B0,D6,C7,D7,B5,B2}
-#define MATRIX_COL_PINS {F5,F4,F6,C6,B6,B4,D3,D1,D4,F1,B3,D5,F0}
+#define MATRIX_ROW_PINS {D0,D2,F7,B1,B0,D6,C7,D7,B5,B2}
+#define MATRIX_COL_PINS {F5,F4,F6,C6,B6,B4,D3,D1,D4,F1,B3,D5,F0}
#define UNUSED_PINS
-#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 2047
+#define DYNAMIC_KEYMAP_LAYER_COUNT 3
/* COL2ROW, ROW2COL*/
#define DIODE_DIRECTION ROW2COL
-#define RGB_DI_PIN B7
+#define RGB_DI_PIN B7
#ifdef RGB_DI_PIN
#define RGBLED_NUM 20
#define RGBLIGHT_HUE_STEP 8
#define RGBLIGHT_SAT_STEP 8
#define RGBLIGHT_VAL_STEP 8
#define RGBLIGHT_LIMIT_VAL 255 /* The maximum brightness level */
- #define RGBLIGHT_ANIMATIONS
+ #define RGBLIGHT_ANIMATIONS
#endif
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
diff --git a/keyboards/kabedon/kabedon980/keymaps/via/keymap.c b/keyboards/kabedon/kabedon980/keymaps/via/keymap.c
index 44574452bf..76eaa3968a 100644
--- a/keyboards/kabedon/kabedon980/keymaps/via/keymap.c
+++ b/keyboards/kabedon/kabedon980/keymaps/via/keymap.c
@@ -6,32 +6,24 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, KC_HOME, KC_PGUP, KC_PGDN,
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_NLCK, KC_PSLS, KC_PAST, KC_PMNS,
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_P7, KC_P8, KC_P9, KC_PPLS,
- KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_P4, KC_P5, KC_P6,
+ KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_P4, KC_P5, KC_P6,
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_P1, KC_P2, KC_P3, KC_PENT,
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(1), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT ),
-
+
[1] = LAYOUT(
RGB_MOD, RGB_TOG, RGB_SAI, RGB_SAD, RGB_HUI, RGB_HUD, RGB_SPI, RGB_SPD, RGB_VAI, RGB_VAD, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS ),
-
+
[2] = LAYOUT(
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS ),
-
- [3] = LAYOUT(
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS )
};
diff --git a/keyboards/mechlovin/olly/jf/keymaps/via/config.h b/keyboards/mechlovin/olly/jf/keymaps/via/config.h
index f330025a00..82c2e51eb9 100644
--- a/keyboards/mechlovin/olly/jf/keymaps/via/config.h
+++ b/keyboards/mechlovin/olly/jf/keymaps/via/config.h
@@ -17,6 +17,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
-#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 1607
-#define DYNAMIC_KEYMAP_LAYER_COUNT 6
-
+#define DYNAMIC_KEYMAP_LAYER_COUNT 3
diff --git a/keyboards/mechlovin/olly/jf/keymaps/via/keymap.c b/keyboards/mechlovin/olly/jf/keymaps/via/keymap.c
index c90eeb1830..18ac685abc 100644
--- a/keyboards/mechlovin/olly/jf/keymaps/via/keymap.c
+++ b/keyboards/mechlovin/olly/jf/keymaps/via/keymap.c
@@ -40,29 +40,4 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS
),
- [3] = LAYOUT_all(
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS
- ),
- [4] = LAYOUT_all(
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS
- ),
- [5] = LAYOUT_all(
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS
- ),
-
}; \ No newline at end of file
diff --git a/platforms/arm_atsam/eeprom.c b/platforms/arm_atsam/eeprom_samd.c
index ff1a692623..beaffeec30 100644
--- a/platforms/arm_atsam/eeprom.c
+++ b/platforms/arm_atsam/eeprom_samd.c
@@ -18,11 +18,7 @@
#include "samd51j18a.h"
#include "core_cm4.h"
#include "component/nvmctrl.h"
-
-#ifndef EEPROM_SIZE
-# include "eeconfig.h"
-# define EEPROM_SIZE (((EECONFIG_SIZE + 3) / 4) * 4) // based off eeconfig's current usage, aligned to 4-byte sizes, to deal with LTO
-#endif
+#include "eeprom_samd.h"
#ifndef MAX
# define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
diff --git a/platforms/arm_atsam/eeprom_samd.h b/platforms/arm_atsam/eeprom_samd.h
new file mode 100755
index 0000000000..7dbff9bfa1
--- /dev/null
+++ b/platforms/arm_atsam/eeprom_samd.h
@@ -0,0 +1,8 @@
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#pragma once
+
+#ifndef EEPROM_SIZE
+# include "eeconfig.h"
+# define EEPROM_SIZE (((EECONFIG_SIZE + 3) / 4) * 4) // based off eeconfig's current usage, aligned to 4-byte sizes, to deal with LTO
+#endif
diff --git a/platforms/chibios/eeprom_stm32.c b/platforms/chibios/eeprom_stm32.c
index acc6a48516..8bf0b19c3d 100644
--- a/platforms/chibios/eeprom_stm32.c
+++ b/platforms/chibios/eeprom_stm32.c
@@ -133,10 +133,6 @@
*/
#include "eeprom_stm32_defs.h"
-#if !defined(FEE_PAGE_SIZE) || !defined(FEE_PAGE_COUNT) || !defined(FEE_MCU_FLASH_SIZE) || !defined(FEE_PAGE_BASE_ADDRESS)
-# error "not implemented."
-#endif
-
/* These bits are used for optimizing encoding of bytes, 0 and 1 */
#define FEE_WORD_ENCODING 0x8000
#define FEE_VALUE_NEXT 0x6000
@@ -144,69 +140,11 @@
#define FEE_VALUE_ENCODED 0x2000
#define FEE_BYTE_RANGE 0x80
-/* Addressable range 16KByte: 0 <-> (0x1FFF << 1) */
-#define FEE_ADDRESS_MAX_SIZE 0x4000
-
/* Flash word value after erase */
#define FEE_EMPTY_WORD ((uint16_t)0xFFFF)
-/* Size of combined compacted eeprom and write log pages */
-#define FEE_DENSITY_MAX_SIZE (FEE_PAGE_COUNT * FEE_PAGE_SIZE)
-
-#ifndef FEE_MCU_FLASH_SIZE_IGNORE_CHECK /* *TODO: Get rid of this check */
-# if FEE_DENSITY_MAX_SIZE > (FEE_MCU_FLASH_SIZE * 1024)
-# pragma message STR(FEE_DENSITY_MAX_SIZE) " > " STR(FEE_MCU_FLASH_SIZE * 1024)
-# error emulated eeprom: FEE_DENSITY_MAX_SIZE is greater than available flash size
-# endif
-#endif
-
-/* Size of emulated eeprom */
-#ifdef FEE_DENSITY_BYTES
-# if (FEE_DENSITY_BYTES > FEE_DENSITY_MAX_SIZE)
-# pragma message STR(FEE_DENSITY_BYTES) " > " STR(FEE_DENSITY_MAX_SIZE)
-# error emulated eeprom: FEE_DENSITY_BYTES exceeds FEE_DENSITY_MAX_SIZE
-# endif
-# if (FEE_DENSITY_BYTES == FEE_DENSITY_MAX_SIZE)
-# pragma message STR(FEE_DENSITY_BYTES) " == " STR(FEE_DENSITY_MAX_SIZE)
-# warning emulated eeprom: FEE_DENSITY_BYTES leaves no room for a write log. This will greatly increase the flash wear rate!
-# endif
-# if FEE_DENSITY_BYTES > FEE_ADDRESS_MAX_SIZE
-# pragma message STR(FEE_DENSITY_BYTES) " > " STR(FEE_ADDRESS_MAX_SIZE)
-# error emulated eeprom: FEE_DENSITY_BYTES is greater than FEE_ADDRESS_MAX_SIZE allows
-# endif
-# if ((FEE_DENSITY_BYTES) % 2) == 1
-# error emulated eeprom: FEE_DENSITY_BYTES must be even
-# endif
-#else
-/* Default to half of allocated space used for emulated eeprom, half for write log */
-# define FEE_DENSITY_BYTES (FEE_PAGE_COUNT * FEE_PAGE_SIZE / 2)
-#endif
-
-/* Size of write log */
-#ifdef FEE_WRITE_LOG_BYTES
-# if ((FEE_DENSITY_BYTES + FEE_WRITE_LOG_BYTES) > FEE_DENSITY_MAX_SIZE)
-# pragma message STR(FEE_DENSITY_BYTES) " + " STR(FEE_WRITE_LOG_BYTES) " > " STR(FEE_DENSITY_MAX_SIZE)
-# error emulated eeprom: FEE_WRITE_LOG_BYTES exceeds remaining FEE_DENSITY_MAX_SIZE
-# endif
-# if ((FEE_WRITE_LOG_BYTES) % 2) == 1
-# error emulated eeprom: FEE_WRITE_LOG_BYTES must be even
-# endif
-#else
-/* Default to use all remaining space */
-# define FEE_WRITE_LOG_BYTES (FEE_PAGE_COUNT * FEE_PAGE_SIZE - FEE_DENSITY_BYTES)
-#endif
-
-/* Start of the emulated eeprom compacted flash area */
-#define FEE_COMPACTED_BASE_ADDRESS FEE_PAGE_BASE_ADDRESS
-/* End of the emulated eeprom compacted flash area */
-#define FEE_COMPACTED_LAST_ADDRESS (FEE_COMPACTED_BASE_ADDRESS + FEE_DENSITY_BYTES)
-/* Start of the emulated eeprom write log */
-#define FEE_WRITE_LOG_BASE_ADDRESS FEE_COMPACTED_LAST_ADDRESS
-/* End of the emulated eeprom write log */
-#define FEE_WRITE_LOG_LAST_ADDRESS (FEE_WRITE_LOG_BASE_ADDRESS + FEE_WRITE_LOG_BYTES)
-
-#if defined(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR) && (DYNAMIC_KEYMAP_EEPROM_MAX_ADDR >= FEE_DENSITY_BYTES)
-# error emulated eeprom: DYNAMIC_KEYMAP_EEPROM_MAX_ADDR is greater than the FEE_DENSITY_BYTES available
+#if !defined(FEE_PAGE_SIZE) || !defined(FEE_PAGE_COUNT) || !defined(FEE_MCU_FLASH_SIZE) || !defined(FEE_PAGE_BASE_ADDRESS)
+# error "not implemented."
#endif
/* In-memory contents of emulated eeprom for faster access */
diff --git a/platforms/chibios/eeprom_stm32_defs.h b/platforms/chibios/eeprom_stm32_defs.h
index 66904f247f..581434eb5e 100644
--- a/platforms/chibios/eeprom_stm32_defs.h
+++ b/platforms/chibios/eeprom_stm32_defs.h
@@ -72,3 +72,65 @@
# define FEE_PAGE_BASE_ADDRESS ((uintptr_t)(FEE_FLASH_BASE) + FEE_MCU_FLASH_SIZE * 1024 - (FEE_PAGE_COUNT * FEE_PAGE_SIZE))
# endif
#endif
+
+/* Addressable range 16KByte: 0 <-> (0x1FFF << 1) */
+#define FEE_ADDRESS_MAX_SIZE 0x4000
+
+/* Size of combined compacted eeprom and write log pages */
+#define FEE_DENSITY_MAX_SIZE (FEE_PAGE_COUNT * FEE_PAGE_SIZE)
+
+#ifndef FEE_MCU_FLASH_SIZE_IGNORE_CHECK /* *TODO: Get rid of this check */
+# if FEE_DENSITY_MAX_SIZE > (FEE_MCU_FLASH_SIZE * 1024)
+# pragma message STR(FEE_DENSITY_MAX_SIZE) " > " STR(FEE_MCU_FLASH_SIZE * 1024)
+# error emulated eeprom: FEE_DENSITY_MAX_SIZE is greater than available flash size
+# endif
+#endif
+
+/* Size of emulated eeprom */
+#ifdef FEE_DENSITY_BYTES
+# if (FEE_DENSITY_BYTES > FEE_DENSITY_MAX_SIZE)
+# pragma message STR(FEE_DENSITY_BYTES) " > " STR(FEE_DENSITY_MAX_SIZE)
+# error emulated eeprom: FEE_DENSITY_BYTES exceeds FEE_DENSITY_MAX_SIZE
+# endif
+# if (FEE_DENSITY_BYTES == FEE_DENSITY_MAX_SIZE)
+# pragma message STR(FEE_DENSITY_BYTES) " == " STR(FEE_DENSITY_MAX_SIZE)
+# warning emulated eeprom: FEE_DENSITY_BYTES leaves no room for a write log. This will greatly increase the flash wear rate!
+# endif
+# if FEE_DENSITY_BYTES > FEE_ADDRESS_MAX_SIZE
+# pragma message STR(FEE_DENSITY_BYTES) " > " STR(FEE_ADDRESS_MAX_SIZE)
+# error emulated eeprom: FEE_DENSITY_BYTES is greater than FEE_ADDRESS_MAX_SIZE allows
+# endif
+# if ((FEE_DENSITY_BYTES) % 2) == 1
+# error emulated eeprom: FEE_DENSITY_BYTES must be even
+# endif
+#else
+/* Default to half of allocated space used for emulated eeprom, half for write log */
+# define FEE_DENSITY_BYTES (FEE_PAGE_COUNT * FEE_PAGE_SIZE / 2)
+#endif
+
+/* Size of write log */
+#ifdef FEE_WRITE_LOG_BYTES
+# if ((FEE_DENSITY_BYTES + FEE_WRITE_LOG_BYTES) > FEE_DENSITY_MAX_SIZE)
+# pragma message STR(FEE_DENSITY_BYTES) " + " STR(FEE_WRITE_LOG_BYTES) " > " STR(FEE_DENSITY_MAX_SIZE)
+# error emulated eeprom: FEE_WRITE_LOG_BYTES exceeds remaining FEE_DENSITY_MAX_SIZE
+# endif
+# if ((FEE_WRITE_LOG_BYTES) % 2) == 1
+# error emulated eeprom: FEE_WRITE_LOG_BYTES must be even
+# endif
+#else
+/* Default to use all remaining space */
+# define FEE_WRITE_LOG_BYTES (FEE_PAGE_COUNT * FEE_PAGE_SIZE - FEE_DENSITY_BYTES)
+#endif
+
+/* Start of the emulated eeprom compacted flash area */
+#define FEE_COMPACTED_BASE_ADDRESS FEE_PAGE_BASE_ADDRESS
+/* End of the emulated eeprom compacted flash area */
+#define FEE_COMPACTED_LAST_ADDRESS (FEE_COMPACTED_BASE_ADDRESS + FEE_DENSITY_BYTES)
+/* Start of the emulated eeprom write log */
+#define FEE_WRITE_LOG_BASE_ADDRESS FEE_COMPACTED_LAST_ADDRESS
+/* End of the emulated eeprom write log */
+#define FEE_WRITE_LOG_LAST_ADDRESS (FEE_WRITE_LOG_BASE_ADDRESS + FEE_WRITE_LOG_BYTES)
+
+#if defined(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR) && (DYNAMIC_KEYMAP_EEPROM_MAX_ADDR >= FEE_DENSITY_BYTES)
+# error emulated eeprom: DYNAMIC_KEYMAP_EEPROM_MAX_ADDR is greater than the FEE_DENSITY_BYTES available
+#endif
diff --git a/platforms/chibios/eeprom_teensy.c b/platforms/chibios/eeprom_teensy.c
index 2093f9b4b2..575f51526e 100644
--- a/platforms/chibios/eeprom_teensy.c
+++ b/platforms/chibios/eeprom_teensy.c
@@ -1,6 +1,7 @@
#include <ch.h>
#include <hal.h>
+#include "eeprom_teensy.h"
#include "eeconfig.h"
/*************************************/
@@ -42,18 +43,6 @@
#if defined(K20x) /* chip selection */
/* Teensy 3.0, 3.1, 3.2; mchck; infinity keyboard */
-// The EEPROM is really RAM with a hardware-based backup system to
-// flash memory. Selecting a smaller size EEPROM allows more wear
-// leveling, for higher write endurance. If you edit this file,
-// set this to the smallest size your application can use. Also,
-// due to Freescale's implementation, writing 16 or 32 bit words
-// (aligned to 2 or 4 byte boundaries) has twice the endurance
-// compared to writing 8 bit bytes.
-//
-# ifndef EEPROM_SIZE
-# define EEPROM_SIZE 32
-# endif
-
/*
^^^ Here be dragons:
NXP AppNote AN4282 section 3.1 states that partitioning must only be done once.
@@ -350,8 +339,6 @@ void do_flash_cmd(volatile uint8_t *fstat)
extern uint32_t __eeprom_workarea_start__;
extern uint32_t __eeprom_workarea_end__;
-# define EEPROM_SIZE 128
-
static uint32_t flashend = 0;
void eeprom_initialize(void) {
diff --git a/platforms/chibios/eeprom_teensy.h b/platforms/chibios/eeprom_teensy.h
new file mode 100755
index 0000000000..ead5998b29
--- /dev/null
+++ b/platforms/chibios/eeprom_teensy.h
@@ -0,0 +1,22 @@
+// Copyright 2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#pragma once
+
+#if defined(K20x)
+/* Teensy 3.0, 3.1, 3.2; mchck; infinity keyboard */
+// The EEPROM is really RAM with a hardware-based backup system to
+// flash memory. Selecting a smaller size EEPROM allows more wear
+// leveling, for higher write endurance. If you edit this file,
+// set this to the smallest size your application can use. Also,
+// due to Freescale's implementation, writing 16 or 32 bit words
+// (aligned to 2 or 4 byte boundaries) has twice the endurance
+// compared to writing 8 bit bytes.
+//
+# ifndef EEPROM_SIZE
+# define EEPROM_SIZE 32
+# endif
+#elif defined(KL2x) /* Teensy LC (emulated) */
+# define EEPROM_SIZE 128
+#else
+# error Unsupported Teensy EEPROM.
+#endif
diff --git a/platforms/eeprom.h b/platforms/eeprom.h
index f5b3f0ad53..091e6e4400 100644
--- a/platforms/eeprom.h
+++ b/platforms/eeprom.h
@@ -1,3 +1,5 @@
+// Copyright 2018-2022 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#if defined(__AVR__) && !defined(EEPROM_DRIVER)
@@ -19,3 +21,50 @@ void eeprom_update_word(uint16_t *__p, uint16_t __value);
void eeprom_update_dword(uint32_t *__p, uint32_t __value);
void eeprom_update_block(const void *__src, void *__dst, size_t __n);
#endif
+
+#if defined(EEPROM_CUSTOM)
+# ifndef EEPROM_SIZE
+# error EEPROM_SIZE has not been defined for custom driver.
+# endif
+# define TOTAL_EEPROM_BYTE_COUNT (EEPROM_SIZE)
+#elif defined(EEPROM_TRANSIENT)
+# include "eeprom_transient.h"
+# define TOTAL_EEPROM_BYTE_COUNT (TRANSIENT_EEPROM_SIZE)
+#elif defined(EEPROM_I2C)
+# include "eeprom_i2c.h"
+# define TOTAL_EEPROM_BYTE_COUNT (EXTERNAL_EEPROM_BYTE_COUNT)
+#elif defined(EEPROM_SPI)
+# include "eeprom_spi.h"
+# define TOTAL_EEPROM_BYTE_COUNT (EXTERNAL_EEPROM_BYTE_COUNT)
+#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"
+# define TOTAL_EEPROM_BYTE_COUNT (EEPROM_SIZE)
+#elif defined(EEPROM_STM32_FLASH_EMULATED)
+# include "eeprom_stm32_defs.h"
+# define TOTAL_EEPROM_BYTE_COUNT (FEE_DENSITY_BYTES)
+#elif defined(EEPROM_SAMD)
+# include "eeprom_samd.h"
+# define TOTAL_EEPROM_BYTE_COUNT (EEPROM_SIZE)
+#elif defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega16U4__) || defined(__AVR_AT90USB162__) || defined(__AVR_ATtiny85__)
+# define TOTAL_EEPROM_BYTE_COUNT 512
+#elif defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega32A__)
+# define TOTAL_EEPROM_BYTE_COUNT 1024
+#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__)
+# define TOTAL_EEPROM_BYTE_COUNT 2048
+#elif defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__)
+# define TOTAL_EEPROM_BYTE_COUNT 4096
+#elif defined(EEPROM_TEST_HARNESS)
+# ifndef FLASH_STM32_MOCKED
+// Normal tests
+# define TOTAL_EEPROM_BYTE_COUNT 32
+# else
+// Flash wear-leveling testing
+# include "eeprom_stm32_tests.h"
+# define TOTAL_EEPROM_BYTE_COUNT (EEPROM_SIZE)
+# endif
+#else
+# error Unknown EEPROM driver.
+#endif
diff --git a/platforms/test/eeprom.c b/platforms/test/eeprom.c
index 5c8e69dae3..e292faa644 100644
--- a/platforms/test/eeprom.c
+++ b/platforms/test/eeprom.c
@@ -16,9 +16,7 @@
#include "eeprom.h"
-#define EEPROM_SIZE 32
-
-static uint8_t buffer[EEPROM_SIZE];
+static uint8_t buffer[TOTAL_EEPROM_BYTE_COUNT];
uint8_t eeprom_read_byte(const uint8_t *addr) {
uintptr_t offset = (uintptr_t)addr;
diff --git a/platforms/test/eeprom_stm32_tests.cpp b/platforms/test/eeprom_stm32_tests.cpp
index 5bc8d87900..57f31d634f 100644
--- a/platforms/test/eeprom_stm32_tests.cpp
+++ b/platforms/test/eeprom_stm32_tests.cpp
@@ -17,8 +17,6 @@
#include "gtest/gtest.h"
extern "C" {
-#include "flash_stm32.h"
-#include "eeprom_stm32.h"
#include "eeprom.h"
}
@@ -46,7 +44,6 @@ extern "C" {
*
*/
-#define EEPROM_SIZE (FEE_PAGE_SIZE * FEE_PAGE_COUNT / 2)
#define LOG_SIZE EEPROM_SIZE
#define LOG_BASE (MOCK_FLASH_SIZE - LOG_SIZE)
#define EEPROM_BASE (LOG_BASE - EEPROM_SIZE)
diff --git a/platforms/test/eeprom_stm32_tests.h b/platforms/test/eeprom_stm32_tests.h
new file mode 100644
index 0000000000..35ed885e52
--- /dev/null
+++ b/platforms/test/eeprom_stm32_tests.h
@@ -0,0 +1,8 @@
+// Copyright 2018-2022 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#pragma once
+
+#include "flash_stm32.h"
+#include "eeprom_stm32.h"
+
+#define EEPROM_SIZE (FEE_PAGE_SIZE * FEE_PAGE_COUNT / 2)
diff --git a/platforms/test/rules.mk b/platforms/test/rules.mk
index 66b853d8ee..55512c7392 100644
--- a/platforms/test/rules.mk
+++ b/platforms/test/rules.mk
@@ -1,4 +1,4 @@
-eeprom_stm32_DEFS := -DFLASH_STM32_MOCKED -DNO_PRINT -DFEE_FLASH_BASE=FlashBuf
+eeprom_stm32_DEFS := -DEEPROM_TEST_HARNESS -DFLASH_STM32_MOCKED -DNO_PRINT -DFEE_FLASH_BASE=FlashBuf
eeprom_stm32_tiny_DEFS := $(eeprom_stm32_DEFS) \
-DFEE_MCU_FLASH_SIZE=1 \
-DMOCK_FLASH_SIZE=1024 \
diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c
index 19a6bea59a..8f1f39bc0f 100644
--- a/quantum/dynamic_keymap.c
+++ b/quantum/dynamic_keymap.c
@@ -29,24 +29,22 @@
# define DYNAMIC_KEYMAP_MACRO_COUNT 16
#endif
-// This is the default EEPROM max address to use for dynamic keymaps.
-// The default is the ATmega32u4 EEPROM max address.
-// Explicitly override it if the keyboard uses a microcontroller with
-// more EEPROM *and* it makes sense to increase it.
+#ifndef TOTAL_EEPROM_BYTE_COUNT
+# error Unknown total EEPROM size. Cannot derive maximum for dynamic keymaps.
+#endif
+
#ifndef DYNAMIC_KEYMAP_EEPROM_MAX_ADDR
-# if defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__)
-# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 2047
-# elif defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__)
-# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 4095
-# elif defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega16U4__) || defined(__AVR_AT90USB162__) || defined(__AVR_ATtiny85__)
-# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 511
-# else
-# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 1023
-# endif
+# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR (TOTAL_EEPROM_BYTE_COUNT - 1)
+#endif
+
+#if DYNAMIC_KEYMAP_EEPROM_MAX_ADDR > (TOTAL_EEPROM_BYTE_COUNT - 1)
+# pragma message STR(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR) " > " STR((TOTAL_EEPROM_BYTE_COUNT - 1))
+# error DYNAMIC_KEYMAP_EEPROM_MAX_ADDR is configured to use more space than what is available for the selected EEPROM driver
#endif
// Due to usage of uint16_t check for max 65535
#if DYNAMIC_KEYMAP_EEPROM_MAX_ADDR > 65535
+# pragma message STR(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR) " > 65535"
# error DYNAMIC_KEYMAP_EEPROM_MAX_ADDR must be less than 65536
#endif
@@ -71,6 +69,7 @@
// or DYNAMIC_KEYMAP_EEPROM_MAX_ADDR to increase it, *only if* the microcontroller has
// more than the default.
#if DYNAMIC_KEYMAP_EEPROM_MAX_ADDR - DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR < 100
+# pragma message STR(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR - DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR) " < 100"
# error Dynamic keymaps are configured to use more EEPROM than is available.
#endif