Using Nordic nRF52840 Dongle under Arduino framework with PlatformIO VSCode

After stranded around, eventually found the solution to compile and upload sketch to Nordic nRF52840 Dongle under PlatformIO and functioning correctly. I decided to put some explanation here so can help you to facilitate the learning process.

Adding nRF52840 Dongle (PCA10059) to PlatformIO:

  1. First, you have to update the bootloader of Nordic nRF52840 Dongle with Adafruit Feather 52840 bootloader using either Arduino IDE or PlatformIO with J-Link EDU ( DON’T USE CLONE J-LINK, IT WON’T WORK ) as shown below.

image

The SWD interface is at the back of the Dongle, check up my comments at Nordic Forum.

  1. After new bootloader is updated, the serial port COMx will be detected by Windows, you can use it to upload sketch later.

  2. Under PlatformIO, create a project using Adafruit_feather_nrf52840 board.

  3. Edit the platformio.ini, add or changed the red highlighted text below:

         [env:adafruit_feather_nrf52840]
         platform = nordicnrf52@5.0.1
         board = pca10059
         framework = arduino
         ;upload_protocol = jlink
         ;debug_tool = jlink
         upload_port = COM15
         upload_speed = 115200
         platform_packages =
             framework-arduinoadafruitnrf52@https://github.com/jpconstantineau/Community_nRF52_Arduino.git#0.1.21
         lib_deps = 
             SPI
             rweather/Crypto@^0.2.0
             adafruit/Adafruit MLX90614 Library@^2.1.3
             adafruit/Adafruit BusIO@^1.9.8
    
  4. Go to https://github.com/maxgerhardt/pio-community-nrf52-example/find/main to download the file “pca10059.json”.

  5. Copy the file “pca10059.json” into “C:.platformio\platforms\nordicnrf52@5.0.1\boards”.
    ( NOTE: The folder “**C:.platformio**” may be under “C:\Users.….platformio” at your PC )

  6. Compile and upload sketch to the Dongle.

  7. DONE

Special thanks to Mr. Maximilian Gerhardt for his guidance.

Hopes, this help.

1 Like

This question is exactly what I wanted to ask. Thanks for the notes. However, I’m not sure how to update the bootloader. Did you mean just connecting the dongle with the J-link? In that case, I don’t have a J-link EDU.

hi,

You have to use the genuine Segger J-Link ( Hardware version 11 ) from the link below to burn the bootloader, the FDTI USB is to burn application ( flash ).

Segger J-Link EDU ( for none commercial ) and J-Link Base ( for commercial ) were the same features, just the usage is different.

Segger J-Link ( Hardware version 11 )

The clone J-Link in the market will not work.

After you have the Segger J-Link hardware programmer, you will find the options to burn your bootloader under the PlatformIO.

The world is shortage of raw materials, aside paying for high price to get the Segger J-Link hardware, common sellers like Digikey, Element14 or even from Octopart, I cannot find one available and no new stock date as well.

1 Like

Segger Edu Mini (US$18) also works fine but make sure it is a genuine Segger J-Link probe.

1 Like

I’m currently using the nrf52840 DK board connected to the dongle via SWD interface to burn the bootloader. The link you posted was for burning bootloader on an adafruit board. Is that exactly the same procedure for burning bootloader on the dongle ( PCA10059)?

For the dongle, are these settings correct?

hi,

The one at Adafruit forum is for nRF52832 only because Mr. Maximilian Gerhardt who created the Arduino wrapper header for Nordic nRF52840 or PCA10059 that time, only works under PlatformIO which automatically downloading the corresponding and latest bootloader (based on Adafruit bootloader) for PCA10059. You need the wrapper header to compile so the GPIO pins work correctly.

By the time you reading this, hopefully the latest Arduino IDE covers the Nordic nRF52840 dongle.

I have moved my embedded development to PlatformIO and I still love the Arduino IDE, either old or new version as I also started from there. For stable, easy maintenance and deployment, I have chosen PlatformIO.

1 Like

@rickygai After the adafruit bootloader is burnt on the dongle, does it still flash red LED in bootloader mode?

