官方文档教程编译源码: 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 即可

nRF5 SDK for Mesh(四) 源码编译的更多相关文章

  1. edgedb 内部pg 数据存储的探索 (四) 源码编译

      edgedb 基于python开发,同时源码重包含了好多子项目,以下进行简单的源码编译 clone 代码 需要递归处理,加上recursive,比较慢稍等 git clone --recursiv ...

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

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

  3. Android源码浅析(四)——我在Android开发中常用到的adb命令,Linux命令,源码编译命令

    Android源码浅析(四)--我在Android开发中常用到的adb命令,Linux命令,源码编译命令 我自己平时开发的时候积累的一些命令,希望对你有所帮助 adb是什么?: adb的全称为Andr ...

  4. nRF5 SDK for Mesh(三) Installing the mesh toolchain 安装编译工具链

    Installing the mesh toolchain To build the example applications, a toolchain based on either CMake o ...

  5. 第四次作业;创建raid5,源码编译安装;磁盘配额

    创建raid5 格式化 ext4 创建物理卷: 创建卷组: 创建逻辑卷: 格式化  ext4 挂载 开机自启动 创建raid配置文件 源码编译安装: 创建本地yum仓库 umount /dev/sr0 ...

  6. Android源码分析(四)-----Android源码编译及刷机步骤

    一 : 获取源码: 每个公司服务器地址不同,以如下源码地址为例: http://10.1.14.6/android/Qualcomm/msm89xx/branches/msm89xx svn环境执行: ...

  7. 十四.自定义yum仓库、源码编译安装

    pc7:192.168.4.7 1.自定义yum仓库1.1 源码仓库下:/root/tools/other]# createrepo .]# ls ntfs-3g-2014.2.15-6.el6.x8 ...

  8. XMPP即时通讯协议使用(四)——Openfire服务器源码编译与添加消息记录保存

    下载Openfire源码 下载地址:https://www.igniterealtime.org/downloads/index.jsp,当前最新版本为:4.2.3 Eclipse上部署Openfir ...

  9. android源码编译1

    一.环境说明: 1.liunx系统:Ubuntu12.04 2.jdk:sun-java6-jdk 3.g++4.5 gcc4.5 二.android源码的目录结构 |-- Makefile |-- ...

随机推荐

  1. Spring入门(三)— AOP注解、jdbc模板、事务

    一.AOP注解开发 导入jar包 aop联盟包. aspectJ实现包 . spring-aop-xxx.jar . spring-aspect-xxx.jar 导入约束 aop约束 托管扩展类和被扩 ...

  2. 当react 项目使用px2rem

    参考资料:http://easywork.xin/2018/09/02/react-2/ 我拿到的设计图 是  375px //配置px2rem px2rem({remUnit: 37.5})   在 ...

  3. System.Media.Color与System.Drawing.Color转换方法

    public static System.Media.Color GetMediaColorFromDrawingColor(System.Drawing.Color color) {      re ...

  4. GAN背后的数学原理

      模拟上帝之手的对抗博弈——GAN背后的数学原理 简介 深度学习的潜在优势就在于可以利用大规模具有层级结构的模型来表示相关数据所服从的概率密度.从深度学习的浪潮掀起至今,深度学习的最大成功在于判别式 ...

  5. Linux基础入门之网络属性配置

    Linux基础入门之网络属性配置 摘要 Linux网络属性配置,最根本的就是ip和子网掩码(netmask),子网掩码是用来让本地主机来判断通信目标是否是本地网络内主机的,从而采取不同的通信机制. L ...

  6. 在AndroidStudio中数据存储第三方数据管理Bmob的使用

    ---恢复内容开始--- 在日常写代码的过程中我们比较痛苦的就是数据库的建立和使用,那么今天来介绍一下一个第三方的数据管理平台Bmonb. 一.我们首先进入Bmob的官网创建一个账号 Bome官网网址 ...

  7. 计算Pan手势到指定点的角度

    计算Pan手势到指定点的角度 效果图: 源码: // // RootViewController.m // Circle // // Copyright (c) 2014年 Y.X. All righ ...

  8. Effective C++(5) 了解C++默默地编写并调用哪些函数

    预热: 一个空的类,当编译器处理过之后,就包含: 一个copy构造函数 一个重载赋值操作符 一个析构函数 一个默认构造函数 Demo: class Empty() { }; // 声明一个空的类 cl ...

  9. linux 无法安装gcc, 可以试试换用 阿里的yum

    1.备份 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup 2.下载新的CentOS-Base ...

  10. Linux中如何安装loadgenerator

    /* 1. 到官方网站到HP官网下载Load Generator 安装文件 _Load_Generator_11.00_T7330-15010.iso或者其它网站下载loadrunner-11-loa ...