summaryrefslogtreecommitdiffstats
path: root/platforms
diff options
context:
space:
mode:
authorlokher <lokher@gmail.com>2022-12-06 17:04:10 +0800
committerlokher <lokher@gmail.com>2022-12-06 17:04:10 +0800
commit27fc28fd2ff52e079a5bc58d6aaea4c752420615 (patch)
tree7ac943fb1ba4f430a7220efd18f66f6a77205c30 /platforms
parente736133392fe6427cfb995da0787337189828272 (diff)
parent2709b6ed616f8012ff4cfd3ee69a822a8d188351 (diff)
Merge upstream master
Diffstat (limited to 'platforms')
-rw-r--r--platforms/arm_atsam/bootloader.mk46
-rw-r--r--platforms/arm_atsam/flash.mk1
-rw-r--r--platforms/avr/bootloader.mk144
-rw-r--r--platforms/avr/flash.mk9
-rw-r--r--platforms/chibios/boards/BLACKPILL_STM32_F401/configs/config.h14
-rw-r--r--platforms/chibios/boards/BLACKPILL_STM32_F411/configs/config.h14
-rw-r--r--platforms/chibios/boards/BONSAI_C4/board/board.mk9
-rw-r--r--platforms/chibios/boards/BONSAI_C4/configs/board.h20
-rw-r--r--platforms/chibios/boards/BONSAI_C4/configs/config.h92
-rw-r--r--platforms/chibios/boards/BONSAI_C4/configs/halconf.h49
-rw-r--r--platforms/chibios/boards/BONSAI_C4/configs/mcuconf.h249
-rw-r--r--platforms/chibios/boards/GENERIC_PROMICRO_RP2040/configs/mcuconf.h13
-rw-r--r--platforms/chibios/boards/GENERIC_RP_RP2040/configs/mcuconf.h13
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F072XB/configs/mcuconf.h1
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F401XC/configs/config.h10
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F401XC/configs/mcuconf.h4
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F411XE/configs/config.h10
-rw-r--r--platforms/chibios/boards/GENERIC_WB32_F3G71XX/board/board.c4
-rw-r--r--platforms/chibios/boards/GENERIC_WB32_FQ95XX/board/board.c4
-rw-r--r--platforms/chibios/boards/GENERIC_WB32_FQ95XX/configs/config.h2
-rw-r--r--platforms/chibios/boards/QMK_PM2040/configs/mcuconf.h13
-rw-r--r--platforms/chibios/boards/STEMCELL/configs/mcuconf.h25
-rw-r--r--platforms/chibios/bootloader.mk122
-rw-r--r--platforms/chibios/chibios_config.h14
-rw-r--r--platforms/chibios/converters/elite_c_to_elite_pi/_pin_defs.h39
-rw-r--r--platforms/chibios/converters/elite_c_to_elite_pi/converter.mk9
-rw-r--r--platforms/chibios/converters/elite_c_to_stemcell/_pin_defs.h54
-rw-r--r--platforms/chibios/converters/elite_c_to_stemcell/converter.mk18
-rw-r--r--platforms/chibios/converters/promicro_to_bonsai_c4/converter.mk4
-rw-r--r--platforms/chibios/converters/promicro_to_bonsai_c4/post_converter.mk5
-rw-r--r--platforms/chibios/converters/promicro_to_elite_pi/_pin_defs.h36
-rw-r--r--platforms/chibios/converters/promicro_to_elite_pi/converter.mk9
-rw-r--r--platforms/chibios/converters/promicro_to_proton_c/post_converter.mk1
-rw-r--r--platforms/chibios/drivers/analog.c12
-rw-r--r--platforms/chibios/drivers/audio_pwm_hardware.c152
-rw-r--r--platforms/chibios/drivers/eeprom/eeprom_kinetis_flexram.c (renamed from platforms/chibios/drivers/eeprom/eeprom_teensy.c)2
-rwxr-xr-xplatforms/chibios/drivers/eeprom/eeprom_kinetis_flexram.h (renamed from platforms/chibios/drivers/eeprom/eeprom_teensy.h)0
-rw-r--r--platforms/chibios/drivers/eeprom/eeprom_legacy_emulated_flash.c (renamed from platforms/chibios/drivers/eeprom/eeprom_stm32.c)6
-rw-r--r--platforms/chibios/drivers/eeprom/eeprom_legacy_emulated_flash.h (renamed from platforms/chibios/drivers/eeprom/eeprom_stm32.h)0
-rw-r--r--platforms/chibios/drivers/eeprom/eeprom_legacy_emulated_flash_defs.h (renamed from platforms/chibios/drivers/eeprom/eeprom_stm32_defs.h)0
-rw-r--r--platforms/chibios/drivers/flash/legacy_flash_ops.c (renamed from platforms/chibios/drivers/flash/flash_stm32.c)2
-rw-r--r--platforms/chibios/drivers/flash/legacy_flash_ops.h (renamed from platforms/chibios/drivers/flash/flash_stm32.h)2
-rw-r--r--platforms/chibios/drivers/serial_protocol.c12
-rw-r--r--platforms/chibios/drivers/uart.c12
-rw-r--r--platforms/chibios/drivers/uart.h46
-rw-r--r--platforms/chibios/drivers/vendor/RP/RP2040/serial_vendor.c24
-rw-r--r--platforms/chibios/drivers/vendor/RP/RP2040/ws2812_vendor.c238
-rw-r--r--platforms/chibios/drivers/wear_leveling/wear_leveling_efl.c30
-rw-r--r--platforms/chibios/drivers/wear_leveling/wear_leveling_efl_config.h4
-rw-r--r--platforms/chibios/drivers/wear_leveling/wear_leveling_legacy.c2
-rw-r--r--platforms/chibios/drivers/ws2812_pwm.c24
-rw-r--r--platforms/chibios/drivers/ws2812_spi.c8
-rw-r--r--platforms/chibios/flash.mk5
-rw-r--r--platforms/chibios/hardware_id.c9
-rw-r--r--platforms/chibios/vendors/RP/RP2040.mk254
-rw-r--r--platforms/eeprom.h12
-rw-r--r--platforms/test/eeprom_legacy_emulated_flash_tests.cpp (renamed from platforms/test/eeprom_stm32_tests.cpp)0
-rw-r--r--platforms/test/eeprom_legacy_emulated_flash_tests.h (renamed from platforms/test/eeprom_stm32_tests.h)4
-rw-r--r--platforms/test/legacy_flash_ops_mock.c (renamed from platforms/test/flash_stm32_mock.c)2
-rw-r--r--platforms/test/rules.mk24
-rw-r--r--platforms/test/testlist.mk2
61 files changed, 1431 insertions, 514 deletions
diff --git a/platforms/arm_atsam/bootloader.mk b/platforms/arm_atsam/bootloader.mk
new file mode 100644
index 0000000000..1ec42edeb6
--- /dev/null
+++ b/platforms/arm_atsam/bootloader.mk
@@ -0,0 +1,46 @@
+# Copyright 2017 Jack Humbert
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# If it's possible that multiple bootloaders can be used for one project,
+# you can leave this unset, and the correct size will be selected
+# automatically.
+#
+# Sets the bootloader defined in the keyboard's/keymap's rules.mk
+#
+# Current options for ARM (ATSAM):
+# md-boot Atmel SAM-BA (only used by Drop boards)
+#
+# If you need to provide your own implementation, you can set inside `rules.mk`
+# `BOOTLOADER = custom` -- you'll need to provide your own implementations. See
+# the respective file under `platforms/<PLATFORM>/bootloaders/custom.c` to see
+# which functions may be overridden.
+
+ifeq ($(strip $(BOOTLOADER)), custom)
+ OPT_DEFS += -DBOOTLOADER_CUSTOM
+ BOOTLOADER_TYPE = custom
+endif
+
+ifeq ($(strip $(BOOTLOADER)), md-boot)
+ OPT_DEFS += -DBOOTLOADER_MD_BOOT
+ BOOTLOADER_TYPE = md_boot
+endif
+
+ifeq ($(strip $(BOOTLOADER_TYPE)),)
+ ifneq ($(strip $(BOOTLOADER)),)
+ $(call CATASTROPHIC_ERROR,Invalid BOOTLOADER,Invalid bootloader specified. Please set an appropriate bootloader in your rules.mk or info.json.)
+ else
+ $(call CATASTROPHIC_ERROR,Invalid BOOTLOADER,No bootloader specified. Please set an appropriate bootloader in your rules.mk or info.json.)
+ endif
+endif
diff --git a/platforms/arm_atsam/flash.mk b/platforms/arm_atsam/flash.mk
index 8152610ceb..8068c08d57 100644
--- a/platforms/arm_atsam/flash.mk
+++ b/platforms/arm_atsam/flash.mk
@@ -13,6 +13,7 @@ mdloader: bin
$(call EXEC_MDLOADER)
flash: bin
+ $(SILENT) || printf "Flashing for bootloader: $(BLUE)$(BOOTLOADER)$(NO_COLOR)\n"
ifneq ($(strip $(PROGRAM_CMD)),)
$(UNSYNC_OUTPUT_CMD) && $(PROGRAM_CMD)
else ifeq ($(strip $(ARM_ATSAM)),SAMD51J18A)
diff --git a/platforms/avr/bootloader.mk b/platforms/avr/bootloader.mk
new file mode 100644
index 0000000000..63fe635d96
--- /dev/null
+++ b/platforms/avr/bootloader.mk
@@ -0,0 +1,144 @@
+# Copyright 2017 Jack Humbert
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# If it's possible that multiple bootloaders can be used for one project,
+# you can leave this unset, and the correct size will be selected
+# automatically.
+#
+# Sets the bootloader defined in the keyboard's/keymap's rules.mk
+#
+# Current options for AVR:
+# halfkay PJRC Teensy
+# caterina Pro Micro (Sparkfun/generic)
+# atmel-dfu Atmel factory DFU
+# lufa-dfu LUFA DFU
+# qmk-dfu QMK DFU (LUFA + blinkenlight)
+# qmk-hid QMK HID (LUFA + blinkenlight)
+# bootloadhid HIDBootFlash compatible (ATmega32A)
+# usbasploader USBaspLoader (ATmega328P)
+#
+# If you need to provide your own implementation, you can set inside `rules.mk`
+# `BOOTLOADER = custom` -- you'll need to provide your own implementations. See
+# the respective file under `platforms/<PLATFORM>/bootloaders/custom.c` to see
+# which functions may be overridden.
+#
+# BOOTLOADER_SIZE can still be defined manually, but it's recommended
+# you add any possible configuration to this list
+
+ifeq ($(strip $(BOOTLOADER)), custom)
+ OPT_DEFS += -DBOOTLOADER_CUSTOM
+ BOOTLOADER_TYPE = custom
+endif
+
+ifeq ($(strip $(BOOTLOADER)), atmel-dfu)
+ OPT_DEFS += -DBOOTLOADER_ATMEL_DFU
+ OPT_DEFS += -DBOOTLOADER_DFU
+ BOOTLOADER_TYPE = dfu
+
+ ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
+ BOOTLOADER_SIZE = 4096
+ endif
+ ifneq (,$(filter $(MCU), at90usb1286 at90usb1287))
+ BOOTLOADER_SIZE = 8192
+ endif
+endif
+ifeq ($(strip $(BOOTLOADER)), lufa-dfu)
+ OPT_DEFS += -DBOOTLOADER_LUFA_DFU
+ OPT_DEFS += -DBOOTLOADER_DFU
+ BOOTLOADER_TYPE = dfu
+
+ ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
+ BOOTLOADER_SIZE ?= 4096
+ endif
+ ifneq (,$(filter $(MCU), at90usb1286 at90usb1287))
+ BOOTLOADER_SIZE ?= 8192
+ endif
+endif
+ifeq ($(strip $(BOOTLOADER)), qmk-dfu)
+ OPT_DEFS += -DBOOTLOADER_QMK_DFU
+ OPT_DEFS += -DBOOTLOADER_DFU
+ BOOTLOADER_TYPE = dfu
+
+ ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
+ BOOTLOADER_SIZE ?= 4096
+ endif
+ ifneq (,$(filter $(MCU), at90usb1286 at90usb1287))
+ BOOTLOADER_SIZE ?= 8192
+ endif
+endif
+ifeq ($(strip $(BOOTLOADER)), qmk-hid)
+ OPT_DEFS += -DBOOTLOADER_QMK_HID
+ OPT_DEFS += -DBOOTLOADER_HID
+ BOOTLOADER_TYPE = dfu
+
+ BOOTLOADER_SIZE ?= 4096
+endif
+ifeq ($(strip $(BOOTLOADER)), halfkay)
+ OPT_DEFS += -DBOOTLOADER_HALFKAY
+ BOOTLOADER_TYPE = halfkay
+
+ # Teensy 2.0
+ ifeq ($(strip $(MCU)), atmega32u4)
+ BOOTLOADER_SIZE = 512
+ endif
+ # Teensy 2.0++
+ ifeq ($(strip $(MCU)), at90usb1286)
+ BOOTLOADER_SIZE = 1024
+ endif
+endif
+ifeq ($(strip $(BOOTLOADER)), caterina)
+ OPT_DEFS += -DBOOTLOADER_CATERINA
+ BOOTLOADER_TYPE = caterina
+
+ BOOTLOADER_SIZE = 4096
+endif
+ifeq ($(strip $(BOOTLOADER)), bootloadhid)
+ OPT_DEFS += -DBOOTLOADER_BOOTLOADHID
+ BOOTLOADER_TYPE = bootloadhid
+
+ BOOTLOADER_SIZE = 4096
+endif
+ifeq ($(strip $(BOOTLOADER)), usbasploader)
+ OPT_DEFS += -DBOOTLOADER_USBASP
+ BOOTLOADER_TYPE = usbasploader
+
+ BOOTLOADER_SIZE = 4096
+endif
+ifeq ($(strip $(BOOTLOADER)), lufa-ms)
+ OPT_DEFS += -DBOOTLOADER_MS
+ BOOTLOADER_TYPE = dfu
+
+ BOOTLOADER_SIZE ?= 8192
+ FIRMWARE_FORMAT = bin
+cpfirmware: lufa_warning
+.INTERMEDIATE: lufa_warning
+lufa_warning: $(FIRMWARE_FORMAT)
+ $(info @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@)
+ $(info LUFA MASS STORAGE Bootloader selected)
+ $(info DO NOT USE THIS BOOTLOADER IN NEW PROJECTS!)
+ $(info It is extremely prone to bricking, and is only included to support existing boards.)
+ $(info @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@)
+endif
+ifdef BOOTLOADER_SIZE
+ OPT_DEFS += -DBOOTLOADER_SIZE=$(strip $(BOOTLOADER_SIZE))
+endif
+
+ifeq ($(strip $(BOOTLOADER_TYPE)),)
+ ifneq ($(strip $(BOOTLOADER)),)
+ $(call CATASTROPHIC_ERROR,Invalid BOOTLOADER,Invalid bootloader specified. Please set an appropriate bootloader in your rules.mk or info.json.)
+ else
+ $(call CATASTROPHIC_ERROR,Invalid BOOTLOADER,No bootloader specified. Please set an appropriate bootloader in your rules.mk or info.json.)
+ endif
+endif
diff --git a/platforms/avr/flash.mk b/platforms/avr/flash.mk
index 6d50e72534..9c2ab72410 100644
--- a/platforms/avr/flash.mk
+++ b/platforms/avr/flash.mk
@@ -78,7 +78,7 @@ AVRDUDE_PROGRAMMER ?= avrdude
define EXEC_AVRDUDE
list_devices() { \
if $(GREP) -q -s icrosoft /proc/version; then \
- wmic.exe path Win32_SerialPort get DeviceID 2>/dev/null | LANG=C perl -pne 's/COM(\d+)/COM.($$1-1)/e' | sed 's!COM!/dev/ttyS!' | xargs echo -n | sort; \
+ powershell.exe 'Get-CimInstance -Class Win32_SerialPort | Select -ExpandProperty "DeviceID"' 2>/dev/null | sed -e "s/\r//g" | LANG=C perl -pne 's/COM(\d+)/COM.($$1-1)/e' | sed 's!COM!/dev/ttyS!' | sort; \
elif [ "`uname`" = "FreeBSD" ]; then \
ls /dev/tty* | grep -v '\.lock$$' | grep -v '\.init$$'; \
else \
@@ -168,7 +168,8 @@ endef
hid_bootloader: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
$(call EXEC_HID_LUFA)
-flash: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
+flash: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
+ $(SILENT) || printf "Flashing for bootloader: $(BLUE)$(BOOTLOADER)$(NO_COLOR)\n"
ifneq ($(strip $(PROGRAM_CMD)),)
$(UNSYNC_OUTPUT_CMD) && $(PROGRAM_CMD)
else ifeq ($(strip $(BOOTLOADER)), caterina)
@@ -177,9 +178,9 @@ else ifeq ($(strip $(BOOTLOADER)), halfkay)
$(UNSYNC_OUTPUT_CMD) && $(call EXEC_TEENSY)
else ifeq (dfu,$(findstring dfu,$(BOOTLOADER)))
$(UNSYNC_OUTPUT_CMD) && $(call EXEC_DFU)
-else ifneq (,$(filter $(BOOTLOADER), usbasploader USBasp))
+else ifeq ($(strip $(BOOTLOADER)), usbasploader)
$(UNSYNC_OUTPUT_CMD) && $(call EXEC_USBASP)
-else ifneq (,$(filter $(BOOTLOADER), bootloadhid bootloadHID))
+else ifeq ($(strip $(BOOTLOADER)), bootloadhid)
$(UNSYNC_OUTPUT_CMD) && $(call EXEC_BOOTLOADHID)
else ifeq ($(strip $(BOOTLOADER)), qmk-hid)
$(UNSYNC_OUTPUT_CMD) && $(call EXEC_HID_LUFA)
diff --git a/platforms/chibios/boards/BLACKPILL_STM32_F401/configs/config.h b/platforms/chibios/boards/BLACKPILL_STM32_F401/configs/config.h
index e181422eba..6d132ea6f3 100644
--- a/platforms/chibios/boards/BLACKPILL_STM32_F401/configs/config.h
+++ b/platforms/chibios/boards/BLACKPILL_STM32_F401/configs/config.h
@@ -19,12 +19,22 @@
#ifndef STM32_LSECLK
# define STM32_LSECLK 32768U
-#endif // STM32_LSECLK
+#endif // STM32_LSECLK
#ifndef STM32_HSECLK
# define STM32_HSECLK 25000000U
-#endif // STM32_HSECLK
+#endif // STM32_HSECLK
#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
#endif
+
+#ifdef WEAR_LEVELING_EMBEDDED_FLASH
+# ifndef WEAR_LEVELING_EFL_FIRST_SECTOR
+# ifdef BOOTLOADER_TINYUF2
+# define WEAR_LEVELING_EFL_FIRST_SECTOR 3
+# else
+# define WEAR_LEVELING_EFL_FIRST_SECTOR 1
+# endif
+# endif
+#endif
diff --git a/platforms/chibios/boards/BLACKPILL_STM32_F411/configs/config.h b/platforms/chibios/boards/BLACKPILL_STM32_F411/configs/config.h
index e181422eba..6d132ea6f3 100644
--- a/platforms/chibios/boards/BLACKPILL_STM32_F411/configs/config.h
+++ b/platforms/chibios/boards/BLACKPILL_STM32_F411/configs/config.h
@@ -19,12 +19,22 @@
#ifndef STM32_LSECLK
# define STM32_LSECLK 32768U
-#endif // STM32_LSECLK
+#endif // STM32_LSECLK
#ifndef STM32_HSECLK
# define STM32_HSECLK 25000000U
-#endif // STM32_HSECLK
+#endif // STM32_HSECLK
#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
#endif
+
+#ifdef WEAR_LEVELING_EMBEDDED_FLASH
+# ifndef WEAR_LEVELING_EFL_FIRST_SECTOR
+# ifdef BOOTLOADER_TINYUF2
+# define WEAR_LEVELING_EFL_FIRST_SECTOR 3
+# else
+# define WEAR_LEVELING_EFL_FIRST_SECTOR 1
+# endif
+# endif
+#endif
diff --git a/platforms/chibios/boards/BONSAI_C4/board/board.mk b/platforms/chibios/boards/BONSAI_C4/board/board.mk
new file mode 100644
index 0000000000..bb00b1a2b0
--- /dev/null
+++ b/platforms/chibios/boards/BONSAI_C4/board/board.mk
@@ -0,0 +1,9 @@
+# List of all the board related files.
+BOARDSRC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_F411RE/board.c
+
+# Required include directories
+BOARDINC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_F411RE
+
+# Shared variables
+ALLCSRC += $(BOARDSRC)
+ALLINC += $(BOARDINC)
diff --git a/platforms/chibios/boards/BONSAI_C4/configs/board.h b/platforms/chibios/boards/BONSAI_C4/configs/board.h
new file mode 100644
index 0000000000..f1ee51c91f
--- /dev/null
+++ b/platforms/chibios/boards/BONSAI_C4/configs/board.h
@@ -0,0 +1,20 @@
+/* Copyright 2020 Nick Brassel (tzarc)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#include_next "board.h"
+
+#undef STM32_HSE_BYPASS \ No newline at end of file
diff --git a/platforms/chibios/boards/BONSAI_C4/configs/config.h b/platforms/chibios/boards/BONSAI_C4/configs/config.h
new file mode 100644
index 0000000000..e412f73d3d
--- /dev/null
+++ b/platforms/chibios/boards/BONSAI_C4/configs/config.h
@@ -0,0 +1,92 @@
+/* Copyright 2022 David Hoelscher, customMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+// Bonsai C4 includes Vbus sensing; derived designs that use PA9 for other purposes
+// may disable Vbus sensing with #define BOARD_OTG_NOVBUSSENS 1
+
+#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
+# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
+#endif
+
+// FRAM configuration
+#ifndef EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN
+# define EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN PAL_LINE(GPIOA, 0)
+# define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 8 // 96MHz / 8 = 12MHz; max supported by MB85R64 is 20MHz
+# define EXTERNAL_EEPROM_BYTE_COUNT 8192
+# define EXTERNAL_EEPROM_PAGE_SIZE 64 // does not matter for FRAM, just sets the RAM buffer size in STM32F chip
+# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 8191
+#endif
+
+// External flash configuration
+#ifndef EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN
+# define EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN PAL_LINE(GPIOB, 12)
+# define EXTERNAL_FLASH_SPI_CLOCK_DIVISOR 2 // 48MHz; max supported by W25Q128JV is 133MHz
+# define EXTERNAL_FLASH_BYTE_COUNT (16 * 1024 * 1024) //128Mbit or 16MByte
+# define EXTERNAL_FLASH_PAGE_SIZE 256
+# define EXTERNAL_FLASH_SPI_TIMEOUT 200000 //datasheet max is 200 seconds for flash chip erase
+#endif
+
+// SPI Configuration (needed for FRAM and FLASH)
+#ifndef SPI_DRIVER
+# define SPI_DRIVER SPID1
+#endif
+#ifndef SPI_SCK_PIN
+# define SPI_SCK_PIN PAL_LINE(GPIOB, 3)
+#endif
+#ifndef SPI_MOSI_PIN
+# define SPI_MOSI_PIN PAL_LINE(GPIOB, 5)
+#endif
+#ifndef SPI_MISO_PIN
+# define SPI_MISO_PIN PAL_LINE(GPIOB, 4)
+#endif
+
+
+// I2C Configuration
+#ifdef CONVERT_TO_BONSAI_C4
+# ifndef I2C1_SCL_PIN
+# define I2C1_SCL_PIN PAL_LINE(GPIOB, 6)
+# endif
+# ifndef I2C1_SDA_PIN
+# define I2C1_SDA_PIN PAL_LINE(GPIOB, 9)
+# endif
+#endif
+
+// WS2812-style LED control on pin A10
+#ifdef WS2812_DRIVER_PWM
+# ifndef RGB_DI_PIN
+# define RGB_DI_PIN PAL_LINE(GPIOA, 10)
+# endif
+# ifndef WS2812_PWM_DRIVER
+# define WS2812_PWM_DRIVER PWMD1
+# endif
+# ifndef WS2812_PWM_CHANNEL
+# define WS2812_PWM_CHANNEL 3
+# endif
+# ifndef WS2812_PWM_PAL_MODE
+# define WS2812_PWM_PAL_MODE 1
+# endif
+# ifndef WS2812_DMA_STREAM
+# define WS2812_DMA_STREAM STM32_DMA2_STREAM5
+# endif
+# ifndef WS2812_DMA_CHANNEL
+# define WS2812_DMA_CHANNEL 6
+# endif
+#endif
+
+#ifndef USB_VBUS_PIN
+# define USB_VBUS_PIN PAL_LINE(GPIOA, 9)
+#endif \ No newline at end of file
diff --git a/platforms/chibios/boards/BONSAI_C4/configs/halconf.h b/platforms/chibios/boards/BONSAI_C4/configs/halconf.h
new file mode 100644
index 0000000000..7887e7c9ba
--- /dev/null
+++ b/platforms/chibios/boards/BONSAI_C4/configs/halconf.h
@@ -0,0 +1,49 @@
+/* Copyright 2022 David Hoelscher, customMK
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#ifndef HAL_USE_SPI
+# define HAL_USE_SPI TRUE
+#endif
+
+#ifndef HAL_USE_I2C
+# define HAL_USE_I2C TRUE
+#endif
+
+#ifdef SPLIT_KEYBOARD
+# ifndef HAL_USE_SERIAL
+# define HAL_USE_SERIAL TRUE
+# endif
+# ifndef SERIAL_BUFFERS_SIZE
+#