qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

wear_leveling_efl_config.h (2665B)


      1 // Copyright 2022 Nick Brassel (@tzarc)
      2 // SPDX-License-Identifier: GPL-2.0-or-later
      3 #pragma once
      4 
      5 #ifndef __ASSEMBLER__
      6 #    include <hal.h>
      7 #endif
      8 
      9 // Work out how many bytes per write to internal flash
     10 #ifndef BACKING_STORE_WRITE_SIZE
     11 // These need to match EFL's XXXXXX_FLASH_LINE_SIZE, see associated code in `lib/chibios/os/hal/ports/**/hal_efl_lld.c`,
     12 // or associated `stm32_registry.h` for the MCU in question (or equivalent for the family).
     13 #    if defined(QMK_MCU_SERIES_GD32VF103)
     14 #        define BACKING_STORE_WRITE_SIZE 2 // from hal_efl_lld.c
     15 #    elif defined(QMK_MCU_FAMILY_NUC123)
     16 #        define BACKING_STORE_WRITE_SIZE 4 // from hal_efl_lld.c
     17 #    elif defined(QMK_MCU_FAMILY_WB32)
     18 #        define BACKING_STORE_WRITE_SIZE 8 // from hal_efl_lld.c
     19 #    elif defined(QMK_MCU_FAMILY_AT32)
     20 #        define BACKING_STORE_WRITE_SIZE 2 // from hal_efl_lld.c
     21 #    elif defined(QMK_MCU_FAMILY_STM32)
     22 #        if defined(STM32_FLASH_LINE_SIZE) // from some family's stm32_registry.h file
     23 #            define BACKING_STORE_WRITE_SIZE (STM32_FLASH_LINE_SIZE)
     24 #        else
     25 #            if defined(QMK_MCU_SERIES_STM32F0XX)
     26 #                define BACKING_STORE_WRITE_SIZE 2 // from hal_efl_lld.c
     27 #            elif defined(QMK_MCU_SERIES_STM32F1XX)
     28 #                define BACKING_STORE_WRITE_SIZE 2 // from hal_efl_lld.c
     29 #            elif defined(QMK_MCU_SERIES_STM32F3XX)
     30 #                define BACKING_STORE_WRITE_SIZE 2 // from hal_efl_lld.c
     31 #            elif defined(QMK_MCU_SERIES_STM32F4XX)
     32 #                define BACKING_STORE_WRITE_SIZE (1 << STM32_FLASH_PSIZE) // from hal_efl_lld.c
     33 #            elif defined(QMK_MCU_SERIES_STM32L4XX)
     34 #                define BACKING_STORE_WRITE_SIZE 8 // from hal_efl_lld.c
     35 #            elif defined(QMK_MCU_SERIES_STM32G0XX)
     36 #                define BACKING_STORE_WRITE_SIZE 8 // from hal_efl_lld.c
     37 #            elif defined(QMK_MCU_SERIES_STM32G4XX)
     38 #                define BACKING_STORE_WRITE_SIZE 8 // from hal_efl_lld.c
     39 #            else
     40 #                error "ChibiOS hasn't defined STM32_FLASH_LINE_SIZE, and could not automatically determine BACKING_STORE_WRITE_SIZE" // normally defined in stm32_registry.h, should be set by STM32_FLASH_LINE_SIZE
     41 #            endif
     42 #        endif
     43 #    else
     44 #        error "Could not automatically determine BACKING_STORE_WRITE_SIZE"
     45 #    endif
     46 #endif
     47 
     48 // 2kB backing space allocated
     49 #ifndef WEAR_LEVELING_BACKING_SIZE
     50 #    define WEAR_LEVELING_BACKING_SIZE 2048
     51 #endif // WEAR_LEVELING_BACKING_SIZE
     52 
     53 // 1kB logical EEPROM
     54 #ifndef WEAR_LEVELING_LOGICAL_SIZE
     55 #    define WEAR_LEVELING_LOGICAL_SIZE ((WEAR_LEVELING_BACKING_SIZE) / 2)
     56 #endif // WEAR_LEVELING_LOGICAL_SIZE