【BLE_Mesh】01,Nordic_nRF51-DK之BLE_Mesh编译

1 篇文章 0 订阅
1 篇文章 0 订阅

一,背景

      偶然在网上看见“蓝牙技术联盟正式发布蓝牙Mesh技术”的新闻,而手头正好有两块闲置的Nordic_nRF51-DK,就瞎捣鼓了一番。

因为看见蓝牙mesh的介绍特别有诱惑力:全新的Mesh功能提供多对多设备传输,并特别提高构建大范围网络覆盖的通信效能,适用于楼宇自动化、无线传感器网络等需要让数以万计个设备在可靠、安全的环境下传输的物联网解决方案。


二,准备

  硬件:

    nRF51-DK(nRF51422)

  

  软件:

    SDK包:nRF5-SDK-for-Mesh

    SoftDevices:S130-SD-v2

    下载工具:nRFgo Studio

     构建工具:CMAKE

     编译工具:ninja

      

    在Nordic官网可以下载到nRF5-SDK-for-Mesh:

http://www.nordicsemi.com/eng/Products/Bluetooth-low-energy/nRF5-SDK-for-Mesh  

  不过是个测试版,拿来试试手还是不错的。。

  下载软件等 也Nordic官网也有:http://www.nordicsemi.com/eng/Products/nRF51-DK


三,编译

SDK包的目录:

      

刚开始以为可以用IDE构建的工程,打开发现是CMAKE,看了doc才知道怎么弄,建议动手前用doxygen生成html文件,里面内容写的很详细,你也可以使用在线的手册:

http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.meshsdk.v0.9.1%2Findex.html


Building with CMake

To build the example applications using CMake, the following tools are required:

  • CMake: CMake is a build management system used for managing a compiler and build system independent environment. Version 3.0 or above is required by the mesh stack.
  • A toolchain: supported toolchains are thearm-none-eabi-gcc toolchain or thearmcc v5 toolchain which is also provided by Keil, and comes bundled with the Keil uVision IDE.
  • A Build System: CMake supports a range of build systems, the preferred build system for the Microsoft Windows operating system isNinja. Ninja comes in the form of a single executable, which should be placed in a folder that is referenced by the system path (i.e. the PATH environment variable). The preferred build system for unix based operating systems isMake.

Note: All the examples built by the CMake generated build system does not include the SoftDevice as part of the generated hex files, and the SoftDevice must be already present on the device before flashing the hex file for the example mesh application.

To build and run the unit tests on a host computer, the following tools are needed:

  • GCC: used to build the unit tests
  • Unity: Unity is the unit testing framework used for running the tests.
  • CMock: CMock is used by the unit tests in order to generate mocks.
  • Ruby: used by CMock.

Note: Currently, the CMock version used in this project is an internal fork of the public repository. This means that downloading the official version of CMock might not work.

Building on Windows

In order to build with Ninja, the correct build files need to be generated first by using CMakecmake -G Ninja <root directory for the mesh stack repository>. Once the Ninja build files are generated runningninja will build all the targets (examples and libraries) except for documentation and pc-lint. In order to see a list of available build targets, runningninja -t targets will show the options available; a specific target can be built by specifying it from this list such as:ninja 51_MBTLE_CORE.

CMake will generage ninja build files in the folder the CMake is run (but not in any of its subfolders), so all targets need to be built from that directory. In otherwords, in-directory building is not supported, i.e. runningninja in one of the examples will result in an error message generated by the Ninja build system.

It is recommended that a build folder is created where all the artifacts generated by the Ninja build system are stored, such as:

mesh-btle $ mkdir build # Create a build directory
mesh-btle $ cd build # Move into that directory
build $ cmake -G Ninja .. # Generate build files
build $ ninja

However, the mesh stack can be built from its root directory, which will place the generated artifacts in the folder where the source files are kept.

mesh-btle $ cmake -G Ninja # Generate build files
mesh-btle $ ninja

By default CMake is configured to build for target using the armcc v5 compiler. In order to build with arm-none-eabi-gcc, theBUILD_TOOLCHAIN needs to be set toGCC, for example:

mesh-btle $ mkdir build && cd build # Create a build directory
build $ cmake -G Ninja -DBUILD_TOOLCHAIN=GCC .. # Generate build files
build $ ninja

In order to build for host (i.e. PC), so that the unit tests can be run, the optionBUILD_HOST should be set toON, and the path to unity and cmock provided:

mesh-btle $ mkdir host_build && cd host_build
host_build $ cmake -G Ninja -DBUILD_HOST=ON -DUNITY_ROOT=<dir/unity> -DCMOCK_ROOT=<dir/cmock> ..
host_build $ ninja
host_build $ ctest # Run all unit tests

Building on Linux

CMake can generate make files as well, which is natively supported by Linux and is the preferred method of building C based programs. On Linux, the build system will default to GCC and Make. So in order to build on Linux with GCC:

mesh-btle $ mkdir build && cd build # Create a build directory
build $ cmake .. # Generate build files
build $ make

Building on Linux with armcc v5:

mesh-btle $ mkdir build && cd build # Create a build directory
build $ cmake -DBUILD_TOOLCHAIN=ARM .. # Generate build files
build $ make

文档里面已经写的很清楚了,编译出例程的HEX文件后进入下载步骤。


四,下载

       使用mini_usb线将开发板接上电脑,安装jlink驱动,要4.80以上的,然后打开 nRFgo Studio 就可以看见设备了,分别下载 SoftDevices 和 Application即可:

  

  



     

   

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值