Possible Reset Boot Loader Problem?

First let me say XIAO is a nice product.

However from within the Arduino IDE, I uploaded some code which directly modifies some TCC0 control registers and interrupt ISR (as defined within Microchip’s TCC0.h component header file, as also seemingly used by Seeed’s TimerTCC0 XIAO driver); I can no longer access the device via its USB interface even after reseting the device by tapping the reset pin quickly twice; which results in the yellow led adjacent to the green power led, pulsing softly at about 4 hertz, but never blinking slowing as it should if the boot loader has successfully brought up its USB host interface port; as if it’s trying to reset, but the default boot loader keeps being interrupted by something?

I suspect my code corrupted some system state which the boot-loader relies upon, but which should not happen if the boot-loader only executes after the system was fully hw-reset, and only executes user partition code if not receiving a second reset-pulse within some period of time?

So as it stands now, the device is useless, which begins executing my corrupt code before it locks up, and apparently can’'t be successfully reset to execute the boot-loader resulting in a functional USB interface to the host Arduino IDE?

Any suggestions would be appreciated.

(Please also consider improving the robustness of the boot-loader, as it should always work, regardless of what state is possibly corrupted by user-code, to help prevent this in the future.)


I was attempting to configure TCC0 as a 24bit 1MHz wrap-around counter which would generate an interrupt upon matching a value in its compare register (while the counter continues to count). Which the TimerTCC0 driver appears not to currently support. So also please consider updating this or another driver to enable this, or please suggest a possibly different approach I should consider.

2 Likes

Hi @pws

Here is the bootloader for XIAO: https://github.com/Seeed-Studio/ArduinoCore-samd/blob/master/bootloaders/XIAOM0/bootloader-XIAO_m0-v3.7.0-33-g90ff611-dirty.bin, you can use jlink to flash.

Please also refer to here: https://wiki.seeedstudio.com/Software-SWD/

@ansonhe97

Thank you. I just placed an order for a “J-Link EDU mini” to interface via SWD.

1 Like

I’m stuck with this same problem; any more info on how to flash a new bootloader? I’m not quite understanding how to pull that off.

1 Like

The J-Link EDU mini can be had for < $20 for non-commercial use, and can be used to re-flash the boot-loader if necessary; you’ll need to either solder wires to the SWD pads on back of the XAIO, or construct some sort of a jig; but I’d try rebooting your host computer first, as it appears sometimes the host’s USB Driver Deamon gets confused, and won’t properly recognize the XIAO’s serial port from time to time (at least on my Mac).

I’ve seen a few places mention using a Raspberry Pi as a SWD programmer, might give that a shot. Once that’s setup how do you actually flash the firmware?

I already tried multiple computers, pretty sure it’s the XIAO. The reset pins don’t do anything on either machine.

I already managed to fry my first XIAO, hoping the second one isn’t also.

Sorry I don’t know about use of the Raspberry Pi as an SWD programmer, but Segger offers free basic SW for use with their J-Link product, capable of re-flashing the XIAO boot-loader. Maybe some one else can answer your question.

Oh no that’s actually helpful thank you. I was thinking there was going to be some standard
SWD commands or something I’d need to learn. Looks like this OpenOCD library for Raspberry Pi can do it. I’ll just need to learn how OpenOCD does the flashing process.

Hi, Is the bootloader code publicly available?

Also, can i upload a different bootloader? like optiboot?

our bootloader is open source. Just checked out optiboot, and it seems only support AVR chips?

hey, thanks to you i came across openocd and was able to repair my xiao bootloader - here is how

1 Like

Hi, I was able to repair the bootloader using the cheap Chinese ST-LINK V2 and OpenOCD for Windows.

@msfujino Yes, Of course.

I’m trying to repair my 3 XIAO’s. Something about the way I use them and my Wio lite MG126 has causede me to be unable to program any of them. I’ve been through

  • resetting the devices
  • re-connecting the devices
  • rebooting my PC
  • resetting the products twice quickly
  • uninstalling the devices from device manager
  • deleting the usb controller
  • removing the registry entries associated with VID/PID

and I still can’t upload to them.

Now I’m trying Black Magic Probe (Jeff Probe BMP Clone). I’ve soldered connections to Reset, SWCLK and SWDIO and have connected to them to the appropriate pins on the included JTAG ribbon cable. I performed a continuity check on them and am positive the pins are correct. I’m definitely connecting power to the BMP as well as powering the XIAO/Wio using external pwoer. I also connected the UART interface to the appropriate TX/RX pins using a grove connector.

The problem is that I’m stupid and don’t know

  • WHERE to find the “bootloader” source file that needs to get uploaded
  • HOW to send it.
  • I actually don’t even know WHAT the “bootloader” does.
  • I thought that resetting twice quickly puts the device into bootloader mode but I actually have no idea what that is or why it would be used.

There are so many programming devices, protocols, toolchains, firmware, flags, and enough documentation to have sent me down rabbit holes for over a month now.

I don’t care what method I use but I need to find A method of programming the bootloader(?)
In Arduino IDE I don’t know what to do to program the target.

I followed the VSCode/PlatformIO instructions and it does communicate through CLI so I see the target system and upload port but it hangs when it’s sending firmware.bin.

Programming using SWD in Atmel studio with a Blackmagic Probe is a total mystery.

Things like baud rates, GDB commands, bootloader file location, would be good to see as a how to.

I understand that this probably isn’t a Seeedstudio manufacturing issue but I was hoping to leverage any debugger/uploading experience anyone has.

I’ve asked for some direction on many different forums. It just so happens that the problems people are having on this forum are exactly like mine.

Would you be so kind as to show how you did it? I have two of these bricked (one by trying the Raspberrypi method). Would like to know how to do it with the stlink. I have stlink v2 and stlink v3.

Thanks

Hi, tannenba
Please refer to my post below.

Thank you, I did and unbricked the good one…other is dead :frowning: This is much easier than trying with the Pi.

1 Like

How to use the jlink edu to flash it. I’ve tried and got nowhere. Which jlink flasher to use?
Thank you

Hi @tannenba ,

Please follow the link below and go into Debugging section to learn how to use Segger J-Link EDU with the Seeeduino XIAO.

Please check this forum topic as well if you find any further problems.

Regards,
Lakshantha

Thanks, will try when I get time.

1 Like