add sn32-dfu to flash utils

This commit is contained in:
Dimitris Mantzouranis 2023-06-06 23:00:03 +03:00
parent a9710700cb
commit bd35c7db80
2 changed files with 16 additions and 1 deletions

View File

@ -109,6 +109,11 @@ BOOTLOADER_VIDS_PIDS = {
'hid-bootloader': {
("03eb", "2067"), # QMK HID
("16c0", "0478") # PJRC halfkay
},
'sn32-dfu': {
("0c45", "7010"), # SN32F260
("0c45", "7040"), # SN32F240B
("0c45", "7900") # SN32F240
}
}

View File

@ -96,7 +96,7 @@ def _find_bootloader():
details = 'halfkay'
else:
details = 'qmk-hid'
elif bl == 'stm32-dfu' or bl == 'apm32-dfu' or bl == 'gd32v-dfu' or bl == 'kiibohd':
elif bl == 'stm32-dfu' or bl == 'apm32-dfu' or bl == 'gd32v-dfu' or bl == 'kiibohd' or bl == 'sn32-dfu':
details = (vid, pid)
else:
details = None
@ -196,6 +196,14 @@ def _flash_uf2(file):
cli.run(['util/uf2conv.py', '--deploy', file], capture_output=False)
def _flash_sonixflasher(details, file):
# SN32F260
if details[0] == '0c45' and details[1] == '7010':
cli.run(['sonixflasher', '--vidpid', f'{details[0]}:{details[1]}', '--offset', '0x200', '--file', file], capture_output=False)
else:
cli.run(['sonixflasher', '--vidpid', f'{details[0]}:{details[1]}', '--file', file], capture_output=False)
def flasher(mcu, file):
bl, details = _find_bootloader()
# Add a small sleep to avoid race conditions
@ -222,6 +230,8 @@ def flasher(mcu, file):
_flash_mdloader(file)
elif bl == '_uf2_compatible_':
_flash_uf2(file)
elif bl == 'sn32-dfu':
_flash_sonixflasher(details, file)
else:
return (True, "Known bootloader found but flashing not currently supported!")