Mac OS X 下搭建nRF51822开发环境

Step1 下载SDK
下载地址:http://developer.nordicsemi.com/
当前最高版本是 V10
解压zip包到某个项目目录

Step2 下载交叉编译工具
gcc-arm-none-eabi-9-2019-q4-major-mac.tar.bz2
下载地址 https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads

我解压到了 /usr/local/gcc-arm-none-eabi-9-2019-q4-major

Step3 下载安装Nordic官方nrfjprog
下载地址 https://www.nordicsemi.com/Software-and-tools/Development-Tools/nRF-Command-Line-Tools/Download
下载的是 nRF-Command-Line-Tools_10_5_0_OSX.tar

Step4 配置编译工具路径
打开 /..../nRF51_SDK_10.0.0_dc26b5e/components/toolchain/gcc/Makefile.posix
改为:

1
2
3
GNU_INSTALL_ROOT := /usr/local/gcc-arm-none-eabi-9-2019-q4-major
GNU_VERSION := 9.2.1
GNU_PREFIX := arm-none-eabi

编译例程代码
进入demo目录

1
2
...../nRF51_SDK_10.0.0_dc26b5e/examples/ble_peripheral/ble_app_template/pca10028/s110/armgcc
make

烧录

清空数据
nrfjprog --eraseall

烧录hex文件
nrfjprog --program /path-to-hex-file.hex
出现以下表示烧录成功

1
2
3
4
Parsing hex file.
Reading flash area to program to guarantee it is erased.
Checking that the area to write is not protected.
Programing device.

也可以使用Makefile中提供的方法

#烧录 softdevice
make flash_softdevice

#烧录application
make flash

文章目录