Last Updated: 19-06-2020

This article goes through setting up a development machine to build the example projects and also how to flash them to your microcontroller. Right now, this only describes how to build on Microsoft Windows but the article will be updated to include Linux and Mac/OSX in due course.

Each of the examples are built using GCC and make and flashed using the NoSMD Raspberry Pi SWD programmer.

Pre-Requisites

GNU Compiler Collection (GCC)

GCC, the compiler and linker used to convert the source to binary is available from here.

Download the current latest package and install on the development machine. At the time of writing, the latest exe package is:

gcc-arm-none-eabi-9-2020-q2-update-win32.exe

Run the installer which by default installs to:

C:\Program Files (x86)\GNU Arm Embedded Toolchain\9 2020-q2-update

GNU Make

GNU Make is the tool that interprets the makefile to produce a binary from source files. The project page for GNU Make for Windows is here. Go to the Download section and select Complete package, except sources to download.

Run the installer which should install the package to:

C:\Program Files (x86)\GnuWin32

Nordic SDK

The Nordic SDK contains low level library code to enable working with the various features of the microcontroller. The SDK is delivered as source files which are compiled into the project. The SDK is available from here.

Select the latest version under changelog and then scroll to the bottom of the page and hit Download Files

Unzip the downloaded zip file which itself will contain a number of other zip files. Extract the zip file nRF5SDK*.zip to some convenient location on the development machine. We tend to use C:\SDK\NordicSDK

NoSMD Raspberry Pi SWD Programmer

This is software that turns a Raspberry Pi into an SWD programmer. Installation instructions are available from here.

Building the Binaries

Each of the examples comes with a makefile to control the build. The makefile is the same for each of the examples and can be used as is to build projects of your own. At the top of the makefile there are a couple of installation/project specific definitions:

TARGET = blinky
TOOLCHAIN_PATH = C:\Program Files (x86)\GNU Arm Embedded Toolchain\9 2020-q2-update\bin

These two lines set up the name of the binary that will be produced by the build process and also the path to where the tool chain binaries are located.

To compile and link a target named blinky, open a terminal and type:

C:\Projects\Blinky> "C:\Program Files (x86)\GnuWin32\bin\make.exe" -f makefile CONFIG=Debug all

Assuming no errors in the source, this will result in the binary blinky.elf being produced:

C:\Projects\Blinky> dir bin\Debug
 Volume in drive C is OS
 Volume Serial Number is 20CB-7DF9

 Directory of C:\Projects\Blinky\bin\Debug

30/06/2020  09:12    <DIR>          .
30/06/2020  09:12    <DIR>          ..
30/06/2020  09:12           189,392 blinky.elf
               1 File(s)        189,392 bytes
               2 Dir(s)  1,976,886,792,192 bytes free

C:\Projects\Blinky>

Flashing the Binaries

You can use any programmer to program the examples to the target microcontroller. However, some microcontrollers expect binaries to be first converted from .elf to .hex. This can be achieved with the tool objcopy that comes as part of GNU GCC.

The NoSMD Raspberry Pi Programmer will flash .elf files directly. Using the NoSMD Raspberry Pi Programmer to program the microcontroller.

0 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: