【nRF52832】【环境搭建 1】【ubuntu下搭建nRF52832开发环境】

在这里插入图片描述

本文讲述如何在 ubuntu 22.04 下开发 nRF52832.

host 环境说明:

$ uname -a
Linux leo 6.8.0-60-generic #63~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Apr 22 19:00:15 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

1. 安装软件

sudo apt install gcc-arm-none-eabisudo apt-get install build-essential checkinstall

2. nRF5 SDK

1. 下载 SDK

Nordic官方对nRF51、nRF52系列提供了SDK,SDK中提供了大量的BLE和ANT示例。

1. SDK 15.3 版本

下载 15.3版本

将其解压:

leo@leo:~/data_4t/nrf_project/nrf5sdk153059ac345/nRF5_SDK_15.3.0_59ac345$ tree -L 2
.
├── components
│   ├── 802_15_4
│   ├── ant
│   ├── ble
│   ├── boards
│   ├── drivers_ext
│   ├── drivers_nrf
│   ├── iot
│   ├── libraries
│   ├── nfc
│   ├── proprietary_rf
│   ├── sdk_validation.h
│   ├── serialization
│   ├── softdevice
│   └── toolchain
├── config
│   ├── nrf52810
│   ├── nrf52811
│   ├── nrf52832
│   └── nrf52840
├── documentation
│   ├── index.html
│   ├── licenses.html
│   ├── licenses.txt
│   ├── NordicS.jpg
│   ├── nRF5_Garmin_Canada_license.txt
│   ├── nRF5_Nordic_license.txt
│   ├── nRF5x_series_logo.png
│   └── release_notes.txt
├── examples
│   ├── 802_15_4
│   ├── ant
│   ├── ble_central
│   ├── ble_central_and_peripheral
│   ├── ble_peripheral
│   ├── connectivity
│   ├── crypto
│   ├── dfu
│   ├── dtm
│   ├── iot
│   ├── multiprotocol
│   ├── nfc
│   ├── peripheral
│   ├── proprietary_rf
│   ├── readme.txt
│   └── usb_drivers
├── external
│   ├── cifra_AES128-EAX
│   ├── cJSON
│   ├── fatfs
│   ├── fnmatch
│   ├── fprintf
│   ├── freertos
│   ├── infineon
│   ├── licenses_external.txt
│   ├── lwip
│   ├── mbedtls
│   ├── micro-ecc
│   ├── nano
│   ├── nano-pb
│   ├── nfc_adafruit_library
│   ├── nrf_cc310
│   ├── nrf_cc310_bl
│   ├── nrf_oberon
│   ├── nrf_tls
│   ├── protothreads
│   ├── segger_rtt
│   ├── thedotfactory_fonts
│   └── utf_converter
├── external_tools
│   └── cmsisconfig
├── integration
│   └── nrfx
├── license.txt
├── modules
│   └── nrfx
├── nRF5x_MDK_8_24_1_IAR_NordicLicense.msi
└── nRF5x_MDK_8_24_1_Keil4_NordicLicense.msi64 directories, 14 files

2. SDK 17.1.0 版本

现在官网上最新的是 17.1.0 版本:

  • 下载
