内容字号:默认大号超大号

段落设置:段首缩进取消段首缩进

字体设置:切换到微软雅黑切换到宋体

在Linux下搭建nRF51822的开发烧写环境(makefile版)

2018-09-12 11:27 出处:清屏网 人气: 评论(0

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.0Note 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
  • 5) 从SEGGER官网下载最新的J-Link工具包 J-Link Software and Documentation Pack,我下载的是最新的linux-64位-deb安装版:

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.pdf15.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


分享给小伙伴们:
本文标签: LinuxnRF51822makefile

相关文章

发表评论愿您的每句评论,都能给大家的生活添色彩,带来共鸣,带来思索,带来快乐。

CopyRight © 2015-2016 QingPingShan.com , All Rights Reserved.

清屏网 版权所有 豫ICP备15026204号