Arduino IDE works but not PlatformIO w/VScode (On Arduino Nano 33 BLE Sense Rev2)

For the Arduino Nano 33 BLE Sense Rev2, whenever I upload my code on the the Arduino IDE, my COM3 port gets disconnected then COM4 (Bootloader) gets initialized, then once the code is finally uploaded, COM4 gets disconnected and COM3 gets reinitialized. So uploading code via Arduino IDE runs perfectly fine.

When I run it with VSCode with platformio, my COM3 port gets disconnected, then COM4 gets initialized, then I’m left with this error, and the upload fails:I will upload screenshots as well:

AVAILABLE: blackmagic, cmsis-dap, jlink, nrfjprog, nrfutil, sam-ba
CURRENT: upload_protocol = sam-ba
Looking for upload port...
Auto-detected: COM3
Forcing reset using 1200bps open/close on port COM3
Waiting for the new upload port...
Uploading .pio\build\nano33ble\firmware.bin
No device found on COM4
*** [upload] Error 1

PlatformIO

ArduinoIDE:

Sketch uses 85264 bytes (8%) of program storage space. Maximum is 983040 bytes.
Global variables use 44560 bytes (16%) of dynamic memory, leaving 217584 bytes for local variables. Maximum is 262144 bytes.
Performing 1200-bps touch reset on serial port COM3
Waiting for upload port...
Upload port found on COM4
"C:\Users\legon\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.9.1-arduino2/bossac.exe" -d --port=COM4 -U -i -e -w "C:\Users\legon\AppData\Local\arduino\sketches\6D89C5DC68A97A52A1F630A9116E18EA/sketch_feb18a.ino.bin" -R
Set binary mode
version()=Arduino Bootloader (SAM-BA extended) 2.0 [Arduino:IKXYZ]
Connected at 921600 baud
identifyChip()=nRF52840-QIAA
write(addr=0,size=0x34)
writeWord(addr=0x30,value=0x400)
writeWord(addr=0x20,value=0)
version()=Arduino Bootloader (SAM-BA extended) 2.0 [Arduino:IKXYZ]
Device       : nRF52840-QIAA
Version      : Arduino Bootloader (SAM-BA extended) 2.0 [Arduino:IKXYZ]
Address      : 0x0
Pages        : 256
Page Size    : 4096 bytes
Total Size   : 1024KB
Planes       : 1
Lock Regions : 0
Locked       : none
Security     : false
Erase flash
chipErase(addr=0)

Done in 0.001 seconds
Write 85272 bytes to flash (21 pages)
...
[==============================] 100% (21/21 pages)
Done in 3.544 seconds
reset()

I’ve tried a couple things such as
using a different port “upload_port = COM4/COM3”
reinstalling platformIO and VScode
changing the upload_protocol
This issue occurs with any project I try to upload my code to.
this is my platformio:

[env:nano33ble]
platform = nordicnrf52
board = nano33ble
framework = arduino

Weird, based on this report the Nano33BLE upload is working.

Try:

  • PIO Core CLIpio pkg update -g -p nordicnrf52 to update to the latest nRF52 platform version
  • Project Tasks → Advanced → Verbose Upload → Find the location of bossac.exe in the log → Go to that folder (should be somwhere in C:\Users\<user>\.platformio\packages\tool-bossac), copy over the C:\Users\legon\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.9.1-arduino2/bossac.exe file, replacling the old bossac

and retry uploading

I tried both of your methods and tried uploading a basic code to the Arduino and I still run into the same problem on VScode.

I think it has something to do with my computer(desktop) because I tested the same builds with a different computer(laptop) and it uploads to the board perfectly fine. I think it has to do with my computer’s file messing up with the COM port communications only on VScode PlatformIO. The laptop also uploaded the code to the board with all the default packages that my desktop was already using.


I reinstalled VScode and all my extensions once again, and still the same problem :frowning:

"Tool Manager: Installing platformio/tool-openocd @ ~3.1200.0
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: tool-openocd@3.1200.0 has been installed!
Tool Manager: Installing platformio/tool-bossac-nordicnrf52 @ ~1.10901.0
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: tool-bossac-nordicnrf52@1.10901.201022 has been installed!
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/nordicnrf52/nano33ble.html
PLATFORM: Nordic nRF52 (10.7.0) > Arduino Nano 33 BLE
HARDWARE: NRF52840 64MHz, 256KB RAM, 960KB Flash
DEBUG: Current (blackmagic) External (blackmagic, cmsis-dap, jlink)
PACKAGES:
 - framework-arduino-mbed @ 4.2.1
 - tool-bossac-nordicnrf52 @ 1.10901.201022 (1.9.1)
 - tool-openocd @ 3.1200.0 (12.0)
 - tool-sreccat @ 1.164.0 (1.64)
 - toolchain-gccarmnoneeabi @ 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 43 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio\build\nano33ble\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  16.2% (used 42472 bytes from 262144 bytes)
Flash: [=         ]   7.7% (used 75348 bytes from 983040 bytes)
Configuring upload protocol...
AVAILABLE: blackmagic, cmsis-dap, jlink, nrfjprog, nrfutil, sam-ba
CURRENT: upload_protocol = sam-ba
Looking for upload port...
Auto-detected: COM3
Forcing reset using 1200bps open/close on port COM3
Waiting for the new upload port...
Uploading .pio\build\nano33ble\firmware.bin
No device found on COM4
*** [upload] Error 1
=========================== [FAILED] Took 13.34 seconds ====================================================

So… I woke up today and turned on my computer to test it again, and I had this error come up

Then I tried uploading again, and it uploads

But for the third time, I tried uploading it… it ran into the same problem once again