PlatformIO IDE integration for the nRF52840 Feather Express with S340

(This is a repost from my personal wiki-page)

Note. this page is building on the assumption that the reader has read content in the posts


Platform IO is a “new generation toolset for embedded C/C++ development” built on Microsoft’s Visual Studio Code. It can be used as an alternative IDE for “Arduino related work”.

It has a limited support for .ino files, as those have to be manually converted to normal C++ source files for full support.

This document is about enabling embedded C/C++ development for ANT+ protocols within PlatformIO. It describes how to add S340 SD support within Platform Io to the Adafruit nRF52 Core for the Arduino nRF52840 Express Feather.


This work is based on rtgree01‘s PlatformIO adaptation. See also the Credits section with the page S340 SoftDevice & Adafruit nRF52840 Express Feather


  1. Compile and build the modified bootloader as per S340 SoftDevice & Adafruit nRF52840 Express Feather

Adding S340 support to Plaform IO

  1. Download and install Platform IO IDE for VSCode as per the instructions.
    1. Ensure that you can program your Feather with Platform IO by, say, compiling and loading the classic Blinky example into the Feather. See for further details
  2. After the first succesful compilation and upload, all the necessary packages has got installed. Go to the location of the “framework package” (this corresponds to the concept of “Core” in the Arduino IDE):
    • On Linux: ~/.platformio/packages/framework-arduinoadafruitnrf52/
    • On Windows: %HOMEDIR%\.platformio\packages\framework-arduinoadafruitnrf52\
  3. So, go to …/.platformio/packages/framework-arduinoadafruitnrf52/bootloader/feather_nrf52840_express/. Copy the bootloader .zip ( and .hex (0.3.0_s340_6.1.1.hex) from the build directory of the freshly modified bootloader package here.
  4. Go to …/.platformio/packages/framework-arduinoadafruitnrf52/. Modify boards.txt just like I did for the Arduino IDE. See sub-step “1” within the section Second major step: replace the bootloader with the modified bootloader at the Arduino IDE adaptation page:

    # ----------------------------------
    # Bluefruit Feather nRF52840 Express s340
    # ---------------------------------- Bluefruit Feather nRF52840 Express w.ANT
    # VID/PID for bootloader with/without UF2, Arduino + Circuitpython App
    # Upload
    #TODO: fix sizes above
    # Build"Adafruit LLC""Feather nRF52840 Express" {build.flags.usb}
    # SofDevice Menu SoftDevice s340 6.1.1
    # Debug Menu 0 (Release) 1 (Error Message) 2 (Full Debug) 3 (Segger SystemView)
  5. Go to …/.platformio/platforms/nordicnrf52/boards/. Copy adafruit_feather_nrf52840.json and name the copy as adafruit_feather_nrf52840_s340.json. Change the following entries:

        "ldscript": "nrf52840_s340_v6.ld",
        "softdevice": {
              "sd_flags": "-DS340",
              "sd_name": "s340",
              "sd_version": "6.1.1",
              "sd_fwid": "0x00B9"
        "name": "Adafruit Feather nRF52840 Express S340",
  6. Go to …/.platformio/packages/framework-arduinoadafruitnrf52/cores/nRF5/linker. Copy/duplicate the S140 linker script as nrf52840_s140_v6.ld. Modify the linker script memory settings just like I did for the Arduino IDE. See sub-step “2” within the section Second major step: replace the bootloader with the modified bootloader at the Arduino IDE adaptation page. Modify the FLASH and RAM settings:

      FLASH (rx)     : ORIGIN = 0x31000, LENGTH = 0xF4000 - 0x31000
        RAM (rwx) :  ORIGIN = 0x20006000, LENGTH = 0x20040000 - 0x20006000
  7. Modify …/.platformio/packages/framework-arduinoadafruitnrf52/platform.txt file because the Adafruit bootloader is now 0.3.0:

        # Bootloader version
        # tools.bootburn.bootloader.file={runtime.platform.path}/bootloader/{build.variant}/{build.variant}_bootloader-0.2.13_{build.sd_name}_{build.sd_version}
  8. Add the S340 API headers to …/.platformio/packages/framework-arduinoadafruitnrf52/cores/nRF5/nordic/softdevice/.
    1. Make s340_nrf52_6.1.1_API and the corresponding dir tree below it: Copy the include subdirectory of the S340 SoftDevice under this s340_nrf52_6.1.1_API subdirectory:

       └── include
           ├── ant_error.h
           ├── ant_interface.h
           ├── ant_parameters.h
           ├── ble.h
           ├── ble_err.h
           ├── ble_gap.h
           ├── ble_gatt.h
           ├── ble_gattc.h
           ├── ble_gatts.h
           ├── ble_hci.h
           ├── ble_l2cap.h
           ├── ble_ranges.h
           ├── ble_types.h
           ├── nrf52
           │   └── nrf_mbr.h
           ├── nrf_error.h
           ├── nrf_error_sdm.h
           ├── nrf_error_soc.h
           ├── nrf_nvic.h
           ├── nrf_sd_def.h
           ├── nrf_sdm.h
           ├── nrf_soc.h
           └── nrf_svc.h
  9. Go to bootloader/feather_nrf52840_express. You will find and feather_nrf52840_express_bootloader-0.3.0_s140_6.1.1.hex here. Now copy the corresponding files or s340 as feather_nrf52840_express_bootloader-0.3.0_s340_6.1.1.hex and from where you have built the modified bootloader with S340 (see page S340 SoftDevice & Adafruit nRF52840 Express Feather about how to build it). That is, the directory bootloader/feather_nrf52840_express should look like this

           ├── feather_nrf52840_express_bootloader-0.2.1_s140_6.1.1.hex
           ├── feather_nrf52840_express_bootloader-0.3.0_s340_6.1.1.hex

Now you should be ready to rock. Restart PlatformIO IDE and select Adafruit Bluefruit Feather nRF52840 Express S340 as your board type 🙂


Kategória: Uncategorized | Közvetlen link a könyvjelzőhöz.

Vélemény, hozzászólás?

Adatok megadása vagy bejelentkezés valamelyik ikonnal: Logo

Hozzászólhat a felhasználói fiók használatával. Kilépés /  Módosítás )

Facebook kép

Hozzászólhat a Facebook felhasználói fiók használatával. Kilépés /  Módosítás )

Kapcsolódás: %s