From 1a53d788d54592e290f4fc565d3ad6b8c6a4c847 Mon Sep 17 00:00:00 2001 From: Pablo Garrido Date: Tue, 9 Aug 2022 11:35:03 +0200 Subject: [PATCH 1/3] Move support to v2.7.x and v3.1.0 (#64) * Add v2.7.0 and v3.1.0 Signed-off-by: Pablo Garrido Fix Signed-off-by: Pablo Garrido Fix Signed-off-by: Pablo Garrido Use ubuntu 20.04 Signed-off-by: Pablo Garrido Update cmake Signed-off-by: Pablo Garrido Fix env Signed-off-by: Pablo Garrido Fix Signed-off-by: Pablo Garrido Deprecate v2.4.0 Signed-off-by: Pablo Garrido Update Signed-off-by: Pablo Garrido Update Readme Signed-off-by: Pablo Garrido Fix CMake Signed-off-by: Pablo Garrido Update Signed-off-by: Pablo Garrido * Revert "Add v2.7.0 and v3.1.0" This reverts commit 64370f19cc08cf410ee46e9a8d0510ae2357f1cc. * Initial Signed-off-by: Pablo Garrido * Update Signed-off-by: Pablo Garrido * Update Signed-off-by: Pablo Garrido * Fix Signed-off-by: Pablo Garrido * Move 2.7.2 to new ci Signed-off-by: Pablo Garrido * Deprecate * Readme Signed-off-by: Pablo Garrido (cherry picked from commit 07797dfc4edab2f160c41a7b47acfd1b7b8b26f2) # Conflicts: # .github/workflows/ci.yml # .github/workflows/nightly.yml # README.md --- .github/workflows/ci.yml | 29 ++++++++++----- .github/workflows/nightly.yml | 36 +++++++++++++------ README.md | 4 +++ .../serial-usb/microros_transports.c | 12 ++++--- .../serial-usb/microros_transports.h | 2 +- prj.conf | 2 -- src/main.c | 6 +--- 7 files changed, 59 insertions(+), 32 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be50ddc..9a91160 100755 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,10 +9,11 @@ jobs: micro_ros_zephyr_module: runs-on: ubuntu-latest - container: ubuntu:20.04 + container: ubuntu:22.04 strategy: fail-fast: false matrix: +<<<<<<< HEAD zephyr_version: ["zephyr-v2.4.0", "zephyr-v2.5.0", "v2.6.0-rc1"] include: - zephyr_version: zephyr-v2.4.0 @@ -24,6 +25,16 @@ jobs: - zephyr_version: v2.6.0-rc1 zephyr_sdk: 0.12.4 sdk_filename: zephyr-toolchain-arm-$TOOLCHAIN_VERSION-x86_64-linux-setup.run +======= + 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 +>>>>>>> 07797df (Move support to v2.7.x and v3.1.0 (#64)) steps: - uses: actions/checkout@v2 with: @@ -34,8 +45,8 @@ jobs: run: | apt update export DEBIAN_FRONTEND=noninteractive - apt install -y --no-install-recommends git cmake ninja-build gperf \ - ccache dfu-util device-tree-compiler wget curl gnupg2 \ + 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 pip3 install --user -U west @@ -52,15 +63,15 @@ jobs: 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 - chmod +x $TOOLCHAIN_FILE_NAME - yes | ./$TOOLCHAIN_FILE_NAME -- -rc -y -d $(pwd)/zephyr-sdk || : - rm -rf $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 + export ZEPHYR_SDK_INSTALL_DIR=$(pwd)/zephyr-sdk-$TOOLCHAIN_VERSION source zephyrproject/zephyr/zephyr-env.sh # Installing micro-ROS prerequisites pip3 install catkin_pkg lark-parser empy colcon-common-extensions - # Workaround. Remove when https://github.com/sphinx-doc/sphinx/issues/10291 and https://github.com/micro-ROS/micro_ros_zephyr_module/runs/5714546662?check_suite_focus=true - pip3 install --upgrade Sphinx # Building the app west build -b disco_l475_iot1 micro_ros_zephyr_module diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 44042cb..1da9921 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -12,17 +12,23 @@ jobs: micro_ros_zephyr_module: runs-on: ubuntu-latest - container: ubuntu:20.04 + container: ubuntu:22.04 strategy: fail-fast: false matrix: +<<<<<<< HEAD zephyr_version: ["zephyr-v2.4.0", "zephyr-v2.5.0", "v2.6.0-rc1"] distro: ["foxy", "rolling"] +======= + zephyr_version: ["zephyr-v3.1.0", "zephyr-v2.7.2"] + distro: ["foxy", "humble", "rolling"] +>>>>>>> 07797df (Move support to v2.7.x and v3.1.0 (#64)) include: - distro: foxy branch: foxy - distro: rolling branch: main +<<<<<<< HEAD - zephyr_version: zephyr-v2.4.0 zephyr_sdk: 0.11.4 sdk_filename: zephyr-toolchain-arm-$TOOLCHAIN_VERSION-setup.run @@ -32,18 +38,28 @@ jobs: - zephyr_version: v2.6.0-rc1 zephyr_sdk: 0.12.4 sdk_filename: zephyr-toolchain-arm-$TOOLCHAIN_VERSION-x86_64-linux-setup.run +======= + - 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 +>>>>>>> 07797df (Move support to v2.7.x and v3.1.0 (#64)) steps: - uses: actions/checkout@v2 with: path: micro_ros_zephyr_module - ref: ${{ matrix.branch }} + - name: Dependencies shell: bash run: | apt update export DEBIAN_FRONTEND=noninteractive - apt install -y --no-install-recommends git cmake ninja-build gperf \ - ccache dfu-util device-tree-compiler wget curl gnupg2 \ + 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 pip3 install --user -U west @@ -60,15 +76,15 @@ jobs: 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 - chmod +x $TOOLCHAIN_FILE_NAME - yes | ./$TOOLCHAIN_FILE_NAME -- -rc -y -d $(pwd)/zephyr-sdk || : - rm -rf $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 + export ZEPHYR_SDK_INSTALL_DIR=$(pwd)/zephyr-sdk-$TOOLCHAIN_VERSION source zephyrproject/zephyr/zephyr-env.sh # Installing micro-ROS prerequisites pip3 install catkin_pkg lark-parser empy colcon-common-extensions - # Workaround. Remove when https://github.com/sphinx-doc/sphinx/issues/10291 and https://github.com/micro-ROS/micro_ros_zephyr_module/runs/5714546662?check_suite_focus=true - pip3 install --upgrade Sphinx # Building the app west build -b disco_l475_iot1 micro_ros_zephyr_module diff --git a/README.md b/README.md index 55b2d41..3d6a20a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,11 @@ # micro-ROS module for Zephyr +<<<<<<< HEAD This module has been tested in Zephyr RTOS v2.4.0 (SDK 0.11.4), v2.5.0 (SDK 0.11.4) and (v2.6.0 SDK 0.12.4). +======= +This module has been tested in Zephyr RTOS v2.7.0 (SDK 0.14.2) and v3.1.0 (SDK 0.14.2). +>>>>>>> 07797df (Move support to v2.7.x and v3.1.0 (#64)) ## Dependencies diff --git a/modules/libmicroros/microros_transports/serial-usb/microros_transports.c b/modules/libmicroros/microros_transports/serial-usb/microros_transports.c index 637064b..2b03461 100644 --- a/modules/libmicroros/microros_transports/serial-usb/microros_transports.c +++ b/modules/libmicroros/microros_transports/serial-usb/microros_transports.c @@ -22,7 +22,7 @@ char uart_out_buffer[RING_BUF_SIZE]; struct ring_buf out_ringbuf, in_ringbuf; -static void uart_fifo_callback(struct device *dev){ +static void uart_fifo_callback(const struct device *dev, void * user_data){ while (uart_irq_update(dev) && uart_irq_is_pending(dev)) { if (uart_irq_rx_ready(dev)) { int recv_len; @@ -36,7 +36,7 @@ static void uart_fifo_callback(struct device *dev){ } - if (uart_irq_tx_ready(dev)) { + if (uart_irq_tx_ready(dev)) { char buffer[64]; int rb_len; @@ -58,6 +58,7 @@ bool zephyr_transport_open(struct uxrCustomTransport * transport){ int ret; uint32_t baudrate, dtr = 0U; + params->uart_dev = device_get_binding("CDC_ACM_0"); if (!params->uart_dev) { printk("CDC ACM device not found\n"); @@ -116,6 +117,7 @@ bool zephyr_transport_open(struct uxrCustomTransport * transport){ bool zephyr_transport_close(struct uxrCustomTransport * transport){ zephyr_transport_params_t * params = (zephyr_transport_params_t*) transport->args; + (void) params; return true; } @@ -124,15 +126,15 @@ size_t zephyr_transport_write(struct uxrCustomTransport* transport, const uint8_ zephyr_transport_params_t * params = (zephyr_transport_params_t*) transport->args; size_t wrote; - + wrote = ring_buf_put(&out_ringbuf, buf, len); - + uart_irq_tx_enable(params->uart_dev); while (!ring_buf_is_empty(&out_ringbuf)){ k_sleep(K_MSEC(5)); } - + return wrote; } diff --git a/modules/libmicroros/microros_transports/serial-usb/microros_transports.h b/modules/libmicroros/microros_transports/serial-usb/microros_transports.h index 144b4b4..281ad5b 100644 --- a/modules/libmicroros/microros_transports/serial-usb/microros_transports.h +++ b/modules/libmicroros/microros_transports/serial-usb/microros_transports.h @@ -26,7 +26,7 @@ extern "C" typedef struct { size_t fd; - struct device *uart_dev; + const struct device *uart_dev; } zephyr_transport_params_t; #define MICRO_ROS_FRAMING_REQUIRED true diff --git a/prj.conf b/prj.conf index 7da89e5..ccb67ed 100644 --- a/prj.conf +++ b/prj.conf @@ -9,12 +9,10 @@ CONFIG_NEWLIB_LIBC_NANO=n CONFIG_PTHREAD_IPC=n CONFIG_POSIX_API=y -CONFIG_NATIVE_POSIX_TIMER=y CONFIG_APP_LINK_WITH_POSIX_SUBSYS=y CONFIG_POSIX_CLOCK=y CONFIG_STDOUT_CONSOLE=y -CONFIG_USB=y CONFIG_USB_DEVICE_STACK=y CONFIG_USB_DEVICE_PRODUCT="Zephyr micro-ROS" CONFIG_LOG=y diff --git a/src/main.c b/src/main.c index 1a335df..0b684c7 100644 --- a/src/main.c +++ b/src/main.c @@ -43,12 +43,8 @@ void main(void) rcl_allocator_t allocator = rcl_get_default_allocator(); rclc_support_t support; - rcl_init_options_t init_options = rcl_get_zero_initialized_init_options(); - RCCHECK(rcl_init_options_init(&init_options, allocator)); - rmw_init_options_t* rmw_options = rcl_init_options_get_rmw_init_options(&init_options); - // create init_options - RCCHECK(rclc_support_init_with_options(&support, 0, NULL, &init_options, &allocator)); + RCCHECK(rclc_support_init(&support, 0, NULL, &allocator)); // create node rcl_node_t node; From fdd9d62cec6f9d8df77032df855fe775c15fafe7 Mon Sep 17 00:00:00 2001 From: Pablo Garrido Date: Tue, 9 Aug 2022 11:37:07 +0200 Subject: [PATCH 2/3] Fix Signed-off-by: Pablo Garrido --- .github/workflows/ci.yml | 14 -------------- .github/workflows/nightly.yml | 17 ----------------- README.md | 4 ---- 3 files changed, 35 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9a91160..6778994 100755 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,19 +13,6 @@ jobs: strategy: fail-fast: false matrix: -<<<<<<< HEAD - zephyr_version: ["zephyr-v2.4.0", "zephyr-v2.5.0", "v2.6.0-rc1"] - include: - - zephyr_version: zephyr-v2.4.0 - zephyr_sdk: 0.11.4 - sdk_filename: zephyr-toolchain-arm-$TOOLCHAIN_VERSION-setup.run - - zephyr_version: zephyr-v2.5.0 - zephyr_sdk: 0.11.4 - sdk_filename: zephyr-toolchain-arm-$TOOLCHAIN_VERSION-setup.run - - zephyr_version: v2.6.0-rc1 - zephyr_sdk: 0.12.4 - sdk_filename: zephyr-toolchain-arm-$TOOLCHAIN_VERSION-x86_64-linux-setup.run -======= zephyr_version: ["zephyr-v3.1.0", "zephyr-v2.7.2"] include: - zephyr_version: zephyr-v2.7.2 @@ -34,7 +21,6 @@ jobs: - zephyr_version: zephyr-v3.1.0 zephyr_sdk: 0.14.2 sdk_filename: zephyr-sdk-$TOOLCHAIN_VERSION\_linux-x86_64_minimal.tar.gz ->>>>>>> 07797df (Move support to v2.7.x and v3.1.0 (#64)) steps: - uses: actions/checkout@v2 with: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 1da9921..e4bde46 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -16,29 +16,13 @@ jobs: strategy: fail-fast: false matrix: -<<<<<<< HEAD - zephyr_version: ["zephyr-v2.4.0", "zephyr-v2.5.0", "v2.6.0-rc1"] - distro: ["foxy", "rolling"] -======= zephyr_version: ["zephyr-v3.1.0", "zephyr-v2.7.2"] distro: ["foxy", "humble", "rolling"] ->>>>>>> 07797df (Move support to v2.7.x and v3.1.0 (#64)) include: - distro: foxy branch: foxy - distro: rolling branch: main -<<<<<<< HEAD - - zephyr_version: zephyr-v2.4.0 - zephyr_sdk: 0.11.4 - sdk_filename: zephyr-toolchain-arm-$TOOLCHAIN_VERSION-setup.run - - zephyr_version: zephyr-v2.5.0 - zephyr_sdk: 0.11.4 - sdk_filename: zephyr-toolchain-arm-$TOOLCHAIN_VERSION-setup.run - - zephyr_version: v2.6.0-rc1 - zephyr_sdk: 0.12.4 - sdk_filename: zephyr-toolchain-arm-$TOOLCHAIN_VERSION-x86_64-linux-setup.run -======= - distro: humble branch: humble - zephyr_version: zephyr-v2.7.2 @@ -47,7 +31,6 @@ jobs: - zephyr_version: zephyr-v3.1.0 zephyr_sdk: 0.14.2 sdk_filename: zephyr-sdk-$TOOLCHAIN_VERSION_linux-x86_64_minimal.tar.gz ->>>>>>> 07797df (Move support to v2.7.x and v3.1.0 (#64)) steps: - uses: actions/checkout@v2 with: diff --git a/README.md b/README.md index 3d6a20a..a3a59e8 100644 --- a/README.md +++ b/README.md @@ -3,11 +3,7 @@ # micro-ROS module for Zephyr -<<<<<<< HEAD -This module has been tested in Zephyr RTOS v2.4.0 (SDK 0.11.4), v2.5.0 (SDK 0.11.4) and (v2.6.0 SDK 0.12.4). -======= This module has been tested in Zephyr RTOS v2.7.0 (SDK 0.14.2) and v3.1.0 (SDK 0.14.2). ->>>>>>> 07797df (Move support to v2.7.x and v3.1.0 (#64)) ## Dependencies From 16882e0438525f79259f0b76624a0c2d331933d8 Mon Sep 17 00:00:00 2001 From: Pablo Garrido Date: Tue, 9 Aug 2022 11:46:37 +0200 Subject: [PATCH 3/3] Fix Signed-off-by: Pablo Garrido --- modules/libmicroros/zephyr_toolchain.cmake.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/libmicroros/zephyr_toolchain.cmake.in b/modules/libmicroros/zephyr_toolchain.cmake.in index b382c95..50c26a8 100644 --- a/modules/libmicroros/zephyr_toolchain.cmake.in +++ b/modules/libmicroros/zephyr_toolchain.cmake.in @@ -26,7 +26,7 @@ SET(CMAKE_CXX_COMPILER_WORKS 1 CACHE INTERNAL "") set(CMAKE_C_COMPILER @CMAKE_C_COMPILER@) set(CMAKE_CXX_COMPILER @CMAKE_CXX_COMPILER@) -set(CMAKE_C_FLAGS_INIT "@CFLAGS@" CACHE STRING "" FORCE) -set(CMAKE_CXX_FLAGS_INIT "@CXXFLAGS@" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_INIT "@CFLAGS@ -DCLOCK_MONOTONIC=0" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_INIT "@CXXFLAGS@ -DCLOCK_MONOTONIC=0" CACHE STRING "" FORCE) set(__BIG_ENDIAN__ 0) \ No newline at end of file