Using nRF Connect for VSCode

Setup

  1. Install nRF Connect for VSCode

  2. Once the extension pack is installed. Install the 2.7.0 Toolchain

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

    Manage toolchains

  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

    Important: if you have the same repository cloned elsewhere, nRF Connect for VSCode will not allow you to init the manfiest again.

  5. nRF Connect for VSCode will ask you if you want to run west init.

    Initialize west workspace button

  6. Once intialized, another window will pop up prompting you to run west update. Click the "Update west workspace" button.

    Run west update

    This process will download a full copy of Zephyr and NCS. It's required for any project that uses a west manifest file. It will take a minute or two to download all the dependencies.

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, edit 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
    
  4. You can locate the .hex file in the build folder. It's also provided in the nRF Connect for VSCode window:

    Build output

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 indicated 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