nRF5_SDK_17.1.0_ddde560$ tree -L 2
.
├── components
│   ├── 802_15_4
│   ├── ant
│   ├── ble
│   ├── boards
│   ├── drivers_ext
│   ├── drivers_nrf
│   ├── libraries
│   ├── nfc
│   ├── proprietary_rf
│   ├── sdk_validation.h
│   ├── serialization
│   ├── softdevice
│   └── toolchain
├── config
│   ├── nrf52810
│   ├── nrf52811
│   ├── nrf52820
│   ├── nrf52832
│   ├── nrf52833
│   └── nrf52840
├── documentation
│   ├── index.html
│   ├── licenses.html
│   ├── licenses.txt
│   ├── NordicS.jpg
│   ├── nRF5_Garmin_Canada_license.txt
│   ├── nRF5_Nordic_license.txt
│   ├── nRF5x_series_logo.png
│   └── release_notes.txt
├── examples
│   ├── 802_15_4
│   ├── ant
│   ├── ble_central
│   ├── ble_central_and_peripheral
│   ├── ble_peripheral
│   ├── connectivity
│   ├── crypto
│   ├── dfu
│   ├── dtm
│   ├── multiprotocol
│   ├── nfc
│   ├── peripheral
│   ├── proprietary_rf
│   ├── readme.txt
│   └── usb_drivers
├── external
│   ├── cifra_AES128-EAX
│   ├── cJSON
│   ├── fatfs
│   ├── fnmatch
│   ├── fprintf
│   ├── freertos
│   ├── infineon
│   ├── licenses_external.txt
│   ├── lwip
│   ├── mbedtls
│   ├── micro-ecc
│   ├── nano
│   ├── nano-pb
│   ├── nfc_adafruit_library
│   ├── nrf_cc310
│   ├── nrf_cc310_bl
│   ├── nrf_oberon
│   ├── nrf_tls
│   ├── protothreads
│   ├── segger_rtt
│   ├── thedotfactory_fonts
│   ├── tile
│   └── utf_converter
├── external_tools
│   └── cmsisconfig
├── integration
│   └── nrfx
├── license.txt
├── modules
│   └── nrfx
└── nRF_MDK_8_40_3_IAR_BSDLicense.msi65 directories, 13 files

2. 配置编译环境

15.3 版本和 17.1.0 版本我都验证了步骤是一样的:

修改如下文件:

  • components/toolchain/gcc/Makefile.posix
// 15.3
GNU_INSTALL_ROOT ?= /usr/bin/
GNU_VERSION ?= 7.3.1
GNU_PREFIX ?= arm-none-eabi
// 17.1.0  components/toolchain/gcc/Makefile.posix
GNU_INSTALL_ROOT ?= /usr/bin/
GNU_VERSION ?= 9.3.1
GNU_PREFIX ?= arm-none-eabi
  • GNU_INSTALL_ROOT : 主要配置交叉工具 按照目录, 编译时可以从当前目录中找 gcc.

查看安装目录:

leo@leo:~$ which arm-none-eabi-gcc
/usr/bin/arm-none-eabi-gcc

3. 编译

这里拿 一个官方跑马灯的例子来验证。

  • pca10040 : 我手里板子,对应官网的 PCA10040 型号
examples/peripheral/blinky/pca10040/blank/armgcc$ tree
.
├── blinky_gcc_nrf52.ld
└── Makefile0 directories, 2 files

在当前目录 make


examples/peripheral/blinky/pca10040/blank/armgcc$ make
mkdir _build
cd _build && mkdir nrf52832_xxaa
Assembling file: gcc_startup_nrf52.S
Compiling file: nrf_log_frontend.c
Compiling file: nrf_log_str_formatter.c
Compiling file: boards.c
Compiling file: app_error.c
Compiling file: app_error_handler_gcc.c
Compiling file: app_error_weak.c
Compiling file: app_util_platform.c
Compiling file: nrf_assert.c
Compiling file: nrf_atomic.c
Compiling file: nrf_balloc.c
Compiling file: nrf_fprintf.c
Compiling file: nrf_fprintf_format.c
Compiling file: nrf_memobj.c
Compiling file: nrf_ringbuf.c
Compiling file: nrf_strerror.c
Compiling file: nrfx_atomic.c
Compiling file: main.c
Compiling file: system_nrf52.c
Linking target: _build/nrf52832_xxaa.outtext	   data	    bss	    dec	    hex	filename2760	    112	    172	   3044	    be4	_build/nrf52832_xxaa.out
Preparing: _build/nrf52832_xxaa.hex
Preparing: _build/nrf52832_xxaa.bin
DONE nrf52832_xxaa# 编译结束leo@leo:~/data_4t/nrf_project/nrf5sdk153059ac345/nRF5_SDK_15.3.0_59ac345/examples/peripheral/blinky/pca10040/blank/armgcc$ tree -L 2
.
├── blinky_gcc_nrf52.ld
├── _build
│   ├── nrf52832_xxaa
│   ├── nrf52832_xxaa.bin
│   ├── nrf52832_xxaa.hex # 他就是我们要烧录进板子的 文件
│   ├── nrf52832_xxaa.in
│   ├── nrf52832_xxaa.map
│   └── nrf52832_xxaa.out
└── Makefile2 directories, 7 files

