From 4006f8c36d2a151116a175a66ec7d3e7d02cc552 Mon Sep 17 00:00:00 2001 From: Dimitris Mantzouranis Date: Wed, 18 Sep 2024 21:00:54 +0300 Subject: [PATCH] sn32: add direct `qmk flash` support build and flash in one line --- platforms/chibios/bootloader.mk | 12 ++++++++++++ platforms/chibios/flash.mk | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/platforms/chibios/bootloader.mk b/platforms/chibios/bootloader.mk index 4871e084475a..e8b9ec94f4ef 100644 --- a/platforms/chibios/bootloader.mk +++ b/platforms/chibios/bootloader.mk @@ -123,6 +123,18 @@ endif ifeq ($(strip $(BOOTLOADER)), sn32-dfu) OPT_DEFS += -DBOOTLOADER_SN32_DFU BOOTLOADER_TYPE = sn32_dfu + + # Options to pass to sonixflasher when flashing + ifeq ($(strip $(MCU_SERIES)), SN32F240) + DFU_ARGS ?= -v 0c45/7900 + endif + ifeq ($(strip $(MCU_SERIES)), SN32F240B) + DFU_ARGS ?= -v 0c45/7040 + endif + ifeq ($(strip $(MCU_SERIES)), SN32F260) + DFU_ARGS ?= -v 0c45/7010 -o 0x200 + endif + endif ifeq ($(strip $(BOOTLOADER_TYPE)),) diff --git a/platforms/chibios/flash.mk b/platforms/chibios/flash.mk index 525f177f9ebb..9fbbffa28196 100644 --- a/platforms/chibios/flash.mk +++ b/platforms/chibios/flash.mk @@ -38,6 +38,12 @@ define EXEC_WB32_DFU_UPDATER $(WB32_DFU_UPDATER) -D $(BUILD_DIR)/$(TARGET).bin && $(WB32_DFU_UPDATER) -R endef +SONIX_FLASHER ?= sonixflasher + +define EXEC_SONIX_FLASHER + $(SONIX_FLASHER) $(DFU_ARGS) -f $(BUILD_DIR)/$(TARGET).bin +endef + dfu-util: $(BUILD_DIR)/$(TARGET).bin cpfirmware sizeafter $(call EXEC_DFU_UTIL) @@ -115,6 +121,8 @@ else ifeq ($(strip $(MCU_FAMILY)),WB32) $(UNSYNC_OUTPUT_CMD) && $(call EXEC_WB32_DFU_UPDATER) else ifeq ($(strip $(MCU_FAMILY)),GD32V) $(UNSYNC_OUTPUT_CMD) && $(call EXEC_DFU_UTIL) +else ifeq ($(strip $(MCU_FAMILY)),SN32) + $(UNSYNC_OUTPUT_CMD) && $(call EXEC_SONIX_FLASHER) else $(PRINT_OK); $(SILENT) || printf "$(MSG_FLASH_BOOTLOADER)" endif