How does Arduino IDE reflash xiao nrf52840 without the boot mode?

I am trying to reflash the board using uf2 without entering the boot mode, as I don’t have access to the reset button, the MCU is in a case. I can reflash from Arduino IDE, but of course the xiao board does not show up as a volume on the system.

If Arduino IDE is able to reflash, I have a reason to think it’s also possible to reflash with uf2 without access to the reset button. Could someone point me to do more reading on how this works?

Hi there,
UF2 is a file format designed by Microsoft that stands for USB Flashing Format. This format was designed for PXT (also known as Microsoft MakeCode) and allows for programming boards over the Mass Storage Class (removable drive). The bootloader is also compatible with BOSSA which is what the Arduino IDE uses.
Look into the BOSSA spec to learn more.
The UF2 file is meant to drag and drop when already in BL mode.
The Flash tool interacts directly with the device, not through the Bootloader.
Just use the Nrf_connect for desktop and programmer to Flash the HEX version of the Uf2 file. Straight away.
Check out the thread for Uf2 files, to get some insight.
HTH
GL :slight_smile: PJ

just tried the connect programmer, it seems to require a dev kit to enable JLink, otherwise it gives “no operation possible” when trying to connect to a device. I am trying to figure out how to reflash without any devkit, no access to reset button, etc.

Arduino IDE seems to use nrfutil to flash the device, which is in /Users/x/.local/lib/python3.7/site-packages/nordicsemi/main.py:serial, but from the command line that results in the following. Do you have any ideas why Arduino IDE makes it work, but directly using nrfutil code does not?

raise NordicSemiException("No data received on serial port. Not able to proceed.")
nordicsemi.exceptions.NordicSemiException: No data received on serial port. Not able to proceed.

Possible causes:
- Selected Bootloader version does not match the one on Bluefruit device.
    Please upgrade the Bootloader or select correct version in Tools->Bootloader.
- Baud rate must be 115200, Flow control must be off.
- Target is not in DFU mode. Ground DFU pin and RESET and release both to enter DFU mode.

Hi there,
Yes, You are correct, To use programmer Device needs to be in BL mode.
Ok so, one thing I had work for me when the REST button took the Thumbnail Temperature Challenge and flew the coop. What I did was Hit the Upload button and it took several tries but I got it finally to go, by connecting the Xiao as the progress bar reached the end, Kind of Glitching it or catching the Reset to Upload. YMMV
HTH
GL :slight_smile: PJ

You have to get the timing down to get it to connect and upload. (as it resets) :v:

Ok, I figured it out. Apparently there is a way to send a reset signal (16 null characters, any idea why?) over Serial:

ser = serial.Serial('/dev/cu.usbmodem101', 1200)
ser.write(b'\x00' * 16)
ser.close()

And then I use adafruit-nrfutil dfu serial to reflash it with a binary.

1 Like

Hi there,
Yes, that is for the adafruit Bootloader, custom for there stuff , AFAIK.
might work with BSP 1.1.x but not with the mbed is what I’m thinking.

I like my tech better(easier) :smile: but requires finesse and patients… :face_with_hand_over_mouth: LOL
Glad you got it though , nice find.
GL :slight_smile: PJ :v:

I need to reflash it using UF2, but the reset button is inaccessible due to the board being enclosed in a protective case. Surprisingly, the Arduino IDE manages to reflash the board without needing direct access to the reset button. I’m curious if there’s a method or workaround with UF2 that allows reprogramming without physically pressing the reset button.

Hi there,
SO if you have access to the Serial Port you can use Nrf_for_Desktop and the programmer app requires a programmer to be present but worth a try , plug in and see if you can see it with the app (pulldown menu devices) , or you can from the command line too if you run the compile with verbose output Highlight the lines after the programming prompt and use that as the command line that works.
Like this:

FQBN: Seeeduino:nrf52:xiaonRF52840Sense
Using board 'xiaonRF52840Sense' from platform in folder: C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\nrf52\1.1.1
Using core 'nRF5' from platform in folder: C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\nrf52\1.1.1
_edit Brevity___
Sketch uses 54560 bytes (6%) of program storage space. Maximum is 811008 bytes.
Global variables use 8432 bytes (3%) of dynamic memory, leaving 229136 bytes for local variables. Maximum is 237568 bytes.
Performing 1200-bps touch reset on serial port COM15
Waiting for upload port...
Upload port found on COM14
"C:\Users\Dude\AppData\Local\Arduino15\packages\Seeeduino\hardware\nrf52\1.1.1/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe" --verbose dfu serial -pkg "C:\Users\Dude\AppData\Local\Temp\arduino\sketches\2EECA4313F66568E739964042897E1EB/OLED_Display.ino.zip" -p COM14 -b 115200 --singlebank
Upgrading target on COM14 with DFU package C:\Users\Dude\AppData\Local\Temp\arduino\sketches\2EECA4313F66568E739964042897E1EB\OLED_Display.ino.zip. Flow control is disabled, Single bank, Touch disabled
Opened serial port COM14
Starting DFU upgrade of type 4, SoftDevice size: 0, bootloader size: 0, application size: 54568
Sending DFU start packet
Sending DFU init packet
Sending firmware file
########################################
########################################
###########################
Activating new firmware

DFU upgrade took 3.8857779502868652s
Device programmed.

You see the Adafruit_nrfutil.exe and the switches it uses to send the DFU packet at 1200 baud
after the DFU reset from com15 to com14 BL mode.
HTH
GL :slight_smile: PJ
:v:

read up on DFU mode, how to do it with the DTR pin of the Serial port at 1200 baud