NRF52x开发环境搭建详解
NRF52x开发环境搭建详解
- 准备
- 环境搭建
- 了解内存布局
- Bootloader工程
- APP工程
- JFlash下载
- 打印log
准备
以下是项目开发环境搭建的一些文档或工具链接:
项目 | 链接 |
---|---|
CPU | nrf52810 |
协议栈 | s112 |
SDK | nRF5_SDK_15.3.0_59ac345.zip |
SDK doc | nRF5_SDK_15.3.0_offline_doc.zip |
IDE | Keil uVision 5 |
ide support pack | nRF_DeviceFamilyPack.8.24.1 |
nrfutil | nrfutil |
下载/log打印工具 | JFlash |
nRF Command Line Tools | nRF Command Line Tools |
蓝牙uart | juma uart.apk |
官方调试工具 | nRF Toolbox, nRF Connect(通过nRF Toolbox的插件功能下载安装) |
工具源码/文档 | nRF Toolbox源码, nRF Connect |
软件工具链 | Software tools |
下载nRF5_SDK_15.3.0_offline_doc.zip 后解压,以下部分参考说明是在离线文档中的链接。
环境搭建
参考 nRF5_SDK_15.3.0_offline_doc\nrf5\nrf52810_user_guide.html
了解内存布局
参考 nRF5_SDK_15.3.0_offline_doc\nrf5\lib_bootloader.html
The following figure shows the default memory layout for nRF52 devices, where nRF52832 has a flash size of 512 kB, nRF52840 has a flash size of 1024 kB, and nRF52810 has a flash size of 192 kB:
Note
The size of the bootloader is fixed for the lifetime of the device. This is because the location (MBR_BOOTLOADER_ADDR) that stores the start address of the bootloader is not (safely) updateable. See the SoftDevice Specification for more information.
我们需要定制的是 bootloader 与 application。
Bootloader工程
选用工程文件:nRF5_SDK_15.3.0\examples\dfu\secure_bootloader\pca10040e_ble\arm5_no_packs
编译步骤参考 nRF5_SDK_15.3.0_offline_doc\nrf5\ble_sdk_app_dfu_bootloader.html
或者参考博客 Nordic–nrf52832–DFU(二)Sercure DFU bootloader
内存参数配置如下(使用默认工程配置,如需修改请参考协议栈文档以及芯片ROM分配表):
APP工程
选用工程文件:nRF5_SDK_15.3.0_beyond\examples\ble_peripheral\ble_app_uart\pca10040e\s112\arm5_no_packs
参考文档 nRF5_SDK_15.3.0_offline_doc\nrf5\nrf52810_user_guide.html
内存参数配置如下(使用默认工程配置,如需修改请参考协议栈文档以及芯片ROM分配表):
JFlash下载
开发过程中可以使用 nRFgo Studio下载或keil5下载,但使用bootloader+app的方式最好使用JFlash(SEGGER J-Flash V6.32或更新的版本)下载;
- 制作合并bin档
详情请参考网址: https://github.com/NordicSemiconductor/pc-nrfutil/
命令如下:
nrfutil settings generate --family NRF52810 --application .\release\mini_car.hex --application-version 1 --bootloader-version 1 --bl-settings-version 2 .\release\settings.hex
mergehex.exe -m .\release\bootloader.hex .\release\s112_nrf52_6.1.1_softdevice.hex -o .\release\two_in_one.hex
mergehex.exe -m .\release\two_in_one.hex .\release\mini_car.hex -o .\release\three_in_one.hex
mergehex.exe -m .\release\three_in_one.hex .\release\settings.hex -o .\release\beyond_car_v2.hex
nrfutil pkg generate --hw-version 1 --sd-req 0xB8 --application-version 1 --application .\release\mini_car.hex --key-file .\key\beyond.pem .\release\mini_car_dfu_package_v2.zip
注意 --family 参数, nrf52832 使用 NRF52, nrf52810 使用 NRF52810,否则jflash下载ROM区域报错
一些说明:
The --family setting depends on the nRF IC that you are targeting:
nRF IC | Family Setting |
---|---|
nRF51xxx | NRF51 |
nRF52832 | NRF52 |
nRF52832-QFAB | NRF52QFAB |
nRF52810 | NRF52810 |
nRF52840 | NRF52840 |
The --bl-settings-version depends on the SDK version used. Check the following table to find out which version to use:
SDK Version | BL Settings Version |
---|---|
12.0 - | 1 |
15.3.0 - | 2 |
The Bootloader DFU settings version supported and used by the SDK you are using can be found in nrf_dfu_types.h in the bootloader library. Even though bootloaders compiled from nRF5 SDK 15.3.0 and higher only use version 2, they can be configured to support settings pages of version 1. If a new bootloader boots with a version 1 settings page, the bootloader will translate the settings page to version 2 before booting. When using settings page version 2, boot validation for SD and APP can be generated with the settings page using the --sd-boot-validation and --app-boot-validation in the same way as for DFU packages.
我们可以在编译链接后执行生成合并bin的脚本:
固件编译后执行脚本的情况:
PS.在此要注意自定义批处理相对路径的问题
执行结果输出如下图所示:
完整的批处理文件:
rem //切换到工作目录
cd /d ..\..\..\..\..\..\output\rem //准备好源文件
del .\hex\release\*.hex
del .\hex\release\*.zip
copy .\hex\mini_car.hex .\release
copy .\hex\bootloader.hex .\release
copy ..\components\softdevice\s112\hex\s112_nrf52_6.1.1_softdevice.hex .\releaserem //生成dfu升级包
nrfutil pkg generate --hw-version 52 --sd-req 0xB8 --application-version 1 --application .\release\mini_car.hex --key-file .\key\mykey.pem .\release\mini_car_dfu_package_v2.zipnrfutil settings generate --family NRF52810 --application .\release\mini_car.hex --application-version 1 --bootloader-version 1 --bl-settings-version 2 .\release\settings.hexrem //合并bin
mergehex.exe -m .\release\settings.hex .\release\mini_car.hex -o .\release\two_in_one.hex
mergehex.exe -m .\release\two_in_one.hex .\release\bootloader.hex -o .\release\three_in_one.hex
mergehex.exe -m .\release\three_in_one.hex .\release\s112_nrf52_6.1.1_softdevice.hex -o .\release\beyond_car_v2.hexrem //清除中间文件
del .\release\settings.hex
del .\release\bootloader.hex
del .\release\mini_car.hex
del .\release\two_in_one.hex
del .\release\three_in_one.hex
del .\release\s112_nrf52_6.1.1_softdevice.hex
各项参数也可以参考下列命令提示填写:
nrfutil settings generate --help
nrfutil pkg generate --help
- 下载
生成bin档后通过JFlash下载步骤:
step1:
step2:
step3:
下载过程中出现错误,很可能与内存分配错误有关系,请详细核对,最好就是直接使用默认工程配置。
打印log
对于嵌入式开发来说,log打印的重要性不言而喻。
参见博文 J-LINK RTT 和 NRF_LOG
APP固件工程中的配置
JLink RTT端的配置
选择正确的芯片配置:
代码使用说明
在工程代码里通过RTT终端打印宏定义如下:
#if DEBUG_PRINT == 1
#define debug_print(...) SEGGER_RTT_printf(0,__VA_ARGS__)
#else
#define debug_print(...)
#endif
使用示例:
debug_print("a=%d,bstr=%s\r\n",111,"hello world!!!");
由于我的设备是机器人小车,所以移动状态下,采用蓝牙uart输出调试信息是一个不错的选择,蓝牙宏定义如下:
uint8_t send_str_buff[20];//字符缓冲区#define ble_uart_print(...) do { \uint16_t length = 0; \extern uint8_t send_str_buff[]; \sprintf(send_str_buff, __VA_ARGS__); \length = strlen(send_str_buff) + 1; \ble_nus_data_send(&m_nus, send_str_buff, &length, m_conn_handle); \
} while(0)
使用示例:
ble_uart_print("a=%d,bstr=%s",111,"hello world!!!");
手机端使用 juma uart.apk 或者 nRF Toolbox的UART功能接收数据。
NRF52x开发环境搭建详解相关推荐
- Java开发环境搭建详解
Java开发环境搭建详解 http://topic.csdn.net/u/20110829/13/BF4FAA45-3E1A-48A8-BC46-0405B7F862A2.html 一.jdk安装与 ...
- linux上 arm开发环境搭建,详解 LINUX下QT For ARM开发环境搭建过程
LINUX下QT For ARM开发环境搭建过程是本文介绍的内容,不多说,先来看内容.在PC上,我们需要得到两个版本的Qt,分别是:Qt-4.5.2和QtEmbedded-4.5.2-arm.前者包括 ...
- 从零开始:小程序开发环境搭建详解
文章目录 人工智能福利文章 前言 一.了解小程序 二.小程序开发环境搭建 开发工具 开发环境 三.小程序开发入门 注册开发者账号 下载小程序开发工具 创建小程序项目 开发小程序页面 调试和测试小程序 ...
- webpack搭建php服务器,webpack搭建react开发环境步骤详解
这次给大家带来webpack搭建react开发环境步骤详解,webpack搭建react开发环境的注意事项有哪些,下面就是实战案例,一起来看一下.mkdir react-redux && ...
- DAMP环境搭建详解 DAMP----Debian Apache2 Mysql PHP5
DAMP环境搭建详解 DAMP----Debian Apache2 Mysql PHP5 1. 更新Debian apt-get update apt-get updgrade 2. 安装Samba服 ...
- 小皮面板有php环境吗,php环境搭建详解
本文主要和大家分享php环境搭建wampserver.Apache.Mysql和php php环境搭建csdn php环境搭建详解 ,希望能帮助到大家. wampserver2.5-Apache-2. ...
- Go语言环境搭建详解(2020版)
最近写了很多Go语言的原创文章,其中Go语言实战系列30篇,近15W字,还有最近更新的Go经典库系列,不过通过大家的咨询来看,还是想要一些入门的知识,这一篇文章写于2017年初,这3年多Go更新了很多 ...
- Java零基础必看学习教程,Java开发环境配置详解
很多Java新手小白在学习Java编程的时候,碰到的第一难题就是不知道如何安装和配置java开发环境. 今天整理了史上最详细的安装及Java开发环境配置教程,通过图文并茂的方式详细讲解每一步骤,手把手 ...
- ubuntu java 开发环境_详解ubuntu搭建Java开发环境
没有用Java写过程序,做为一个Java新手,在写第一个Hello,world程序之前,先在Ubuntu中搭建Java开发环境. 本文结构: 一.JDK安装 二.MyEclipse安装 三.Hello ...
最新文章
- linux2.0版本发布时间,Ubuntu 20.04 LTS发布时间表公布 4月23日放出最终稳定版
- mysql 设置表空间位置_如何修改表空间数据文件路径
- php 数组 随机选择_php中通过数组进行高效随机抽取指定条记录的算法
- 编程软件python怎样开始学-编程零基础应当如何开始学习 Python?
- selenium判断是否出现弹窗_如何判断三元催化器是否出现故障
- tensorflow.reshap(tensor,shape,name)的使用说明
- 三十八、学Sql,不了解Sql注入怎么行?
- SparkSQL发展历史,DataFrame,SparkSQL的数据源,运行框架,tree和rule,Rule,Context运行过程,hiveContext运行过程,SparkSQL CLI等
- 2017/9/26Codeforces E题
- c语言如何编写mysql客户端_【C/C++学院】(23)Mysql数据库编程--C语言编程实现mysql客户端...
- WP7技巧 扩展【共享...】按钮
- 微软重拳出击:盗版 Windows 将无处遁形!
- ECShop如何设置默认的配送方式和支付方式
- 从文件夹里面多个文件里面查找指定内容
- html 倒计时字体消失,最简单的一个网页倒计时代码 时间到期后会显示出提醒内容 收藏版...
- C#导入Excel报错问题3。
- matlab 浮动波动率,Matlab计算股票价格波动率
- 《大秦帝国》:中国文明正源的强势生存
- 如何用计算机还原魔方,魔方复原
- 基于winsock的局域网聊天室实现
热门文章
- oralce trunc用法
- d盾web查杀 linux,D盾扫描_D盾_Web查杀 [webshell查杀]
- linux系统 git修改账号密码
- [单片机][KEIL5] 参数的意义和使用 L #L @L K #K $, #, %, @, ~, ^
- keil5工程文件中的hex消失
- SAP 软件的精髓之一:各种各样的决定机制 - Determination Logic
- 小学生C++编程基础 课程7(B)
- vue3.0-axios拦截器、proxy跨域代理
- 《Python编程》第一章:先睹为快
- boostrapvue+vue开发桌面旅游网站