-
Notifications
You must be signed in to change notification settings - Fork 182
How to Build the Firmware Samples
Firmware samples live in the code/samples/ directory. The parent code/ directory is a west workspace.
Samples built with the default configs are readily available in the releases page. This is the easiest way to get started.
Clone the repo and initialize the west workspace in the code/ directory:
cd code/
west init -l prstlib
west update --narrow --fetch-opt=--depth=1
# Open VSCode on code/
code .In the VSCode nRF Connect Extension, select Open an existing application and add one one the sample's directory (e.g.: code/samples/ble). Add a build configuration, and make sure to select the appropriate hardware target and version:
The code/scripts/build-with-docker.sh is a thin wrapper around the docker cli:
cd code/
./scripts/build-with-docker.sh --help
usage: build.sh <sample> [soc] [revision]
sample blinky | input | ble | soil-read-loop | zigbee
soc nrf52840 (default) | nrf52833
revision 2.0.0 (default) | 1.2.0 | 1.1.0 | 1.0.0
env:
CMAKE_EXTRA extra -D… flags appended to west buildFor example, building the ble sample for the nrf52840 on revision 2.0.0:
cd code/
./scripts/build-with-docker.sh ble nrf52840 2.0.0
...
225/225] Linking C executable zephyr/zephyr.elf
Memory region Used Size Region Size %age Used
FLASH: 200244 B 1 MB 19.10%
RAM: 30588 B 256 KB 11.67%
IDT_LIST: 0 GB 32 KB 0.00%
[8/10] Completed 'ble'
[9/10] cd /workspace/samples/ble/build_nrf52840_2.0.0/_sysbuild && /usr/bin/cmake -E true
[10/10] Generating ../merged.hexThe built binary will be in samples/ble/build_nrf52840_2.0.0/merged.hex.
GitHub Codespaces let you run an instance of VS Code directly in your browser. More importantly, it also supports plugins, including nRF Connect for VS Code! This PR introduces .devcontainer/devcontainer.json, which configures a Codespace with both the nRF VS Code plugin, as well as the whole nRF Connect SDK + toolchain. This lets you edit code and build the sample straight in your browser.
- Go to Codespaces and click "New codespace"
- Select
rbaron/b-parasite, branchnrf-connect - Wait. The underlying Docker image is pretty big and the build might fail. It worked on the second try for me
- Once the codespace is ready, navigate to
code/nrf-connect/samples/ble, selectble.code-workspaceand click on "Open workspace". This makes sure both theblesample and theprstlibare present in the workspace - Build the sample normally, as described in the nRF Connect SDK docs
- Download the built sample from
ble/build/zephyr/zephyr.hex