diff --git a/README.md b/README.md index c10b0b25..b0e67f7f 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ This package is the **official build system for micro-ROS**. It provides tools a | RTOS | Platform | Version | Example | | ---------------------------------------- | ---------------------------------------------------------------------------------------------------- | -------------------- | ---------------------------- | | [Nuttx](https://nuttx.org/) | [Olimex STM32-E407](https://www.olimex.com/Products/ARM/ST/STM32-E407/open-source-hardware) | v7.29 | `nuttx olimex-stm32-e407` | +| [Nuttx](https://nuttx.org/) | [Spresense](https://developer.sony.com/develop/spresense/) | v2.2.0 | `nuttx spresense` | | [FreeRTOS](https://www.freertos.org/) | [Crazyflie 2.1](https://www.bitcraze.io/crazyflie-2-1/) | v10.2.1 - CF 2020.06 | `freertos crazyflie21` | | [FreeRTOS](https://www.freertos.org/) | [Olimex STM32-E407](https://www.olimex.com/Products/ARM/ST/STM32-E407/open-source-hardware) | STM32CubeMX latest | `freertos olimex-stm32-e407` | | [FreeRTOS](https://www.freertos.org/) | [ST Nucleo F446RE](https://www.st.com/en/evaluation-tools/nucleo-f446re.html) 1 | STM32CubeMX latest | `freertos nucleo_f446re` | @@ -42,7 +43,9 @@ This package is the **official build system for micro-ROS**. It provides tools a *3 a valid CMake toolchain with custom crosscompilation definition is required* -Please note that NuttX with Olimex STM32-E407 board is the reference platform and not everything might be supported on other platforms. +Please note that +- NuttX with Olimex STM32-E407 board is the reference platform and not everything might be supported on other platforms. +- NuttX with Spresense board is the reference platform and other platforms don't support this board. ## Secondary build system tools @@ -138,6 +141,7 @@ In summary, the supported configurations for transports are: | ST Nucleo H743ZI 1 | - | - | UART | | ST Nucleo F746ZG 1 | - | UART | UART | | ST Nucleo F767ZI 1 | - | UART | - | +| Spresense | Network | - | - | *1 Community supported, may have lack of official support* diff --git a/config/nuttx/spresense/build.sh b/config/nuttx/spresense/build.sh new file mode 100755 index 00000000..7bde4bd7 --- /dev/null +++ b/config/nuttx/spresense/build.sh @@ -0,0 +1,12 @@ +#! /bin/bash + +set -e +set -o nounset +set -o pipefail + + +NUTTX_DIR=$FW_TARGETDIR/spresense/sdk + +pushd $NUTTX_DIR >/dev/null + make +popd >/dev/null diff --git a/config/nuttx/spresense/client-colcon.meta b/config/nuttx/spresense/client-colcon.meta new file mode 120000 index 00000000..e5952815 --- /dev/null +++ b/config/nuttx/spresense/client-colcon.meta @@ -0,0 +1 @@ +../generic/client-colcon.meta \ No newline at end of file diff --git a/config/nuttx/spresense/client_uros_packages.repos b/config/nuttx/spresense/client_uros_packages.repos new file mode 120000 index 00000000..16937d3a --- /dev/null +++ b/config/nuttx/spresense/client_uros_packages.repos @@ -0,0 +1 @@ +../generic/client_uros_packages.repos \ No newline at end of file diff --git a/config/nuttx/spresense/configure.sh b/config/nuttx/spresense/configure.sh new file mode 100755 index 00000000..8248ca72 --- /dev/null +++ b/config/nuttx/spresense/configure.sh @@ -0,0 +1,40 @@ +#! /bin/bash +# +# + +set -e +set -o nounset +set -o pipefail + + +# spresense uses own sdk to config +NUTTX_DIR=$FW_TARGETDIR/spresense/sdk +MCU_WS_DIR=$FW_TARGETDIR/mcu_ws + +# parse the platform from this script's path name +PLATFORM=$(head -n2 $FW_TARGETDIR/PLATFORM | tail -n1) + +# for the "generic" platform, the user must supply both board and config +# if [ "$PLATFORM" = "generic" ] +# then +# CONFIG=configs/$CONFIG_NAME +# else +# CONFIG="configs/$PLATFORM/$CONFIG_NAME" +# fi + +# if [ ! -d "$NUTTX_DIR/$CONFIG" ] +# then +# echo "Configuration $CONFIG (expanded from $CONFIG_NAME) not found" +# exit 1 +# fi + +# source dev_ws for kconfig +set +o nounset +. $FW_TARGETDIR/dev_ws/install/setup.bash +set -o nounset + +pushd $NUTTX_DIR >/dev/null +make distclean +#tools/configure.sh $CONFIG +tools/config.py $CONFIG_NAME +popd >/dev/null diff --git a/config/nuttx/spresense/create.sh b/config/nuttx/spresense/create.sh new file mode 100755 index 00000000..5bd24569 --- /dev/null +++ b/config/nuttx/spresense/create.sh @@ -0,0 +1,49 @@ +#! /bin/bash + +set -e +set -o nounset +set -o pipefail + + +[ -d $FW_TARGETDIR ] || mkdir $FW_TARGETDIR +pushd $FW_TARGETDIR >/dev/null + + vcs import --input $PREFIX/config/$RTOS/$PLATFORM/uros_packages.repos --recursive + + # copy uros apps from nuttx_apps to spresense/sdk/apps + cp -a apps/uros spresense/sdk/apps + sed -i 's#default "../mcu_ws/"#default "../../../mcu_ws/"#' spresense/sdk/apps/uros/Kconfig + sed -i "/\${NUTTX_TOPDIR}\/include\/uClibc++/a \${NUTTX_TOPDIR}\/..\/sdk\/include" spresense/sdk/apps/uros/arm_toolchain.cmake.in + sed -i "/\${NUTTX_APPDIR}\/configs\/olimex-stm32-e407\/src/d" spresense/sdk/apps/uros/arm_toolchain.cmake.in + sed -i '2 a \ "rcutils": {' spresense/sdk/apps/uros/rmw_config.meta.in + sed -i '3 a \ "cmake-args": [' spresense/sdk/apps/uros/rmw_config.meta.in + sed -i '4 a \ "-DRCUTILS_NO_64_ATOMIC=ON"' spresense/sdk/apps/uros/rmw_config.meta.in + sed -i '5 a \ ]' spresense/sdk/apps/uros/rmw_config.meta.in + sed -i '6 a \ },' spresense/sdk/apps/uros/rmw_config.meta.in + + # install uclibc + if [ ! -d "spresense/nuttx/libs/libxx/uClibc++" ] + then + pushd uclibc >/dev/null + ./install.sh ../spresense/nuttx + popd >/dev/null + fi + + # ignore broken packages + touch mcu_ws/ros2/rcl_logging/rcl_logging_log4cxx/COLCON_IGNORE + touch mcu_ws/ros2/rcl_logging/rcl_logging_spdlog/COLCON_IGNORE + touch mcu_ws/ros2/rcl/rcl_action/COLCON_IGNORE + + touch mcu_ws/ros2/rcl/COLCON_IGNORE + touch mcu_ws/ros2/rosidl/rosidl_typesupport_introspection_c/COLCON_IGNORE + touch mcu_ws/ros2/rosidl/rosidl_typesupport_introspection_cpp/COLCON_IGNORE + touch mcu_ws/ros2/rcpputils/COLCON_IGNORE + touch mcu_ws/uros/rcl/rcl_yaml_param_parser/COLCON_IGNORE + touch mcu_ws/uros/rclc/rclc_examples/COLCON_IGNORE + + rosdep install -y --from-paths mcu_ws -i mcu_ws --rosdistro foxy --skip-keys="$SKIP" + +popd >/dev/null + +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 foxy diff --git a/config/nuttx/spresense/flash.sh b/config/nuttx/spresense/flash.sh new file mode 100755 index 00000000..914dd423 --- /dev/null +++ b/config/nuttx/spresense/flash.sh @@ -0,0 +1,22 @@ +#! /bin/bash + +set -e +set -o nounset +set -o pipefail + + +pushd $FW_TARGETDIR/spresense/sdk > /dev/null + +if [ "$PLATFORM" = "spresense" ]; then + if [ -f nuttx.spk ]; then + echo "Flashing firmware for $RTOS platform $PLATFORM" + ./tools/flash.sh -c $DEVICE_NAME nuttx.spk + else + echo "Nuttx/nuttx.spk not found: please compile before flashing." + fi +else + echo "Unrecognized board: $PLATFORM" + exit 1 +fi + +popd > /dev/null diff --git a/config/nuttx/spresense/package.xml b/config/nuttx/spresense/package.xml new file mode 100644 index 00000000..00257942 --- /dev/null +++ b/config/nuttx/spresense/package.xml @@ -0,0 +1,22 @@ + + + + firmware + 0.0.1 + This is a dummy package to supply firmware build dependencies for spresense. + Ingo Luetkebohle + Barry Xu + Tomoya Fujita + APL2 + + gcc-arm-none-eabi + clang-tidy + clang-format + gperf + automake + nuttx_kconfig_vendor + git + openocd + ed + + diff --git a/config/nuttx/spresense/supported_platforms b/config/nuttx/spresense/supported_platforms new file mode 100644 index 00000000..878a8ec6 --- /dev/null +++ b/config/nuttx/spresense/supported_platforms @@ -0,0 +1 @@ +spresense diff --git a/config/nuttx/spresense/uros_packages.repos b/config/nuttx/spresense/uros_packages.repos new file mode 100644 index 00000000..ab20c489 --- /dev/null +++ b/config/nuttx/spresense/uros_packages.repos @@ -0,0 +1,17 @@ +repositories: + spresense: + type: git + url: https://github.com/sonydevworld/spresense.git + version: master + apps: + type: git + url: https://github.com/micro-ROS/nuttx_apps.git + version: foxy + uclibc: + type: git + url: https://github.com/micro-ROS/uclibc.git + version: master + drive_base: + type: git + url: https://github.com/micro-ROS/drive_base.git + version: master diff --git a/scripts/build_firmware.sh b/scripts/build_firmware.sh index 804fa8cf..765d74ca 100755 --- a/scripts/build_firmware.sh +++ b/scripts/build_firmware.sh @@ -69,7 +69,7 @@ fi # Building specific firmware folder echo "Building firmware for $RTOS platform $PLATFORM" -if [ $PLATFORM != "generic" ] && [ -d "$PREFIX/config/$RTOS/generic" ]; then +if [ $PLATFORM == "generic" ] || [ ! -d "$PREFIX/config/$RTOS/$PLATFORM" ]; then . $PREFIX/config/$RTOS/generic/build.sh else . $PREFIX/config/$RTOS/$PLATFORM/build.sh diff --git a/scripts/configure_firmware.sh b/scripts/configure_firmware.sh index e8c79153..27feabbe 100755 --- a/scripts/configure_firmware.sh +++ b/scripts/configure_firmware.sh @@ -17,7 +17,7 @@ else fi # Check if configure script exists -if [ $PLATFORM != "generic" ] && [ -d "$PREFIX/config/$RTOS/generic" ]; then +if [ $PLATFORM == "generic" ] || [ ! -d "$PREFIX/config/$RTOS/$PLATFORM" ]; then if [ ! -f $PREFIX/config/$RTOS/generic/configure.sh ]; then echo "No configuration step needed for generic platform $PLATFORM" exit 0 @@ -80,7 +80,7 @@ while [[ $# -gt 0 ]]; do done # Configure specific firmware folder if needed -if [ $PLATFORM != "generic" ] && [ -d "$PREFIX/config/$RTOS/generic" ]; then +if [ $PLATFORM == "generic" ] || [ ! -d "$PREFIX/config/$RTOS/$PLATFORM" ]; then echo "Configuring firmware for $RTOS platform $PLATFORM" exec $PREFIX/config/$RTOS/generic/configure.sh $@ else diff --git a/scripts/create_firmware_ws.sh b/scripts/create_firmware_ws.sh index 3951808c..00557c9e 100755 --- a/scripts/create_firmware_ws.sh +++ b/scripts/create_firmware_ws.sh @@ -75,7 +75,7 @@ rosdep update rosdep install -y --from-paths src -i src --rosdistro foxy --skip-keys="$SKIP" # Check generic build -if [ $PLATFORM != "generic" ] && [ -d "$PREFIX/config/$RTOS/generic" ]; then +if [ $PLATFORM == "generic" ] || [ ! -d "$PREFIX/config/$RTOS/$PLATFORM" ]; then TARGET_FOLDER=generic else TARGET_FOLDER=$PLATFORM diff --git a/scripts/flash_firmware.sh b/scripts/flash_firmware.sh index 7f257cad..ce9b7cda 100755 --- a/scripts/flash_firmware.sh +++ b/scripts/flash_firmware.sh @@ -16,8 +16,10 @@ else exit 1 fi +export DEVICE_NAME=${1:-/dev/ttyUSB0} + # Flash specific firmware folder if needed -if [ $PLATFORM != "generic" ] && [ -d "$PREFIX/config/$RTOS/generic" ]; then +if [ $PLATFORM == "generic" ] || [ ! -d "$PREFIX/config/$RTOS/$PLATFORM" ]; then if [ -f $PREFIX/config/$RTOS/generic/flash.sh ]; then echo "Flashing firmware for $RTOS platform $PLATFORM" . $PREFIX/config/$RTOS/generic/flash.sh