Using nRF Connect for VSCode

Setup

  1. Install nRF Connect for VSCode

  2. Once the extension pack is installed. Install both the 2.7.0 Toolchain and the 2.7.0 SDK.

    You can use the nRF Connect : Manage Toolchains command to do this.

    Manage toolchains

    And the nRF Connect : Install SDK command to do this.

    Install SDK

  3. Then clone the nRF9160 Feather Examples and Drivers to a good location:

    git clone https://github.com/circuitdojo/nrf9160-feather-examples-and-drivers.git --branch v2.7.x
    

    Note: this will allow you to use the most up-to-date board definitions for the nRF9151 Feather.

  4. Then open the nrf9160-feather-examples-and-drivers folder in VSCode. nRF Connect for VSCode will automatically detect that this is a Zephyr Project.

    Open nRF9160 Feather Examples and Drivers

  5. Finally, click Manage west workspace and click Switch West Manifest Repository.

    Switch west manifest repository

    Note, if you already have this folder open and this option is greyed out, you should be good to go!

  6. Then select the west.yml in the directory you cloned the repository to:

    Select nfed

    Note: if you do not see the correct option, you can click Browse.. and navigate to the west.yml in the nfed folder.

Selecting SDK

In the case you already have a nRF Connect SDK installed, you will need to make sure you selected the correct SDK.

  1. Run nRF Connect: Install SDK command.

    Select nRF Connect: Install SDK command

  2. Then choose version 2.7.0:

    Choose version

  3. Then run the nRF Connect: Set Active SDK command:

    Select Set Active SDK command

    Note: be sure to select the SDK version you installed.

Building

  1. Click the Open Existing Application button and choose, for example, the nrf9160-feather-examples-and-drivers/samples/blinky folder.

    Open blinky sample

  2. Then click the Add Build Configuration button.

    Add build configuration

    Make sure you choose circuitdojo/nrf9151-feather/ns as the board.

    Additionally, change the build directory if you'd like. We recommend build/circuitdojo_feather_nrf9151.

    And finally, make sure that Use sysbuild is checked.

    Set build folder and use sysbuild

    Then click Build Configuration

  3. The app will build. You can view the build output in the tab to the right:

    Build output

    Once you get this output, you're good to go!

    [7/207] Generating include/generated/version.h
    -- Zephyr version: 3.6.99 (/home/jaredwolff/Git/nrf9160-feather-examples-and-driverszephyr), build: v3.6.99-ncs2
    [207/207] Linking C executable zephyr/zephyr.elf
    Memory region         Used Size  Region Size  %age Used
            FLASH:       46844 B        48 KB     95.30%
               RAM:       22720 B        32 KB     69.34%
         IDT_LIST:          0 GB        32 KB      0.00%
    Generating files from /home/jaredwolff/Git/nrf9160-feather-examples-and-drivers/nfed/samples/blinky/build/circuitdojo_feather_nrf9151/mcuboot/zephyr/zephyr.elf for board:circuitdojo_feather_nrf9151
    [20/20] Generating ../merged.hex
    

Flashing

Note: we're working on ways to flash from the UI in VSCode. In the meantime, here's how to do it manually.

The nRF9151 Feather has a build-in CMSIS-DAP debugger. You can use it to flash the firmware. The two utilities that you can use are:

  1. probe-rs
  2. pyocd

probe-rs

Note: you will need to have rust installed before you can install probe-rs. See here for more info.

To install use:

cargo install probe-rs-tools --git https://github.com/probe-rs/probe-rs --rev 4a711751dd250ae232cb2668fedfa9678c47e4ab

Note: Make sure you use the revision indicateda above. There are multiple improvements which makes programming several seconds speedier than pyocd

Then you can program using:

cd samples/blinky
probe-rs download --chip nRF9160_xxAA --binary-format hex build/circuitdojo_feather_nrf9151/merged.hex --allow-erase-all
probe-rs reset --chip nRF9160_xxAA

Note: change location to the sample/application you're working on. This is where your build folder is located.

pyocd

pyocd does have some dependencies depending on your OS.

Mac Dependencies

For Mac you'll need to install libusb using brew:

brew install libusb

Installing & Running

To install run:

python -m venv .venv
source .venv/bin/activate
python3 -m pip install -U pyocd
pyocd pack install nRF9160_xxAA

Note: you will need to source .venv/bin/activate after closing & reopening VSCode.

Then you can flash using:

cd samples/blinky
pyocd load --target nRF9160_xxAA --format hex build/circuitdojo_feather_nrf9151/merged.hex
pyocd reset --target nrf9160_xxaa