XIAO BLE flash method?

Hi there! I’m working on expanding TinyGo’s support to the XIAO BLE board (it currently already supports the SAMD board, and it’s a lot of fun). I’m getting stuck on a couple configuration options, and was wondering if anyone had some idea of what I should be looking for for them. The options for these as provided for the SAMD board isn’t working as I’ve outlined below:

  • flash method (the SAMD version uses msd, but some other nRF52840 boards use openocd. I also was unable to find reference to msd in either the arduino libraries for nrf nor samd xiao boards, making this even more confusing for me)
  • (if flash is msd) the msd volume name (the samd board uses “Arduino”)
  • (if flash is msd) the msd firmware name (the samd board uses “firmware.uf2”)
  • (if openocd) the openocd interface (some other nrf boards use “cmsis-dap”)

The rest of the configuration options I’m pretty sure I found equivalents in the arduino library, but those three above are kinda sticking for me. I’ve also tried downloading/using the nrfjprog cli and nrf connect from nordic, but I’m not exactly sure how to use either of those, I’m kind of new to microcontroller flashing. nrf connect recognizes that the board is connected, but when opening it up in the programmer is says: “Unsupported device. The detected device could not be recognized as neither JLink device nor Nordic USB device.”

If anyone has it, I could alternatively use a link to the CircuitPython library that provides support for the XIAO and XIAO BLE, i can try and glean info out of those like i did for the arduino libraries. I haven’t been able to track that down online yet.

Any direction on this would be super helpful. I’ve really been enjoying using golang to structure my iot applications, and would really love to expand functionality to this new and fun upgrade to the XIAO boards.

Hello therebelrobot,

I am pretty confident that the msd method will work with the XIAO BLE.

When pressing the (tiny) reset button on the board twice with the board connected to a computer, the flash partition shows up on the computer as USB storage with the name “XIAO-SENSE” (used to be “Arduino” for SAMD boards, as you mention).
See the documentation for flashing with CircuitPython firmware.

My guess is that the firmware file name does not matter so much, and any *.uf2 file would then be accepted.

Good luck with your experiments.

1 Like

Unfortunately, no joy on “XIAO-SENSE” as the msd volume. Similarly, when I boot the xiao sense into bootloader mode, I do see a volume by that name show up and can indeed flash to it, but the code doesn’t seem to get run, and anytime reset is triggered, it reverts to the old arduino code. When not in bootloader mode, it can’t find that volume at all.

In the CircuitPython documentation, it loads a custom uf2 bootloader into XIAO-SENSE and then it reloads as a new volume, CIRCUITPY or something similar, and it’s that volume that’s used to load the python code. I’m suspecting I need either a generic xiao-sense bootloader (i tried using the hex file from the arduino library to no avail) or a bootloader specific to tinygo, which seems a lot more unlikely to find.

Oh that’s unlucky.

I am not so sure about the need to change the bootloader. I am not familiar with TinyGo, but looking at the documentation for the legacy XIAO board it seems that TinyGo programs work well with the UF2 bootloader that is also present on the XIAO BLE.

Can it be that the binary that you are uploading to the XIAO BLE is rejected because it is not compatible with the board? (e.g. not targeting the right controller?)

Yeah, I’ve been using those docs as well as the tinygo source code to try and port it over. I’ve been compiling the code for the nRF52840, which is what I though was running on the new hardware, and which tinygo has done for other boards with that chip. My next thought is to find a way to manually flash a hex program directly onto the board using something like nrfutil, but i haven’t had much luck with that yet, though it does seem to be doing more on the board (it halts the previous program when flashing now). I’m not as familiar with python, so using that utility / parsing its errors are a bit more tricky, but I feel like it’s going to be a more solid solution in the long run.

I also sent off an email to the xiao dev team to see if they have any suggestions on the manual flash method.

I hope my answers are not too naive, as I am quite new to this platform.
Looking at the UF2 format, other UF2 flashing parameters that are platform dependent are:

  • the address where the data should be written
  • board family ID

Do you also have that covered already, or is that something to further investigate?

Hello, from your description, this method of copying the uf2 file to the XIAO BLE through the bootloader mode can flash the firmware. Of course, it can also be burned into XIAO BLE through hex or bin file.