Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 19 additions & 42 deletions .github/workflows/ci.yml
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,71 +1,48 @@
name: CI

on:
workflow_dispatch:
inputs:
name:
description: "Manual trigger"
pull_request:
branches:
- '**'
branches: ["rolling", "jazzy", "humble"]

jobs:

micro_ros_zephyr_module:
runs-on: ubuntu-latest
container: ubuntu:22.04
container:
image: zephyrprojectrtos/ci:v0.26.17
options: --user root
env:
CMAKE_PREFIX_PATH: /opt/toolchains
strategy:
fail-fast: false
matrix:
zephyr_version: ["zephyr-v3.1.0", "zephyr-v2.7.2"]
include:
- zephyr_version: zephyr-v2.7.2
zephyr_sdk: 0.14.2
sdk_filename: zephyr-sdk-$TOOLCHAIN_VERSION\_linux-x86_64_minimal.tar.gz
- zephyr_version: zephyr-v3.1.0
zephyr_sdk: 0.14.2
sdk_filename: zephyr-sdk-$TOOLCHAIN_VERSION\_linux-x86_64_minimal.tar.gz
zephyr_version: ["v4.0.0", "v4.1.0"]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
path: micro_ros_zephyr_module

- name: Build
shell: bash
run: |
# Install dependencies
apt update
export DEBIAN_FRONTEND=noninteractive
apt install -y --no-install-recommends wget git cmake ninja-build gperf \
ccache dfu-util device-tree-compiler wget \
python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \
make gcc gcc-multilib g++-multilib libsdl2-dev

# Install Zephyr environment
pip3 install --user -U west
export PATH=~/.local/bin:/github/home/.local/bin:"$PATH"
west init zephyrproject
cd zephyrproject
# Zephyr setup
apt -y update
west init
cd zephyr
git checkout ${{ matrix.zephyr_version }}
cd ..
west update
west zephyr-export
pip3 install --user -r zephyr/scripts/requirements.txt
cd ..
export TOOLCHAIN_VERSION=${{ matrix.zephyr_sdk }}
export TOOLCHAIN_FILE_NAME=${{ matrix.sdk_filename }}
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v$TOOLCHAIN_VERSION/$TOOLCHAIN_FILE_NAME
tar xvf $TOOLCHAIN_FILE_NAME
cd zephyr-sdk-$TOOLCHAIN_VERSION
./setup.sh -h -t arm-zephyr-eabi -c
cd ..
source zephyr-sdk-$TOOLCHAIN_VERSION/environment-setup-x86_64-pokysdk-linux
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
export ZEPHYR_SDK_INSTALL_DIR=$(pwd)/zephyr-sdk-$TOOLCHAIN_VERSION
source zephyrproject/zephyr/zephyr-env.sh
west update --narrow

# Installing micro-ROS prerequisites
pip3 install catkin_pkg lark-parser empy colcon-common-extensions

# Build with Serial USB transport
west build -b disco_l475_iot1 micro_ros_zephyr_module -- -DCONFIG_MICROROS_TRANSPORT_SERIAL_USB=y
west build -b disco_l475_iot1 $GITHUB_WORKSPACE/micro_ros_zephyr_module -p -- -DCONFIG_MICROROS_TRANSPORT_SERIAL_USB=y

# Build with Serial transport
west build -b disco_l475_iot1 micro_ros_zephyr_module -- -DCONFIG_MICROROS_TRANSPORT_SERIAL=y
west build -b disco_l475_iot1 $GITHUB_WORKSPACE/micro_ros_zephyr_module -p -- -DCONFIG_MICROROS_TRANSPORT_SERIAL=y

62 changes: 18 additions & 44 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,73 +10,47 @@ on:

jobs:

