This repository contains information on the communication between the ground robot 3pi+
, the nrf52840 dongle
, and the Crazyradio 2.0
.
- goal: establish a communication between the
3pi+ robot
and theCrazyradio 2.0
via thenrf52840 dongle
in order to control the3pi+ robot
from theCrazyradio 2.0
for experiments - members:
julien
,dennis
- system overview:
3pi+ <==> nrf52840 dongle <==> Crazyradio 2.0 (PC)
- task assignment:
julien
- working out the details of programming the
3pi+ robot
- get the information on UART communication for the
3pi+ robot
- porting the code from the summer school to the
3pi+ robot
- working out the details of programming the
dennis
- working out the details of programming the
nrf52840 dongle
- get the information on UART communication for the
nrf52840 dongle
- work out the details of radio communication between the
nrf52840 dongle
and theCrazyradio 2.0
- working out the details of programming the
This section contains helpful information on the nrf52840 dongle
that has been gathered during the project.
Note: The following information applies to Windows. The installation steps may vary for other operating systems but this will be mentioned in the referenced materials.
The dongle can be powered in two ways:
- USB power supply
- External power supply
External power can be connected to the pin VDD OUT
of the nrf52840 dongle
. The allowed voltage ranges from 1.8V to 3.6V with a maximum current of 50mA. On the nrf52840 dongle
, the nrf52840
is configured in high voltage mode. To enable an external regulated source you will have to cut the board pad SB2
and solder SB1
. [1]
The nrf52840
can operate in two modes [2]:
- High voltage mode: Supply voltage ranges from 2.5V to 5.5V with a typical voltage of 3.7V.
- Normal voltage mode: Supply voltage ranges from 1.7V to 3.6V with a typical voltage of 3.0V.
After correctly configuring the nrf52840 dongle
, it could be connected to the pin 3V3
pin of the 3pi+ robot
. The 3pi+ robot
provides a regulated 3.3V supply voltage when powered by the battery or USB port. When supplied by a battery, it is able to deliver up to 1.5A via the 3V3
pin. [3]
The nrf52840 dongle
provides two UART interfaces, UARTE0
and UARTE1
.
UARTE0
: id=2
UARTE1
: id=40
The UART pins have to be configured for the nrf52840
. Here is the pin list:
RTS
CTS
TXD
RXD
The nrf52840 dongle
can be programmed by using VS Code and the extension nRF Connect for VS Code Extension Pack
. Please follow the following steps which are also outlined here:
- Install the package
nRF Command Line Tools
for your operating system. - Install the programm
nRF Connect for Desktop
for your operating system. You can find it here - Proceed with installing the VS Code extension
nRF Connect for VS Code Extension Pack
. - Open the
nRF Connect for VS Code Extension Pack
by clicking on the icon in the left sidebar. You can now install the toolchain and SDK. I donwloaded the newest version of both which was2.6.0
. This may take a while. You can find more information here. - After installing the toolchain and nRF SDK, you can browse and open a sample. I used the
blinky
example to test the flashing process. - Build the project by adding a build configuration. To build programs for the
nrf52840 dongle
the board namenrf52840dongle_nrf52840
has to be used. You can leave the optimization level as it is for now. This will become important when debugging the program later. - The built programm will be located in the
build
directory of the project, e.g.build\zephyr\zephyr.hex
. Other files like.bin
or.elf
are also available. - Flash the application
build\zephyr\zephyr.hex
to thenrf52840 dongle
using thenRF Connect for Desktop
tool.- You will need to connect the
nrf52840 dongle
to your computer's USB port and press the reset button to switch into bootloader mode [1]. - Open the
nRF Connect for Desktop
tool and select theProgrammer
tab. - Select the connected device.
- Add the hex file and write it to the device.
- Your device should now be flashed with the new application and a green LED should blink on the
nrf52840 dongle
.
- You will need to connect the
The nrf52840 dongle
does not feature a built-in debugger-chip. However, the nrf52840 dongle
can be debugged using the J-Link EDU Mini
debugger which targets 3.3V platforms. The debugger can be connected to the nrf52840 dongle
using the SWD
interface. The SWD
interface is located on the backside of the nrf52840 dongle
. You can use the 10-pin ribbon cable and a USB hub to connect the debugger to the nrf52840 dongle
[4]. Image of the setup are given in the following.
To debug the nrf52840 dongle
using the J-Link EDU Mini
debugger, you will need to follow the these steps:
-
Copy the above hardware setup for the
nrf52840 dongle
and theJ-Link EDU Mini
debugger. Please first power up both devices and afterward connect the 10-pin ribbon cable to theSWD
interface of thenrf52840 dongle
and theJ-Link EDU Mini
debugger. The order of connecting the devices may cause problems. -
Install another version of the
J-Link
software on your computer. [5]. I downloadedV7.96
and checked the box to additionally install the USB driver. Having multiple versions of theJ-Link
software installed on your computer is not a problem. I was required to follow this step on my Windows laptop due to connection issues with theJ-Link EDU Mini
debugger. For now I am using theJ-Link
version that came with thenRF Connect for Desktop
tool which isV7.94e
. -
Open the
J-Link Commander
tool and typeconnect
in order to connect to theJ-Link EDU Mini
debugger. You can find theJ-Link Commander
tool in theJ-Link
software folder. [6] You will be prompted for more information afterward. You can find it below.- target device:
nRF52840_xxAA
- target interface:
SWD
- target frequency:
8000
[2]
The terminal should look like this if the connection was successful:
Connecting to target via SWD InitTarget() start InitTarget() end - Took 5.20ms Found SW-DP with ID 0x2BA01477 DPIDR: 0x2BA01477 CoreSight SoC-400 or earlier 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 [0][0]: E000E000 CID B105E00D PID 000BB00C SCS-M7 [0][1]: E0001000 CID B105E00D PID 003BB002 DWT [0][2]: E0002000 CID B105E00D PID 002BB003 FPB [0][3]: E0000000 CID B105E00D PID 003BB001 ITM [0][4]: E0040000 CID B105900D PID 000BB9A1 TPIU [0][5]: E0041000 CID B105900D PID 000BB925 ETM Memory zones: Zone: "Default" Description: Default access mode Cortex-M4 identified.
You can close the
J-Link Commander
tool after successfully verifying the connection. - target device:
-
Open the VS Code and install the extension
Cortex-Debug
[8] as we will follow the debugging steps outlined in [7]. -
Download and unpack the
ARM GNU Toolchain
[9] for your operating system. Thenrf52840
features anARM Cortex-M4
32-bit processor [2]. I have downloaded the Windows (mingw-w64-i686) hosted cross toolchain for AArch32 bare-metal target (arm-none-eabi
). -
Open VS Code and click on the icon
Run and Debug
to create alaunch.json
file. You can select theCortex-Debug
configuration. -
Add the following configuration to the
launch.json
file:{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Cortex Debug", "cwd": "${workspaceFolder}", "executable": "C:\\ncs\\v2.6.0\\zephyr\\samples\\basic\\blinky\\build\\zephyr\\zephyr.elf", "request": "launch", "type": "cortex-debug", "runToEntryPoint": "main", "servertype": "jlink", "serverpath": "C:\\Program Files\\SEGGER\\JLink_V794e\\JLinkGDBServerCL.exe", // "serverargs": "", "device": "nRF52840_xxAA", "interface": "swd", // "showDevDebugOutput": "raw", // "serialNumber": "", //If you have more than one J-Link probe, add the serial number here. // "jlinkscript":"${workspaceFolder}/BSP/SEGGER/K66FN2M0_emPower/Setup/Kinetis_K66_Target.js", // "svdFile": "${workspaceFolder}/SVD/MK66F18.svd", "armToolchainPath": "C:\\Users\\denni\\Downloads\\arm-gnu-toolchain-13.2.rel1-mingw-w64-i686-arm-none-eabi\\arm-gnu-toolchain-13.2.Rel1-mingw-w64-i686-arm-none-eabi\\bin" } ] }
The
armToolchainPath
should point to the location of thearm-none-eabi
toolchain on your computer. Theexecutable
should point to the.elf
file of the project you want to debug. Theserverpath
should point to theJLinkGDBServerCL.exe
file of theJ-Link
software. -
If you haven't already, build your application with the optimization level
-Og
to enable debugging symbols in thebuild\zephyr\zephyr.elf
file. -
Add a breakpoint to your code and start the debugging process by clicking on the
Run and Debug
icon in VS Code. The program should stop at the breakpoint and you can now debug your application.
Note: Please do not accidentally disconnect the
nrf52840 dongle
,J-Link EDU Mini
debugger or any other part of the hardware setup while debugging. This could brick thenrf52840 dongle
and you will have to restore its functionality afterward to use it again. Always stop the debugging process before disconnecting the devices.
- Test debugging using
Cortex-Debug
- Find an UART example for the
nrf52840 dongle
- Find an UART example for the
3pi+ robot
- Solder jumper cables to the
nrf52840 dongle
and3pi+
for UART communication - Adjust UART communication programs on both sides
- Test UART communication between the
nrf52840 dongle
and the3pi+ robot
- Move to radio communication between the
nrf52840 dongle
and theCrazyradio 2.0
- ...