Developing Nordics' nRF9160 DK using Qt Creator


So I've got my hands into a nRF9160DK (development kit). Like I did with the nRF51822 I would love to develop software for this board using as much FLOSS tools as possible to avoid any kind of vendor lock-in.

This board actually has two interesting ICs: the nRF9160 which anyone would expect and a nRF52840. At first I'm targeting the first one.

The nRF9160's firmware is based on Zephyr which uses CMake. This is great as my preferred IDE is Qt Creator which has quite nice CMake integration.

Preparing the toolchain and proprietary code

There is of course some Nordic proprietary code to put in the mix. So the first step is to setup Nordic's SDK. For that one needs to follow the "Get started with development" section in their web page. One needs to download an nRFConnect AppImage binary and start it. How safe it is to run proprietary code in our machines? Now that's an interesting question.

Once there, and still following Nordic's documentation, we need to install the "Getting started Assistant" and run it. We will follow all steps in it except the last ones for installing a proprietary IDE. We want to code using Qt Creator after all.

Building the asset tracker example from the command line

So let's start by trying to build the example (the only one so far?) from the command line. After some trial and error I've got the following:

mkdir build
cd build
GNUARMEMB_TOOLCHAIN_PATH="/opt/gcc-arm-none-eabi-7-2018-q2-update"

ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb ZEPHYR_BASE="$NCS_BASE/zephyr"

cmake -DBOARD_ROOT="$NCS_BASE/zephyr/boards/arm/nrf9160_pca10090"

-DBOARD="nrf9160_pca10090ns" ../

Where NCS_BASE is the path to the previously downloaded SDK. In this case I selected the non secure version build for this board.

The next step is then easy.

Building the asset tracker example from within Qt Creator

Once we've got to compile the example from the command line switching to Qt Creator is easy. First of all we want to set up a Kit as I did for the nRF51822. Follow the instructions there but this time set up the new GCC version required by this development kit.

The next step is to provide as much definitions as possible as part of the kit itself. Got to ToolsOptions... and then to Kits. Select the newly created kit (I called it nRF9160) and then change "CMake Configuration" settings. The resulting text should look like:

::: {style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"} [BOARD:STRING=nrf9160_pca10090ns]{style="font-family: \"Courier New\", Courier, monospace;"} :::

[]{style="font-family: \"Courier New\", Courier, monospace;"}

::: {style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"} [BOARD_ROOT:STRING=path/to/ncs/zephyr/boards/arm/nrf9160_pca10090]{style="font-family: \"Courier New\", Courier, monospace;"} :::

[]{style="font-family: \"Courier New\", Courier, monospace;"}

::: {style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"} [CMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}]{style="font-family: \"Courier New\", Courier, monospace;"} :::

[]{style="font-family: \"Courier New\", Courier, monospace;"}

::: {style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"} [CMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}]{style="font-family: \"Courier New\", Courier, monospace;"} :::

[]{style="font-family: \"Courier New\", Courier, monospace;"}

::: {style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"} [CMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}]{style="font-family: \"Courier New\", Courier, monospace;"} :::

[]{style="font-family: \"Courier New\", Courier, monospace;"}

::: {style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"} [GNUARMEMB_TOOLCHAIN_PATH:STRING=/opt/gcc-arm-none-eabi-7-2018-q2-update]{style="font-family: \"Courier New\", Courier, monospace;"} :::

[]{style="font-family: \"Courier New\", Courier, monospace;"}

::: {style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"} []{style="font-family: \"Courier New\", Courier, monospace;"} :::

[]{style="font-family: \"Courier New\", Courier, monospace;"}

::: {style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"} [ZEPHYR_TOOLCHAIN_VARIANT:STRING=gnuarmemb]{style="font-family: \"Courier New\", Courier, monospace;"} :::

::: {style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"}

:::

::: {style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"} Some of those definitions are not really necessary in there. ZEPHYR_BASE needs to be set as an environment variable. This is the only akward part of this setup, as the only way I could find to do so from within Qt Creator is to set it up in a per-project fashion. :::

::: {style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"}

:::

::: {style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"} Once the above is done open \$NCS_BASE/nrf/applications/asset_tracker/CMakeLists.txt. The configuration will fail, as we haven't suplied ZEPHYR_BASE yet. To do so go to "Projects" on the right, Select "Build" within the kit and set up ZEPHYR_BASE within the "Build Environment" section at the bottom. :::

::: {style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"}

:::

::: {style="-qt-block-indent: 0; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-indent: 0px;"} That's is, you are now ready to use "Run CMake" from within the "Build" menu and you are ready to go. :::

Comments


There are no comments yet.

Add a Comment

You can use the Markdown syntax to format your comment.

Comment Atom Feed