官方文档教程编译源码: http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk%2Fdita%2Fsdk%2Fmesh_sdk.html&cp=4_1

Building the mesh stack

The mesh library and example applications can be built using either CMake or SEGGER Embedded Studio.

Using CMake provides the possiblity to build both for host (unit tests) and target, while SEGGER Embedded Studio provides a way of quickly getting the example code up and running with full debug capability.

Before you continue, check Installing the mesh toolchain ro instructions on setting up the development environment for mesh.

编译 MESH 协议栈

可以使用CMake或SEGGER嵌入式Studio构建网格库和示例应用程序。使用CMake提供了为主机(单元测试)和目标构建的可能性,而SEGGER嵌入式Studio提供了一种快速获取示例代码并运行完全调试功能的方法。在继续之前,请检查安装网格工具链的指令,以设置网格的开发环境。

Building with SEGGER Embedded Studio

To build with SEGGER Embedded Studio, open one of the project files located in the examples/ folder, e.g.,examples/light_switch/client/light_switch_client_nrf52832_xxAA_s132_5_0_0.emProject.

To compile the example, go to Build -> Build light_switch_client_nrf52832_xxAA_s132_5.0.0. After the compilation is complete, first erase the device using Target -> Erase all and run the example with Debug -> Go. This will download the matching SoftDevice and the compiled example and start the debugger. When the download is complete select Debug -> Goagain to start the code execution.

Building with CMake

From About CMake:

CMake is an extensible, open-source system that manages the build process in an operating system and in a compiler-independent manner.

In other words, CMake does not build from the source directly, but generates the native build tool files (for example, a set of Makefiles or a build.ninja configuration). Which build tool to target is controlled via the -G argument, for example: -G Ninja-G "Unix Makefiles" and many more. CMake can generate IDE project files for IDEs such as Eclipse as well. However, this guide only targets Ninja and GNU Make.

Important: All examples built by the CMake-generated build system do not include the SoftDevice as part of the generated HEX files. Therefore, the SoftDevice must already be present on the device before flashing the HEX file for the example mesh application.

Generating build files

Important: In this section, we are genating build files for the Ninja build tool. On Debian/Linux, you may drop the -G Ninja argument as the default generator is for Unix Makefiles and use the make command instead of ninja.

Good practice is to create a build folder in the root directory for the mesh stack repository, where all artifacts generated by the Ninja build system are stored, such as:

mesh-btle $ mkdir build
mesh-btle $ cd build

Before you can build with Ninja, you must generate the correct build files with CMake:

build$ cmake -G Ninja -DTOOLCHAIN=gccarmemb -DPLATFORM=nrf52840_xxAA ..

Based on the options given in the command line arguments, four main parameters are set:

  1. TOOLCHAIN

    • gccarmemb for the GNU ARM Embedded toolchain
    • armcc for the Keil ARMCC toolchain
    • clang for the Clang compiler (with GNU ARM Embedded assembler and linker)
  2. PLATFORM
    • nrf51422_xxAC
    • nrf52832_xxAA
    • nrf52840_xxAA
  3. BOARD: valid board combination based on platform type
  4. SOFTDEVICE: valid SoftDevice based on platform type

The build system will ensure a valid BOARD and SOFTDEVICE for each given platform. Calling cmake -G Ninja .. will default to thenrf52832_xxAA platform with the S132 v5.0.0 SoftDevice and the GNU ARM Embedded Toolchain.

After the Ninja build files are generated, running ninja will build all the targets (examples and libraries). Documentation can be built with ninja doc. If you have PC-Lint installed, the sources can be linted using the ninja lint command. To see a list of available build targets, run the following command:

build $ ninja help

To build a specific target from this list, run, for example, ninja mesh_core_nrf52840_xxAA if the current platform is nrf52840_xxAA.

CMake generates Ninja build files in the folder in which CMake is run (but not in any of its subfolders), so all targets must be built from that directory. In other words, in-directory building is not supported and running ninja in one of the example folders will result in an error message generated by the Ninja build system.

However, the mesh stack can be built from its root directory as well, 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 GNU ARM Embedded toolchain. To build with ARMCC instead, setTOOLCHAIN to armcc:

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

Generating SEGGER Embedded Studio project files

Warning: The generator will overwrite any existing projects, please back up existing projects before running the generator.