micro_ros_zephyr_module:
nightly_micro_ros_zephyr_module:
runs-on: ubuntu-latest
container: ubuntu:22.04
container:
image: zephyrprojectrtos/ci:v0.26.17
options: --user root
env:
CMAKE_PREFIX_PATH: /opt/toolchains
strategy:
fail-fast: false
matrix:
zephyr_version: ["zephyr-v3.1.0", "zephyr-v2.7.2"]
distro: ["iron", "humble", "rolling"]
zephyr_version: ["v4.0.0", "v4.1.0"]
distro: ["rolling", "jazzy", "humble"]
include:
- distro: iron
branch: iron
- distro: rolling
branch: rolling
- distro: jazzy
branch: jazzy
- distro: humble
branch: humble
- zephyr_version: zephyr-v2.7.2
zephyr_sdk: 0.14.2
sdk_filename: zephyr-sdk-$TOOLCHAIN_VERSION\_linux-x86_64_minimal.tar.gz
- zephyr_version: zephyr-v3.1.0
zephyr_sdk: 0.14.2
sdk_filename: zephyr-sdk-$TOOLCHAIN_VERSION\_linux-x86_64_minimal.tar.gz
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
path: micro_ros_zephyr_module
branch: ${{ matrix.branch }}
ref: ${{ matrix.branch }}

- name: Build
shell: bash
run: |
# Install dependencies
apt update
export DEBIAN_FRONTEND=noninteractive
apt install -y --no-install-recommends wget git cmake ninja-build gperf \
ccache dfu-util device-tree-compiler wget \
python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \
make gcc gcc-multilib g++-multilib libsdl2-dev

# Install Zephyr environment
pip3 install --user -U west
export PATH=~/.local/bin:/github/home/.local/bin:"$PATH"
west init zephyrproject
cd zephyrproject
# Zephyr setup
apt -y update
west init
cd zephyr
git checkout ${{ matrix.zephyr_version }}
cd ..
west update
west zephyr-export
pip3 install --user -r zephyr/scripts/requirements.txt
cd ..
export TOOLCHAIN_VERSION=${{ matrix.zephyr_sdk }}
export TOOLCHAIN_FILE_NAME=${{ matrix.sdk_filename }}
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v$TOOLCHAIN_VERSION/$TOOLCHAIN_FILE_NAME
tar xvf $TOOLCHAIN_FILE_NAME
cd zephyr-sdk-$TOOLCHAIN_VERSION
./setup.sh -h -t arm-zephyr-eabi -c
cd ..
source zephyr-sdk-$TOOLCHAIN_VERSION/environment-setup-x86_64-pokysdk-linux
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
export ZEPHYR_SDK_INSTALL_DIR=$(pwd)/zephyr-sdk-$TOOLCHAIN_VERSION
source zephyrproject/zephyr/zephyr-env.sh
west update --narrow

# Installing micro-ROS prerequisites
pip3 install catkin_pkg lark-parser empy colcon-common-extensions

# Build with Serial USB transport
west build -b disco_l475_iot1 micro_ros_zephyr_module -- -DCONFIG_MICROROS_TRANSPORT_SERIAL_USB=y
west build -b disco_l475_iot1 $GITHUB_WORKSPACE/micro_ros_zephyr_module -p -- -DCONFIG_MICROROS_TRANSPORT_SERIAL_USB=y

# Build with Serial transport
west build -b disco_l475_iot1 micro_ros_zephyr_module -- -DCONFIG_MICROROS_TRANSPORT_SERIAL=y
west build -b disco_l475_iot1 $GITHUB_WORKSPACE/micro_ros_zephyr_module -p -- -DCONFIG_MICROROS_TRANSPORT_SERIAL=y
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# micro-ROS module for Zephyr

This module has been tested in Zephyr RTOS v2.7.0 (SDK 0.14.2) and v3.1.0 (SDK 0.14.2).
This module has been tested in Zephyr RTOS v4.0.0 (SDK 0.16.9-rc3), and v4.1.0 (SDK 0.16.9-rc3), using a docker image based on 'zephyrprojectrtos/zephyr-build:v0.26.17'.

## Dependencies

Expand All @@ -18,7 +18,7 @@ pip3 install catkin_pkg lark-parser empy colcon-common-extensions
For example for `disco_l475_iot1` board:

```bash
west build -b disco_l475_iot1 micro_ros_zephyr_module
west build -b disco_l475_iot1 -p
```

