Skip to content

Latest commit

 

History

History

nrfx-blink-sdk

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

nrfx-blink-sdk

This example demonstrates how to integrate with the Zephyr SDK via CMake and how to build a Swift firmware application on top of the SDK and the libraries from it. The example was tested on a nRF52840-DK board, but it should also work on other Zephyr-supported boards.

Requirements

  • Download and install Zephyr, and make sure you are set up for development with it, e.g. by following the Zephyr Getting Started Guide. In particular, you will need:

    • CMake, Ninja, and other build tools.
    • The West build system.
    • A Python virtualenv for Zephyr.
    • Zephyr SDK/toolchain.
    • Host flash/debug tools for the board you're using. For example, for the nRF52840-DK board you'll need the nRF Command Line Tools.
  • Before trying to use Swift with the Zephyr SDK, make sure your environment works and can build the provided C/C++ sample projects, in particular:

    • Try building and running the "simple/blink" example from Zephyr written in C.

Building

  • Make sure you have a recent nightly Swift toolchain that has Embedded Swift support.
  • Build the program in the Zephyr virtualenv, specify the nightly toolchain to be used via the TOOLCHAINS environment variable and the target board type via the -DBOARD=... CMake setting:
$ cd nrfx-blink-sdk
$ source ~/zephyrproject/.venv/bin/activate
(.venv) export TOOLCHAINS='<toolchain-identifier>'
(.venv) cmake -B build -G Ninja -DBOARD=nrf52840dk_nrf52840 -DUSE_CCACHE=0 .
(.venv) cmake --build build

Running

  • Connect the nRF52840-DK board over a USB cable to your Mac using the J-Link connector on the board.
  • Use nrfjprog to upload the firmware and to run it:
(.venv) nrfjprog --recover --program build/zephyr/zephyr.hex --verify
(.venv) nrfjprog --run
  • The green LED should now be blinking in a pattern.