同样在 17.1.0 下的操作

leo@leo:~/data_4t/nrf_project/nRF5_SDK_17.1.0_ddde560/examples/peripheral/blinky/pca10040/blank/armgcc/_build$ tree -L 1
.
├── nrf52832_xxaa
├── nrf52832_xxaa.bin
├── nrf52832_xxaa.hex
├── nrf52832_xxaa.in
├── nrf52832_xxaa.map
└── nrf52832_xxaa.out1 directory, 5 files

3. 烧录

1. 软件安装

下载 nRF-Command-Line-Tools_10_9_0_Linux-amd64
https://www.nordicsemi.com/Products/Development-tools/nrf-command-line-tools/download#infotabs

在这里插入图片描述

解压:


nrfcommandlinetools1090linuxamd64$ tree
.
├── JLink_Linux_V680a_x86_64.deb
├── JLink_Linux_V680a_x86_64.tgz
├── nRF-Command-Line-Tools_10_9_0_Linux-amd64.deb
├── nRF-Command-Line-Tools_10_9_0.tar
└── README.txt0 directories, 5 files

安装:


# 第一步
sudo dpkg -i JLink_Linux_V680a_x86_64.deb# 第二步
sudo dpkg -i nRF-Command-Line-Tools_10_9_0_Linux-amd64.deb
  • 注意安装先后顺序

查看安装后的版本:

$ nrfjprog -v
nrfjprog version: 10.9.0 
JLinkARM.dll version: 6.80a$ JLinkExe -v
SEGGER J-Link Commander V6.80a (Compiled May 29 2020 16:30:49)
DLL version V6.80a, compiled May 29 2020 16:30:38
  • 如果能看到上面的信息,表示下载环境已经ok 了。

2. 连接板子

1. 硬件接线:

我这里使用 Jlink-v9 仿真器 SWD 接口和板子进行连接:

在这里插入图片描述


2. 软件侧

执行如下命令 :

JLinkExe -device NRF52 -if SWD -speed 4000 -autoconnect 1

如果有如下输出信息:表示已经识别到板子了。

SEGGER J-Link Commander V6.80a (Compiled May 29 2020 16:30:49)
DLL version V6.80a, compiled May 29 2020 16:30:38Connecting to J-Link via USB...O.K.
Firmware: J-Link V9 compiled May  7 2021 16:26:12
Hardware version: V9.70
S/N: 69706099
License(s): RDI, FlashBP, FlashDL, JFlash, GDB
VTref=3.261V
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>

3. 烧录

1. 方式1: 使用 Jlink 进行烧录

// 1. 首先输入上面的命令 连接板子:
JLinkExe -device NRF52 -if SWD -speed 4000 -autoconnect 1// 2. 擦除之前的程序
J-Link> erase
Erasing device...
Comparing flash   [100%] Done.
Erasing flash     [100%] Done.
J-Link: Flash download: Total time needed: 0.026s (Prepare: 0.015s, Compare: 0.000s, Erase: 0.007s, Program: 0.000s, Verify: 0.000s, Restore: 0.003s)
Erasing done.// 3. 烧录之前 编译的 跑马灯 程序
J-Link> loadfile nrf52832_xxaa.hex 
Downloading file [nrf52832_xxaa.hex]...
Comparing flash   [100%] Done.
Erasing flash     [100%] Done.
Programming flash [100%] Done.
J-Link: Flash download: Bank 0 @ 0x00000000: 1 range affected (4096 bytes)
J-Link: Flash download: Total: 0.092s (Prepare: 0.026s, Compare: 0.002s, Erase: 0.000s, Program & Verify: 0.052s, Restore: 0.011s)
J-Link: Flash download: Program & Verify speed: 76 KB/s
O.K.// 4. 退出, 此时 程序就开始执行了。
J-Link>exit

