- 0 0
I love Nordic! How many chip makers support development tools based on free software officially!? Hats off to Nordic for making a difference! Most of the other manufacturers only provide software for Crapposoft's OS. Being an open source advocate, its such a pleasure now, to tag the other companies worthless, compared to what Nordic offers :P
Here is a short write up on how to setup a simple development & debug environment without having to depend on the beefy Eclipse based stuff!
nRF52832 Development Kit
pca10040, this development board comes with the nRF52832 which contains and ARM Cortex M4 microcontroller running at 64 MHz. Well, the most important thing is that this SoC contains the Bluetooth PHY as well, so this is as small a powerful microcontroller can get! I purchased it from Mouser.
Pretty straightforward actually. Most of the linux distros have the
arm-none-eabi-gcc package in their repositories, just search for them with your package manager and install it. I would not prefer downloading from Linaro's archives, since if you install the version in your repo, you will painlessly get updates as well. You also need to install the corresponding cross compiled packages for
GDB, Binutils etc., all of which must be in the repos.
Nordic provides software tools that work with GCC and Linux in general. Arch Linux has a User Repository, called AUR that contains some of the free-to-use software so that you can setup the environment painlessly.
Get the NRF5 SDK from Nordic. THis contains all you need to get started with the development board. Once installed, open the text file
components/toolchain/gcc/Makefile.posix and give set the variables appropriately. Mine Looks like:
GNU_INSTALL_ROOT := /usr GNU_VERSION := 6.3.0 GNU_PREFIX := arm-none-eabi
If you installed your toolchain to some non standard path, it should be reflected in this file.
nrfjprog that depends on
JLink software suite from Segger. These tools can be easily installed in arch linux from the AUR packages
nrf5x-command-line-tools. I use yaourt to install it, which just a one liner:
yaourt -S jlink nrf5x-command-line-tools. How sweet. No need to do look around in their website.
Once installed, plug your hardware and run
nrfjprog -i to check if your dev board is being detected.
No intro is complete without the venerable blinky. Go to the location where you installed the SDK and:
- Navigate to
Now you have the basic blinky compiled. Now:
That should program your Development board!
Now that you have flashed the firmware, next step is to ensure that you can do all things GDB with it. With your development board plugged in, open a terminal & run this:
JLinkGDBServer -if SWD -device nRF52832_xxAA
You will see the output as:
SEGGER J-Link GDB Server V6.14b Command Line Version JLinkARM.dll V6.14b (DLL compiled Mar 9 2017 08:48:20) -----GDB Server start settings----- GDBInit file: none GDB Server Listening port: 2331 SWO raw output listening port: 2332 Terminal I/O port: 2333 Accept remote connection: yes Generate logfile: off Verify download: off Init regs on start: off Silent mode: off Single run mode: off Target connection timeout: 0 ms ------J-Link related settings------ J-Link Host interface: USB J-Link script: none J-Link settings file: none ------Target related settings------ Target device: nRF52832_xxAA Target interface: SWD Target interface speed: 1000kHz Target endian: little Connecting to J-Link... J-Link is connected. Firmware: J-Link OB-SAM3U128-V2-NordicSemi compiled Mar 2 2017 12:22:13 Hardware: V1.00 S/N: 682774337 Checking target voltage... Target voltage: 3.30 V Listening on TCP/IP port 2331 Connecting to target...Connected to target Waiting for GDB connection...
Now the GDB server is up, and is listening for connections! Now open up another terminal and, and go to your the
armgcc directory. The compiled file will be present in the
_build directory. So, invoke the cross-compiled arm gdb:
You will be greeted with the GDB prompt. Now connect to the GDB server:
target remote :2331
Now you are connected and you can do all things GDB!
Put some break points, single step, reset, inspect or write registers, whatever you want!