Seeed Xiao BLE nRF52840 - upload problem

Hi,
just got my board today, and having no experience with such projects I decided to follow the instructions. I’m stuck at blinking LED example: clicking Upload on this sketch (or a blank sketch) in Arduino IDE results in following errors:

Sketch uses 40080 bytes (4%) of program storage space. Maximum is 811008 bytes.
Global variables use 6964 bytes (2%) of dynamic memory, leaving 230604 bytes for local variables. Maximum is 237568 bytes.
Performing 1200-bps touch reset on serial port COM7
Waiting for upload port...
No upload port found, using address:"COM7" label:"COM7" protocol:"serial" protocol_label:"Serial Port (USB)" properties:{key:"pid" value:"0x0045"} properties:{key:"serialNumber" value:"4AB3A892676847FD"} properties:{key:"vid" value:"0x2886"} as fallback
"C:\Users\tybin\AppData\Local\Arduino15\packages\Seeeduino\hardware\mbed\1.0.0/tools/adafruit-nrfutil/win32/adafruit-nrfutil.exe" --verbose dfu serial -pkg "C:\Users\tybin\AppData\Local\Temp\arduino-sketch-19D390B8B67D895B7298D13DCC878327/Blink.ino.zip" -p COM7 -b 115200 --singlebank
Upgrading target on COM7 with DFU package C:\Users\tybin\AppData\Local\Temp\arduino-sketch-19D390B8B67D895B7298D13DCC878327\Blink.ino.zip. Flow control is disabled, Single bank, Touch disabled
Opened serial port COM7
Starting DFU upgrade of type 4, SoftDevice size: 0, bootloader size: 0, application size: 40088
Sending DFU start packet
Sending DFU init packet
Sending firmware file

Failed to upgrade target. Error is: WriteFile failed (PermissionError(13, 'Urz�dzenie nie rozpoznaje polecenia.', None, 22))
Traceback (most recent call last):
  File "__main__.py", line 296, in serial
  File "dfu\dfu.py", line 235, in dfu_send_images
  File "dfu\dfu.py", line 206, in _dfu_send_image
  File "dfu\dfu_transport_serial.py", line 213, in send_firmware
  File "dfu\dfu_transport_serial.py", line 241, in send_packet
  File "serial\serialwin32.py", line 317, in write
serial.serialutil.SerialException: WriteFile failed (PermissionError(13, 'Urz�dzenie nie rozpoznaje polecenia.', None, 22))

Last line is polish Windows error, it translates to “Device does not recognize the command”.

Cable is data-enabled, board resets on pressing “Reset” button (Windows redetects it with audible sound and a pop-up), I have tried both available boards (mbed and not-mbed) in all possible combinations (with version 2.6.1 of mbed). Installing version 2.8.1 of mbed variant gives:

Error: 13 INTERNAL: Cannot install platform: installing platform Seeeduino:mbed@2.8.1: searching package root dir: no unique root dir in archive (...path)

I’ve tried launching Arduino IDE as admin and whitelisted it in Windows Defender.

Arduino IDE seems to detect the board - COM7 is labeled with product name, “Board info” returns product name and 2 codes.

The problem doesn’t seem to be Windows-specific as it also fails on Ubuntu 22.04, with COM-related problems.

Is the board bricked? Or is it something with Windows USB stack? Does the board package version matter, and if so, how to get around that error?

EDIT: I’ve tried different cables, ports, computers, reinstalling Arduino IDE, all to no avail.

Welcome tybin,
You should be able to reset it fast (Twice) a drive should appear then, you are in DFU upload mode.
May take a few tries, I usually push the reset and hold it until I hear the windows device sound. Then I double tap it fast. Works every time. Also once I upload some code it seams the next few times I DON’T have to put it in DFU mode ??? IT! just uploads
I also used the 3d printed reset helmet big Button I made. it’s posted here.

HTH
GL :-p

Thanks @PJ_Glasso, I’ve tried your advice but it didn’t seem to work. This thread, specifically the step with deleting AppData folder containing cached preferences helped me get past the errors, then the trick with adding default upload tool in boards.txt worked.

Arduino IDE reports successful uploads every time now, but after the upload Windows stops seeing the board and the LED doesn’t blink. Clicking reset button once makes the board visible again. I’m using following sketch:

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000);
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
}

Should I be able to run this program with USB as power source?

EDIT: I’m using mbed version of the board - choosing either sense or not sense didn’t make a difference (I have non-sense one).

Yes, I have edited the boards file and added that default upload tool. edit, Prior too that I would get the occasional Upload “undefined nag”.
I also removed any ghost serial ports in Device manager and rebooted. It works SOLID now.
Either versions of the IDE 1.8 or 2.0X , wish the Xiao ESP32c3 worked this well.
Nrf52840 BLE Sense versions work Great for me.
Yes, one caveat is Most power banks will turn off if the device doesn’t draw enough current so be advised. I have a video on here of that as well.
Works once powered but Power bank powers off after a few seconds.
connected a low battery to it and it stayed on and charged the Batt
HTH
GL :slight_smile:

I’ve managed to blink the LED using CircuitPython - it worked the first time. The board turns out to be fine, I guess there is still something wrong with my Arduino IDE.

CircuitPython solution requires no external power aside from the USB connection used to download data.

Will report back if I manage to get it working with Arduino IDE.

Out of curiosity, I reverted my board back to original firmware and I saw blinking LEDs using sketch posted before.

I have no idea what changed, I haven’t touched the Arduino IDE or firmware in 2 days. I uploaded CiruitPython firmware, then after some time double-tapped the Reset button, fired up Arduino IDE and boom, it works. Too bad I can’t really share any solid advice on what to do in this case, it literally started working on its own.