This project uses CMake and the GNU ARM-Toolchain as build system and GDB/OpenOCD are used for debugging purposes.
By using these tools the development environment is platform agnostic and independent of chip manufacturer specific Integrated Development Environments.
It allows to build the project either by using a command line terminal or by using IDE’s like VSCode or KDevelop.
pacman -S cmake
C:\Program Files\CMake\bin
to Path
variable )brew install cmake
GNU/Linux:
libnewlib
causing the linker to fail. sudo apt install gcc-arm-none-eabi
pacman -S arm-none-eabi-gcc arm-none-eabi-newlib
Windows:
pacman -S mingw-w64-x86_64-make
.Note: Please ensure that both paths are added to the system PATH variable. Add for example: C:\msys64\mingw64\bin
and C:\Program Files (x86)\GNU Tools ARM Embedded\6 2017-q2-update\bin
to Path
variable.
OSX:
brew tap ARMmbed/homebrew-formulae && brew install arm-none-eabi-gcc
apt-get install openocd
pacman -S openocd
brew install openocd
Go to root directory of the project
cd path/to/project/directory
Create a directory named ‘build’
mkdir build
Go to the created build
directory
cd build
run
cmake -DCMAKE_TOOLCHAIN_FILE="cmake/toolchain-arm-none-eabi.cmake" ..
Note: If the GNU ARM-Toolchain is not installed under the default path (GNU Linux:/usr
, Mac OS /usr/local
) a prefix has to be provided:
cmake -DCMAKE_TOOLCHAIN_FILE="cmake/toolchain-arm-none-eabi.cmake" -DTOOLCHAIN_PREFIX="/path/to/the/toolchain" ..
For Windows platforms the prefix has to be provided anyway and additionally the CMake Generator for MinGW Makefiles has to be chosen:
cmake -DCMAKE_TOOLCHAIN_FILE="cmake/toolchain-arm-none-eabi.cmake" -DTOOLCHAIN_PREFIX="/path/to/the/toolchain" -G "MinGW Makefiles" ..
The possibility to choose the application, target board and more options can be done using the provided configuration options.
These configuration options can be set through additional commandline parameters, for example:
cmake -DCMAKE_TOOLCHAIN_FILE="cmake/toolchain-arm-none-eabi.cmake" -DAPPLICATION="LoRaMac" -DSUB_PROJECT="periodic-uplink-lpp" ..
Alternatively one can use a graphical interface to configure CMake, drop down menus and check boxes will provide to the user the possible options.
cmake-gui ..
ccmake ..
APPLICATION
- Application example choice.SUB_PROJECT
- LoRaMac sub project example choice.APPLICATION
choice.ACTIVE_REGION
- Active region for which the stack will be initialized.APPLICATION
choice.MODULATION
- Type of modulation choice.APPLICATION
choice.USE_DEBUGGER
- Enables debugger support. (Default ON)BOARD
- Target board choice.REGION_EU868
- Enables support for the Region EU868 (Default ON)REGION_US915
- Enables support for the Region US915 (Default OFF)REGION_CN779
- Enables support for the Region CN779 (Default OFF)REGION_EU433
- Enables support for the Region EU433 (Default OFF)REGION_AU915
- Enables support for the Region AU915 (Default OFF)REGION_AS923
- Enables support for the Region AS923 (Default OFF)REGION_CN470
- Enables support for the Region CN470 (Default OFF)REGION_KR920
- Enables support for the Region IN865 (Default OFF)REGION_IN865
- Enables support for the Region AS923 (Default OFF)REGION_RU864
- Enables support for the Region RU864 (Default OFF)RADIO
- Defines the radio to be used.LINKER_SCRIPT
- Defines the target specific linker script path.OPENOCD_BIN
- Defines the OpenOCD path.OPENOCD_INTERFACE
- Defines the interface configuration file to be used by OpenOCD.OPENOCD_TARGET
- Defines the target configuration file to be used by OpenOCD.OpenOCD
OpenOCD has to be started with parameters that depend on the used debugger device and target board.
Some examples are shown below:
NucleoL073 + STLinkV2-1 (On board debugger):
openocd -f interface/stlink-v2-1.cfg -f target/stm32l0.cfg
SAMR34 Xplained Pro (On board debugger, tested with openocd 0.10, did not work with 0.9):
openocd -f interface/cmsis-dap.cfg -f target/at91samdXX.cfg
GDB
The below GDB usage example shows how to start a debug session, writing the program to the flash and run.
arm-none-eabi-gdb
file src/apps/LoRaMac/LoRaMac-classA
target extended-remote localhost:3333
monitor reset halt
load
thbreak main
continue
continue
VSCode ->EXTENSION (Crtl+Shift+x)
and search for:
For Windows platforms it is necessary to make some additional configurations. Open your settings under File->Preferences->Settings and add the following lines:
Add MinGW Makefiles as preferred Generator:
"cmake.preferredGenerators": [
"MinGW Makefiles",
"Ninja",
"Unix Makefiles"
]
Set the CMake path:
"cmake.cmakePath": "path/to/cmake.exe"
.cmaketools.json
file based on the CMakeLists.settings.json
file under .vscode
directory is the place where one can change the build options.Debug
or Release
).Build
button will now be available.launch.json
file which setups the debugging process for the given board.F5
key to start a debug session.CMake: Edit the CMake Cache
CMake: Clean rebuild
For detailed information about CMake Tools extension please see their github repository.
apt-get install kdevelop
pacman -S kdevelop
Project->Open /Import Project...
and choose the top level CMakeLists.txt
directory of the cloned repository.-DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-arm-none-eabi.cmake
to the Extra Arguments
.Open configuration...
.Build
to build the project.Run->Configure Launches...
and add a new Compiled Binary Launcher
.Debugger executable
according to your system. For example /usr/bin/arm-none-eabi-gdb
.Run gdb script
according to the application you want to debug.loramac-node/build/src/apps/LoRaMac/openocd-run.gdb
.