From f9430e530b1ba61891990d7c23c78c78e6656a6c Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Fri, 10 Jan 2025 16:21:07 +0000 Subject: [PATCH] Ensure `qmk flash` rejects invalid files for uf2 compatible bootloaders (#24802) Ensure 'qmk flash' rejects invalid files for uf2 compatible bootloaders --- lib/python/qmk/flashers.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/python/qmk/flashers.py b/lib/python/qmk/flashers.py index 7ee1bc8de7..2cca4941d3 100644 --- a/lib/python/qmk/flashers.py +++ b/lib/python/qmk/flashers.py @@ -202,6 +202,10 @@ def _flash_mdloader(file): def _flash_uf2(file): + output = cli.run(['util/uf2conv.py', '--info', file]).stdout + if 'UF2 File' not in output: + return True + cli.run(['util/uf2conv.py', '--deploy', file], capture_output=False) @@ -235,7 +239,8 @@ def flasher(mcu, file): elif bl == 'md-boot': _flash_mdloader(file) elif bl == '_uf2_compatible_': - _flash_uf2(file) + if _flash_uf2(file): + return (True, "Flashing only supports uf2 format files.") else: return (True, "Known bootloader found but flashing not currently supported!")