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.

1 Like

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/


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.

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.