diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 783cb1e9..49161328 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,79 +3,81 @@ name: CI on: pull_request: branches: - - dashing - - crystal + - dashing + - crystal jobs: micro_ros_build: runs-on: ubuntu-latest - container: microros/base:${{github.base_ref}} + container: ros:${{github.base_ref}} steps: - - uses: actions/checkout@v2 - with: - path: src/micro-ros-build - - - name: rosdep - run: rosdep update - - - name: Build micro_ros_setup - run: | - . /opt/ros/$ROS_DISTRO/setup.sh - rosdep install -y --from-paths . -i . - colcon build --merge-install - - - name: Test micro_ros_setup build - uses: BorjaOuterelo/test-file-system-action@v0.0.2 - with: - path: 'install' - files: 'lib/micro_ros_setup/build_firmware.sh' - - - name: Upload artifact - uses: actions/upload-artifact@v1 - with: - name: micro_ros_build - path: install + - uses: actions/checkout@v2 + with: + path: src/micro-ros-build + + - name: dependencies + run: | + apt update + apt install -y python3-colcon-metadata + rosdep update + rosdep install -y --from-paths src --ignore-src -y + + - name: build + run: | + . /opt/ros/$ROS_DISTRO/setup.sh + colcon build --merge-install + + - name: installation + run: | + (test -f install/lib/micro_ros_setup/build_firmware.sh) && true || false + + - uses: actions/upload-artifact@v1 + with: + name: micro_ros_build + path: install agent: runs-on: ubuntu-latest - container: microros/base:${{github.base_ref}} + container: ros:${{github.base_ref}} needs: micro_ros_build steps: - - uses: actions/checkout@v2 - with: - path: src/micro-ros-build - - - name: rosdep - run: rosdep update - - - name: Download artifact - uses: actions/download-artifact@v1 - with: - name: micro_ros_build - path: install - - # Workaround https://github.com/actions/upload-artifact/issues/38 - - run: | - chmod +x -R install/lib/micro_ros_setup - - - name: Create ws and build - run: | - . /opt/ros/$ROS_DISTRO/setup.sh - . install/local_setup.sh - ros2 run micro_ros_setup create_agent_ws.sh src - colcon build --merge-install - - - name: Test micro_ros_agent build - uses: BorjaOuterelo/test-file-system-action@v0.0.2 - with: - files: 'install/lib/micro_ros_agent/micro_ros_agent' + - uses: actions/checkout@v2 + with: + path: src/micro-ros-build + + - name: dependencies + run: | + apt update + apt install -y python3-colcon-metadata + rosdep update + rosdep install -y --from-paths src --ignore-src -y + + - uses: actions/download-artifact@v1 + with: + name: micro_ros_build + path: install + + # Workaround https://github.com/actions/upload-artifact/issues/38 + - run: | + chmod +x -R install/lib/micro_ros_setup + + - name: build + run: | + . /opt/ros/$ROS_DISTRO/setup.sh + . install/local_setup.sh + ros2 run micro_ros_setup create_agent_ws.sh src + colcon build --merge-install + + - name: installation + run: | + (test -f install/lib/micro_ros_agent/micro_ros_agent) && true || false client_host: runs-on: ubuntu-latest - container: microros/base:${{github.base_ref}} + container: ros:${{github.base_ref}} needs: micro_ros_build steps: @@ -83,11 +85,14 @@ jobs: with: path: src/micro-ros-build - - name: rosdep - run: rosdep update + - name: dependencies + run: | + apt update + apt install -y python3-colcon-metadata + rosdep update + rosdep install -y --from-paths src --ignore-src -y - - name: Download artifact - uses: actions/download-artifact@v1 + - uses: actions/download-artifact@v1 with: name: micro_ros_build path: install @@ -97,91 +102,135 @@ jobs: chmod +x -R install/lib/micro_ros_setup chmod +x install/config/host/generic/*.sh - - name: Create ws and build + # Skip rclc packages due to build fail. Once the issues with rclc are solved will be back to CI. + - name: build run: | . /opt/ros/$ROS_DISTRO/setup.sh . install/local_setup.sh ros2 run micro_ros_setup create_firmware_ws.sh host - ros2 run micro_ros_setup build_firmware.sh --merge-install + colcon build --merge-install --metas src - --packages-skip rclc micro_ros_demos_rclc rclc_examples - - name: Test micro_ros_demos_rcl - uses: BorjaOuterelo/test-file-system-action@v0.0.2 - with: - path: 'install/lib/micro_ros_demos_rcl' - files: 'addtwoints_client/addtwoints_client, - addtwoints_server/addtwoints_server, - configured_publisher/configured_publisher, - configured_subscriber/configured_subscriber, - fibonacci_action_client/fibonacci_action_client, - fibonacci_action_server/fibonacci_action_server, - guard_condition/guard_condition, - int32_multinode/int32_multinode, - int32_publisher/int32_publisher, - int32_publisher_subscriber/int32_publisher_subscriber, - int32_subscriber/int32_subscriber' - - - name: Test micro_ros_demos_rclc - uses: BorjaOuterelo/test-file-system-action@v0.0.2 + - name: installation + run: | + (test -f install/lib/micro_ros_demos_rcl/int32_publisher/int32_publisher) && true || false + (test -f install/lib/micro_ros_demos_rcl/int32_subscriber/int32_subscriber) && true || false + (test -f install/lib/micro_ros_demos_rcl/int32_publisher_subscriber/int32_publisher_subscriber) && true || false + (test -f install/lib/micro_ros_demos_rcl/int32_multinode/int32_multinode) && true || false + (test -f install/lib/micro_ros_demos_rcl/guard_condition/guard_condition) && true || false + (test -f install/lib/micro_ros_demos_rcl/fibonacci_action_server/fibonacci_action_server) && true || false + (test -f install/lib/micro_ros_demos_rcl/fibonacci_action_client/fibonacci_action_client) && true || false + (test -f install/lib/micro_ros_demos_rcl/configured_subscriber/configured_subscriber) && true || false + (test -f install/lib/micro_ros_demos_rcl/configured_publisher/configured_publisher) && true || false + (test -f install/lib/micro_ros_demos_rcl/addtwoints_server/addtwoints_server) && true || false + (test -f install/lib/micro_ros_demos_rcl/addtwoints_client/addtwoints_client) && true || false + + # Temporary solution due to NuttX is no fully implemented on the generic build system + client_nuttx_firmware: + runs-on: ubuntu-latest + container: microros/ci:${{github.base_ref}} + needs: micro_ros_build + + steps: + - uses: actions/checkout@v2 with: - path: 'install/lib/micro_ros_demos_rclc' - files: 'complex_msg_publisher/complex_msg_publisher, - complex_msg_subscriber/complex_msg_subscriber, - int32_publisher/int32_publisher, - int32_subscriber/int32_subscriber, - rad0_actuator/rad0_actuator, - rad0_altitude_sensor/rad0_altitude_sensor, - rad0_display/rad0_display, - string_publisher/string_publisher, - string_subscriber/string_subscriber' - - - name: Test micro_ros_demos_rclcpp - uses: BorjaOuterelo/test-file-system-action@v0.0.2 + path: src/micro-ros-build + + - name: dependencies + run: | + apt update + apt install -y python3-colcon-metadata + apt install -y ed + rosdep update + rosdep install -y --from-paths src --ignore-src -y + + - uses: actions/download-artifact@v1 with: - path: 'install/lib/micro_ros_demos_rclcpp' - files: 'complex_msg_publisher/complex_msg_publisher, - complex_msg_subscriber/complex_msg_subscriber, - int32_publisher/int32_publisher, - int32_subscriber/int32_subscriber, - rad0_control/rad0_control, - string_publisher/string_publisher, - string_subscriber/string_subscriber' + name: micro_ros_build + path: install + + # Workaround https://github.com/actions/upload-artifact/issues/38 + - run: | + chmod +x -R install/lib/micro_ros_setup + chmod +x install/config/nuttx/generic/*.sh + + - name: build + run: | + . /opt/ros/$ROS_DISTRO/setup.sh + . install/local_setup.sh + ros2 run micro_ros_setup create_firmware_ws.sh nuttx olimex-stm32-e407 + cd firmware/NuttX + git checkout fix/reorganize_defconfig + cd ../.. + ros2 run micro_ros_setup configure_firmware.sh uros + ros2 run micro_ros_setup build_firmware.sh + - name: binary + run: | + (test -f firmware/NuttX/nuttx.bin) && true || false + + #Build test for FreeRTOS and Zephyr client_firmware: runs-on: ubuntu-latest - container: microros/ci:${{github.base_ref}} + container: microros/ci:dashing needs: micro_ros_build strategy: fail-fast: false matrix: - rtos: [nuttx, freertos] - platform: [crazyflie21, generic] + rtos: [freertos,zephyr] + platform: [crazyflie21, generic, olimex-stm32-e407, discovery_l475_iot1] exclude: - rtos: freertos platform: generic - - rtos: nuttx + + - rtos: freertos + platform: discovery_l475_iot1 + + - rtos: zephyr + platform: generic + + - rtos: zephyr platform: crazyflie21 + include: - - rtos: nuttx - platform: generic - configuration: olimex-stm32-e407/uros - files: 'firmware/NuttX/nuttx' - rtos: freertos - files: 'firmware/crazyflie_microros_extensions/cf2.elf' + platform: crazyflie21 + configuration: crazyflie_position_publisher + transport_arguments: -t serial -d /dev/ttyS0 + binary: 'firmware/freertos_apps/microros_crazyflie21_extensions/cf2.bin' + + - rtos: freertos + platform: olimex-stm32-e407 + configuration: olimex_ping_pong + transport_arguments: -t serial -d /dev/ttyS0 + binary: 'firmware/freertos_apps/microros_olimex_e407_extensions/build/micro-ROS.elf' + + - rtos: zephyr + platform: olimex-stm32-e407 + configuration: sample_publisher + transport_arguments: -t serial-usb + binary: 'firmware/build/zephyr/zephyr.bin' + + - rtos: zephyr + platform: discovery_l475_iot1 + configuration: sample_publisher + transport_arguments: -t serial-usb + binary: 'firmware/build/zephyr/zephyr.bin' steps: - uses: actions/checkout@v2 with: path: src/micro-ros-build - - name: Dependencies - run: apt-get install -y ed - - - name: Rosdep - run: rosdep update + - name: dependencies + run: | + apt update + apt install -y python3-colcon-metadata + apt install -y ed + rosdep update + rosdep install -y --from-paths src --ignore-src -y - - name: Download artifact - uses: actions/download-artifact@v1 + - uses: actions/download-artifact@v1 with: name: micro_ros_build path: install @@ -189,24 +238,16 @@ jobs: # Workaround https://github.com/actions/upload-artifact/issues/38 - run: | chmod +x -R install/lib/micro_ros_setup - chmod +x install/config/${{ matrix.rtos }}/${{ matrix.platform }}/*.sh + chmod +x -R install/config - - name: Test micro_ros_agent build - uses: BorjaOuterelo/test-file-system-action@v0.0.2 - with: - path: 'install' - files: 'lib/micro_ros_setup/build_firmware.sh' - - - name: Create ws and build + - name: build run: | - . /opt/ros/$ROS_DISTRO/setup.sh + . /opt/ros/dashing/setup.sh . install/local_setup.sh ros2 run micro_ros_setup create_firmware_ws.sh ${{ matrix.rtos }} ${{ matrix.platform }} - ros2 run micro_ros_setup configure_firmware.sh ${{ matrix.configuration }} + ros2 run micro_ros_setup configure_firmware.sh ${{ matrix.configuration }} ${{ matrix.transport_arguments }} ros2 run micro_ros_setup build_firmware.sh - - name: Test firmware build - if: matrix.files - uses: BorjaOuterelo/test-file-system-action@v0.0.2 - with: - files: ${{ matrix.files }} + - name: binaries + run: | + (test -f ${{ matrix.binary }}) && true || false diff --git a/micro_ros_setup/CMakeLists.txt b/micro_ros_setup/CMakeLists.txt index 7a22c35b..45ba80ef 100644 --- a/micro_ros_setup/CMakeLists.txt +++ b/micro_ros_setup/CMakeLists.txt @@ -38,17 +38,6 @@ install( DIRECTORY config DESTINATION . USE_SOURCE_PERMISSIONS ) -set(NUTTX_SUPPORTED_PLATFORMS olimex-stm32-e407 stm32f4discovery) -foreach(NUTTX_PLATFORM ${NUTTX_SUPPORTED_PLATFORMS}) - install( - DIRECTORY - config/nuttx/generic/ - DESTINATION - config/nuttx/${NUTTX_PLATFORM} - USE_SOURCE_PERMISSIONS - ) -endforeach() - install( PROGRAMS scripts/create_ws.sh diff --git a/micro_ros_setup/README.md b/micro_ros_setup/README.md index fca8eae3..cbe31301 100644 --- a/micro_ros_setup/README.md +++ b/micro_ros_setup/README.md @@ -15,9 +15,11 @@ This ROS 2 package is the entry point for building micro-ROS apps for different | RTOS | Platform | Example | |-|-|-| -| [Nuttx](https://nuttx.org/) | Olimex STM32-E407, STM32F4Discovery | `nuttx olimex-stm32-e407` | +| [Nuttx](https://nuttx.org/) | Olimex STM32-E407, STM32F4Discovery ** | `nuttx olimex-stm32-e407` | | [FreeRTOS](https://www.freertos.org/) | [Crazyflie 2.1](https://www.bitcraze.io/crazyflie-2-1/) | `freertos crazyflie21` | -| [FreeRTOS](https://www.freertos.org/) | [Olimex STM32-E407](https://www.olimex.com/Products/ARM/ST/STM32-E407/open-source-hardware) | `freertos olimex_e407` | +| [FreeRTOS](https://www.freertos.org/) | [Olimex STM32-E407](https://www.olimex.com/Products/ARM/ST/STM32-E407/open-source-hardware) | `freertos olimex-stm32-e407` | +| [Zephyr](https://www.zephyrproject.org/) | [Olimex STM32-E407](https://www.olimex.com/Products/ARM/ST/STM32-E407/open-source-hardware) | `zephyr olimex-stm32-e407` | +| [Zephyr](https://www.zephyrproject.org/) | [ST B-L475E-IOT01A](https://docs.zephyrproject.org/latest/boards/arm/disco_l475_iot1/doc/index.html) | `zephyr discovery_l475_iot1` | | Linux / Windows | *Host* * | Please note that NuttX with Olimex STM32-E407 board is the reference platform and not everything might be supported on other platforms. @@ -67,23 +69,20 @@ Once the package is built, the firmware scripts are ready to run. Using `create_firmware_ws.sh [RTOS] [Platform]` command a firmware folder will be created with the required code for building a micro-ROS app. For example, for our reference platform, the invocation is: -``` +```bash +# Creating a Nuttx + micro-ROS firmware workspace ros2 run micro_ros_setup create_firmware_ws.sh nuttx olimex-stm32-e407 -``` - -If you are instead targeting FreeRTOS, you would use: -``` +# Creating a FreeRTOS + micro-ROS firmware workspace ros2 run micro_ros_setup create_firmware_ws.sh freertos olimex-stm32-e407 ``` - ## Configuring micro-ROS firmware By running `configure_firmware.sh` command the installed firmware is configured and modified in a pre-build step. Usually this command will show its usage if parameters are required: ``` -ros2 run micro_ros_setup configure_firmware.sh [configuration] +ros2 run micro_ros_setup configure_firmware.sh [configuration] [options] ``` For NuttX, several different configurations are supported. @@ -97,6 +96,12 @@ For NuttX, several different configurations are supported. Please note that these are only default configurations. Each RTOS has its configuration approach that you might use for further customization of these base configurations. +Common options available at this configuration step are: + - `--transport` or `-t`: `udp`, `tcp`, `serial` or any hardware specific transport label + - `--dev` or `-d`: agent string descriptor in a serial-like transport + - `--ip` or `-i`: agent IP in a network-like transport + - `--port` or `-p`: agent port in a network-like transport + ## Building micro-ROS firmware By running `build_firmware.sh` the firmware is built: diff --git a/micro_ros_setup/config/freertos/crazyflie21/crazyflie.repos b/micro_ros_setup/config/freertos/crazyflie21/board.repos similarity index 65% rename from micro_ros_setup/config/freertos/crazyflie21/crazyflie.repos rename to micro_ros_setup/config/freertos/crazyflie21/board.repos index 0932d081..66b1c7eb 100644 --- a/micro_ros_setup/config/freertos/crazyflie21/crazyflie.repos +++ b/micro_ros_setup/config/freertos/crazyflie21/board.repos @@ -4,9 +4,8 @@ repositories: url: https://github.com/bitcraze/crazyflie-firmware version: 5142cacdde8b2a21ae0bef0ae4d0a26088335bee - crazyflie_microros_extensions: + freertos_apps: type: git - url: https://github.com/micro-ROS/crazyflie_extensions - - + url: https://github.com/micro-ROS/freertos_apps + version: dashing diff --git a/micro_ros_setup/config/freertos/crazyflie21/build.sh b/micro_ros_setup/config/freertos/crazyflie21/build.sh index 45a51130..dba09afa 100755 --- a/micro_ros_setup/config/freertos/crazyflie21/build.sh +++ b/micro_ros_setup/config/freertos/crazyflie21/build.sh @@ -1,19 +1,37 @@ CF_DIR=$FW_TARGETDIR/crazyflie_firmware -CF_EXTENSIONS_DIR=$FW_TARGETDIR/crazyflie_microros_extensions +EXTENSIONS_DIR=$FW_TARGETDIR/freertos_apps/microros_crazyflie21_extensions + +. $PREFIX/config/utils.sh pushd $CF_DIR >/dev/null git submodule init git submodule update popd >/dev/null -pushd $CF_EXTENSIONS_DIR >/dev/null - if [ "$UROS_FAST_BUILD" = "off" ] || [ ! -d "bin" ]; then - # clean build +pushd $EXTENSIONS_DIR >/dev/null + + export UROS_APP=$(head -n1 $FW_TARGETDIR/APP | tail -n1) + export UROS_APP_FOLDER="$FW_TARGETDIR/freertos_apps/apps/$UROS_APP" + + if [ -d "$UROS_APP_FOLDER" ]; then + echo "Selected app: $UROS_APP" + else + echo "App not found: $UROS_APP" + print_available_apps + exit 1 + fi + + if [ "$UROS_FAST_BUILD" = "off" ] || [ ! -d "build" ]; then + # Clean micro-ROS build + rm -rf $FW_TARGETDIR/mcu_ws/build $FW_TARGETDIR/mcu_ws/install $FW_TARGETDIR/mcu_ws/log + + # Clean build make clean - # build micro-ROS stack + # Build micro-ROS stack make libmicroros fi - # build crayflie firmware - make PLATFORM=cf2 CLOAD=0 + + # build firmware + make PLATFORM=cf2 CLOAD=0 UROS_APP_FOLDER=$UROS_APP_FOLDER popd >/dev/null diff --git a/micro_ros_setup/config/freertos/crazyflie21/client-colcon.meta b/micro_ros_setup/config/freertos/crazyflie21/client-colcon.meta index f7f0c76c..cb7215bb 100644 --- a/micro_ros_setup/config/freertos/crazyflie21/client-colcon.meta +++ b/micro_ros_setup/config/freertos/crazyflie21/client-colcon.meta @@ -9,21 +9,12 @@ }, "microxrcedds_client":{ "cmake-args":[ - "-DUCLIENT_PIC=OFF", - "-DEXTERNAL_TRANSPORT_HEADER=../../../crazyflie_microros_extensions/src/crazyflie_transport.h", - "-DEXTERNAL_TRANSPORT_SRC=../../../crazyflie_microros_extensions/src/crazyflie_transport.c" + "-DUCLIENT_PIC=OFF" ] }, "rmw_microxrcedds":{ "cmake-args":[ - "-DRMW_UXRCE_TRANSPORT=custom", - "-DRMW_UXRCE_MAX_NODES=1", - "-DRMW_UXRCE_MAX_PUBLISHERS_X_NODE=2", - "-DRMW_UXRCE_MAX_SUBSCRIPTIONS_X_NODE=1", - "-DRMW_UXRCE_MAX_SERVICES_X_NODE=1", - "-DRMW_UXRCE_MAX_CLIENTS_X_NODE=1", - "-DRMW_UXRCE_MAX_HISTORY=1", - "-DRMW_UXRCE_XML_BUFFER_LENGTH=400" + "-DRMW_UXRCE_TRANSPORT=custom_serial" ] } } diff --git a/micro_ros_setup/config/freertos/crazyflie21/client_uros_packages.repos b/micro_ros_setup/config/freertos/crazyflie21/client_uros_packages.repos index 0ff8c01e..61bb25ac 100644 --- a/micro_ros_setup/config/freertos/crazyflie21/client_uros_packages.repos +++ b/micro_ros_setup/config/freertos/crazyflie21/client_uros_packages.repos @@ -21,7 +21,7 @@ repositories: uros/rmw_microxrcedds: type: git url: https://github.com/micro-ROS/rmw-microxrcedds.git - version: dashing + version: feature/xrce_session_management uros/rosidl_typesupport_microxrcedds: type: git url: https://github.com/micro-ROS/rosidl_typesupport_microxrcedds.git diff --git a/micro_ros_setup/config/freertos/crazyflie21/configure.sh b/micro_ros_setup/config/freertos/crazyflie21/configure.sh new file mode 100755 index 00000000..d8014956 --- /dev/null +++ b/micro_ros_setup/config/freertos/crazyflie21/configure.sh @@ -0,0 +1,10 @@ + +EXTENSIONS_DIR=$FW_TARGETDIR/freertos_apps/microros_crazyflie21_extensions + +. $PREFIX/config/utils.sh + +echo $CONFIG_NAME > $FW_TARGETDIR/APP + +cp -f $EXTENSIONS_DIR/src/crazyflie_transport.c $FW_TARGETDIR/mcu_ws/eProsima/Micro-XRCE-DDS-Client/src/c/profile/transport/serial/serial_transport_external.c +cp -f $EXTENSIONS_DIR/src/crazyflie_transport.h $FW_TARGETDIR/mcu_ws/eProsima/Micro-XRCE-DDS-Client/include/uxr/client/profile/transport/serial/serial_transport_external.h +update_meta "microxrcedds_client" "UCLIENT_EXTERNAL_SERIAL=ON" \ No newline at end of file diff --git a/micro_ros_setup/config/freertos/crazyflie21/create.sh b/micro_ros_setup/config/freertos/crazyflie21/create.sh index 97089cbd..c7aa6b71 100755 --- a/micro_ros_setup/config/freertos/crazyflie21/create.sh +++ b/micro_ros_setup/config/freertos/crazyflie21/create.sh @@ -2,13 +2,16 @@ pushd $FW_TARGETDIR >/dev/null # Install toolchain mkdir toolchain + + # Install toolchain echo "Downloading ARM compiler, this may take a while" - curl -fsSLO https://developer.arm.com/-/media/Files/downloads/gnu-rm/8-2019q3/RC1.1/gcc-arm-none-eabi-8-2019-q3-update-linux.tar.bz2 + curl -fsSLO https://developer.arm.com/-/media/Files/downloads/gnu-rm/8-2019q3/RC1.1/gcc-arm-none-eabi-8-2019-q3-update-linux.tar.bz2 tar --strip-components=1 -xvjf gcc-arm-none-eabi-8-2019-q3-update-linux.tar.bz2 -C toolchain > /dev/null rm gcc-arm-none-eabi-8-2019-q3-update-linux.tar.bz2 + # Import repos - vcs import --input $PREFIX/config/$RTOS/$PLATFORM/crazyflie.repos >/dev/null + vcs import --input $PREFIX/config/$RTOS/$PLATFORM/board.repos >/dev/null # ignore broken packages touch mcu_ws/ros2/rcl_logging/rcl_logging_log4cxx/COLCON_IGNORE diff --git a/micro_ros_setup/config/freertos/list_apps.sh b/micro_ros_setup/config/freertos/list_apps.sh new file mode 100644 index 00000000..1b67958b --- /dev/null +++ b/micro_ros_setup/config/freertos/list_apps.sh @@ -0,0 +1,18 @@ +function print_available_apps { + echo "Available apps for FreeRTOS and $PLATFORM:" + pushd $FW_TARGETDIR/freertos_apps/apps >/dev/null + for app in $(ls -d */ | cut -f1 -d'/'); do + echo "+-- $app" + done + popd >/dev/null +} + +function check_available_app { + pushd $FW_TARGETDIR/freertos_apps/apps >/dev/null + if [ ! -d $1 ]; then + echo "App $1 for FreeRTOS not available" + print_available_apps + exit 1 + fi + popd >/dev/null +} \ No newline at end of file diff --git a/micro_ros_setup/config/freertos/olimex-stm32-e407/board.repos b/micro_ros_setup/config/freertos/olimex-stm32-e407/board.repos new file mode 100644 index 00000000..7fa5f072 --- /dev/null +++ b/micro_ros_setup/config/freertos/olimex-stm32-e407/board.repos @@ -0,0 +1,8 @@ +repositories: + freertos_apps: + type: git + url: https://github.com/micro-ROS/freertos_apps + version: dashing + + + diff --git a/micro_ros_setup/config/freertos/olimex-stm32-e407/build.sh b/micro_ros_setup/config/freertos/olimex-stm32-e407/build.sh index a97f2265..e057c750 100755 --- a/micro_ros_setup/config/freertos/olimex-stm32-e407/build.sh +++ b/micro_ros_setup/config/freertos/olimex-stm32-e407/build.sh @@ -1,14 +1,31 @@ -OLIMEX_EXTENSIONS_DIR=$FW_TARGETDIR/olimex_e407_extensions +EXTENSIONS_DIR=$FW_TARGETDIR/freertos_apps/microros_olimex_e407_extensions + +. $PREFIX/config/utils.sh + +pushd $EXTENSIONS_DIR >/dev/null + + export UROS_APP=$(head -n1 $FW_TARGETDIR/APP | tail -n1) + export UROS_APP_FOLDER="$FW_TARGETDIR/freertos_apps/apps/$UROS_APP" + + if [ -d "$UROS_APP_FOLDER" ]; then + echo "Selected app: $UROS_APP" + else + echo "App not found: $UROS_APP" + print_available_apps + exit 1 + fi -pushd $OLIMEX_EXTENSIONS_DIR >/dev/null if [ "$UROS_FAST_BUILD" = "off" ] || [ ! -d "build" ]; then - # clean build + # Clean micro-ROS build + rm -rf $FW_TARGETDIR/mcu_ws/build $FW_TARGETDIR/mcu_ws/install $FW_TARGETDIR/mcu_ws/log + + # Clean build make clean - # build micro-ROS stack + # Build micro-ROS stack make libmicroros fi - # build firmware - make + # Build firmware + make UROS_APP_FOLDER=$UROS_APP_FOLDER popd >/dev/null diff --git a/micro_ros_setup/config/freertos/olimex-stm32-e407/client-colcon.meta b/micro_ros_setup/config/freertos/olimex-stm32-e407/client-colcon.meta index 2c2b49f1..1b90f924 100644 --- a/micro_ros_setup/config/freertos/olimex-stm32-e407/client-colcon.meta +++ b/micro_ros_setup/config/freertos/olimex-stm32-e407/client-colcon.meta @@ -1,13 +1,23 @@ -{ "names": { - "rcutils": { "cmake-args": [ "-DENABLE_TESTING=OFF", "-DRCUTILS_NO_FILESYSTEM=ON", "-DRCUTILS_AVOID_DYNAMIC_ALLOCATION=ON" ] }, - "microxrcedds_client": { "cmake-args": [ "-DUCLIENT_ISOLATED_INSTALL=OFF", "-DUCLIENT_PIC=OFF", "-DUCLIENT_SUPERBUILD=OFF" ] }, - "rmw_microxrcedds": { "cmake-args": [ - "-DRMW_UXRCE_MAX_NODES=1", - "-DRMW_UXRCE_MAX_PUBLISHERS_X_NODE=2", - "-DRMW_UXRCE_MAX_SUBSCRIPTIONS_X_NODE=1", - "-DRMW_UXRCE_MAX_SERVICES_X_NODE=1", - "-DRMW_UXRCE_MAX_CLIENTS_X_NODE=1", - "-DRMW_UXRCE_MAX_HISTORY=4", - "-DRMW_UXRCE_XML_BUFFER_LENGTH=400"] } - } +{ + "names": { + "rcutils": { + "cmake-args": [ + "-DENABLE_TESTING=OFF", + "-DRCUTILS_NO_FILESYSTEM=ON", + "-DRCUTILS_AVOID_DYNAMIC_ALLOCATION=ON" + ] + }, + "microxrcedds_client": { + "cmake-args": [ + "-DUCLIENT_PIC=OFF" + ] + }, + "rmw_microxrcedds": { + "cmake-args": [ + "-DRMW_UXRCE_XML_BUFFER_LENGTH=400", + "-DRMW_UXRCE_TRANSPORT=custom_serial", + "-DRMW_UXRCE_DEFAULT_SERIAL_DEVICE=3" + ] + } + } } diff --git a/micro_ros_setup/config/freertos/olimex-stm32-e407/client_uros_packages.repos b/micro_ros_setup/config/freertos/olimex-stm32-e407/client_uros_packages.repos index 36265641..4c53e1b6 100644 --- a/micro_ros_setup/config/freertos/olimex-stm32-e407/client_uros_packages.repos +++ b/micro_ros_setup/config/freertos/olimex-stm32-e407/client_uros_packages.repos @@ -6,7 +6,7 @@ repositories: eProsima/Micro-XRCE-DDS-Client: type: git url: https://github.com/eProsima/Micro-XRCE-DDS-Client.git - version: feature/posix_nopoll + version: dashing # MicroROS @@ -25,7 +25,7 @@ repositories: uros/rosidl_typesupport_microxrcedds: type: git url: https://github.com/micro-ROS/rosidl_typesupport_microxrcedds.git - version: feature/dashing_migration + version: dashing # Remove this when it returns to ros2.repos ros2/tinydir_vendor: diff --git a/micro_ros_setup/config/freertos/olimex-stm32-e407/configure.sh b/micro_ros_setup/config/freertos/olimex-stm32-e407/configure.sh index c22906c6..de71a7b6 100755 --- a/micro_ros_setup/config/freertos/olimex-stm32-e407/configure.sh +++ b/micro_ros_setup/config/freertos/olimex-stm32-e407/configure.sh @@ -1,58 +1,58 @@ -OLIMEX_EXTENSIONS_DIR=$FW_TARGETDIR/olimex_e407_extensions +EXTENSIONS_DIR=$FW_TARGETDIR/freertos_apps/microros_olimex_e407_extensions -function update_meta { - python3 -c "import sys; import json; c = '$2'; s = json.loads(''.join([l for l in sys.stdin])); k = s['names']['$1']['cmake-args']; i = [c.startswith(v.split('=')[0]) for v in k]; k.pop(i.index(True)) if any(i) else None; k.append(c) if len(c.split('=')[1]) else None; print(json.dumps(s,indent=4))" < $FW_TARGETDIR/mcu_ws/colcon.meta > $FW_TARGETDIR/mcu_ws/colcon_new.meta - mv $FW_TARGETDIR/mcu_ws/colcon_new.meta $FW_TARGETDIR/mcu_ws/colcon.meta -} +. $PREFIX/config/utils.sh function help { - echo "Configure script need an argument. For example: ros2 run micro_ros_setup configure_firmware.sh [udp | tcp | serial] [IP address | Serial port] [IP port]" + echo "Configure script need an argument." + echo " --transport -t udp, tcp, serial or serial-usb" + echo " --dev -d agent string descriptor in a serial-like transport" + echo " --ip -i agent IP in a network-like transport" + echo " --port -p agent port in a network-like transport" } -if [ $# -lt 1 ]; then - help - exit 1 -fi +echo $CONFIG_NAME > $FW_TARGETDIR/APP + +if [ "$UROS_TRANSPORT" == "udp" ] || [ "$UROS_TRANSPORT" == "tcp" ]; then + + update_meta "rmw_microxrcedds" "RMW_UXRCE_TRANSPORT="$UROS_TRANSPORT + update_meta "rmw_microxrcedds" "RMW_UXRCE_DEFAULT_UDP_IP="$UROS_AGENT_IP + update_meta "rmw_microxrcedds" "RMW_UXRCE_DEFAULT_UDP_PORT="$UROS_AGENT_PORT + + remove_meta "rmw_microxrcedds" "RMW_UXRCE_DEFAULT_SERIAL_DEVICE" + remove_meta "microxrcedds_client" "EXTERNAL_TRANSPORT_HEADER_SERIAL" + remove_meta "microxrcedds_client" "EXTERNAL_TRANSPORT_SRC_SERIAL" + + echo "Configured $UROS_TRANSPORT mode with agent at $UROS_AGENT_IP:$UROS_AGENT_PORT" -TRANSPORT=$1 +elif [ "$UROS_TRANSPORT" == "serial" ]; then + echo "Using serial device USART$UROS_AGENT_DEVICE." -if [ "$TRANSPORT" == "udp" ] || [ "$TRANSPORT" == "tcp" ]; then - if [ $# -lt 3 ]; then - echo "UDP or TCP configuration needs IP and port. For example: ros2 run micro_ros_setup configure_firmware.sh [udp | tcp] [IP address] [IP port]" - exit 1 - fi + cp -f $EXTENSIONS_DIR/Src/olimex_e407_serial_transport.c $FW_TARGETDIR/mcu_ws/eProsima/Micro-XRCE-DDS-Client/src/c/profile/transport/serial/serial_transport_external.c + cp -f $EXTENSIONS_DIR/Inc/olimex_e407_serial_transport.h $FW_TARGETDIR/mcu_ws/eProsima/Micro-XRCE-DDS-Client/include/uxr/client/profile/transport/serial/serial_transport_external.h + update_meta "microxrcedds_client" "UCLIENT_EXTERNAL_SERIAL=ON" - IP=$2 - PORT=$3 + update_meta "rmw_microxrcedds" "RMW_UXRCE_TRANSPORT=custom" + update_meta "rmw_microxrcedds" "RMW_UXRCE_DEFAULT_SERIAL_DEVICE="$UROS_AGENT_DEVICE - update_meta "rmw_microxrcedds" "-DRMW_UXRCE_TRANSPORT="$TRANSPORT - update_meta "rmw_microxrcedds" "-DRMW_UXRCE_DEFAULT_UDP_IP="$IP - update_meta "rmw_microxrcedds" "-DRMW_UXRCE_DEFAULT_UDP_PORT="$PORT + remove_meta "rmw_microxrcedds" "RMW_UXRCE_DEFAULT_UDP_IP" + remove_meta "rmw_microxrcedds" "RMW_UXRCE_DEFAULT_UDP_PORT" - update_meta "rmw_microxrcedds" "-DRMW_UXRCE_DEFAULT_SERIAL_DEVICE=" - update_meta "microxrcedds_client" "-DEXTERNAL_TRANSPORT_HEADER_SERIAL=" - update_meta "microxrcedds_client" "-DEXTERNAL_TRANSPORT_SRC_SERIAL=" + echo "Configured $UROS_TRANSPORT mode with agent at USART$UROS_AGENT_DEVICE" - echo "Configured $TRANSPORT mode with agent at $IP:$PORT" +elif [ "$UROS_TRANSPORT" == "serial-usb" ]; then + echo "Using serial USB device. EXPERIMENTAL." -elif [ "$TRANSPORT" == "serial" ]; then - if [ $# -lt 2 ]; then - SERIAL="3" - else - SERIAL=$2 - fi - echo "Using serial device USART$SERIAL." + cp -f $EXTENSIONS_DIR/Src/olimex_e407_usb_transport.c $FW_TARGETDIR/mcu_ws/eProsima/Micro-XRCE-DDS-Client/src/c/profile/transport/serial/serial_transport_external.c + cp -f $EXTENSIONS_DIR/Inc/olimex_e407_usb_transport.h $FW_TARGETDIR/mcu_ws/eProsima/Micro-XRCE-DDS-Client/include/uxr/client/profile/transport/serial/serial_transport_external.h + update_meta "microxrcedds_client" "UCLIENT_EXTERNAL_SERIAL=ON" - update_meta "rmw_microxrcedds" "-DRMW_UXRCE_TRANSPORT=custom" - update_meta "rmw_microxrcedds" "-DRMW_UXRCE_DEFAULT_SERIAL_DEVICE="$SERIAL - update_meta "microxrcedds_client" "-DEXTERNAL_TRANSPORT_HEADER_SERIAL="$OLIMEX_EXTENSIONS_DIR"/Inc/olimex_e407_serial_transport.h" - update_meta "microxrcedds_client" "-DEXTERNAL_TRANSPORT_SRC_SERIAL="$OLIMEX_EXTENSIONS_DIR"/Src/olimex_e407_serial_transport.c" + update_meta "rmw_microxrcedds" "RMW_UXRCE_TRANSPORT=custom_serial" - update_meta "rmw_microxrcedds" "-DRMW_UXRCE_DEFAULT_UDP_IP=" - update_meta "rmw_microxrcedds" "-DRMW_UXRCE_DEFAULT_UDP_PORT=" + remove_meta "rmw_microxrcedds" "RMW_UXRCE_DEFAULT_UDP_IP" + remove_meta "rmw_microxrcedds" "RMW_UXRCE_DEFAULT_UDP_PORT" - echo "Configured $TRANSPORT mode with agent at USART$SERIAL" + echo "Configured $UROS_TRANSPORT mode with agent" else help fi diff --git a/micro_ros_setup/config/freertos/olimex-stm32-e407/create.sh b/micro_ros_setup/config/freertos/olimex-stm32-e407/create.sh index e5310396..77313da8 100755 --- a/micro_ros_setup/config/freertos/olimex-stm32-e407/create.sh +++ b/micro_ros_setup/config/freertos/olimex-stm32-e407/create.sh @@ -2,13 +2,15 @@ pushd $FW_TARGETDIR >/dev/null # Install toolchain mkdir toolchain + + # Install toolchain echo "Downloading ARM compiler, this may take a while" - curl -fsSLO https://developer.arm.com/-/media/Files/downloads/gnu-rm/8-2019q3/RC1.1/gcc-arm-none-eabi-8-2019-q3-update-linux.tar.bz2 + curl -fsSLO https://developer.arm.com/-/media/Files/downloads/gnu-rm/8-2019q3/RC1.1/gcc-arm-none-eabi-8-2019-q3-update-linux.tar.bz2 tar --strip-components=1 -xvjf gcc-arm-none-eabi-8-2019-q3-update-linux.tar.bz2 -C toolchain > /dev/null rm gcc-arm-none-eabi-8-2019-q3-update-linux.tar.bz2 - + # Import repos - vcs import --input $PREFIX/config/$RTOS/$PLATFORM/olimex_e407.repos >/dev/null + vcs import --input $PREFIX/config/$RTOS/$PLATFORM/board.repos >/dev/null # ignore broken packages touch mcu_ws/ros2/rcl_logging/rcl_logging_log4cxx/COLCON_IGNORE diff --git a/micro_ros_setup/config/freertos/olimex-stm32-e407/flash.sh b/micro_ros_setup/config/freertos/olimex-stm32-e407/flash.sh index 1292b617..1225c181 100755 --- a/micro_ros_setup/config/freertos/olimex-stm32-e407/flash.sh +++ b/micro_ros_setup/config/freertos/olimex-stm32-e407/flash.sh @@ -1,4 +1,4 @@ -OLIMEX_EXTENSIONS_DIR=$FW_TARGETDIR/olimex_e407_extensions +OLIMEX_EXTENSIONS_DIR=$FW_TARGETDIR/freertos_apps/microros_olimex_e407_extensions pushd $OLIMEX_EXTENSIONS_DIR > /dev/null diff --git a/micro_ros_setup/config/freertos/olimex-stm32-e407/olimex_e407.repos b/micro_ros_setup/config/freertos/olimex-stm32-e407/olimex_e407.repos deleted file mode 100644 index 5815a7a3..00000000 --- a/micro_ros_setup/config/freertos/olimex-stm32-e407/olimex_e407.repos +++ /dev/null @@ -1,7 +0,0 @@ -repositories: - olimex_e407_extensions: - type: git - url: https://github.com/micro-ROS/olimex_e407_extensions - - - diff --git a/micro_ros_setup/config/host/generic/create.sh b/micro_ros_setup/config/host/generic/create.sh index d1a27797..5c5c3b97 100755 --- a/micro_ros_setup/config/host/generic/create.sh +++ b/micro_ros_setup/config/host/generic/create.sh @@ -5,3 +5,7 @@ ros2 run micro_ros_setup create_ws.sh src $PREFIX/config/client_ros2_packages.tx cp $PREFIX/config/$RTOS/$PLATFORM/client-host-colcon.meta src/colcon.meta rosdep install -y --from-paths src -i src --skip-keys="$SKIP" + +# TODO (pablogs9): Remove when rclc builds correctly +touch src/uros/micro-ROS-demos/rclc/COLCON_IGNORE +touch src/uros/rclc/COLCON_IGNORE \ No newline at end of file diff --git a/micro_ros_setup/config/nuttx/generic/client-colcon.meta b/micro_ros_setup/config/nuttx/generic/client-colcon.meta index e072aa12..ccc376c5 100644 --- a/micro_ros_setup/config/nuttx/generic/client-colcon.meta +++ b/micro_ros_setup/config/nuttx/generic/client-colcon.meta @@ -7,7 +7,7 @@ }, "microxrcedds_client":{ "cmake-args":[ - "-DUCLIENT_PIC=OFF", + "-DUCLIENT_PIC=OFF" ] }, "rmw_microxrcedds":{ diff --git a/micro_ros_setup/config/nuttx/generic/configure.sh b/micro_ros_setup/config/nuttx/generic/configure.sh index af100a28..94e14601 100755 --- a/micro_ros_setup/config/nuttx/generic/configure.sh +++ b/micro_ros_setup/config/nuttx/generic/configure.sh @@ -10,14 +10,8 @@ set -o pipefail NUTTX_DIR=$FW_TARGETDIR/NuttX MCU_WS_DIR=$FW_TARGETDIR/mcu_ws -if [ $# -lt 1 ]; then - echo "Syntax: configure.sh " - exit 1 -fi - # parse the platform from this script's path name -PLATFORM=$(basename $(dirname $0)) -CONFIG_NAME=$1 +PLATFORM=$(head -n2 $FW_TARGETDIR/PLATFORM | tail -n1) # for the "generic" platform, the user must supply both board and config if [ "$PLATFORM" = "generic" ] diff --git a/micro_ros_setup/config/nuttx/generic/create.sh b/micro_ros_setup/config/nuttx/generic/create.sh index e987cdd8..97c37e52 100755 --- a/micro_ros_setup/config/nuttx/generic/create.sh +++ b/micro_ros_setup/config/nuttx/generic/create.sh @@ -8,7 +8,7 @@ set -o pipefail [ -d $FW_TARGETDIR ] || mkdir $FW_TARGETDIR pushd $FW_TARGETDIR >/dev/null - vcs import --input $PREFIX/config/$RTOS/$PLATFORM/uros_packages.repos >/dev/null + vcs import --input $PREFIX/config/$RTOS/generic/uros_packages.repos >/dev/null # install uclibc if [ ! -d "NuttX/libs/libxx/uClibc++" ] @@ -29,5 +29,5 @@ pushd $FW_TARGETDIR >/dev/null popd >/dev/null -cp $PREFIX/config/$RTOS/$PLATFORM/package.xml $FW_TARGETDIR/apps/package.xml +cp $PREFIX/config/$RTOS/generic/package.xml $FW_TARGETDIR/apps/package.xml rosdep install -y --from-paths $FW_TARGETDIR/apps -i $FW_TARGETDIR/apps --rosdistro dashing diff --git a/micro_ros_setup/config/nuttx/generic/supported_platforms b/micro_ros_setup/config/nuttx/generic/supported_platforms new file mode 100644 index 00000000..c0109458 --- /dev/null +++ b/micro_ros_setup/config/nuttx/generic/supported_platforms @@ -0,0 +1 @@ +olimex-stm32-e407 diff --git a/micro_ros_setup/config/utils.sh b/micro_ros_setup/config/utils.sh new file mode 100644 index 00000000..91b054b7 --- /dev/null +++ b/micro_ros_setup/config/utils.sh @@ -0,0 +1,9 @@ +function update_meta { + python3 -c "import sys; import json; c = '-D' +'$2'; s = json.loads(''.join([l for l in sys.stdin])); k = s['names']['$1']['cmake-args']; i = [c.startswith(v.split('=')[0]) for v in k]; k.pop(i.index(True)) if any(i) else None; k.append(c) if len(c.split('=')[1]) else None; print(json.dumps(s,indent=4))" < $FW_TARGETDIR/mcu_ws/colcon.meta > $FW_TARGETDIR/mcu_ws/colcon_new.meta + mv $FW_TARGETDIR/mcu_ws/colcon_new.meta $FW_TARGETDIR/mcu_ws/colcon.meta +} + +function remove_meta { + python3 -c "import sys; import json; c = '-D' +'$2'; s = json.loads(''.join([l for l in sys.stdin])); k = s['names']['$1']['cmake-args']; i = [c.startswith(v.split('=')[0]) for v in k]; k.pop(i.index(True)) if any(i) else None; print(json.dumps(s,indent=4))" < $FW_TARGETDIR/mcu_ws/colcon.meta > $FW_TARGETDIR/mcu_ws/colcon_new.meta + mv $FW_TARGETDIR/mcu_ws/colcon_new.meta $FW_TARGETDIR/mcu_ws/colcon.meta +} diff --git a/micro_ros_setup/config/zephyr/dev_ros2_packages.txt b/micro_ros_setup/config/zephyr/dev_ros2_packages.txt new file mode 100644 index 00000000..c04d6a17 --- /dev/null +++ b/micro_ros_setup/config/zephyr/dev_ros2_packages.txt @@ -0,0 +1,9 @@ +keep: + ament/ament_cmake + ament/ament_index + ament/ament_lint + ament/ament_package + ament/googletest + ament/osrf_pycommon + ament/uncrustify_vendor + ros2/ament_cmake_ros diff --git a/micro_ros_setup/config/zephyr/dev_uros_packages.repos b/micro_ros_setup/config/zephyr/dev_uros_packages.repos new file mode 100644 index 00000000..56f46b6f --- /dev/null +++ b/micro_ros_setup/config/zephyr/dev_uros_packages.repos @@ -0,0 +1 @@ +repositories: diff --git a/micro_ros_setup/config/zephyr/generic/board.repos b/micro_ros_setup/config/zephyr/generic/board.repos new file mode 100644 index 00000000..fea7e853 --- /dev/null +++ b/micro_ros_setup/config/zephyr/generic/board.repos @@ -0,0 +1,8 @@ +repositories: + zephyr_apps: + type: git + url: https://github.com/micro-ROS/zephyr_apps + version: dashing + + + diff --git a/micro_ros_setup/config/zephyr/generic/build.sh b/micro_ros_setup/config/zephyr/generic/build.sh new file mode 100755 index 00000000..97f93b33 --- /dev/null +++ b/micro_ros_setup/config/zephyr/generic/build.sh @@ -0,0 +1,45 @@ +. $PREFIX/config/utils.sh + +pushd $FW_TARGETDIR >/dev/null + source $FW_TARGETDIR/zephyrproject/zephyr/zephyr-env.sh + + export ZEPHYR_TOOLCHAIN_VARIANT=zephyr + export ZEPHYR_SDK_INSTALL_DIR=$FW_TARGETDIR/zephyr-sdk + export PATH=~/.local/bin:"$PATH" + + + # Retrieve user app + unset UROS_APP + + export UROS_APP=$(head -n1 $FW_TARGETDIR/APP | tail -n1) + export UROS_APP_FOLDER="$FW_TARGETDIR/zephyr_apps/apps/$UROS_APP" + + if [ -d "$UROS_APP_FOLDER" ]; then + echo "Selected app: $UROS_APP" + else + echo "App not found: $UROS_APP" + print_available_apps + exit 1 + fi + + # Clean previous builds + rm -rf build + + if [ "$UROS_FAST_BUILD" = "off" ] || [ ! -d "mcu_ws/build" ]; then + rm -rf mcu_ws/build mcu_ws/install mcu_ws/log + fi + + + # Set platform for Zephyr + if [ "$PLATFORM" = "discovery_l475_iot1" ]; then + export BOARD="disco_l475_iot1" + elif [ "$PLATFORM" = "olimex-stm32-e407" ]; then + export BOARD="olimex_stm32_e407" + else + echo "Unrecognized board: $PLATFORM" + exit 1 + fi + + # Build Zephyr + app + west build -b $BOARD -p auto $UROS_APP_FOLDER -- -G'Unix Makefiles' -DCMAKE_VERBOSE_MAKEFILE=ON +popd >/dev/null diff --git a/micro_ros_setup/config/zephyr/generic/client-colcon.meta b/micro_ros_setup/config/zephyr/generic/client-colcon.meta new file mode 100644 index 00000000..168f2c8a --- /dev/null +++ b/micro_ros_setup/config/zephyr/generic/client-colcon.meta @@ -0,0 +1,32 @@ +{ + "names": { + "rcl": { + "cmake-args": [ + "-DBUILD_TESTING=OFF" + ] + }, + "rcutils": { + "cmake-args": [ + "-DENABLE_TESTING=OFF", + "-DRCUTILS_NO_FILESYSTEM=ON", + "-DRCUTILS_NO_THREAD_SUPPORT=ON", + "-DRCUTILS_AVOID_DYNAMIC_ALLOCATION=ON" + ] + }, + "microxrcedds_client": { + "cmake-args": [ + "-DUCLIENT_PIC=OFF" + ] + }, + "rmw_microxrcedds": { + "cmake-args": [ + "-DRMW_UXRCE_MAX_NODES=1", + "-DRMW_UXRCE_MAX_PUBLISHERS=1", + "-DRMW_UXRCE_MAX_SUBSCRIPTIONS=1", + "-DRMW_UXRCE_MAX_SERVICES=1", + "-DRMW_UXRCE_MAX_CLIENTS=1", + "-DRMW_UXRCE_MAX_HISTORY=4" + ] + } + } +} diff --git a/micro_ros_setup/config/zephyr/generic/client_uros_packages.repos b/micro_ros_setup/config/zephyr/generic/client_uros_packages.repos new file mode 100644 index 00000000..e859eb6a --- /dev/null +++ b/micro_ros_setup/config/zephyr/generic/client_uros_packages.repos @@ -0,0 +1,34 @@ +repositories: + eProsima/Micro-CDR: + type: git + url: https://github.com/eProsima/micro-CDR.git + version: dashing + eProsima/Micro-XRCE-DDS-Client: + type: git + url: https://github.com/eProsima/Micro-XRCE-DDS-Client.git + version: dashing + +# MicroROS + + uros/rcl: + type: git + url: https://github.com/micro-ROS/rcl + version: dashing + uros/rcutils: + type: git + url: https://github.com/micro-ROS/rcutils + version: dashing + uros/rmw_microxrcedds: + type: git + url: https://github.com/micro-ROS/rmw-microxrcedds.git + version: feature/qos + uros/rosidl_typesupport_microxrcedds: + type: git + url: https://github.com/micro-ROS/rosidl_typesupport_microxrcedds.git + version: dashing + +# Remove this when it returns to ros2.repos + ros2/tinydir_vendor: + type: git + url: https://github.com/ros2/tinydir_vendor.git + version: master \ No newline at end of file diff --git a/micro_ros_setup/config/zephyr/generic/configure.sh b/micro_ros_setup/config/zephyr/generic/configure.sh new file mode 100755 index 00000000..1e0e8b06 --- /dev/null +++ b/micro_ros_setup/config/zephyr/generic/configure.sh @@ -0,0 +1,42 @@ + +EXTENSIONS_DIR=$FW_TARGETDIR/zephyr_apps + +. $PREFIX/config/utils.sh + +function help { + echo "Configure script need an argument." + echo " --transport -t udp, tcp, serial or serial-usb" + echo " --dev -d agent string descriptor in a serial-like transport" + echo " --ip -i agent IP in a network-like transport" + echo " --port -p agent port in a network-like transport" + +} + +echo $CONFIG_NAME > $FW_TARGETDIR/APP + +if [ "$UROS_TRANSPORT" == "udp" ] || [ "$UROS_TRANSPORT" == "tcp" ]; then + echo "Zephyr network support not available yet" + help + exit 1 + +elif [ "$UROS_TRANSPORT" == "serial" ]; then + echo "Zephyr UART serial support not available yet" + help + exit 1 + +elif [ "$UROS_TRANSPORT" == "serial-usb" ]; then + echo "Using USB serial device." + + cp -f $EXTENSIONS_DIR/microros_extensions/zephyr_usb_serial_transport.c $FW_TARGETDIR/mcu_ws/eProsima/Micro-XRCE-DDS-Client/src/c/profile/transport/serial/serial_transport_external.c + cp -f $EXTENSIONS_DIR/microros_extensions/zephyr_usb_serial_transport.h $FW_TARGETDIR/mcu_ws/eProsima/Micro-XRCE-DDS-Client/include/uxr/client/profile/transport/serial/serial_transport_external.h + update_meta "microxrcedds_client" "UCLIENT_EXTERNAL_SERIAL=ON" + + update_meta "rmw_microxrcedds" "RMW_UXRCE_TRANSPORT=custom_serial" + + remove_meta "rmw_microxrcedds" "RMW_UXRCE_DEFAULT_UDP_IP" + remove_meta "rmw_microxrcedds" "RMW_UXRCE_DEFAULT_UDP_PORT" + + echo "Configured $UROS_TRANSPORT mode with agent at USB serial" +else + help +fi diff --git a/micro_ros_setup/config/zephyr/generic/create.sh b/micro_ros_setup/config/zephyr/generic/create.sh new file mode 100755 index 00000000..f4f90449 --- /dev/null +++ b/micro_ros_setup/config/zephyr/generic/create.sh @@ -0,0 +1,46 @@ +# Reminder: Zephyr recommended dependecies are: git cmake ninja-build gperf ccache dfu-util device-tree-compiler wget python3-pip python3-setuptools python3-tk python3-wheel xz-utils file make gcc gcc-multilib software-properties-common -y + +# We need a version newer than the repo +wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add - +echo "deb https://apt.kitware.com/ubuntu/ bionic main" > /etc/apt/sources.list.d/kitware.list +sudo apt update +sudo apt install cmake -y + +export PATH=~/.local/bin:"$PATH" + +pushd $FW_TARGETDIR >/dev/null + + west init zephyrproject + pushd zephyrproject >/dev/null + west update + popd >/dev/null + + pip3 install -r zephyrproject/zephyr/scripts/requirements.txt + + export TOOLCHAIN_VERSION=zephyr-toolchain-arm-0.11.2-setup.run + wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.11.2/$TOOLCHAIN_VERSION + chmod +x $TOOLCHAIN_VERSION + ./$TOOLCHAIN_VERSION -- -d $(pwd)/zephyr-sdk -y + + rm -rf $TOOLCHAIN_VERSION + + + # Temporal until driver in mainstream + pushd zephyrproject/zephyr >/dev/null + git remote add eprosima https://github.com/eProsima/zephyr + git fetch --all + git checkout remotes/eprosima/feature/driver_vl53l1 + popd >/dev/null + + export ZEPHYR_TOOLCHAIN_VARIANT=zephyr + export ZEPHYR_SDK_INSTALL_DIR=$FW_TARGETDIR/zephyr-sdk + + # Import repos + vcs import --input $PREFIX/config/$RTOS/generic/board.repos >/dev/null + + # ignore broken packages + touch mcu_ws/ros2/rcl_logging/rcl_logging_log4cxx/COLCON_IGNORE + touch mcu_ws/ros2/rcl/COLCON_IGNORE + + rosdep install -y --from-paths mcu_ws -i mcu_ws --rosdistro dashing --skip-keys="$SKIP" +popd >/dev/null \ No newline at end of file diff --git a/micro_ros_setup/config/zephyr/generic/flash.sh b/micro_ros_setup/config/zephyr/generic/flash.sh new file mode 100755 index 00000000..2f29ef11 --- /dev/null +++ b/micro_ros_setup/config/zephyr/generic/flash.sh @@ -0,0 +1,13 @@ +pushd $FW_TARGETDIR > /dev/null + + export ZEPHYR_TOOLCHAIN_VARIANT=zephyr + export ZEPHYR_SDK_INSTALL_DIR=$FW_TARGETDIR/zephyr-sdk + + source $FW_TARGETDIR/zephyrproject/zephyr/zephyr-env.sh + + export PATH=~/.local/bin:"$PATH" + + west flash + +popd > /dev/null + diff --git a/micro_ros_setup/config/zephyr/generic/package.xml b/micro_ros_setup/config/zephyr/generic/package.xml new file mode 100644 index 00000000..e1161282 --- /dev/null +++ b/micro_ros_setup/config/zephyr/generic/package.xml @@ -0,0 +1,19 @@ + + + + firmware + 0.0.0 + Micro-ROS dependecies for Zephyr RTOS + Pablo Garrido + APL2 + + ninja-build + gperf + dfu-util + wget + xz-utils + gcc-multilib + + python3-west-pip + + diff --git a/micro_ros_setup/config/zephyr/generic/supported_platforms b/micro_ros_setup/config/zephyr/generic/supported_platforms new file mode 100644 index 00000000..931c9e4c --- /dev/null +++ b/micro_ros_setup/config/zephyr/generic/supported_platforms @@ -0,0 +1,2 @@ +discovery_l475_iot1 +olimex-stm32-e407 diff --git a/micro_ros_setup/config/zephyr/list_apps.sh b/micro_ros_setup/config/zephyr/list_apps.sh new file mode 100644 index 00000000..46c19fa2 --- /dev/null +++ b/micro_ros_setup/config/zephyr/list_apps.sh @@ -0,0 +1,18 @@ +function print_available_apps { + echo "Available apps for Zephyr and $PLATFORM:" + pushd $FW_TARGETDIR/zephyr_apps/apps >/dev/null + for app in $(ls -d */ | cut -f1 -d'/'); do + echo "+-- $app" + done + popd >/dev/null +} + +function check_available_app { + pushd $FW_TARGETDIR/zephyr_apps/apps >/dev/null + if [ ! -d $1 ]; then + echo "App $1 for Zephyr not available" + print_available_apps + exit 1 + fi + popd >/dev/null +} \ No newline at end of file diff --git a/micro_ros_setup/scripts/build_firmware.sh b/micro_ros_setup/scripts/build_firmware.sh index e012a079..a39cff0b 100755 --- a/micro_ros_setup/scripts/build_firmware.sh +++ b/micro_ros_setup/scripts/build_firmware.sh @@ -21,7 +21,7 @@ export UROS_FAST_BUILD # Checking if firmware exists if [ -d $FW_TARGETDIR ]; then RTOS=$(head -n1 $FW_TARGETDIR/PLATFORM) - PLATFORM=$(tail -n1 $FW_TARGETDIR/PLATFORM) + PLATFORM=$(head -n2 firmware/PLATFORM | tail -n1) else echo "Firmware folder not found. Please use ros2 run micro_ros_setup create_firmware_ws.sh to create a new project." exit 1 @@ -39,4 +39,10 @@ fi # Building specific firmware folder echo "Building firmware for $RTOS platform $PLATFORM" -. $PREFIX/config/$RTOS/$PLATFORM/build.sh + +if [ $PLATFORM != "generic" ] && [ -d "$PREFIX/config/$RTOS/generic" ]; then + . $PREFIX/config/$RTOS/generic/build.sh +else + . $PREFIX/config/$RTOS/$PLATFORM/build.sh +fi + diff --git a/micro_ros_setup/scripts/configure_firmware.sh b/micro_ros_setup/scripts/configure_firmware.sh index c25c68d7..f09fdec6 100755 --- a/micro_ros_setup/scripts/configure_firmware.sh +++ b/micro_ros_setup/scripts/configure_firmware.sh @@ -10,17 +10,81 @@ export PREFIX=$(ros2 pkg prefix micro_ros_setup) # Checking if firmware exists if [ -d $FW_TARGETDIR ]; then RTOS=$(head -n1 $FW_TARGETDIR/PLATFORM) - PLATFORM=$(tail -n1 $FW_TARGETDIR/PLATFORM) + PLATFORM=$(head -n2 firmware/PLATFORM | tail -n1) else echo "Firmware folder not found. Please use ros2 run micro_ros_setup create_firmware_ws.sh to create a new project." exit 1 fi +# Check if configure script exists +if [ $PLATFORM != "generic" ] && [ -d "$PREFIX/config/$RTOS/generic" ]; then + if [ ! -f $PREFIX/config/$RTOS/generic/configure.sh ]; then + echo "No configuration step needed for generic platform $PLATFORM" + exit 1 + fi +else + if [ ! -f $PREFIX/config/$RTOS/$PLATFORM/configure.sh ]; then + echo "No configuration step needed for $RTOS platform $PLATFORM" + exit 1 + fi +fi + +# Parsing micro-ROS arguments +if [ $# -lt 1 ]; then + echo "micro-ROS application name must be provided: ros2 run micro_ros_setup configure_firmware.sh [app name] [options]" + # Check if RTOS has app listing funcions and source in case + if [ -f $PREFIX/config/$RTOS/list_apps.sh ]; then + . $PREFIX/config/$RTOS/list_apps.sh + print_available_apps + fi + exit 1 +fi + +if [ -f $PREFIX/config/$RTOS/list_apps.sh ]; then + . $PREFIX/config/$RTOS/list_apps.sh + check_available_app $1 +fi + +export CONFIG_NAME=$1 +shift + +while [[ $# -gt 0 ]]; do + key="$1" + + case $key in + -t|--transport) + export UROS_TRANSPORT="$2" + shift # past argument + shift # past value + ;; + -d|--dev) + export UROS_AGENT_DEVICE="$2" + shift # past argument + shift # past value + ;; + -i|--ip) + export UROS_AGENT_IP="$2" + shift # past argument + shift # past value + ;; + -p|--port) + export UROS_AGENT_PORT="$2" + shift # past argument + shift # past value + ;; + *) # unknown option + echo "Unknown argument $1" + exit 1 + ;; + esac +done + # Configure specific firmware folder if needed -if [ -f $PREFIX/config/$RTOS/$PLATFORM/configure.sh ]; then - echo "Configuring firmware for $RTOS platform $PLATFORM" - exec $PREFIX/config/$RTOS/$PLATFORM/configure.sh $@ +if [ $PLATFORM != "generic" ] && [ -d "$PREFIX/config/$RTOS/generic" ]; then + echo "Configuring firmware for $RTOS platform $PLATFORM" + exec $PREFIX/config/$RTOS/generic/configure.sh $@ else - echo "No configuration step needed for $RTOS platform $PLATFORM" + echo "Configuring firmware for $RTOS platform $PLATFORM" + exec $PREFIX/config/$RTOS/$PLATFORM/configure.sh $@ fi diff --git a/micro_ros_setup/scripts/create_firmware_ws.sh b/micro_ros_setup/scripts/create_firmware_ws.sh index ebf26d11..33247bf8 100755 --- a/micro_ros_setup/scripts/create_firmware_ws.sh +++ b/micro_ros_setup/scripts/create_firmware_ws.sh @@ -13,11 +13,18 @@ print_available_platforms () { pushd $PREFIX/config >/dev/null for rtos in $(ls -d */ | cut -f1 -d'/'); do echo ". $rtos" - pushd $rtos >/dev/null - for platform in $(ls -d */ | cut -f1 -d'/'); do - echo "+-- $platform" - done - popd >/dev/null + if [ -f $PREFIX/config/$rtos/generic/supported_platforms ];then + + while read line; do + echo "+-- $line" + done < $PREFIX/config/$rtos/generic/supported_platforms + else + pushd $rtos >/dev/null + for platform in $(ls -d */ | cut -f1 -d'/'); do + echo "+-- $platform" + done + popd >/dev/null + fi done popd >/dev/null } @@ -45,7 +52,7 @@ if [ -d $FW_TARGETDIR ]; then fi # Checking folders -if [ -d $PREFIX/config/$RTOS/$PLATFORM ]; then +if [ -d $PREFIX/config/$RTOS/$PLATFORM ] || [ -d "$PREFIX/config/$RTOS/generic" ]; then echo "Creating firmware for $RTOS platform $PLATFORM" FOLDER=$PREFIX/config/$RTOS/$PLATFORM else @@ -67,6 +74,13 @@ SKIP="microxrcedds_client microcdr rosidl_typesupport_connext_cpp rosidl_typesup rosdep update rosdep install -y --from-paths src -i src --rosdistro dashing --skip-keys="$SKIP" +# Check generic build +if [ $PLATFORM != "generic" ] && [ -d "$PREFIX/config/$RTOS/generic" ]; then + TARGET_FOLDER=generic +else + TARGET_FOLDER=$PLATFORM +fi + pushd $FW_TARGETDIR >/dev/null # Creating dev directory mkdir $DEV_WS_DIR @@ -78,8 +92,8 @@ pushd $FW_TARGETDIR >/dev/null # Creating mcu directory mkdir mcu_ws - ros2 run micro_ros_setup create_ws.sh mcu_ws $PREFIX/config/client_ros2_packages.txt $PREFIX/config/$RTOS/$PLATFORM/client_uros_packages.repos - cp $PREFIX/config/$RTOS/$PLATFORM/client-colcon.meta mcu_ws/colcon.meta + ros2 run micro_ros_setup create_ws.sh mcu_ws $PREFIX/config/client_ros2_packages.txt $PREFIX/config/$RTOS/$TARGET_FOLDER/client_uros_packages.repos + cp $PREFIX/config/$RTOS/$TARGET_FOLDER/client-colcon.meta mcu_ws/colcon.meta fi popd >/dev/null @@ -94,9 +108,9 @@ if [ $RTOS != "host" ]; then popd > /dev/null fi -# CHECKME: this is probably no longer necessary -rosdep install -y --from-paths $FW_TARGETDIR -i $FW_TARGETDIR --rosdistro dashing --skip-keys="$SKIP" +# Install dependecies for specific platform +rosdep install -y --from-paths $PREFIX/config/$RTOS/$TARGET_FOLDER -i $PREFIX/config/$RTOS/$TARGET_FOLDER --rosdistro dashing --skip-keys="$SKIP" # Creating specific firmware folder -. $PREFIX/config/$RTOS/$PLATFORM/create.sh +. $PREFIX/config/$RTOS/$TARGET_FOLDER/create.sh diff --git a/micro_ros_setup/scripts/flash_firmware.sh b/micro_ros_setup/scripts/flash_firmware.sh index b1af7d89..7f257cad 100755 --- a/micro_ros_setup/scripts/flash_firmware.sh +++ b/micro_ros_setup/scripts/flash_firmware.sh @@ -10,17 +10,25 @@ PREFIX=$(ros2 pkg prefix micro_ros_setup) # Checking if firmware exists if [ -d $FW_TARGETDIR ]; then RTOS=$(head -n1 $FW_TARGETDIR/PLATFORM) - PLATFORM=$(tail -n1 $FW_TARGETDIR/PLATFORM) + PLATFORM=$(head -n2 firmware/PLATFORM | tail -n1) else echo "Firmware folder not found. Please use ros2 run micro_ros_setup create_firmware_ws.sh to create a new project." exit 1 fi # Flash specific firmware folder if needed -if [ -f $PREFIX/config/$RTOS/$PLATFORM/flash.sh ]; then - echo "Flashing firmware for $RTOS platform $PLATFORM" - . $PREFIX/config/$RTOS/$PLATFORM/flash.sh +if [ $PLATFORM != "generic" ] && [ -d "$PREFIX/config/$RTOS/generic" ]; then + if [ -f $PREFIX/config/$RTOS/generic/flash.sh ]; then + echo "Flashing firmware for $RTOS platform $PLATFORM" + . $PREFIX/config/$RTOS/generic/flash.sh + else + echo "No flash step found for $RTOS platform $PLATFORM" + fi else - echo "No flash step found for $RTOS platform $PLATFORM" + if [ -f $PREFIX/config/$RTOS/$PLATFORM/flash.sh ]; then + echo "Flashing firmware for $RTOS platform $PLATFORM" + . $PREFIX/config/$RTOS/$PLATFORM/flash.sh + else + echo "No flash step found for $RTOS platform $PLATFORM" + fi fi -