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:[email protected]: 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.

Upgrading target on COM5 with DFU package C:\Users\ONLILO~1\AppData\Local\Temp\arduino_build_284381\mic_modify.ino.zip. Flow control is disabled, Single bank, Touch disabled
Timed out waiting for acknowledgement from device.

Failed to upgrade target. Error is: No data received on serial port. Not able to proceed.
Traceback (most recent call last):
File “nordicsemi_main_.py”, line 294, in serial
File “nordicsemi\dfu\dfu.py”, line 235, in dfu_send_images
File “nordicsemi\dfu\dfu.py”, line 200, in _dfu_send_image
File “nordicsemi\dfu\dfu_transport_serial.py”, line 179, in send_start_dfu
File “nordicsemi\dfu\dfu_transport_serial.py”, line 243, in send_packet
File “nordicsemi\dfu\dfu_transport_serial.py”, line 282, in get_ack_nr
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, is there a way to prevent the board from entering DFU mode on reset? The reason why i am looking for this options is because I am trying to create a energy-harvested sensor and I see after the board is woken up (by external interrupt) from system off there is a period of 500ms when the current consumption stays high (5mA nearly). My guess is that this is the DFU bootloader. Thank you :slight_smile:

Hi there,
and Welcome here.
That`s not normal operation, Check that you do NOT have any of the strapping pins connected or in a wrong state when it resets. Take a look at the threads by msfujino for the 411 on power consumption and Sleep modes, BSP that support the least draw as well.

HTH
GL :slight_smile: PJ
:v:

Thanks @PJ_Glasso . I have created a new topic for this. I am not really sure if it is indeed the DFU bootloader that is causing the long startup time. Cheers!