Prerequisites
- Zephyr RTOS
https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/gs_assistant.html - Zephyr SDK
https://docs.zephyrproject.org/1.11.0/getting_started/getting_started.html - Nordic CLI Tools (includes JLink Tools)
https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Command-Line-Tools - VSCode
- SEGGER JLINK
-NORDIC nRF52-DK
Building and uploading the hello-world program
- change directory to the
nRF_Connect_SDK/ncs/zephyr/samples/hello_world
directory - Add -DNRF_LOG_USES_RTT=1 to makefile. e.g. CMakeLists.txt
set(CMAKE_C_FLAGS "-DNRF_LOG_USES_RTT=1")
- Enable RTT in prj.conf
#CONFIG_NO_OPTIMIZATIONS=y
CONFIG_PRINTK=y
CONFIG_CONSOLE=y
# UART logging devzone.nordicsemi.com/.../nrf91-zephyr-enable-lte-logging
#CONFIG_LOG=y
#CONFIG_SERIAL=y
#CONFIG_STDOUT_CONSOLE=y
#CONFIG_UART_INTERRUPT_DRIVEN=y
# or disable it
CONFIG_SERIAL=y
CONFIG_STDOUT_CONSOLE=y
#docs.zephyrproject.org/.../nordic_segger.html
CONFIG_UART_CONSOLE=n
CONFIG_RTT_CONSOLE=y
CONFIG_USE_SEGGER_RTT=y
#CONFIG_LOG_BACKEND_RTT=y
#CONFIG_SHELL_BACKEND_RTT=y
#CONFIG_LOG_BACKEND_RTT_FORCE_PRINTK=y
- Rebuild e.g. nRF52-DK using west
west build -b nrf52dk_nrf52832 --pristine
-
Connect SEGGER JLink to Debug In port (P18) on nRF52-dk board using 2×10 SWD cable
-
Upload binary to target
west flash --erase
Using JLinkRTTClient
- Reset the device:
nrfjprog -r
chris@devmachine:/mnt/sda/nRF_Connect_SDK/ncs$ nrfjprog -r
Applying system reset.
Run.
- Run JLink for nRF52-dk:
JLinkExe -device NRF52 -speed 4000 -if SWD
chris@devmachine:/mnt/sda/nRF_Connect_SDK/ncs$ JLinkExe -device NRF52 -speed 4000 -if SWD
SEGGER J-Link Commander V6.84a (Compiled Sep 7 2020 18:28:09)
DLL version V6.84a, compiled Sep 7 2020 18:27:57
Connecting to J-Link via USB...O.K.
Firmware: J-Link V11 compiled Jul 17 2020 16:24:07
Hardware version: V11.00
S/N: 261002652
License(s): FlashBP, GDB
OEM: SEGGER-EDU
VTref=2.993V
Type "connect" to establish a target connection, '?' for help
J-Link>
- Open a second terminal and run
JLinkRTTClient
- Go back to the JLink terminal and type
connect
J-Link>connect
Device "NRF52" selected.
Connecting to target via SWD
InitTarget() start
InitTarget() end
Found SW-DP with ID 0x2BA01477
DPIDR: 0x2BA01477
Scanning AP map to find all available APs
AP[2]: Stopped AP scan as end of AP map has been reached
AP[0]: AHB-AP (IDR: 0x24770011)
AP[1]: JTAG-AP (IDR: 0x02880000)
Iterating through AP map to find AHB-AP to use
AP[0]: Core found
AP[0]: AHB-AP ROM base: 0xE00FF000
CPUID register: 0x410FC241. Implementer code: 0x41 (ARM)
Found Cortex-M4 r0p1, Little endian.
FPUnit: 6 code (BP) slots and 2 literal slots
CoreSight components:
ROMTbl[0] @ E00FF000
ROMTbl[0][0]: E000E000, CID: B105E00D, PID: 000BB00C SCS-M7
ROMTbl[0][1]: E0001000, CID: B105E00D, PID: 003BB002 DWT
ROMTbl[0][2]: E0002000, CID: B105E00D, PID: 002BB003 FPB
ROMTbl[0][3]: E0000000, CID: B105E00D, PID: 003BB001 ITM
ROMTbl[0][4]: E0040000, CID: B105900D, PID: 000BB9A1 TPIU
ROMTbl[0][5]: E0041000, CID: B105900D, PID: 000BB925 ETM
Cortex-M4 identified.
J-Link>
- The JLinkRTTClient terminal should output something over the serial connection
Process: JLinkExe
Booting Zephyr OS build v2.3.0-rc1-ncs2
Hello World! nrf52dk_nrf52832