Getting Started nRF5SDK Ses
Getting Started nRF5SDK Ses
Getting Started nRF5SDK Ses
1 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2 Minimum requirements. . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3 Related documentation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
5 SoftDevices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
8 Programming an application. . . . . . . . . . . . . . . . . . . . . . . . . 16
8.1 Erasing the kit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
8.2 Importing Keil projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
8.3 Compiling the application . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
8.4 Configuring placement of the SoftDevice . . . . . . . . . . . . . . . . . . . . . . 23
8.5 Programming the firmware . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
8.6 Adding files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
8.6.1 Adding source files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
8.6.2 Including header files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
11 Debugging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Legal notices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
1159720_163 v1.4 ii
Revision history
Date Version Description
April 2020 1.4 • Changed the document title to clarify that this Getting Started
Guide targets the nRF5 SDK
• Editorial changes
1159720_163 v1.4 4
2 Minimum requirements
Ensure that you have all the required hardware and that your computer fulfills the software requirements.
Hardware requirements
• One of the following development kits:
• nRF52840 DK
• nRF52833 DK
• nRF52 DK
• nRF51 DK
• Micro-USB 2.0 cable
• Personal computer (PC)
• Optional for testing:
• Smartphone or tablet that supports Bluetooth® Low Energy
• nRF52840 Dongle, nRF51 Dongle, or a second Nordic DK
Software requirements
One of the following operating systems:
• Windows 8 or Windows 10
• macOS
• Linux
1159720_163 v1.4 5
3 Related documentation
In addition to the information in this document, you may need to refer to other documents.
Compatibility Matrices
nRF52840 Compatibility Matrix
nRF52833 Compatibility Matrix
nRF52832 Compatibility Matrix
nRF52811 Compatibility Matrix
nRF52810 Compatibility Matrix
nRF51 Series Compatibility Matrix
SDK documentation
nRF5 SDK v16.0.0
1159720_163 v1.4 6
Development kits, PCA numbers, and
4 chips
Nordic Semiconductor's software tools either target the chip that is soldered onto the kit's development
kit, or target the development kit itself.
The following table lists the PCA number and the chip bundled in each kit.
1159720_163 v1.4 7
5 SoftDevices
A SoftDevice is a wireless protocol stack that complements an nRF5 Series System on Chip (SoC).
Nordic Semiconductor provides them as qualified, precompiled binary files. While it is possible to build
applications without using a SoftDevice, all nRF5 SDK example applications that use Bluetooth Low Energy
or ANT™ require a SoftDevice.
See the compatibility matrices for detailed information about which SoftDevice versions are supported for
each chip. The following table summarizes the usage scenarios for each SoftDevice.
• nRF52810 S112
• nRF52832
• nRF52833 S113
• nRF52832 S132
• nRF52833 S140
• nRF52840
• nRF52832 S212
• nRF52840 S340
1159720_163 v1.4 8
6 Running a first test
Before you start developing, program and run a precompiled application on your development kit
to ensure that the kit functions as expected and the communication between your computer and
development kit works.
1. Download the latest compatible version of the nRF5 SDK.
The nRF5 SDK contains precompiled HEX files of the most common examples. Extract the zip file into a
folder of your choice.
For information about which SDK supports which IC revisions, check the compatibility matrices.
2. Power up the development kit:
a) Connect one end of a micro-USB 2.0 cable to the Universal Serial Bus (USB) connector on the kit
and the other end to one of your PC's USB host ports.
b) Slide the power switch to ON.
1159720_163 v1.4 9
Running a first test
4. In the folder where you extracted the nRF5 SDK, navigate to examples\ble_peripheral
\ble_app_hrs\hex.
5. Select the HEX file that corresponds to your development kit and copy it to the JLINK drive.
The development kit will now restart and run the application. Note that while restarting, the JLINK
drive will be disconnected.
6. Download and install the Nordic nRF Toolbox app from Google Play or App Store.
7. Open nRF Toolbox.
8. Tap HRM.
9. Tap Connect.
10.Select Nordic_HRS.
A simulated heart rate and battery charge percentage is displayed.
For more advanced testing scenarios, see Testing the application on page 32.
Next, continue to set up your development toolchain and build and program an application from the
source code.
1159720_163 v1.4 10
7 Setting up your toolchain
Before you can start developing, you must install the required software. This software includes tools to
connect to your development kit, an IDE for developing your application, and the nRF5 SDK that provides
libraries and example applications.
See Nordic tools and downloads on page 11 for an overview of available tools and the links to
download the latest versions for your operating system.
The following tools are required for this Getting Started Guide:
• nRF5 SDK
• SEGGER J-Link Software and Documentation Pack
• SEGGER Embedded Studio (SES)
The following tool is optional:
• nRF Command Line Tools (including nrfjprog)
See the following sections for installation instructions.
Development IDE
Pick one of the IDEs with a compiler supported by Nordic:
SES is the recommended platform. It is free for use with nRF devices.
Essential tools
You need to download these Nordic tools to develop with our devices.
1159720_163 v1.4 11
Setting up your toolchain
nRF Collection of nRF Command Line Tools nRF Command Line BLE/ANT
Command command line Tools
Line Tools tools, like nrfjprog,
mergehex
Optional tools
These tools are not essential, but we recommend that you use them.
1159720_163 v1.4 12
Setting up your toolchain
nRF Connect for Expandable desktop nRF Connect for nRF Connect BLE
Desktop tool with several apps, Desktop Bluetooth Low Energy
including:
• Peer device
emulator
• Power Profiler
• Programmer
• Cloud Gateway
nRF Connect for Peer device emulator Android v4.3 or later BLE
Mobile app for smartphones
IOS v8 or later
Nordic nRF Toolbox App that contains all Android v4.3 or later BLE
app the Nordic apps
IOS v8 or later
Windows Phone v8.1
or later
1159720_163 v1.4 13
Setting up your toolchain
See also Nordic mobile apps for a list of available Bluetooth Low Energy and Mesh mobile apps for iOS,
Android, and Windows Phones.
Note: Compilers tend to run into problems with long path names. Therefore, place the folder as
close to the root level of your file system as possible (for example, at C:/Nordic/SDK). Also,
avoid using spaces in the file path and folder name.
Note: In SES versions before 3.34, this option was called Get a Free License.
1159720_163 v1.4 14
Setting up your toolchain
export PATH=$PATH:/opt/nrfjprog
Open a new command prompt and repeat the command. It should now succeed.
1159720_163 v1.4 15
8 Programming an application
After setting up the required toolchain, you are ready to compile your application and program (or "flash")
it to your development kit.
Starting with v14.1.0, the nRF5 SDK supplies SEGGER Embedded Studio projects. If you are using an older
version of the nRF5 SDK (for example, nRF5 SDK v12.3.0, which supports nRF51 Series devices), you must
import and convert the Keil µVision projects.
There is a series of video tutorials that show how to get started with SEGGER Embedded Studio in
combination with the nRF5 SDK. Check them out here: Getting started with SEGGER Embedded Studio and
the nRF5 SDK
• To erase the contents of the kit with nrfjprog, enter the following command:
1159720_163 v1.4 16
Programming an application
1159720_163 v1.4 17
Programming an application
4. If the project that you imported contains a Target for flashing the SoftDevice, delete this Target in SES:
a) Select Project > Build Configurations.
b) Under Public Configurations, select the Target (for example, flash_s130_nrf51_2.0.1_softdevice).
c) Click the - symbol to remove the Target.
The build configuration should now look similar to this:
5. Add the nRF5 MDK files that are required for startup and system setup.
In Keil µVision, these files are provided by the nRF_DeviceFamilyPack. Since this pack is not available
for SES, you must add them manually to the SES project.
a) Download ses_nrf51_startup.s and ses_nrf52_startup.s and save them in a new folder SDK_dir/
components/toolchain/embedded_studio.
b) In the Project Explorer, navigate to Internal Files and remove the Cortex_M_Startup.s file.
c) Right-click Internal Files and select Add Existing File.
d) Browse to the SDK_dir/components/toolchain/ folder and select the .c file that
corresponds to your device (for example, system_nrf52.c).
e) Right-click Internal Files and select Add Existing File again. This time, select the startup file that
you downloaded, for example, SDK_dir/components/toolchain/embedded_studio/
ses_nrf51_startup.s.
1159720_163 v1.4 18
Programming an application
1159720_163 v1.4 19
Programming an application
7. If your project uses modules that require section variables (for example, the Peer Manager, Flash Data
Storage, or Flash Storage), define where in the flash information from these modules should be stored.
a) Download the flash_placement.xml and place it in your project directory.
Files are provided for the following versions of the nRF5 SDK:
• For nRF5 SDK v12.x.x: flash_placement.xml
• For nRF5 SDK v13.x.x and nRF5 SDK v14.0.0: flash_placement.xml
b) If you are using SES v3.50 or later, right-click your project, select Edit Options, select Linker, and
change the Linker option to GNU.
1159720_163 v1.4 20
Programming an application
Note: This option does not exist in SES versions before 3.50.
c) Right-click on your project in the Project Explorer and select Import Section Placement.
1159720_163 v1.4 21
Programming an application
d) Confirm that you want to use the section placement for the current build configuration.
1159720_163 v1.4 22
Programming an application
Note:
If your application does not use a SoftDevice, you can skip this step.
If you are using a SES project from nRF5 SDK v14.2.0 or later, the placement of the SoftDevice is
already configured correctly and you can skip this step.
If your application requires a SoftDevice, the flash and SRAM position where the compiled binary will be
placed must be configured as follows:
1. In SES, right-click your project and select Edit Options.
2. Select Linker.
3. In the Section Placement Macros field, add values for FLASH_START and SRAM_START.
To find the correct values, check the Keil project that you imported (in Keil µVision, select Options for
Target > Target), or program the firmware with approximate values, run it, and check the log output in
the debug terminal for the recommended values.
For example, when running the ble_app_uart example application from nRF5 SDK v12.3.0 on PCA10028
with SoftDevice S130 v2.0.1, specify the section placement macros as shown:
1159720_163 v1.4 23
Programming an application
1159720_163 v1.4 24
Programming an application
1159720_163 v1.4 25
Programming an application
1159720_163 v1.4 26
Programming an application
• To create a file, right-click your project or any subfolder in the Project Explorer and select Add New
File.
By default, the file is created in the project directory.
3. Select Preprocessor.
4. Double-click User Include Directories and add the path to the folder that contains the header file.
You can specify an absolute path or a path that is relative to the project directory. Using a relative path
is preferable if you might want to move or copy your project to, for example, a new SDK version in the
future.
1159720_163 v1.4 27
Programming an application
5. Click OK.
1159720_163 v1.4 28
9 Communicating with the kit
If your application outputs logging information or needs console input, you should connect the kit to your
computer to interact with a console. You can use Real Time Transfer (RTT) or Universal Asynchronous
Receiver/Transmitter (UART) for communicating with the kit.
SEGGER Real Time Transfer (RTT) is a proprietary technology for bidirectional communication that
supports J-Link devices and ARM-based microcontrollers. The advantage of using RTT is that it is very
efficient and does not require any other peripheral than the J-Link debugging interface. RTT is directly
supported in SES.
Connecting via UART is quick and power-efficient, but it requires dedicated use of the UART peripheral for
logging. The nRF5 DKs and the nRF51 Dongle include a UART to USB CDC ACM bridge, which is needed to
connect to the UART. Alternatively, you can use an external UART to USB bridge. We use the term CDC-
UART to refer to UART communication through the UART to USB CDC ACM bridge, to distinguish it from
communication through the Nordic UART Service (NUS) over Bluetooth Low Energy.
Note: SES natively supports RTT. If enabled, the monitor shows up when you start debugging.
Alternatively, you can use SEGGER's J-Link RTT Viewer as described below.
The J-Link RTT Viewer is installed as part of the nRF Command Line Tools.
To run the J-Link RTT Viewer on Windows, complete the following steps:
1. Select the correct target device.
The target device is represented by the ID of your development kit.
2. Select SWD as the target interface.
1159720_163 v1.4 29
Communicating with the kit
Note: SES natively supports RTT. If enabled, the monitor shows up when you start debugging.
Alternatively, you can use SEGGER's J-Link RTT Viewer as described below.
SEGGER's J-Link RTT is part of the J-Link Software and Documentation Pack, which is available from
SEGGER downloads.
To use J-Link RTT on Linux, complete the following steps:
1. Enter JLinkExe -if SWD to set up the connection:
1159720_163 v1.4 30
Communicating with the kit
1159720_163 v1.4 31
10 Testing the application
The next step after compiling and programming your application is to test it. With the nRF Connect
platform, Nordic Semiconductor provides its own testing apps, which are available both for mobile and for
desktop.
1159720_163 v1.4 32
Testing the application
This example communicates over Bluetooth Low Energy using the Nordic UART Service (NUS).
7. Tap the options button and select Show log.
8. In a terminal connected via CDC-UART, enter hello and send it to the development kit.
The text is sent through the development kit to your mobile device over a Bluetooth Low Energy link.
The mobile device will then display it in the nRF Connect log:
Note: This method requires a dongle or a second Nordic DK with Bluetooth Low Energy support to
be connected to your computer.
The following procedure assumes that you have programmed the Bluetooth Low Energy Peripheral UART
example from the nRF5 SDK (examples/ble_peripheral/ble_app_uart) on your development
kit. Steps for testing other examples are similar. See the testing instructions for each example in the nRF5
SDK documentation for more information.
1. Download and install nRF Connect for Desktop.
2. Connect the dongle or the second development kit to a USB port of your computer.
3. Connect to the kit that runs the ble_app_uart example via CDC-UART.
4. Open nRF Connect for Desktop and install the Bluetooth Low Energy app.
See nRF Connect for Desktop for information about how to install and open apps.
5. Launch the Bluetooth Low Energy app.
6. Select the serial port for the dongle or the development kit that is connected to your computer (not
the kit that runs the Peripheral UART example).
1159720_163 v1.4 33
Testing the application
If the device has not been used with the nRF Connect Bluetooth Low Energy app before, you may
be asked to update the J-Link firmware and connectivity firmware for the device. You must have the
correct connectivity firmware on the nRF SoC to continue. When the nRF SoC has been programmed
with the correct firmware, the nRF Connect Bluetooth Low Energy app proceeds to connect to it over
USB. When the connection is established, the device appears in the main view.
7. Click Start scan.
8. Find the device and click Connect.
The default device name for the Peripheral UART example is "Nordic_UART".
9. Select the UART RX characteristic value.
10.Write 30 31 32 33 34 35 36 37 38 39 (the hexadecimal value for the string "0123456789")
and click write.
The data is transmitted over Bluetooth Low Energy from the app to the development kit that runs the
Peripheral UART example. The text "0123456789" is displayed in the terminal that is connected to the
kit that runs the Peripheral UART example via UART.
11.Enter any text, for example, Hello, in the terminal.
In nRF Connect, the UART TX characteristic value changes to the corresponding ASCII value. For
example, the value for Hello is 48 65 6C 6C 6F.
1159720_163 v1.4 34
11 Debugging
To actually see what is happening on the development kit while the application is running, you must set
up a J-Link debugging session. SES has an integrated debugger that you can use to step through your
application.
Complete the following steps to start debugging:
1. Open your project in SES.
2. Build and program your application to the kit as described in Building and programming a sample
application.
3. Select Debug > Go.
Alternatively, press F5.
The debugging interface looks like this:
By default, the application will break in main. You can set additional break points, single-step through
the application, read registers, and so on.
This video tutorial shows you how to use SES for debugging:
1159720_163 v1.4 35
Debugging
1159720_163 v1.4 36
Glossary
Development Kit (DK)
A development platform used for application development.
SoftDevice
A wireless protocol stack that complements the nRF5 Series SoCs. Nordic Semiconductor provides
these stacks as qualified, precompiled binary files.
Target
The goal of an operation, for example, programming a specific image on a device, compiling a
specific set of files, or removing previously generated files.
1159720_163 v1.4 37
Acronyms and abbreviations
These acronyms and abbreviations are used in this document.
DK
Development Kit
IDE
Integrated Development Environment
RTT
SEGGER Real Time Transfer
SDK
Software Development Kit
SES
SEGGER Embedded Studio
SoC
System on Chip
UART
Universal Asynchronous Receiver/Transmitter
USB
Universal Serial Bus
1159720_163 v1.4 38
Legal notices
By using this documentation you agree to our terms and conditions of use. Nordic Semiconductor may
change these terms and conditions at any time without notice.
Liability disclaimer
Nordic Semiconductor ASA reserves the right to make changes without further notice to the product to
improve reliability, function, or design. Nordic Semiconductor ASA does not assume any liability arising out
of the application or use of any product or circuits described herein.
Nordic Semiconductor ASA does not give any representations or warranties, expressed or implied, as to
the accuracy or completeness of such information and shall have no liability for the consequences of use
of such information. If there are any discrepancies, ambiguities or conflicts in Nordic Semiconductor’s
documentation, the Product Specification prevails.
Nordic Semiconductor ASA reserves the right to make corrections, enhancements, and other changes to
this document without notice.
Trademarks
All trademarks, service marks, trade names, product names, and logos appearing in this documentation
are the property of their respective owners.
Copyright notice
© 2020 Nordic Semiconductor ASA. All rights are reserved. Reproduction in whole or in part is prohibited
without the prior written permission of the copyright holder.
1159720_163 v1.4 39