Greybus for Zephyr
Build Status
Overview
This repository contains a Greybus module for the Zephyr Real-Time Operating System and the assosciated changes for instantiating mikroBUS ports over Greybus.
Building and Running
First, ensure that all required tools are installed by following Zephyr's Getting Started Guide.
Next, clone and synchronize repositories.
west init -m https://github.com/cfriedt/greybus-for-zephyr.git zephyrproject
cd zephyrproject
west update
While that is updating, choose a board from Zephyr's list of Supported Boards.
Next, update git submodules. Currently, there is a git submodule for the
manifesto
utility.
cd greybus
git submodule init
git submodule update
cd ..
Lastly, flash firmware for the chosen $BOARD
using the commands below.
cd zephyr
source zephyr-env.sh
git apply ../greybus/zephyr-gpio-get-direction.patch
git apply ../greybus/zephyr-sys-byteorder-posix.patch
git apply ../greybus/zephyr-dynamic-pthread-stacks.patch
west build -b $BOARD -t flash ../greybus/samples/subsys/greybus/net
A number of patches are required until respective functionality is added upstream in the Zephyr Project.
Note, there may be an overlay required for the connectivity options that a particular board supports.
IEEE 802.15.4 Overlay
In that case, say for IEEE 802.15.4 support, the west build
command
above should be modified as shown below.
west build -b $BOARD -t flash ../greybus/samples/subsys/greybus/net \
-- -DOVERLAY_CONFIG="overlay-802154.conf"
Bluetooth Low Energy Overlay
In that case, say for BLE support, the west build
command
above should be modified as shown below.
west build -b $BOARD -t flash ../greybus/samples/subsys/greybus/net \
-- -DOVERLAY_CONFIG="overlay-ble.conf"
Network Configuration
While Greybus is capable of operating over any reliable transport, the focus of this project is TCP/IP (although quite an assortment of physical and data-link layers are supported in Zephyr).
Depending on the board that was chosen and the available connectivity options, some additional steps may be required for network connectivity.
Once network connectivity is established, it should be possible to use an mDNS browser such as Avahi to scan for service discovery.
avahi-browse -t -r _greybus._tcp
+ lowpan0 IPv6 zephyr _greybus._tcp local
= lowpan0 IPv6 zephyr _greybus._tcp local
hostname = [zephyr.local]
address = [2001:db8::1]
port = [4242]
txt = []
Client-Side Software Requirements
A Linux machine is required in order to connect to and control our Zephyr device via Greybus so be sure to follow Linux Software Requirements.
Using Greybus for I/O
At this point, we should be ready to perform some I/O on our remote devices using Greybus. Currently, this module supports the protocols below.
Trying out different add-on boards/devices over mikroBUS
Currently the add-on board manifests are selected at compile time(temporarily until add-on board ID driver is implemented in Zephyr) and the add-on board can be choosen by updating the Kconfig options here
CONFIG_GREYBUS_CLICK_MANIFEST_BUILTIN=y
CONFIG_GREYBUS_MIKROBUS_CLICK1_NAME="WEATHER-CLICK"
CONFIG_GREYBUS_MIKROBUS_CLICK2_NAME="AIR-QUALITY-2-CLICK"
The names of the add-on boards should be specified same as that present in the manifesto/manifests repository.
Describing On-board devices through Zephyr DT
For MCU Clients like the SensorTag,the on-board fixed devices(like the OPT3001) can be described over the Zephyr Device Tree Overlay in this manner :
gbstring3 {
label = "GBSTRING_3";
status = "okay";
compatible = "zephyr,greybus-string";
id = <3>;
greybus-string = "opt3001";
};
gbdevice0 {
label = "GBDEVICE_0";
status = "okay";
compatible = "zephyr,greybus-device";
id = <1>;
driver-string-id = <&gbstring3>;
protocol = <3>;
addr = <0x44>;
};
Contribute Back
In case a board was chosen that does not yet support Greybus, consider submitting a DeviceTree overlay file similar to cc1352r_sensortag.overlay and a board-specific configuration file similar to cc1352r_sensortag.conf.
The contribution guidelines for this module follow the Zephyr Contribution Guidelines.
To summarize,
- Create an Issue
- Code up your contribution
- Code up any tests and samples as required
- Ensure that tests pass and samples run as expected
- Make a Pull Request
Additional Information
Additional Information about Greybus including videos, slide presentations, and deprecated demo instructions can be found here.
A compiled version of the Greybus Specification is available here.