My Workflow: Setting up nRF52 DK Development Environment on Apple Silicon (M4 Pro)

Post Title Image (Illustration: Unbox Apple MacBook Pro M4 Pro and reMarkable Paper Pro. Taken at AWS re:Invent 2024, Las Vegas. Image source: Ernest)

Today I spent some time setting up a development environment for the nRF52 DK (PCA10040) board on my macOS Sequoia 15.1.1 machine running on an Apple Macbook Pro M4 Pro (Apple Silicon). This blog post documents the process and can serve as a reference for anyone working with Nordic Semiconductor’s nRF52 DK (development kit).

Workflow

Here’s a conceptual flow diagram of the nRF52 DK development environment setup process covered in this article:

flowchart TD A[Start Setup] --> B[Install Prerequisites] B --> B1[Xcode Command Line Tools] B --> B2[Homebrew] B1 & B2 --> C[Install Core Tools] C --> C1[GNU Arm Embedded Toolchain] C --> C2[Install nrfutil Components] C --> C3[Install Optional Tools] C1 --> C1a[gcc-arm-embedded] C2 --> C2a[nrf5sdk-tools] C2 --> C2b[device] C2 --> C2c[completion] C3 --> C3a[OpenOCD] C1a & C2a & C2b & C2c & C3a --> F[Verify Installation] F --> F1[Verify arm-none-eabi-gcc] F --> F2[Verify nrfjprog] F --> F3[Check Device Connection] F1 & F2 & F3 --> G[Development Environment Ready] %% Set background color style C1 fill:#f9d5e5,stroke:#333,stroke-width:1px style C2 fill:#d5f9e5,stroke:#333,stroke-width:1px style C3 fill:#d5e5f9,stroke:#333,stroke-width:1px

This flowchart demonstrates the complete path from installing prerequisites to having a ready development environment. Follow this workflow to set up a complete nRF52 DK development environment. The main steps include installing basic tools first, followed by Nordic-specific development tools, and finally verifying successful installation.


Prerequisites

Before diving into the setup, make sure you have these essential components installed:

  • Xcode Command Line Tools: Installed via xcode-select --install
  • Homebrew: The package manager for macOS

Installation Process

GNU Arm Embedded Toolchain

Homebrew has a pre-packaged gcc-arm-embedded:

brew install --cask gcc-arm-embedded

After installation, verify that it’s correctly installed:

$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (Arm GNU Toolchain 14.2.Rel1 (Build arm-14.52)) 14.2.1 20241119
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ make -v
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0

Important: Do not install arm-none-eabi-gcc. Install gcc-arm-embedded to avoid compatibility issues.


nRF Util (nrfutil)

nRF Util is a command-line tool that integrates various Nordic functionalities:

  1. Download the latest version from Nordic Semiconductor nRF Util official webpage. It should be version 7.0.0 or higher. Currently, this step can’t be done using homebrew or pip - you need to download it from the official website. (Don’t use pip for installation, as it will only get you the old version v5.2.0. Nordic has completely rewritten nrfutil.)

  2. Then set it up with these commands:

$ cd Downloads
$ chmod +x nrfutil
$ ./nrfutil --version
$ sudo mv nrfutil /usr/local/bin

$ nrfutil --version
nrfutil 7.12.0 (39003c9 2024-06-10)
commit-hash: 39003c9d0e5d946af0f417cfadf4ac55a6d03c19
commit-date: 2024-06-10
host: aarch64-apple-darwin
build-timestamp: 2024-06-10T15:50:53.137997000Z
classification: nrf-external

Next, use nrfutil to install additional components:

$ nrfutil install nrf5sdk-tools
$ nrfutil install device
$ nrfutil install completion
$ nrfutil completion install zsh

You can also install all components at once:

$ nrfutil install nrf5sdk-tools; nrfutil install device; nrfutil install completion; nrfutil completion install zsh

After installation, add the following to your .zshrc file for command auto-completion:

# From nrfutil completion install
[[ -r "${HOME}/.nrfutil/share/nrfutil-completion/scripts/zsh/setup.zsh" ]] && . "${HOME}/.nrfutil/share/nrfutil-completion/scripts/zsh/setup.zsh"

# Initialize zsh completion system
autoload -Uz compinit
compinit

Verify successful installation - you should have the nrfjprog tool available:

$ nrfjprog -v
nrfjprog version: 10.24.2 external
JLinkARM.dll version: 8.16

Check if your nRF52 DK device is recognized:

$ nrfutil device list
682629006
product         J-Link
board version   PCA10040
ports           /dev/tty.usbmodem0006826290061
traits          devkit, jlink, seggerUsb, serialPorts, usb

Found 1 supported device(s)

OpenOCD (Optional)

For on-chip debugging capabilities, you can install OpenOCD:

brew install open-ocd

Reference Information about nRF SDK

nRF5 SDK v.s nRF Connect SDK

It’s worth noting that the nRF5 SDK is now in maintenance mode, and Nordic Semiconductor recommends using the nRF Connect SDK for new projects:

  • nRF Connect SDK is a unified SDK for building products based on nRF52, nRF53, nRF70, and nRF91 Series devices
  • It integrates the Zephyr RTOS with various samples, protocols, and drivers
  • The SDK is publicly hosted on GitHub and supports the free nRF Connect for VS Code IDE
  • 👉 nRF Connect SDK and nRF5 SDK statement - Nordic Blog

I have several existing projects developed with nRF5 SDK, but in the future I might need to explore nRF Connect SDK.


Key Features of nRF Util

nRF Util provides several useful commands:

nrfutil nrf5sdk-tools command

Provides functionality from previous versions of nrfutil including:

  • Device firmware update (DFU) package generation
  • Cryptographic key management
  • Bootloader settings generation
  • DFU procedures over various transports (BLE, UART, USB, Thread, Zigbee)

nrfutil device command

  • Listing connected devices
  • Programming devices
  • Erasing and recovery operations
  • Various device management tasks

nrfutil completion command

Makes it easier to use nrfutil commands through command auto-completion in your shell.


Deprecated Tools

The nRF Command Line Tools are being archived and gradually replaced by the new version of nRF Util (> v7.0.0). While they can still be installed with:

brew install --cask nordic-nrf-command-line-tools

It’s recommended to use the new version of nRF Util (> v7.0.0) for all new development work.


Bottom Line

With these tools installed, I now have a complete (hopefully, haha) development environment for working with the nRF52 DK board on macOS (Apple Silicon). Next, I can revisit some of my previous projects.

The migration from nRF5 SDK to nRF Connect SDK represents an important shift in Nordic’s development ecosystem, offering better integration, more features, and broader device support. For any new projects, I’ll be following Nordic’s recommendation to use the nRF Connect SDK rather than the older nRF5 SDK. Since I have some existing projects using nRF5 SDK, it looks like I’ll need to spend some time exploring nRF Connect SDK in the future.