Edgehog device library for the Zephyr framework.
Before getting started, make sure you have a proper Zephyr development environment. Follow the official Zephyr Getting Started Guide.
The following information is sent to the remote Edgehog instance:
- OS info
- Hardware info
- System info
- [OTA update using Mcuboot](doc/Over The Air (OTA) updates.md)
- Base image
- Runtime info and Zephyr version
- Reboot command
- System status
- Storage usage
- [Led Behavior](doc/Led feedback.md)
- WiFi APs seen by board antenna
- Battery status API
- Data Rate Control for telemetry
To add this module as a dependency to an application, the application west.yml manifest file
should be modified in the following way.
First, a new remote should be added:
remotes:
# ... other remotes ...
- name: edgehog-device-manager
url-base: https://github.com/edgehog-device-managerSecond, a new entry should be added to the projects list:
projects:
# ... other projects ...
- name: edgehog-zephyr-device
remote: edgehog-device-manager
repo-path: edgehog-zephyr-device.git
path: edgehog-zephyr-device
revision: v0.8.0
import: trueRemember to run west update after performing changes to the manifest file.
For development or evaluation purposes it can be useful to add this module as a standalone application in its own workspace. This will make it possible to run the module samples without having to set up an additional application.
The first step is to create a new workspace folder and a venv where west will reside.
mkdir ~/edgehog-zephyrproject && cd ~/edgehog-zephyrproject
python3 -m venv .venv
source .venv/bin/activate
pip install westThe second step is to initialize the west workspace, using the Edgehog library repository as the manifest repository.
west init -m git@github.com:edgehog-device-manager/edgehog-zephyr-device --mr v0.8.0
west updatePerform some final configuration operations.
west zephyr-export
west packages pip --install
west packages pip --install -- -r ./edgehog-zephyr-device/scripts/requirements.txtFollow the sample specific README.
While usually the configuration setting are set in a prj.conf file, during development it might
be useful to set them manually.
To do so run the following command:
west build -t menuconfigThis command will require the application to have already been build to function correctly.
After changing the configuration, the application can be flashed directly using west flash.
The standard configuration for all the samples include settings for printing the logs through the serial port connected to the host.
To run the unit tests use:
west twister -c -v --inline-logs -p unit_testing -T ./edgehog-zephyr-device/testsThe code in this module is formatted using clang-format.
An extension command for west has been created to facilitate formatting, clang-format
should be installed before running this command.
Run west format --help to learn about the formatting options.
CodeChecker is the one of the
various natively supported static
analysis tools in west.
It can be configured to run different static checkers, such as clang-tidy and cppcheck.
Install the python dependencies the extensions with the following command:
pip install -r ~/zephyr-workspace/edgehog-zephyr-device/scripts/requirements.txtIn addition, clang-tidy should be installed, if not already present on the system:
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh $LLVM_VERSION
sudo update-alternatives --install /bin/clang-tidy clang-tidy /bin/clang-tidy-$LLVM_VERSION 100Where $LLVM_VERSION is LLVM version to install.
An extension command for west has been created to facilitate running static analysis with
clang-tidy.
Run west static --help to read what this command performs.
Note that this extension is only available when using this repository as a stand-alone project.
The dependencies for generating the doxygen documentation are:
doxygen <= 1.9.4graphviz
An extension command for west has been created to facilitate generating the documentation.
Run west docs --help for more information on how to generate the documentation.
Here are some quick tips to configure VS Code with a Zephyr workspace. Make sure the following extensions are installed:
- C/C++ Extension Pack
- Python
Create the file ./.vscode/settings.json and fill it with the following content:
{
// Hush CMake
"cmake.configureOnOpen": false,
// Configure Python so that each new terminal will activate the venv
// defaultInterpreterPath is not always be picked up, backup cmd: 'Python: select interpreter'
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
"python.terminal.activateEnvironment": true,
"python.terminal.activateEnvInCurrentTerminal": true,
// IntelliSense
"C_Cpp.default.compilerPath": "${userHome}/zephyr-sdk-0.16.3/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc",
"C_Cpp.default.compileCommands": "${workspaceFolder}/build/compile_commands.json",
"C_Cpp.autoAddFileAssociations": false,
"C_Cpp.debugShortcut": false
}The first setting will avoid noisy popups from the CMake extension.
The python related settings will ensure that each time the integrated terminal is open, the
venv containing west will be automatically activated.
The C/C++ settings will configure intellisense. Those setting might be slightly different
for your specific Zephyr SDK installation as versions might change.
Also, the compile commands path assumes west build gets run from the root of the zephyr
workspace.
One more step is required. The python extension does not load at startup when opening VS Code
unless some
specific activation
events happens.
This means that for a zephyr workspace, that by default does not have any of such activation
events, the extension does not load and when opening a terminal the venv does not activate.
To fix this you can create an empty mspythonconfig.json file that will serve as an activation
event. However, note that this file might interfere when using Pyright in your project.