2. 方式2: nrfjprog 烧录

全片擦除 +下载+ 复位运行。

$ nrfjprog -f NRF52 --program ./IK-52832DK-V2-TEST.hex  --chiperase -rParsing hex file.
Erasing user available code and UICR flash areas.
Applying system reset.
Checking that the area to write is not protected.
Programming device.
Applying system reset.
Run.

4. nrfjprog 命令介绍

nrfjprog 是使用 J-Link 仿真器对 nRF5x 系列 SoC 进行编程的命令行工具。

1. 全片擦除

执行全片擦除后,会擦除片内所有 Flash 和掉电保持的寄存器。

// 擦除
$ nrfjprog -f NRF52 -eErasing user available code and UICR flash areas.
Applying system reset.

2. 下载

nrfjprog 的命令是可以组合的,对于程序下载,可以使用下面两种组合命令,注意他们
的区别。

1. 仅下载+复位运行:芯片必须是空的(擦除过的),否则下载会失败

$ nrfjprog -f NRF52 --program ./IK-52832DK-V2-TEST.hex Parsing hex file.
Reading flash area to program to guarantee it is erased.
Checking that the area to write is not protected.
Programming device.
  • 此时重新掉电启动即可

2.全片擦除 +下载+ 复位运行

$ nrfjprog -f NRF52 --program ./IK-52832DK-V2-TEST.hex  --chiperase -rParsing hex file.
Erasing user available code and UICR flash areas.
Applying system reset.
Checking that the area to write is not protected.
Programming device.
Applying system reset.
Run.
  • 我一般情况会使用这种方式烧录。

3.启用回读保护机制

nrfjprog -f NRF52 --rbp ALL

该命令执行后,无法使用仿真器通过 DEBUG 接口读出芯片的数据,当我们发布产品的
时候,可以通过启用回读保护防止别人读取芯片中烧写的固件,从而保护产品的权益不被侵犯。

3. 读出 SoftDevice 的 FWID

只有已经下载了 SoftDevice 的芯片才可以读出 FWID。

  • nRF51xx 系列命令:nrfjprog --family NRF51 --memrd 0x0000300C
  • nRF52xx 系列命令:nrfjprog --family NRF52 --memrd 0x0000300C
$ nrfjprog --family NRF52 --memrd 0x0000300C
0x0000300C: FFFF00AF    
  • 所示,读出的数据是:0xFFFF00AF,表示协议栈的 FWID 是 0xAF,根据 FWID 即可知道
    协议栈的版本(FWID 在固件更新 DFU 中会用到)

4. 恢复

恢复:全片擦除并禁用回读保护机制(如果启用)
命令:nrfjprog -f NRF52 -recover
该命令执行后,会擦除片内所有 Flash 和掉电保持的寄存器。

5. ps

本文档 所涉及的软件包我已经打包,请点击下载。

  • nRF52832-ubuntu-开关环境资源打包
nrf-52832-env-soft$ tree
.
├── IK-52832DK-V2-TEST.hex
├── nrf52832_xxaa.hex
├── nrf5sdk153059ac345.zip
└── nrfcommandlinetools1090linuxamd64.tar.gz
$ md5sum nrf-52832-env-soft.7z
b61a6911bab6684f9721648740448926  nrf-52832-env-soft.7z

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.tpcf.cn/web/86250.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【Nginx】403 Forbidden错误

