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