How to unbrick a dead XIAO using ST-LINK and OpenOCD

Hi pata,

Does “after programming the XIAO” mean the bootloader flash? Or a sketch upload?

Does “the orange LED flashes” mean that the LED slowly brightens and slowly darkens? Or ON / OFF?

Does “the computer doesn’t recognize the board” mean that XIAO does not appear in Device Manager?

Hello and thanks for the quick reply :slight_smile:

  1. I haven’t really gotten to upload a sketch. I only tried flashing the bootloader with both “program … verify” (from this guide) and “flash write_image …” (from How to unbrick a dead xiao using raspberry pi [ GUIDE ][openocd]).
  2. The orange LED doesn’t turn completely off, as in a blink sketch. It brightens and darkens but it’s not as slow as when entering bootloader mode with the other XIAO I have. Actually it’s much quicker (maybe OSC malfunction?).
  3. The XIAO doesn’t appear in Device Manager.

When you flash the bootloader with ST-LINK, do you get the following message?
** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **

Could you show me your screenshot?

Yes, apparently the programming is ok.

EDIT (since max replies reached):
I tried to “unbrick” the XIAO because none of my machines would recognize it anymore (as in not seen by Device Manager or lsusb).
It’s hard to say what sketch was uploaded before because I’ve been trying to unbrick it for a while now. But I believe that sketch shouldn’t be there anymore since I used command “at91samd chip-erase” a couple of times before (after that the orange LED is off).

Why did you have to flush the bootloader in the first place?
Does the last uploaded sketch have code to make the orange LED bright / dark?

Worked like charm!!!
Thank you so much. I recovered a Xiao (stoped working after a few days transmitting LoRaWan to ThethingsNetwork on battery- brown out??). But most of all it was pure joy when I saw the Xiao port again.

Thank you!

Hi, Pedotech
I’m glad I could help you.
You may also find the following link useful.

Hi I’ve followed everything so far and am now getting this error.

I can’t say for sure because our PC environment are different, but it sounds like there is a problem with the USB driver.
I suggest you look into the USB driver “Zadig”.

Thank you it worked!


Can someone help me ?

Hi PANOK,
I think the situation is exactly the same as post #32. It sounds like there is a problem with the USB driver. I suggest you look into the USB driver “Zadig”.

@msfujino Would you be able to give me a quick hand?

I’m getting the error:

I ended up soldering the cables directly to the pads and using a multimeter I ensured there is connection between the ST-link V2 and the microcontroller. I also swapped SWDIO with SWCLK just in case I got it wrong the first time around but still no luck.
I’m 100% sure the wiring is correct, I checked it a bunch of times and also rewired it from scratch a few times.

I was looking around and found this article (Programming RP2040 with ST-LINK - Electrical Engineering Stack Exchange) that explains how the ST-LINK V2 can’t connect to the Seeed XIAO RP2040. Someone said to do the update however I have no idea what that guide is talking about. I updated it to the latest version (V2.J37.S7) using the “STM32 ST-link” software.
Did you have to do some weird update or did it just work?
Am I missing something?
Any Idea on how I can fix it?

Thank you,
Andrea

Hi Andrea_Nizzola,
If you have an unbricked XIAO_SAMD21, the method in the link below is very easy.

How to unbrick a dead XIAO using a XIAO(DAPLink) and OpenOCD

Hi Andrea_Nizzola,
I have made a RescueTool for ST-Link.
Unzip the file to a suitabule location and rewrite xxxxxxxx to yours in two places in “flash.bat”.
Double-click “flash.bat” to write the bootloader.
XIAO_BootloaderRescueTool_STLink.zip (10.5 KB)

Andrea_Nizzola,

@msfujino Would you be able to give me a quick hand?

Since you seemed to be in a hurry to resolve the issue, I posted two solutions.
What were the results?

Greetings, if you are still monitoring this feed, would you be so kind as to explain the following? You write

  1. Download the bootloader file bootloader-XIAO_m0-v3.7.0-33-g90ff611-dirty.bin to C:/XIAO_bootloader.

But where do I find the file I am to download? You told me where to place it but I cannot find it. Would you please tell me what the source is? I am certain the information is in your article but it is rather lengthy and I am somewhat dyslexic.

Many Thanks - Baran

The bootloader should be in the following holder
“C:\Users\XXXXXXX\AppData\Local\Arduino15\packages\Seeeduino\hardware\samd\1.8.4\bootloaders\XIAOM0”

If you have more than one SAMD21, it is very easy to use DAPLink from the link below. It also includes the bootloader files.
How to unbrick a dead XIAO using a XIAO(DAPLink) and OpenOCD

Also, if you use ST-Link, post #39 at the following link has everything you need.
How to unbrick a dead XIAO using ST-LINK and OpenOCD - #40 by msfujino

Make sure your USB cable is a data cable and not just a charging cable
Also try switching cables

I’ve used this guide a couple of times, and provided that the MCU isn’t damaged, it works just the way you’d expect. (Sometimes it takes more than one try.)

Here’s a small improvement. At least in current versions of OpenOCD, the at91samdXX.cfg file allows you to override CPUTAPID directly from your config file. So, instead of modifying the at91samdXX.cfg file and changing XIAO_openocd.cfg to load the modified file, you can insert a line just before, like so:

...
set CPUTAPID 0x0bc11477
source [find target/at91samdXX.cfg]
...

This change allows you to use a stock OpenOCD package, regardless of how you’ve installed it.