Using an inexpensive Chinese ST-LINK and OpenOCD for Windows, I was able to repair the XIAO bootloader. Here is a summary of the procedure. I hope it will be helpful.
Download OpenOCD for Windows from https://gnutoolchains.com/arm-eabi/openocd/ and extract it to C:/OpenOCD.
Copy the file C:/OpenOCD/share/openocd/script/target/at91samdXX.cfg and rename it XIAO_at91samdXX.cfg and modify the following:
set _CPUTAPID 0x4ba00477---->
set _CPUTAPID 0x0bc11477
Create the directory C:/XIAO_bootloader.
Copy the openocd.cfg from the adafruit article “Create OpenOCD config” to C:/XIAO_bootloader and rename it XIAO_openocd.cfg and modify the following four parts.
source [find interface/raspberrypi2-native.cfg]
----> source [find interface/stlink.cfg]
transport select swd
----> transport select hla_swd
source [find target/at91samdXX.cfg]
----> source [find target/XIAO_at91samdXX.cfg]
program samd21_sam_ba verify
----> program bootloader-XIAO_m0-v3.7.0-33-g90ff611-dirty.bin verify
Download the bootloader file bootloader-XIAO_m0-v3.7.0-33-g90ff611-dirty.bin to C:/XIAO_bootloader.
At the command prompt
C:/XIAO_bootloader>C:/openocd/bin/openocd -f XIAO_openocd.cfg
Do not press the Enter key yet.
As shown in the photo, connect the power supply to the XIAO, keeping the pin header pressed against the pads, finally insert the ST-LINK into the USB port.
P ress Enter to execute. If it is successful, the following message will appear.
Info : SAMD MCU SAMD21G18A (256KB Flash, 32KB RAM)
Verified OK Verified OK
shutdown command invoked
The write time is very short, 2-3 seconds, so by pressing the pin header to the pads I was able to write and did not have to do any difficult soldering to the pads.
If you get an message Error: init mode failed (unable to connect to the target) and cannot write, unplug the ST-LINK once and repeat steps (6) through (8). If you still get an Error message, you will have to solder the pads.