Reflashing your board could be done by two different methods:
-
Via a USB. To make that work, a USB-aware bootloader must be flashed first to your board - in other words, USB commands are handled by a program that resides on flash which either performs reprogramming, or loads user’s sketch. XIAOs get shipped with a pre-flashed bootloader. If a bootloader gets damaged/reprogrammed for any reason, then there is no way to reflash the board using this method.
-
Via two SWD pins. This method always works, because SWD handling logic is hardwired into the ARM cores. XIAO SWD connectors are located at the bottom of the board as pads. Via SWD, it is possible to reflash any area of the flash memory - a sketch program, or a bootloader. So, you can use SWD to restore a bootloader.
In order to use SWD method, you need another board with an “SWD programmer” firmware on it - it could be a Raspberry PI, an ST-Link, a Blackmagic, a ESP32 - there are plenty of variants:
+------+ +---------------+
| XIAO | --- two SWD wires --- | another board | <--- firmware.hex
+------+ +---------------+
Below are two of them:
- The ST-Link method is described at @msfujino topic How to unbrick a dead XIAO using ST-LINK and OpenOCD
- The ESP32 method is described by me at Upload different bootloader into XIAO