It is possible to generate SEGGER Embedded Studio project files using the CMake build system. With the optionGENERATE_SES_PROJECTS enabled, CMake will generate a SEGGER Embedded Studio project based on the current settings. For example, to generate a project for nrf51422_xxAC using the S110 SoftDevice, run CMake in your build directory like this:

cmake -G Ninja -DGENERATE_SES_PROJECTS=ON -DPLATFORM=nrf51422_xxAC -DSOFTDEVICE=s110_8.0.0 ..

Useful CMake command line options

CMake allows you to generate project files in release or debug configurations. To do so, use the -DCMAKE_BUILD_TYPE option:

build $ cmake -DCMAKE_BUILD_TYPE=Release .. # Generates build files in release mode
build $ cmake -DCMAKE_BUILD_TYPE=Debug ..   # Generates build files in debug mode

The default build type is Debug if the CMake project is a Git repository (contains a .git directory), otherwise it is set toRelWithDebInfo.

Building the documentation

To build all documentation (API documentation and internal documentation), call the build system with the target doc.

build $ ninja doc

The Doxygen documentation is generated in <build folder>/doc/offline/html.

Unit test build (host)

The nRF5 SDK for Mesh contains a set of unit tests that verify module behavior. These unit tests run on the host system (i.e. PC, not the nRF5 device), and are built with GCC. See Installing the mesh toolchain for toolchain requirements.

The nRF5 SDK for Mesh depends on two frameworks for unit testing:

  • Unity is the unit testing framework that is used for running the tests.
  • CMock is used by the unit tests to generate mocks.

Note that an installation of Git is required to download these modules.

CMock bundles Unity as a submodule, thus in the same directory as the nRF5 SDK for Mesh, make sure to clone the CMock repository recursively:

$ git clone https://github.com/ThrowTheSwitch/CMock.git --recursive cmock

The directory structure should now look like this:

.
+-- cmock/
+-- nrf5_sdk_for_bluetooth_mesh/

Enter the nrf5_sdk_for_bluetooth_mesh directory, and make a new build directory, e.g. build_host:

nrf5_sdk_for_bluetooth_mesh $ mkdir -p build_host && cd build_host

To build for host, so that the unit tests can be run, set the option BUILD_HOST to ON and provide the path to CMock using theCMOCK_ROOT option. Note that all paths given to CMake must use forward slashes ('/') as directory separators.

build_host $ cmake -G Ninja -DBUILD_HOST=ON -DCMOCK_ROOT=<dir/cmock> ..

If a different version of Unity from the one included as a submodule in CMock is wanted, this can be specified by passing -DUNITY_ROOT=<dir/unity> to CMake. Note that the two paths can be set permanently with environmental variables (UNITY_ROOTand CMOCK_ROOT), and CMake is set up to look for CMock in the directory above the nrf5_sdk_for_bluetooth_mesh, so if the instructions above have been followed, both these variables are redundant.

Build all the unit tests with ninja:

build_host $ ninja

To run the tests, run ctest (bundled with CMake) or call ninja test in the build directory.

build_host $ ctest # Run all unit tests

我 没有 选择 CMAKE 工具 ,反而选择的 是 jlink  公司给  NRF 提供  的 免费软件,

SEGGER Embedded Studio

下载 安装 即可 ,然后 将下载的  MESH 源码 放在  非中文目录下 ,打开  examples/light_switch/client/light_switch_client_nrf52832_xxAA_s132_5_0_0.emProject

编译即可。

这个软件 一点 小技巧:
由于很多窗口关掉,找不到,可以一键恢复的:在菜单栏——Tools——Admin——Restore Default Environment Settings 即可

转载于:https://www.cnblogs.com/suozhang/p/7831996.html