当 Nginx 代理配置出现 403 Forbidden 错误时,通常是由于权限或配置问题导致。以下是常见原因和解决方案: 常见原因及解决方法 1. 后端服务器拒绝访问 原因:后端 HTTPS 服务配置了 IP 白名单或访问控制解决: 检查后端服务器&…

详解 `pip install -e .` 命令【PythonLinux】

详解 pip install -e . 命令 pip install -e . 是 Python 开发中一个非常有用的命令,用于以"可编辑"或"开发"模式安装当前目录中的 Python 包。 命令分解 pip: Python 的包管理工具install: pip 的子命令,用于安装包-e: 是 --edi…

将VSCode的配置迁移到Cursor

目录 方式一:一键导入配置 1.适用场景 2.导入前的配置 3.导入步骤 4.查看导入效果 5.原理 6.注意 方式二:手动迁移配置文件 1.使用场景 2.导入步骤 3.注意 方式一:一键导入配置 1.适用场景 VSCode和Cursor这两个编辑器&#xff0…

大规模流媒体系统架构实践

📋 文章目录 系统概述 - 流媒体系统的基本挑战整体架构设计 - 分层架构与核心组件接入层设计 - CDN与负载均衡策略处理层架构 - 实时转码与分发存储层优化 - 多级缓存与热点数据监控与运维 - 全链路监控体系实战经验总结 - 踩坑指南与最佳实践 🎬 系统概…

Vue 3 + Vite 项目 px 转 vw 完整使用指南

Vue 3 Vite 项目 px 转 vw 完整使用指南 🚀 第一步:插件安装 1.1 安装命令 # 使用 npm 安装 npm install postcss-px-to-viewport-8-plugin --save-dev# 或使用 yarn 安装 yarn add postcss-px-to-viewport-8-plugin --dev# 或使用 pnpm 安装 pnpm a…

setsate()使用详解原理及注意事项

📚 Flutter 状态管理系列文章目录 Flutter 状态管理(setState、InheritedWidget、 Provider 、Riverpod、 BLoC / Cubit、 GetX 、MobX 、Redux) setState() 使用详解:原理及注意事项 InheritedWidget 组件使用及原理 Flutter 中 Provider 的使用、注…

ffmpeg环境配置

ffmpeg是一个跨平台功能强大的音视频处理工具。它不仅能够进行音视频的转换、剪切、合并等操作,还支持多种音视频格式的解码和编码。无论是处理高清视频还是音频文件,ffmpg都能提供高效且稳定的服务。其丰富的参数设置和插件支持,使得用户可以…

Lamp和友点CMS一键部署脚本(Rocky linux)

先上传youdiancms9.3.0.zip包,可以去官网下载 #!/bin/bash #function:install apache mysql php for youdiancms9.3.0ip$(hostname -I | awk {print $1}) yhyoudian passwordyoudian123#检查是否为root用户 if [ "$USER" ! "root" ]; thenecho…

Arm架构下麒麟V10桌面版安装MySQL

Arm架构下麒麟V10桌面版安装MySQL 文章目录 Arm架构下麒麟V10桌面版安装MySQL基础环境下载安装包安装步骤**一、准备工作****二、解压并配置 MySQL****三、初始化 MySQL****四、启动 MySQL 服务****五、设置环境变量****六、配置 MySQL****七、验证安装****常见问题****总结** …

Science Advances:皮肤附着触觉贴片,实现多功能和增强的触觉交互

可穿戴触觉界面可以通过向皮肤添加触觉刺激以及传递给用户的视觉和听觉信息来增强虚拟/增强现实系统中的沉浸式体验。研究人员介绍了一种平锥介电弹性体致动器(FCDEA)阵列,该阵列薄而柔软,能够响应大面积皮肤上的电压信号产生时空…

Ntfs!LfsGetLbcb函数分析之nt!CcPreparePinWrite

