星期日, 09. 九月 2018 07:51下午 - beautifulzzzz
1、安装步骤
1) 从GNU Arm Embedded Toolchain官网下载最新的gcc-arm工具链,写文章时下载的是:
gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2
2) 从NORDIC官网下载相应版本的SDK,我这里选择的是12.3.0版本:
Code Name Version nRF5-SDK-v12-zip nRF5 SDK Zip File - works with S132 v3 and S130 v2 12.3.0 nRF5-SDK-zip nRF5 SDK Zip File - works with S112 v6.1.0, S132 v6.1.0, S140 v6.1.0, and S212 v5.0.0 Note that support for the nRF51 Series was included up until v12.3 of the nRF5 SDK 15.1.0
3) 解压工具链和nRF5-SDK到AAAA目录下,并编辑sdk_root/components/toolchain/gcc/Makefile.posix :
GNU_INSTALL_ROOT := /home/btfz/Downloads/AAAA/gcc-arm-none-eabi-5_4-2016q3 GNU_VERSION := 5.4.1 GNU_PREFIX := arm-none-eabi
4) 从NORDIC官网下在nRF5x-Tools-Linux,我下载的版本是(解压后也放在AAAA目录下):
nRF5x-Command-Line-Tools_9_7_3_Linux-x86_64.tar
2、编译与烧写BLINK工程
1) 检查开发板所用的芯片为nRF51822-QFAA,参考nRF51822 Product Anomaly Notification v3.3,得知QFAA是256 kB Flash, 16 kB RAM:
2) 参考developer(#5)>Software Development Kit > nRF5 SDK > nRF5 SDK v12.3.0 > Getting Started > Using the SDK with other boards中的介绍:
Depending on the device on the legacy board, you might need to change the memory layout. For example, all nRF51 examples assume that you are using the 32 kB variant of nRF51, so if you are using a variant with 16 kB RAM, you must decrease the size of IRAM1 by 16 kB (0x4000 in hex). In Keil, click Project > Options for Target '...' and modify the values for "Read/Write Memory Area". For GCC, change the linked *.ld file in the Makefile.
因此需要修改
nRF5_SDK_12.3.0_d7731ad/examples/peripheral/blinky/pca10028/blank/armgcc/blinky_gcc_nrf51.ld
中的RAM配置为0x4000:MEMORY { FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x40000 RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x4000 }
注:如果RAM大小不符合条件,会导致程序烧写成功,但是没有任何效果!!!
3) 编译运行(以blinky - blank为例):
➜ cd /examples/peripheral/blinky/pca10028/blank/armgcc ➜ armgcc make clean rm -rf _build ➜ armgcc make all mkdir _build Compiling file: nrf_log_backend_serial.c ... Compiling file: system_nrf51.c Linking target: _build/nrf51422_xxac.out text data bss dec hex filename 3160 112 112 3384 d38 _build/nrf51422_xxac.out Preparing: _build/nrf51422_xxac.hex Preparing: _build/nrf51422_xxac.bin
4) 烧写运行:
运行烧写的脚本在makefile中都有,但是在此之前要做两件事:
- 将nrfjprog加入全局变量
- 修改makefile中的erase芯片类型为nrf51
注:在当前terminal中运行一次
export PATH=$PATH:/home/btfz/Downloads/AAAA/nRF5x-Command-Line-Tools_9_7_3/nrfjprog/
,则对当前窗口有效,直至串口关闭。➜ armgcc export PATH=$PATH:/home/btfz/Downloads/AAAA/nRF5x-Command-Line-Tools_9_7_3/nrfjprog/ ➜ armgcc make erase nrfjprog --eraseall -f nrf51 Erasing user available code and UICR flash areas. Applying system reset. ➜ armgcc make flash Flashing: _build/nrf51422_xxac.hex nrfjprog --program _build/nrf51422_xxac.hex -f nrf51 --sectorerase Parsing hex file. Erasing page at address 0x0. Erasing page at address 0x400. Erasing page at address 0x800. Erasing page at address 0xC00. Applying system reset. Checking that the area to write is not protected. Programming device. nrfjprog --reset -f nrf51 Applying system reset. Run.
3、编译烧写BLE-HRS工程
1) 类似2中的需要调整RAM,这里也要将flash和ram配置做修改。参考S130_SDS_v2.0.pdf的
15.1 Memory resource map and usage
:其中flash的占用情况为:
其中ram的占用情况为:
因此修改
ble_app_hrs_gcc_nrf51.ld
中的flash和ram的配置为:MEMORY { FLASH (rx) : ORIGIN = 0x1b000, LENGTH = 0x23000 RAM (rwx) : ORIGIN = 0x20002000, LENGTH = 0x2000 }
- 2) 修改makefile中的erase的芯片系列为nrf51
3) 烧写:
make erase make flash_softdevice make flash
4、玩转nRF51822必备知识
1)板子和芯片对应关系
由于nRf51822和nRF51422差别不大,因此我们之前一直用pca10028工程来做实验。此外我看了下最新的SDK中的DEMO,发现没有pca10028了,我猜测应该是nRF51822在新版本SDK中不继续支持了。
2)协议栈和芯片对应关系
可见我们上面用的S130支持众多芯片且具备BLE的Central and Peripheral功能。
3)NORDIC提供的一些协议栈
LINKS
[1].GNU Arm Embedded Toolchain
[2].nRF5-SDK Download Page
[3].nRF5x-Tools-Linux Download Page
[4].nRF51 Development Kit complete setup for Linux
[5].NORDIC 开发者社区 -- 资料最全的地方
[6].nRF51822_pan_v3.3.pdf
[7].S130_SDS_v2.0.pdf
nRF51822系列文章
[nRF51822] 1、一个简单的nRF51822驱动的天马4线SPI-1.77寸LCD彩屏DEMO
[nRF51822] 2、D-BUG之诗
[nRF51822] 3、 新年也来个总结——图解nRF51 SDK中的Button handling library和FIFO library
[nRF51822] 4、 图解nRF51 SDK中的Schedule handling library 和Timer library
[nRF51822] 5、 霸屏了——详解nRF51 SDK中的GPIOTE(从GPIO电平变化到产生中断事件的流程详解)
[nRF51822] 6、基于nRF51822平台的flash读写研究
[nRF51822] 7、基础实验代码解析大全(前十)
[nRF51822] 8、基础实验代码解析大全 · 实验11 - PPI
[nRF51822] 9、基础实验代码解析大全 · 实验12 - ADC
[nRF51822] 10、基础实验代码解析大全 · 实验15 - RTC
[nRF51822] 11、基础实验代码解析大全 · 实验16 - 内部FLASH读写
[nRF51822] 12、基础实验代码解析大全 · 实验19 - PWM
[nRF51822] 13、浅谈nRF51822和NRF24LE1/NRF24LU1/NRF24L01经典2.4G模块无线通信配置与流程
[nRF51822] 14、浅谈蓝牙低功耗(BLE)的几种常见的应用场景及架构(科普类干货)
[nRF51822] 15、穿戴式设备上电量检测装置的设计及细节技术点(偏专业硬件文章)
[nRF51822] 16、nRF51822的随机数生成器,及随机数生成器的一些知识(可以帮您补补随机数发生器的知识)
[异常解决] Keil安装好nRF51822开发环境,运行DEMO报错:Error:“GPIOTE_CONFIG_NUM_OF_LOW_POWER_ENVENTS” is undefined
[异常解决] How to build a gcc toolchain for nRF51 on linux (very detailed!!!)
[蓝牙] 1、蓝牙核心技术了解(蓝牙协议、架构、硬件和软件笔记)
[蓝牙] 2、蓝牙BLE协议及架构浅析&&基于广播超时待机说广播事件
[蓝牙] 3、 剖析BLE心率检测工程
[蓝牙] 4、Heart Rate Service module
[蓝牙] 5、Battery Service module
[蓝牙] 6、基于nRF51822的蓝牙心率计工程消息流Log分析(详细)
@beautifulzzzz
智能硬件、物联网,热爱技术,关注产品
博客:http://blog.beautifulzzzz.com
园友交流群:414948975