Hi, when I try to compile I got error about “tusb_compiler.h: No such file or directory”
anyone can help?

Nevermind, just got it to work. now i have blink running. thanks.

I am very new to embedded development and just spent a night and a day figuring out how to use the Nordic nRF52840 Dongle under the Arduino framework with PlatformIO. I don’t have JLink or anything similar and finally succeeded in programming the device with the default bootloader over just a USB connection.

Everything described in this post was the situation on 11/15/2025. Keep in mind that versions may change over time, and the instructions in this post may eventually be obsoleted as software changes.

The process I ended up with is very similar to the one described at nrf52 - Programming NRF52840 dongle from PlatformIO - Stack Overflow. That might be enough to get everything working. If not, I elaborate on some of the problems I ran into below. I spent hours looking for help on the internet late into the night and didn’t find the Stack Overflow post previously linked until after I solved my problem. I want to make sure all the details are documented here so that others may be able to get out of a place of confusion.

Nordic Semiconductor claims in the datasheet for the dongle that you can use nrfutil to program it. In getting that to work, there were two major hurdles to overcome. First, I wasn’t able to coax the nrfutil program that Nordic Semiconductor links to in their datasheet into uploading application firmware without specifying a SoftDevice version requirement for it. The solution was to download the SoftDevice firmware version of my choice from Nordic Semiconductor and use the Programmer tool that can be installed from nRFConnect to write the SoftDevice firmware to the device. I haven’t yet found a way to do this with nrfutil, although my experience troubleshooting this suggests that it may be possible, just not clearly documented. I’d be happy to hear if someone knows how to do it.

In my troubleshooting, I found the nrfutil device fw-info command helpful, as well as the list of firmware IDs in the nrfutil nrf5sdk-tools pkg generate --help output. And that leads into the second problem.

There are three different nrfutil versions that I found so far. There is a Python package maintained by Nordic, a separate, newer implementation maintained by Nordic (this is the one they link to from the datasheet), and an adafruit-nrfutil Python module, which seems to be the one that PlatformIO uses by default if you specify “nrfutil” as the upload method in your platformio.ini.

At the time I write this comment, Nordic’s nrfutil Python module does not have a version compatible with the version requirements of the Click module that PlatformIO and nrfutil both depend on. I was not able to get past compilation with Nordic’s nrfutil Python module installed in the same environment as PlatformIO.

The adafruit-nrfutil module puts a dfu_version: 0.5 in the manifest.json which is packaged in the zipfile that nrfutil needs to upload to the device. Upon uploading, the bootloader will reject the upload because the version is too old. When I manually took that line out of manifest.json and rezipped the archive, adafruit-nrfutil got far enough to complain that my SoftDevice version was incompatible. That was before I solved my SoftDevice problem, and I haven’t tested that approach since solving that. I do not know whether it may be possible to work around the issue with the adafruit-nrfutil.

The trick I found was to use the nrfutil binary linked to from the datasheet. It knows how to talk to the Open Bootloader with the right version. But a lot of the commands changed. A lot of instructions you can find the internet are for the Nordic Python module mentioned above, and do not work with their new implementation. These are the commands to package a .hex file for the nRF52840 Dongle and upload it with the Open Bootloader DFU, using Nordic Semiconductor’s modern nrfutil:

nrfutil nrf5sdk-tools pkg generate --application firmware.hex --hw-version 52 --sd-req 0x123 --application-version-string “0.1.0” firmware.zip
nrfutil device program --traits nordicDfu --firmware firmware.zip

Note that I used–-sd-req 0x123 because 0x123 is the firmware ID for the SoftDevice version that I first uploaded with nrfConnect Programmer. As I described above, you can find the firmware ID for each version in the helppage for the pkg generate command. If you end up with a SoftDevice with version number 5001000 (which you can find from the fw-info command) then your device has the s140 5.0.0 alpha release of SoftDevice on it, which does not have a firmware ID. Therefore, it seems it may not be possible to upload for that SoftDevice version (there could be a workaround I did not find).

It should be possible to construct an uploading script with these commands for PlatformIO to use similar to the one shown at the Stack Overflow link above.