nRF5 SDK for Mesh(四) 源码编译相关推荐

  1. LNMP架构的搭建——源码编译(PHP,nginx,Mysql)

    一.源码编译 在企业中,我们常常是需要什么模块才会添加什么模块,而源码编译就可以让我们按需安装. yum安装的优缺点: yum安装的优点:安装东西,方便快捷,特别是不用考虑包依赖. yum安装的缺点: ...

  2. Ubuntu下源码编译VirtualBox五 —— 源码编译(4)

    接前一篇文章<Ubuntu下源码编译VirtualBox四 -- 源码编译(3)>,链接如下: Ubuntu下源码编译VirtualBox四 -- 源码编译(3)_蓝天居士的博客-CSDN ...

  3. nRF5 SDK for Mesh(一) 介绍和下载源码

    一: 官网介绍地址:http://www.nordicsemi.com/Products/Bluetooth-low-energy/nRF5-SDK-for-Mesh Nordic offers a ...

  4. android 4.4 源码编译,ubuntu12.04(64bit)编译android4.4源码、sdk及kernel

    最近闲来无事,就想编译一下android源码折腾折腾.过程还算顺利,编译源码用了近3小时,编译sdk用了近30分钟.关于为什么要编译4.4的源码,而不编译5.0.6.0的源码,一是正好笔记本中有下载好 ...

  5. Slicer学习笔记(四十二)slicer c++源码编译

    Slicer学习笔记(四十二)slicer c++源码编译 1.cmake生成项目 2.编译失败的原因汇总 2.1.下载代码失败 之前在windows下编译slicer,没有做笔记. 后面再次编译还会 ...

  6. Linphone SDK 源码编译

    Linphone SDK 源码编译 一.环境准备 编译环境 系统:Ubuntu – 建议使用Ubuntu,其他的系统可能有某些依赖存在问题,编译报错 Android SDK r24.2 Android ...

  7. KylinV10上qt5.9开发应用打包步骤(四)--linuxdeployqt源码编译

    文章目录 1.linuxdeployqt源码编译 下载linuxdeployqt源码包,6版本的 执行下面的步骤 遇到报错 对'ucal_clone_56'未定义的引用 2. 解决依赖 linuxde ...

  8. Android源码编译详解【四】:Android 6.0_源码的下载与编译

     1.AOSP源码下载  AOSP:即为"Android Open-Source Project"的缩写,中文意为 :"安卓开放源代码项目". Google官方 ...

  9. 【流媒体开发】VLC Media Player - Android 平台源码编译 与 二次开发详解 (提供详细800M下载好的编译源码及eclipse可调试播放器源码下载)

    作者 : 韩曙亮  博客地址 : http://blog.csdn.net/shulianghan/article/details/42707293 转载请注明出处 : http://blog.csd ...

最新文章

  1. 基于python和OpenCV构建智能停车系统
  2. Python和Java结合的项目实战_[项目实战] Python高级教程项目实战篇 Python和Java结合的项目实战 视频教程 [...
  3. @query传参_vue-router中params传参和query传参的区别及处理方法
  4. (转)Web Services使用多态(XmlInclude) ,支持自定义类型
  5. 新闻列表页flex_C端列表页如何设计?
  6. 32 配置引脚中断_PCIe的中断机制
  7. Java-json系列(一):用GSON解析Json格式数据
  8. 关于页面导航和数据传递的简单总结
  9. 车辆颜色识别opencv
  10. MySQL异构同步_详解MySQL数据库异构数据同步
  11. twitter点赞图标分析
  12. XXL-JOB(2)-使用
  13. Windows 与 Linux之间进行文件传输,文件传输工具Cuteftp的使用方法。
  14. 小程序登录、支付、上传图片流程
  15. HTML5快速入门(一)—— HTML简介
  16. python期中考试试卷分析_期中考试考试试卷分析及反思
  17. 上海快速拿计算机本科文凭,怎么快速拿文凭,急!(建议收藏)
  18. 如何在Vivado创建一个FIFO的IP核并使用ILA工具验证
  19. 美洽客服端下载地址是什么?
  20. echarts地图api series_echarts实现中国地图数据展示

热门文章

  1. Tom邮箱注册机|注册辅助工具!!!
  2. 我应该做哪个行业的销售
  3. 和屌丝一起学cocos2dx-CCScrollView
  4. Docker应用容器引擎_简介---Docker工作笔记003
  5. ES6新特性_ES6语法糖-子类对父类方法的重写---JavaScript_ECMAScript_ES6-ES11新特性工作笔记037
  6. k8s核心技术-Helm引入---K8S_Google工作笔记0043
  7. 微信公众开放平台开发02---微信公众平台PHP接口和java接口对比
  8. Ui学习笔记---EasyUI的介绍
  9. viso stido 在图上写字
  10. make: *** [.build_release/lib/libcaffe.so] 错误 1