Ntfs!LfsGetLbcb函数分析之nt!CcPreparePinWrite 第一部分: 1: kd> p Ntfs!LfsPrepareLfcbForLogRecord0x78: f7179d72 e891210000 call Ntfs!LfsGetLbcb (f717bf08) 1: kd> t Ntfs!LfsGetLbcb: f717bf08 6a40 push 40h 1: kd> kc …

面试150 整数转罗马数字

思路 建立数字和字符的字典映射表&#xff0c;遍历映射表做差&#xff0c;将字符添加到结果中&#xff0c;当差为0的时候&#xff0c;break退出循环。返回最后的结果output class Solution:def intToRoman(self, num: int) -> str:if num<1:return num_to_map[(1000,M)…

大模型推理-高通qnn基础

一、高通ai 软件的介绍 QualcommAI Engine Direct SDK(qnn) 提供较低级别、高度可定制的统一API&#xff0c;通过单独的库加速所有AI加速器核心上的AI模型, 可以直接用于针对特定的加速器核心或从流行的运行时&#xff08;包括Qualcomm Neural Processing SDK、TensorFlow Li…

UE5 - 制作《塞尔达传说》中林克的技能 - 14 - 技能面板

让我们继续《塞尔达传说》中林克技能的制作&#xff01;&#xff01;&#xff01; UE版本&#xff1a;5.6.0 VS版本&#xff1a;2022 本章节的核心目标&#xff1a;技能面板 先让我们看一下完成后的效果&#xff1a; 第14章效果 本章节项目链接&#xff1a; 通过网盘分享的文件…

用Tensorflow进行线性回归和逻辑回归(八)

新的TensorFlow概念 创建简单的机器学习系统需要学习一些新的概念。 优化器 上两节介绍的元素已经提示了TensorFlow是如何完成机器学习的。你已学习了如何用张量操作来定义损失函数。缺少的是你不知道如何用TensorFlow进行梯度下降。尽管可以用TensorFlow元素直接用 Python定…

基于python代码的通过爬虫方式实现TK下载视频(2025年6月)

Tk的视频页面通常需要登录才能获取完整数据,但通过构造匿名游客的请求,我们可以绕过登录限制,提取视频的元信息(如标题、ID和播放地址)。核心思路如下: 构造匿名Cookie:通过模拟浏览器的请求,获取Tk服务器分配的游客Cookie。解析网页:利用BeautifulSoup解析HTML,定位…

火山 RTC 引擎14 设置CB

一、火山RTC引擎集成时,设置CB 1、统一设置 void NRTCEngine::SetByteRtcCBS() {UserPublishStreamCallback callback = [this](const std::string& roomId, const std::string& uid, bytertc::MediaStreamType type) {this->OnSigUserPublishStream(roomId, uid, …

BUUCTF在线评测-练习场-WebCTF习题[极客大挑战 2019]PHP1-flag获取、解析

解题思路 打开靶场&#xff0c;提示备份 常见的备份后缀名有.bak&#xff0c;.backup&#xff0c;.zip等等 这里肯定是要扫目录了&#xff0c;不知道是我的问题还是目录扫描工具的问题还是BUUCTF的问题&#xff0c;每次要扫目录能扫出一堆东西来&#xff0c;不管你用什么后缀…

对话云蝠智能:大模型如何让企业呼叫系统从 “成本中心” 变身 “价值枢纽”?

在人工智能重塑企业服务的浪潮中&#xff0c;云蝠智能&#xff08;南京星蝠科技有限公司旗下品牌&#xff09;以深厚的技术积累和行业实践&#xff0c;逐步成长为国内智能外呼领域的标杆企业。其发展路径揭示了技术自主创新与场景深度结合的必然性。 一、技术架构&#xff1a;全…

Python-文件管理

1. Open方法 Python 中的文件操作主要通过内置的 open() 函数来完成&#xff0c;该函数用于打开文件&#xff0c;并返回一个文件对象。通过文件对象&#xff0c;可以进行各种文件操作&#xff0c;如读取、写入、关闭等。 使用 open() 方法一定要保证关闭文件对象&#xff0c;即…