Skip to content

Commit bfbea6c

Browse files
Z0rdonmergify[bot]
authored andcommitted
updates project to work with zephyr v4.0.x (#146)
* updates project to work with zephyr v4.0.x * updating workflows for zephyr v4.0.x * adds cmake prefix path, changes to ci image * adds manual trigger to ci workflows * updates CI workflows for all active ROS2 distros * Get uart device with Zephyr 4's Devicetree-centric approach Signed-off-by: Antón Casas <[email protected]> * Tested in v4.1.0 using manual installation on Ubuntu:24.04 base Docker image Signed-off-by: Antón Casas <[email protected]> * Add v4.1.0 to CI and nightly Signed-off-by: Antón Casas <[email protected]> * State SDK used in CI. Restore Z0rdon's info about docker image used. Signed-off-by: Antón Casas <[email protected]> --------- Signed-off-by: Antón Casas <[email protected]> Co-authored-by: Antón Casas <[email protected]> (cherry picked from commit 7cbe6da) # Conflicts: # .github/workflows/nightly.yml
1 parent f7a8e3c commit bfbea6c

File tree

7 files changed

+54
-89
lines changed

7 files changed

+54
-89
lines changed

.github/workflows/ci.yml

100755100644
Lines changed: 19 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,48 @@
11
name: CI
22

33
on:
4+
workflow_dispatch:
5+
inputs:
6+
name:
7+
description: "Manual trigger"
48
pull_request:
5-
branches:
6-
- '**'
9+
branches: ["rolling", "jazzy", "humble"]
710

811
jobs:
912

1013
micro_ros_zephyr_module:
1114
runs-on: ubuntu-latest
12-
container: ubuntu:22.04
15+
container:
16+
image: zephyrprojectrtos/ci:v0.26.17
17+
options: --user root
18+
env:
19+
CMAKE_PREFIX_PATH: /opt/toolchains
1320
strategy:
1421
fail-fast: false
1522
matrix:
16-
zephyr_version: ["zephyr-v3.1.0", "zephyr-v2.7.2"]
17-
include:
18-
- zephyr_version: zephyr-v2.7.2
19-
zephyr_sdk: 0.14.2
20-
sdk_filename: zephyr-sdk-$TOOLCHAIN_VERSION\_linux-x86_64_minimal.tar.gz
21-
- zephyr_version: zephyr-v3.1.0
22-
zephyr_sdk: 0.14.2
23-
sdk_filename: zephyr-sdk-$TOOLCHAIN_VERSION\_linux-x86_64_minimal.tar.gz
23+
zephyr_version: ["v4.0.0", "v4.1.0"]
2424
steps:
25-
- uses: actions/checkout@v2
25+
- uses: actions/checkout@v4
2626
with:
2727
path: micro_ros_zephyr_module
2828

2929
- name: Build
3030
shell: bash
3131
run: |
32-
# Install dependencies
33-
apt update
34-
export DEBIAN_FRONTEND=noninteractive
35-
apt install -y --no-install-recommends wget git cmake ninja-build gperf \
36-
ccache dfu-util device-tree-compiler wget \
37-
python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \
38-
make gcc gcc-multilib g++-multilib libsdl2-dev
39-
40-
# Install Zephyr environment
41-
pip3 install --user -U west
42-
export PATH=~/.local/bin:/github/home/.local/bin:"$PATH"
43-
west init zephyrproject
44-
cd zephyrproject
32+
# Zephyr setup
33+
apt -y update
34+
west init
4535
cd zephyr
4636
git checkout ${{ matrix.zephyr_version }}
4737
cd ..
48-
west update
49-
west zephyr-export
50-
pip3 install --user -r zephyr/scripts/requirements.txt
51-
cd ..
52-
export TOOLCHAIN_VERSION=${{ matrix.zephyr_sdk }}
53-
export TOOLCHAIN_FILE_NAME=${{ matrix.sdk_filename }}
54-
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v$TOOLCHAIN_VERSION/$TOOLCHAIN_FILE_NAME
55-
tar xvf $TOOLCHAIN_FILE_NAME
56-
cd zephyr-sdk-$TOOLCHAIN_VERSION
57-
./setup.sh -h -t arm-zephyr-eabi -c
58-
cd ..
59-
source zephyr-sdk-$TOOLCHAIN_VERSION/environment-setup-x86_64-pokysdk-linux
60-
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
61-
export ZEPHYR_SDK_INSTALL_DIR=$(pwd)/zephyr-sdk-$TOOLCHAIN_VERSION
62-
source zephyrproject/zephyr/zephyr-env.sh
38+
west update --narrow
6339
6440
# Installing micro-ROS prerequisites
6541
pip3 install catkin_pkg lark-parser empy colcon-common-extensions
6642
6743
# Build with Serial USB transport
68-
west build -b disco_l475_iot1 micro_ros_zephyr_module -- -DCONFIG_MICROROS_TRANSPORT_SERIAL_USB=y
44+
west build -b disco_l475_iot1 $GITHUB_WORKSPACE/micro_ros_zephyr_module -p -- -DCONFIG_MICROROS_TRANSPORT_SERIAL_USB=y
6945
7046
# Build with Serial transport
71-
west build -b disco_l475_iot1 micro_ros_zephyr_module -- -DCONFIG_MICROROS_TRANSPORT_SERIAL=y
47+
west build -b disco_l475_iot1 $GITHUB_WORKSPACE/micro_ros_zephyr_module -p -- -DCONFIG_MICROROS_TRANSPORT_SERIAL=y
48+

.github/workflows/nightly.yml

Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,27 @@ on:
1010

1111
jobs:
1212

13-
micro_ros_zephyr_module:
13+
nightly_micro_ros_zephyr_module:
1414
runs-on: ubuntu-latest
15-
container: ubuntu:22.04
15+
container:
16+
image: zephyrprojectrtos/ci:v0.26.17
17+
options: --user root
18+
env:
19+
CMAKE_PREFIX_PATH: /opt/toolchains
1620
strategy:
1721
fail-fast: false
1822
matrix:
23+
<<<<<<< HEAD
1924
zephyr_version: ["zephyr-v3.1.0", "zephyr-v2.7.2"]
2025
distro: ["iron", "humble", "rolling"]
26+
=======
27+
zephyr_version: ["v4.0.0", "v4.1.0"]
28+
distro: ["rolling", "jazzy", "humble"]
29+
>>>>>>> 7cbe6da (updates project to work with zephyr v4.0.x (#146))
2130
include:
22-
- distro: iron
23-
branch: iron
2431
- distro: rolling
2532
branch: rolling
33+
<<<<<<< HEAD
2634
- distro: humble
2735
branch: humble
2836
- zephyr_version: zephyr-v2.7.2
@@ -31,52 +39,34 @@ jobs:
3139
- zephyr_version: zephyr-v3.1.0
3240
zephyr_sdk: 0.14.2
3341
sdk_filename: zephyr-sdk-$TOOLCHAIN_VERSION\_linux-x86_64_minimal.tar.gz
42+
=======
43+
- distro: jazzy
44+
branch: jazzy
45+
- distro: humble
46+
branch: humble
47+
>>>>>>> 7cbe6da (updates project to work with zephyr v4.0.x (#146))
3448
steps:
35-
- uses: actions/checkout@v2
49+
- uses: actions/checkout@v4
3650
with:
3751
path: micro_ros_zephyr_module
38-
branch: ${{ matrix.branch }}
52+
ref: ${{ matrix.branch }}
3953

4054
- name: Build
4155
shell: bash
4256
run: |
43-
# Install dependencies
44-
apt update
45-
export DEBIAN_FRONTEND=noninteractive
46-
apt install -y --no-install-recommends wget git cmake ninja-build gperf \
47-
ccache dfu-util device-tree-compiler wget \
48-
python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \
49-
make gcc gcc-multilib g++-multilib libsdl2-dev
50-
51-
# Install Zephyr environment
52-
pip3 install --user -U west
53-
export PATH=~/.local/bin:/github/home/.local/bin:"$PATH"
54-
west init zephyrproject
55-
cd zephyrproject
57+
# Zephyr setup
58+
apt -y update
59+
west init
5660
cd zephyr
5761
git checkout ${{ matrix.zephyr_version }}
5862
cd ..
59-
west update
60-
west zephyr-export
61-
pip3 install --user -r zephyr/scripts/requirements.txt
62-
cd ..
63-
export TOOLCHAIN_VERSION=${{ matrix.zephyr_sdk }}
64-
export TOOLCHAIN_FILE_NAME=${{ matrix.sdk_filename }}
65-
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v$TOOLCHAIN_VERSION/$TOOLCHAIN_FILE_NAME
66-
tar xvf $TOOLCHAIN_FILE_NAME
67-
cd zephyr-sdk-$TOOLCHAIN_VERSION
68-
./setup.sh -h -t arm-zephyr-eabi -c
69-
cd ..
70-
source zephyr-sdk-$TOOLCHAIN_VERSION/environment-setup-x86_64-pokysdk-linux
71-
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
72-
export ZEPHYR_SDK_INSTALL_DIR=$(pwd)/zephyr-sdk-$TOOLCHAIN_VERSION
73-
source zephyrproject/zephyr/zephyr-env.sh
63+
west update --narrow
7464
7565
# Installing micro-ROS prerequisites
7666
pip3 install catkin_pkg lark-parser empy colcon-common-extensions
7767
7868
# Build with Serial USB transport
79-
west build -b disco_l475_iot1 micro_ros_zephyr_module -- -DCONFIG_MICROROS_TRANSPORT_SERIAL_USB=y
69+
west build -b disco_l475_iot1 $GITHUB_WORKSPACE/micro_ros_zephyr_module -p -- -DCONFIG_MICROROS_TRANSPORT_SERIAL_USB=y
8070
8171
# Build with Serial transport
82-
west build -b disco_l475_iot1 micro_ros_zephyr_module -- -DCONFIG_MICROROS_TRANSPORT_SERIAL=y
72+
west build -b disco_l475_iot1 $GITHUB_WORKSPACE/micro_ros_zephyr_module -p -- -DCONFIG_MICROROS_TRANSPORT_SERIAL=y

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# micro-ROS module for Zephyr
55

6-
This module has been tested in Zephyr RTOS v2.7.0 (SDK 0.14.2) and v3.1.0 (SDK 0.14.2).
6+
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'.
77

88
## Dependencies
99

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

2020
```bash
21-
west build -b disco_l475_iot1 micro_ros_zephyr_module
21+
west build -b disco_l475_iot1 -p
2222
```
2323

2424
Some configuration parameters can be found using:

modules/libmicroros/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,9 @@ externalproject_add(libmicroros_project
5252
BUILD_BYPRODUCTS ${MICROROS_DIR}/libmicroros.a
5353
)
5454

55-
zephyr_library_import(libmicroros ${MICROROS_DIR}/libmicroros.a)
55+
zephyr_link_libraries(${MICROROS_DIR}/libmicroros.a)
5656

5757
zephyr_interface_library_named(microros)
58-
add_dependencies(microros libmicroros)
5958
add_dependencies(microros libmicroros_project)
6059
target_include_directories(microros INTERFACE ${MICROROS_DIR}/include)
6160

@@ -96,7 +95,6 @@ zephyr_library_sources(
9695

9796
add_dependencies(microros microros_transports)
9897
add_dependencies(microros_transports libmicroros_project)
99-
add_dependencies(microros_transports libmicroros)
10098

10199
# Cleaning
102100

modules/libmicroros/microros_transports/serial/microros_transports.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <stdbool.h>
2525

2626
#define RING_BUF_SIZE 2048
27+
#define UART_NODE DT_NODELABEL(usart1)
2728

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

55-
char uart_descriptor[8];
56-
sprintf(uart_descriptor,"UART_%d", params->fd);
57-
params->uart_dev = device_get_binding(uart_descriptor);
56+
params->uart_dev = DEVICE_DT_GET(UART_NODE);
5857
if (!params->uart_dev) {
5958
printk("Serial device not found\n");
6059
return false;

prj.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
CONFIG_GPIO=y
22
CONFIG_MICROROS=y
3+
CONFIG_CPP=y
34

45
CONFIG_MAIN_STACK_SIZE=25000
56
CONFIG_MAIN_THREAD_PRIORITY=3
@@ -9,7 +10,6 @@ CONFIG_NEWLIB_LIBC_NANO=n
910
CONFIG_PTHREAD_IPC=n
1011

1112
CONFIG_POSIX_API=y
12-
CONFIG_APP_LINK_WITH_POSIX_SUBSYS=y
1313
CONFIG_POSIX_CLOCK=y
1414

1515
CONFIG_STDOUT_CONSOLE=y

src/main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <version.h>
22

33
#if ZEPHYR_VERSION_CODE >= ZEPHYR_VERSION(3,1,0)
4-
#include <zephyr/zephyr.h>
4+
#include <zephyr/kernel.h>
55
#include <zephyr/device.h>
66
#include <zephyr/devicetree.h>
77
#include <zephyr/drivers/gpio.h>
@@ -39,7 +39,7 @@ void timer_callback(rcl_timer_t * timer, int64_t last_call_time)
3939
}
4040
}
4141

42-
void main(void)
42+
int main(void)
4343
{
4444
rmw_uros_set_custom_transport(
4545
MICRO_ROS_FRAMING_REQUIRED,
@@ -91,4 +91,5 @@ void main(void)
9191
// free resources
9292
RCCHECK(rcl_publisher_fini(&publisher, &node))
9393
RCCHECK(rcl_node_fini(&node))
94+
return 0;
9495
}

0 commit comments

Comments
 (0)