qmk / qmk_firmware

Open-source keyboard firmware for Atmel AVR and Arm USB families
https://qmk.fm
GNU General Public License v2.0
18.1k stars 38.93k forks source link

[Bug] Fix disabled GPIO groups D & E on some of STM32L4xx family caused by a ChibiOS "Oops!" #14280

Closed donicrosby closed 2 years ago

donicrosby commented 3 years ago

Update ChibiOS to the latest version of the stable 20.3.x branch to allow for the STM32L4xx (found in at least the STM32L443 but possibly other MCUs). ChibiOS has in the stm32_registry.h for the STM32L4xx family it says it does not have a GPIO D & E group but the MCU does in fact have those GPIO groups.

Describe the Bug

For at least the STM32L443 (QMK uses that as the MCU for the STM32L433 as well), the ChibiOS does not enable a few of the GPIO groups for that MCU even through they are actually on the MCU and don't have a "programmatic" cost to enable them.

Currently is:

#if defined(STM32L443xx) || defined(__DOXYGEN__)
-- snip --
#define STM32_HAS_GPIOA                     TRUE
#define STM32_HAS_GPIOB                     TRUE
#define STM32_HAS_GPIOC                     TRUE
#define STM32_HAS_GPIOD                     FALSE
#define STM32_HAS_GPIOE                     FALSE
-- snip --
#define STM32_HAS_GPIOH                     TRUE
-- snip --
#define STM32_GPIO_EN_MASK                  (RCC_AHB2ENR_GPIOAEN |          \
                                             RCC_AHB2ENR_GPIOBEN |          \
                                             RCC_AHB2ENR_GPIOCEN |          \
                                             RCC_AHB2ENR_GPIOHEN)

Should be:

#if defined(STM32L443xx) || defined(__DOXYGEN__)
-- snip --
#define STM32_HAS_GPIOA                     TRUE
#define STM32_HAS_GPIOB                     TRUE
#define STM32_HAS_GPIOC                     TRUE
#define STM32_HAS_GPIOD                     TRUE
#define STM32_HAS_GPIOE                     TRUE
-- snip --
#define STM32_HAS_GPIOH                     TRUE
-- snip --
#define STM32_GPIO_EN_MASK                  (RCC_AHB2ENR_GPIOAEN |          \
                                             RCC_AHB2ENR_GPIOBEN |          \
                                             RCC_AHB2ENR_GPIOCEN |          \
                                             RCC_AHB2ENR_GPIODEN |          \
                                             RCC_AHB2ENR_GPIOEEN |          \
                                             RCC_AHB2ENR_GPIOHEN)

Additional Context

From my discussion with Giovanni it looks like there may be some other MCUs that had this error so this would fix those as well. These changes are backported from the more recent 21.6.x branch.

There is no way to override the stm32_registry.h in ChibiOS during the build so for things like this meaning QMK is dependent on upstream configuration changes. It may make sense to allow for keyboards to supply a stm32_registry.h so that there isn't so much extra work to get things like configuration updates for the project.

tzarc commented 2 years ago

Fixed in latest ChibiOS.