This library is not under active development anymore. More details why and the implications. The source code for nbiot.engineering is published to https://github.com/eesrc/horde.
This repository includes a few sample applications to help get you started with using the nRF9160 with the Telenor IoT Gateway which, as of March 2020, is only enabled for Telenor Norway.
Samples included
Hello, World!
.At the time of the writing, concise and reliable instructions for setting up one's development environment were hard to come by. To reduce the barrier of entry into the IoT market, we've tried to simplify the setup process.
Nordic Semiconductor have chosen Zephyr for firmware development on the nRF9160. The build tool for Zephyr relies on python and many pip dependencies. To produce a determnistic build, we've created a Pipfile for pipenv with all the pip dependencies from the different Zephyr repositories. Currently it's based on nRF Connect SDK v1.2.0.
You are welcome to follow Nordic's instructions for setting up the nRF Connect SDK, but we beleive our instuctions are easier and more reliable.
If you previously have set up this project when it was based on nRF Connect SDK v1.1.0, follow these steps to start using v1.2.0:
git pull
pipenv run west update
pipenv install
to install new pip dependencies to the virtualenv.You might also want to read the nRF Connect SDK v1.2.0 Release notes.
The nRF9160 DK module with Telenor SIM card
Micro-USB cable
nRF Connect for desktop v3.3.0 (or newer)
nRF Command Line Tools v10.5.0 (or newer)
Install pipenv
pip3 install pipenv
Set environment variables
Windows (make sure the path to gnuarmemb is correct)
setx ZEPHYR_TOOLCHAIN_VARIANT gnuarmemb
setx GNUARMEMB_TOOLCHAIN_PATH C:\gnuarmemb
MacOS
echo "export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb" >> ~/.profile
echo "export GNUARMEMB_TOOLCHAIN_PATH=/usr/local/opt/gcc-arm-none-eabi" >> ~/.profile
Linux
# depends on your distro
echo "export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb" >> ~/.profile
echo "export GNUARMEMB_TOOLCHAIN_PATH=/usr" >> ~/.profile
MacOS only
Install libgit2
brew install libgit2
git clone https://github.com/ExploratoryEngineering/nrf9160-telenor
cd nrf9160-telenor
pipenv install # install python dependencies in projects virtualenv
pipenv run west update # download the Zephyr dependencies using west
In order to see the output from the sample applications, follow our tutorial to install a serial terminal application.
Follow the Getting Started tutorial so that your device can get online.
TL;DR - you need to run build <sample name>
before you run the flash
task. Delete the build
folder or run pristine
before building another sample. See why further down.
The default build target is the nRF9160 Development Kit (nrf9160_pca10090ns)
nrf9160_pca10090ns
with the board you'd like to build for in .vscode/tasks.json
Open the Command Palette with
Start typing «run task
»
Select «Tasks: Run Task
» using arrow keys and hit
Choose the sample you want to build using arrow keys and hit
flash
to upload the binary from the build step to the connected nrf9160 DKreset.S
before the application is loadedNote: The compiler will try to optimize your code, so you'll probably see <optimized out>
under variables instead of the variable value. To disable the optimizations when debugging, add these lines to the prj.conf:
CONFIG_NO_OPTIMIZATIONS=y
CONFIG_DEBUG=y
We've included configuration to make it possible to build the samples and debug on the nrf9160 from Visual Studio Code.
First, let me explain an important feature in West (Zephyrs build tool). When you build an application/sample using west, the output will be in the build
folder of the current working directory.
Say you've cloned this project into ~/nrf9160-telenor
:
pipenv run west build samples/hello_world
from ~/nrf9160-telenor
, the output will be in ~/nrf9160-telenor/build
. It will also store what path you used when building. So if you now just run west build
without specifying a path, it will still build hello_world
. If you want to switch sample, you have to clean the build/
folder first.cd
into the samples/hello_world
folder and run pipenv run west build
there, it will output the build folder to samples/hello_world/build
.Both methods work fine, but the tasks we've defined in VS Code always build from the project root folder. Then we only need to duplicate the build ...
task for each sample, and the flash
and debug
assume you've already ran the build task first.
The amount of config options for Zephyr can be quite daunting, but they actually have a command line user interface that allows you to browse the config options interactiely. Either navigate using arrow keys or search using the /
D
prj.conf
.
pipenv run west build -t menuconfig samples/hello_world
If you get tired of typing pipenv run
before every west
command, you can run pipenv shell
first. This will create a new shell that activates the pipenv virtualenv. Just remember to exit before you us the shell for other things.
Very often when a build fails, some files are left in the build/
folder which confuses subsequent builds. Try to delete the build/
folder and build again.
Sometimes when changing dependency versions, the cache can cause build errors. Deleting it doesn't do any damage, it just increases the build time on the next build.
Delete this folder:
%LOCALAPPDATA%\.cache\zephyr
~/Library/Caches/zephyr
$XDG_CACHE_HOME/zephyr
or ~/.cache/zephyr