From 38069f3cc05e5ec9da44c88265dd1ebebbcf8176 Mon Sep 17 00:00:00 2001 From: Z0rdon <101883124+Z0rdon@users.noreply.github.com> Date: Mon, 13 Jan 2025 21:15:24 -0500 Subject: [PATCH 1/4] updates project to work with zephyr v4.0.x --- README.md | 4 ++-- modules/libmicroros/CMakeLists.txt | 4 +--- prj.conf | 2 +- src/main.c | 5 +++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index af8a08e..3560a99 100644 --- a/README.md +++ b/README.md @@ -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.99 (SDK 0.16.9-rc3), using a docker image based on 'zephyrprojectrtos/zephyr-build:v0.26.17'. ## Dependencies @@ -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: diff --git a/modules/libmicroros/CMakeLists.txt b/modules/libmicroros/CMakeLists.txt index 193524d..4e8c213 100644 --- a/modules/libmicroros/CMakeLists.txt +++ b/modules/libmicroros/CMakeLists.txt @@ -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) @@ -96,7 +95,6 @@ zephyr_library_sources( add_dependencies(microros microros_transports) add_dependencies(microros_transports libmicroros_project) -add_dependencies(microros_transports libmicroros) # Cleaning diff --git a/prj.conf b/prj.conf index aa11d31..8c8706b 100644 --- a/prj.conf +++ b/prj.conf @@ -1,5 +1,6 @@ CONFIG_GPIO=y CONFIG_MICROROS=y +CONFIG_CPP=y CONFIG_MAIN_STACK_SIZE=25000 CONFIG_MAIN_THREAD_PRIORITY=3 @@ -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 diff --git a/src/main.c b/src/main.c index d24f06b..6efe05c 100644 --- a/src/main.c +++ b/src/main.c @@ -1,7 +1,7 @@ #include #if ZEPHYR_VERSION_CODE >= ZEPHYR_VERSION(3,1,0) -#include +#include #include #include #include @@ -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, @@ -91,4 +91,5 @@ void main(void) // free resources RCCHECK(rcl_publisher_fini(&publisher, &node)) RCCHECK(rcl_node_fini(&node)) + return 0; } From 37f041246f396925aa10ef82c4c6e867c0c76f3f Mon Sep 17 00:00:00 2001 From: Z0rdon <101883124+Z0rdon@users.noreply.github.com> Date: Wed, 15 Jan 2025 23:48:36 -0500 Subject: [PATCH 2/4] updating workflows for zephyr v4.0.x --- .github/workflows/ci.yml | 60 ++++++------------------ .github/workflows/legacy_ci.yml | 45 ++++++++++++++++++ .github/workflows/legacy_nightly.yml | 57 ++++++++++++++++++++++ .github/workflows/nightly.yml | 70 ++++++---------------------- 4 files changed, 131 insertions(+), 101 deletions(-) create mode 100644 .github/workflows/legacy_ci.yml create mode 100644 .github/workflows/legacy_nightly.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34ab831..ac472be 100755 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,70 +2,38 @@ name: CI on: pull_request: - branches: - - '**' + branches-ignore: ["iron", "rolling", "humble"] jobs: micro_ros_zephyr_module: runs-on: ubuntu-latest - container: ubuntu:22.04 + container: + image: zephyrprojectrtos/zephyr-build:v0.26.17 + options: --user root 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 + defaults: + run: + working-directory: /workdir 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 - 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 + # Zephyr setup + apt -y update + west init + 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 diff --git a/.github/workflows/legacy_ci.yml b/.github/workflows/legacy_ci.yml new file mode 100644 index 0000000..0b31854 --- /dev/null +++ b/.github/workflows/legacy_ci.yml @@ -0,0 +1,45 @@ +name: Legacy_CI + +on: + pull_request: + branches: ["iron", "rolling", "humble"] + +jobs: + + legacy_micro_ros_zephyr_module: + runs-on: ubuntu-latest + container: + image: zephyrprojectrtos/zephyr-build:v0.23.2 + options: --user root + strategy: + fail-fast: false + matrix: + zephyr_version: ["zephyr-v3.1.0", "zephyr-v2.7.2"] + defaults: + run: + working-directory: /workdir + steps: + - uses: actions/checkout@v4 + with: + path: micro_ros_zephyr_module + + - name: Build + shell: bash + run: | + # Zephyr setup + apt -y update + west init + cd zephyr + git checkout ${{ matrix.zephyr_version }} + cd .. + 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 $GITHUB_WORKSPACE/micro_ros_zephyr_module -p -- -DCONFIG_MICROROS_TRANSPORT_SERIAL_USB=y + + # Build with Serial transport + west build -b disco_l475_iot1 $GITHUB_WORKSPACE/micro_ros_zephyr_module -p -- -DCONFIG_MICROROS_TRANSPORT_SERIAL=y + diff --git a/.github/workflows/legacy_nightly.yml b/.github/workflows/legacy_nightly.yml new file mode 100644 index 0000000..c9a8386 --- /dev/null +++ b/.github/workflows/legacy_nightly.yml @@ -0,0 +1,57 @@ +name: Legacy_Nightly + +on: + workflow_dispatch: + inputs: + name: + description: "Manual trigger" + schedule: + - cron: '0 4 * * *' + +jobs: + + legacy_nightly_micro_ros_zephyr_module: + runs-on: ubuntu-latest + container: + image: zephyrprojectrtos/zephyr-build:v0.23.2 + options: --user root + strategy: + fail-fast: false + matrix: + zephyr_version: ["zephyr-v3.1.0", "zephyr-v2.7.2"] + distro: ["iron", "humble", "rolling"] + include: + - distro: iron + branch: iron + - distro: humble + branch: humble + - distro: rolling + branch: rolling + defaults: + run: + working-directory: /workdir + steps: + - uses: actions/checkout@v4 + with: + path: micro_ros_zephyr_module + ref: ${{ matrix.branch }} + + - name: Build + shell: bash + run: | + # Zephyr setup + apt -y update + west init + cd zephyr + git checkout ${{ matrix.zephyr_version }} + cd .. + 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 $GITHUB_WORKSPACE/micro_ros_zephyr_module -p -- -DCONFIG_MICROROS_TRANSPORT_SERIAL_USB=y + + # Build with Serial transport + west build -b disco_l475_iot1 $GITHUB_WORKSPACE/micro_ros_zephyr_module -p -- -DCONFIG_MICROROS_TRANSPORT_SERIAL=y diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 6bab7f5..b4915f0 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -10,75 +10,35 @@ on: jobs: - micro_ros_zephyr_module: + nightly_micro_ros_zephyr_module: runs-on: ubuntu-latest - container: ubuntu:22.04 + container: + image: zephyrprojectrtos/zephyr-build:v0.26.17 + options: --user root strategy: fail-fast: false - matrix: - zephyr_version: ["zephyr-v3.1.0", "zephyr-v2.7.2"] - distro: ["iron", "humble", "rolling", "jazzy"] - include: - - distro: iron - branch: iron - - distro: rolling - branch: rolling - - distro: humble - branch: humble - - distro: jazzy - branch: jazzy - - 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 + defaults: + run: + working-directory: /workdir steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: path: micro_ros_zephyr_module - branch: ${{ matrix.branch }} + ref: jazzy - 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 - 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 + # Zephyr setup + apt -y update + west init + 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 From 33e68fef20827b811135e444891a266910ae58cf Mon Sep 17 00:00:00 2001 From: Z0rdon <101883124+Z0rdon@users.noreply.github.com> Date: Thu, 16 Jan 2025 19:49:06 -0500 Subject: [PATCH 3/4] adds cmake prefix path, changes to ci image --- .github/workflows/ci.yml | 7 +++---- .github/workflows/legacy_ci.yml | 7 +++---- .github/workflows/legacy_nightly.yml | 7 +++---- .github/workflows/nightly.yml | 7 +++---- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac472be..e7455a2 100755 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,13 +9,12 @@ jobs: micro_ros_zephyr_module: runs-on: ubuntu-latest container: - image: zephyrprojectrtos/zephyr-build:v0.26.17 + image: zephyrprojectrtos/ci:v0.26.17 options: --user root + env: + CMAKE_PREFIX_PATH: /opt/toolchains strategy: fail-fast: false - defaults: - run: - working-directory: /workdir steps: - uses: actions/checkout@v4 with: diff --git a/.github/workflows/legacy_ci.yml b/.github/workflows/legacy_ci.yml index 0b31854..b3e78ef 100644 --- a/.github/workflows/legacy_ci.yml +++ b/.github/workflows/legacy_ci.yml @@ -9,15 +9,14 @@ jobs: legacy_micro_ros_zephyr_module: runs-on: ubuntu-latest container: - image: zephyrprojectrtos/zephyr-build:v0.23.2 + image: zephyrprojectrtos/ci:v0.23.2 options: --user root + env: + CMAKE_PREFIX_PATH: /opt/toolchains strategy: fail-fast: false matrix: zephyr_version: ["zephyr-v3.1.0", "zephyr-v2.7.2"] - defaults: - run: - working-directory: /workdir steps: - uses: actions/checkout@v4 with: diff --git a/.github/workflows/legacy_nightly.yml b/.github/workflows/legacy_nightly.yml index c9a8386..f4f475d 100644 --- a/.github/workflows/legacy_nightly.yml +++ b/.github/workflows/legacy_nightly.yml @@ -13,8 +13,10 @@ jobs: legacy_nightly_micro_ros_zephyr_module: runs-on: ubuntu-latest container: - image: zephyrprojectrtos/zephyr-build:v0.23.2 + image: zephyrprojectrtos/ci:v0.23.2 options: --user root + env: + CMAKE_PREFIX_PATH: /opt/toolchains strategy: fail-fast: false matrix: @@ -27,9 +29,6 @@ jobs: branch: humble - distro: rolling branch: rolling - defaults: - run: - working-directory: /workdir steps: - uses: actions/checkout@v4 with: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index b4915f0..893315e 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -13,13 +13,12 @@ jobs: nightly_micro_ros_zephyr_module: runs-on: ubuntu-latest container: - image: zephyrprojectrtos/zephyr-build:v0.26.17 + image: zephyrprojectrtos/ci:v0.26.17 options: --user root + env: + CMAKE_PREFIX_PATH: /opt/toolchains strategy: fail-fast: false - defaults: - run: - working-directory: /workdir steps: - uses: actions/checkout@v4 with: From cdd97ddcf150ed6a095a12fc2c2eb34b12397a45 Mon Sep 17 00:00:00 2001 From: Z0rdon <101883124+Z0rdon@users.noreply.github.com> Date: Thu, 16 Jan 2025 20:08:08 -0500 Subject: [PATCH 4/4] adds manual trigger to ci workflows --- .github/workflows/ci.yml | 4 ++++ .github/workflows/legacy_ci.yml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e7455a2..c9b86bb 100755 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,10 @@ name: CI on: + workflow_dispatch: + inputs: + name: + description: "Manual trigger" pull_request: branches-ignore: ["iron", "rolling", "humble"] diff --git a/.github/workflows/legacy_ci.yml b/.github/workflows/legacy_ci.yml index b3e78ef..33d7a5c 100644 --- a/.github/workflows/legacy_ci.yml +++ b/.github/workflows/legacy_ci.yml @@ -1,6 +1,10 @@ name: Legacy_CI on: + workflow_dispatch: + inputs: + name: + description: "Manual trigger" pull_request: branches: ["iron", "rolling", "humble"]