1Nordic nRF9161
2==============
3
4The nRF9161 development kit (DK) is a single-board development kit for
5the evaluation and development on the Nordic nRF9161 SiP for LTE-M and NB-IoT.
6
7The nRF9161 SoC features a full-featured Arm® Cortex®-M33F core with DSP
8instructions, FPU, and ARMv8-M Security Extension, running at up to 64 MHz.
9
10Documentation
11-------------
12
13The following links provide useful information about the nRF9161
14
15nRF9161 DK website:
16   https://www.nordicsemi.com/products/nrf9161
17
18Nordic Semiconductor TechDocs: https://docs.nordicsemi.com
19
20
21Building TF-M on nRF9161
22------------------------
23
24To build an S and NS application image for the nRF9161 run the
25following commands:
26
27.. code-block:: bash
28
29   cmake -S <TF-M base folder> -B build_spe \
30           -DTFM_PLATFORM=nordic_nrf/nrf9161dk_nrf9161 \
31           -DTFM_TOOLCHAIN_FILE=../toolchain_GNUARM.cmake \
32   cmake --build build_spe -- install
33
34   cmake -S <Application base folder> -B build_app \
35           -DCONFIG_SPE_PATH<Absolute path to TF-M base folder>/build_spe/api_ns
36           -DTFM_TOOLCHAIN_FILE=cmake/toolchain_ns_GNUARM.cmake
37   cmake --build
38
39.. note::
40   Currently, applications can only be built using GCC (GNU ARM Embedded
41   toolchain).
42
43.. note::
44   For BL2 (MCUBoot) logging output to be available, the project needs to be
45   built with Debug configuration (CMAKE_BUILD_TYPE=Debug).
46
47Flashing and debugging with Nordic nRF Segger J-Link
48-----------------------------------------------------
49
50nRF9161 DK is equipped with a Debug IC (Atmel ATSAM3U2C) which provides the
51following functionality:
52
53* Segger J-Link firmware and desktop tools
54* SWD debug for the nRF9161 IC
55* Mass Storage device for drag-and-drop image flashing
56* USB CDC ACM Serial Port bridged to the nRFx UART peripheral
57* Segger RTT Console
58* Segger Ozone Debugger
59
60To install the J-Link Software and documentation pack, follow the steps below:
61
62#. Download the appropriate package from the `J-Link Software and documentation pack`_ website
63#. Depending on your platform, install the package or run the installer
64#. When connecting a J-Link-enabled board such as an nRF9161 DK, a
65   drive corresponding to a USB Mass Storage device as well as a serial port should come up
66
67nRF Util Installation
68*********************
69
70nRF Util allows you to control your nRF9161 device from the command line,
71including resetting it, erasing or programming the flash memory and more.
72
73To install nRF Util:
74
751. Visit `nRF Util product page`_.
762. Download the executable.
773. Follow the `nRF Util installation instructions`_.
784. Install ``nrfutil device`` subcommand for programming, flashing, and erasing devices:
79
80   .. code-block:: console
81
82      nrfutil install device
83
84After installing, make sure that ``nrfutil.exe`` is somewhere in your executable
85path to be able to invoke it from anywhere.
86
87BL2, S, and NS application images can be flashed into nRF9161 separately or may be merged
88together into a single binary.
89
90Flashing the nRF9161 DK
91***********************
92
93To program the flash with a compiled TF-M image (i.e. S, NS or both) after having
94followed the instructions to install the Segger J-Link Software and the nRFx
95Command-Line Tools, follow the steps below:
96
97Generate Intel hex files from the output binary (bin) files as follows:
98
99.. code-block:: console
100
101   srec_cat build_app/tfm_s_ns_signed.bin -binary --offset 0x10000 \
102         -o build_app/tfm_s_ns_signed.hex -intel
103
104* Connect the micro-USB cable to the nRF9161 DK and to your computer
105* Erase the flash memory in the nRF9161 IC:
106
107.. code-block:: console
108
109   nrfutil device erase --all --x-family nrf91
110
111* (Optionally) Erase the flash memory and reset flash protection and disable
112   the read back protection mechanism if enabled.
113
114.. code-block:: console
115
116   nrfutil device recover --x-family nrf91
117
118* Flash the BL2 and TF-M image binaries from the sample folder of your choice:
119
120.. code-block:: console
121
122   nrfutil device program --x-family nrf91 --firmware build_spe/bin/bl2.hex --options chip_erase_mode=ERASE_RANGES_TOUCHED_BY_FIRMWARE
123   nrfutil device program --x-family nrf91 --firmware build_app/tfm_s_ns_signed.hex --options chip_erase_mode=ERASE_RANGES_TOUCHED_BY_FIRMWARE
124
125* Reset and start TF-M:
126
127.. code-block:: console
128
129   nrfutil device reset --x-family nrf91
130
131Secure UART Console on nRF9161 DK
132**********************************
133
134SECURE_UART1 is enabled by default when building TF-M on nRF9161 DK, so the secure firmware console output
135is available via USART1.
136
137Non-Secure console output is available via USART0.
138
139.. note::
140   By default USART0 and USART1 outputs are routed to separate serial ports.
141
142.. _nRF Util product page: https://www.nordicsemi.com/Products/Development-tools/nRF-Util/
143
144.. _nRF Util installation instructions: https://docs.nordicsemi.com/bundle/nrfutil/page/guides/installing.html
145
146.. _J-Link Software and documentation pack: https://www.segger.com/jlink-software.html
147
148--------------
149
150*Copyright (c) 2023, Nordic Semiconductor. All rights reserved.*
151