diff --git a/docs/driver_installation_zadig.md b/docs/driver_installation_zadig.md index 3b2c0b74dc41..4ad71ea2d0d9 100644 --- a/docs/driver_installation_zadig.md +++ b/docs/driver_installation_zadig.md @@ -2,7 +2,7 @@ QMK presents itself to the host as a regular HID keyboard device, and as such requires no special drivers. However, in order to flash your keyboard on Windows, the bootloader device that appears when you reset the board often *does*. -There are two notable exceptions: the Caterina bootloader, usually seen on Pro Micros, and the HalfKay bootloader shipped with PJRC Teensys, appear as a serial port and a generic HID device respectively, and so do not require a driver. +There are three notable exceptions: the Caterina bootloader, usually seen on Pro Micros, the HalfKay bootloader shipped with PJRC Teensys, and the SN32 DFU bootloader shipped with Sonix SN32F2xx, appear as a serial port and a generic HID device respectively, and so do not require a driver. We recommend the use of the [Zadig](https://zadig.akeo.ie/) utility. If you have set up the development environment with MSYS2, the `qmk_install.sh` script will have already installed the drivers for you. @@ -96,4 +96,7 @@ The device name here is the name that appears in Zadig, and may not be what the |`gd32v-dfu` |GD32V BOOTLOADER |`28E9:0189` |WinUSB | |`kiibohd` |Kiibohd DFU Bootloader |`1C11:B007` |WinUSB | |`stm32duino` |Maple 003 |`1EAF:0003` |WinUSB | +|`sn32-dfu` |*none* |`0c45:7010` |HidUsb | +|`sn32-dfu` |*none* |`0c45:7040` |HidUsb | +|`sn32-dfu` |*none* |`0c45:7900` |HidUsb | |`qmk-hid` |(keyboard name) Bootloader |`03EB:2067` |HidUsb | diff --git a/docs/flashing.md b/docs/flashing.md index 113d90ca38ff..5a69c602b9be 100644 --- a/docs/flashing.md +++ b/docs/flashing.md @@ -465,3 +465,45 @@ CLI Flashing sequence: 4. Wait for the keyboard to become available 1: This works only if QMK was compiled with `RP2040_BOOTLOADER_DOUBLE_TAP_RESET` defined. + +## SN32 DFU + +All SN32 MCUs, except for 2601 come preloaded with a factory bootloader that cannot be modified nor deleted. + +To ensure compatibility with the SN32-DFU bootloader, make sure this block is present in your `rules.mk` : + +```make +# Bootloader selection +BOOTLOADER = sn32-dfu +``` + +Compatible flashers: + +* [QMK Toolbox](https://github.com/qmk/qmk_toolbox/releases) (recommended GUI) +* [Sonix-Flasher](https://github.com/SonixQMK/sonix-flasher/releases) (advanced GUI with MCU specific functionalities) +* [SonixFlasherC](https://github.com/SonixQMK/SonixFlasherC/releases) (recommended command line) + ``` + sonixflasher --vidpid 0c45:7040 -f + ``` +1: 260 series of chips have part of the SN32-DFU bootloader in userspace and therefore must be guarded to avoid bricking. Install the [sonix-bootloader](https://github.com/SonixQMK/sonix-keyboard-bootloader) before flashing the firmware +``` +sonixflasher --vidpid 0c45:7010 --jumploader -f + +``` +as a one-shot operation, then flash the firmware with an offset `0x200` +``` +sonixflasher --vidpid 0c45:7010 -o 0x200 -f + +``` + +If using `$ qmk flash` to flash a firmware, the offset is automatically applied if needed. + +Flashing sequence: + +1. Enter the bootloader using any of the following methods: + * Tap the `QK_BOOT` keycode + * If a reset circuit is present, tap the `RESET` button on the PCB; some boards may also have a toggle switch that must be flipped + * Otherwise, you need to bridge `BOOT` to GND (via `BOOT` button or jumper), short `RESET` to GND (via `RESET` button, jumper or by unplugging and replugging USB), and then let go of the `BOOT` bridge +2. Wait for the OS to detect the device +3. Flash a .bin file +4. Reset the device into application mode (may be done automatically) diff --git a/lib/python/qmk/cli/doctor/check.py b/lib/python/qmk/cli/doctor/check.py index cd69cdd11c8d..4bd590b99e75 100644 --- a/lib/python/qmk/cli/doctor/check.py +++ b/lib/python/qmk/cli/doctor/check.py @@ -44,7 +44,12 @@ def _check_arm_gcc_version(): version_number = ESSENTIAL_BINARIES['arm-none-eabi-gcc']['output'].strip() cli.log.info('Found arm-none-eabi-gcc version %s', version_number) - return CheckStatus.OK # Right now all known arm versions are ok + parsed_version = _parse_gcc_version(version_number) + if (parsed_version['major'], parsed_version['minor']) < (10, 3): + cli.log.warning('{fg_yellow}We do not recommend arm-none-eabi-gcc older than 10.3.x. Upgrading to 10.3.x or higher is recommended.') + return CheckStatus.WARNING + + return CheckStatus.OK # arm versions less than 10.3.x cause issues on sn32 def _check_avr_gcc_version(): diff --git a/lib/python/qmk/constants.py b/lib/python/qmk/constants.py index 97bd84aa2344..1dcce612df23 100644 --- a/lib/python/qmk/constants.py +++ b/lib/python/qmk/constants.py @@ -112,6 +112,11 @@ 'hid-bootloader': { ("03eb", "2067"), # QMK HID ("16c0", "0478") # PJRC halfkay + }, + 'sn32-dfu': { + ("0c45", "7010"), # SN32F260 + ("0c45", "7040"), # SN32F240B + ("0c45", "7900") # SN32F240 } } diff --git a/lib/python/qmk/flashers.py b/lib/python/qmk/flashers.py index 9ecb5e4b9c8f..77452b92fa0a 100644 --- a/lib/python/qmk/flashers.py +++ b/lib/python/qmk/flashers.py @@ -96,7 +96,7 @@ def _find_bootloader(): details = 'halfkay' else: details = 'qmk-hid' - elif bl in {'apm32-dfu', 'gd32v-dfu', 'kiibohd', 'stm32-dfu'}: + elif bl in {'apm32-dfu', 'gd32v-dfu', 'kiibohd', 'stm32-dfu', 'sn32-dfu'}: details = (vid, pid) else: details = None @@ -205,6 +205,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 @@ -234,6 +242,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!") diff --git a/util/install/linux_shared.sh b/util/install/linux_shared.sh index e060f425f579..50fd3fe84cf1 100755 --- a/util/install/linux_shared.sh +++ b/util/install/linux_shared.sh @@ -11,3 +11,15 @@ _qmk_install_bootloadhid() { popd > /dev/null fi } + +# No distros package sonixflasher yet +_qmk_install_sonixflasher() { + if ! command -v sonixflasher > /dev/null; then + wget https://github.com/SonixQMK/SonixFlasherC/archive/refs/tags/1.1.0.tar.gz -O - | tar -xz -C /tmp + pushd /tmp/SonixFlasherC-1.1.0/ > /dev/null + if make; then + sudo cp sonixflasher /usr/local/bin + fi + popd > /dev/null + fi +} \ No newline at end of file diff --git a/util/install/msys2.sh b/util/install/msys2.sh index fa422023ab60..d5aa2559474a 100755 --- a/util/install/msys2.sh +++ b/util/install/msys2.sh @@ -12,7 +12,8 @@ _qmk_install() { base-devel: toolchain:x clang:x python-qmk:x hidapi:x \ avr-binutils:x avr-gcc:x avr-libc:x \ arm-none-eabi-binutils:x arm-none-eabi-gcc:x arm-none-eabi-newlib:x \ - avrdude:x bootloadhid:x dfu-programmer:x dfu-util:x hid-bootloader-cli:x mdloader:x teensy-loader-cli:x wb32-dfu-updater:x + avrdude:x bootloadhid:x dfu-programmer:x dfu-util:x hid-bootloader-cli:x mdloader:x \ + teensy-loader-cli:x wb32-dfu-updater:x sonixflasher:x _qmk_install_drivers } diff --git a/util/qmk_install.sh b/util/qmk_install.sh index 3f49bd255a7e..510724964a95 100755 --- a/util/qmk_install.sh +++ b/util/qmk_install.sh @@ -73,3 +73,7 @@ _qmk_install if type _qmk_install_bootloadhid &>/dev/null; then _qmk_install_bootloadhid fi + +if type _qmk_install_sonixflasher &>/dev/null; then + _qmk_install_sonixflasher +fi diff --git a/util/udev/50-qmk.rules b/util/udev/50-qmk.rules index 1cc19b41428c..cc7bb7544398 100644 --- a/util/udev/50-qmk.rules +++ b/util/udev/50-qmk.rules @@ -84,3 +84,8 @@ SUBSYSTEMS=="usb", ATTRS{idVendor}=="28e9", ATTRS{idProduct}=="0189", TAG+="uacc # WB32 DFU SUBSYSTEMS=="usb", ATTRS{idVendor}=="342d", ATTRS{idProduct}=="dfa0", TAG+="uaccess" + +# SN32 DFU +SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7010", TAG+="uaccess" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7040", TAG+="uaccess" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7900", TAG+="uaccess"