Some configuration parameters can be found using:
Expand Down
4 changes: 1 addition & 3 deletions modules/libmicroros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ externalproject_add(libmicroros_project
BUILD_BYPRODUCTS ${MICROROS_DIR}/libmicroros.a
)

zephyr_library_import(libmicroros ${MICROROS_DIR}/libmicroros.a)
zephyr_link_libraries(${MICROROS_DIR}/libmicroros.a)

zephyr_interface_library_named(microros)
add_dependencies(microros libmicroros)
add_dependencies(microros libmicroros_project)
target_include_directories(microros INTERFACE ${MICROROS_DIR}/include)

Expand Down Expand Up @@ -96,7 +95,6 @@ zephyr_library_sources(

add_dependencies(microros microros_transports)
add_dependencies(microros_transports libmicroros_project)
add_dependencies(microros_transports libmicroros)

# Cleaning

Expand Down
3 changes: 2 additions & 1 deletion modules/libmicroros/libmicroros.mk
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ $(COMPONENT_PATH)/micro_ros_src/src:
touch src/common_interfaces/std_srvs/COLCON_IGNORE; \
touch src/rcl/rcl_yaml_param_parser/COLCON_IGNORE; \
touch src/rcl_logging/rcl_logging_spdlog/COLCON_IGNORE; \
touch src/rcl_interfaces/test_msgs/COLCON_IGNORE;
touch src/rcl_interfaces/test_msgs/COLCON_IGNORE; \
touch src/rmw/rmw_security_common/COLCON_IGNORE;

$(COMPONENT_PATH)/micro_ros_src/install: configure_colcon_meta configure_toolchain $(COMPONENT_PATH)/micro_ros_dev/install $(COMPONENT_PATH)/micro_ros_src/src
cd $(UROS_DIR); \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <stdbool.h>

#define RING_BUF_SIZE 2048
#define UART_NODE DT_NODELABEL(usart1)

char uart_in_buffer[RING_BUF_SIZE];
char uart_out_buffer[RING_BUF_SIZE];
Expand Down Expand Up @@ -52,9 +53,7 @@ static void uart_fifo_callback(const struct device * dev, void * args){
bool zephyr_transport_open(struct uxrCustomTransport * transport){
zephyr_transport_params_t * params = (zephyr_transport_params_t*) transport->args;

char uart_descriptor[8];
sprintf(uart_descriptor,"UART_%d", params->fd);
params->uart_dev = device_get_binding(uart_descriptor);
params->uart_dev = DEVICE_DT_GET(UART_NODE);
if (!params->uart_dev) {
printk("Serial device not found\n");
return false;
Expand Down
2 changes: 1 addition & 1 deletion prj.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
CONFIG_GPIO=y
CONFIG_MICROROS=y
CONFIG_CPP=y

CONFIG_MAIN_STACK_SIZE=25000
CONFIG_MAIN_THREAD_PRIORITY=3
Expand All @@ -9,7 +10,6 @@ CONFIG_NEWLIB_LIBC_NANO=n
CONFIG_PTHREAD_IPC=n

CONFIG_POSIX_API=y
CONFIG_APP_LINK_WITH_POSIX_SUBSYS=y
CONFIG_POSIX_CLOCK=y

CONFIG_STDOUT_CONSOLE=y
Expand Down
5 changes: 3 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <version.h>

#if ZEPHYR_VERSION_CODE >= ZEPHYR_VERSION(3,1,0)
#include <zephyr/zephyr.h>
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
#include <zephyr/drivers/gpio.h>
Expand Down Expand Up @@ -39,7 +39,7 @@ void timer_callback(rcl_timer_t * timer, int64_t last_call_time)
}
}

void main(void)
int main(void)
{
rmw_uros_set_custom_transport(
MICRO_ROS_FRAMING_REQUIRED,
Expand Down Expand Up @@ -91,4 +91,5 @@ void main(void)
// free resources
RCCHECK(rcl_publisher_fini(&publisher, &node))
RCCHECK(rcl_node_fini(&node))
return 0;
}