Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Spresense board support #323

Open
wants to merge 2 commits into
base: foxy
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) <sup>1</sup> | STM32CubeMX latest | `freertos nucleo_f446re` |
Expand All @@ -42,7 +43,9 @@ This package is the **official build system for micro-ROS**. It provides tools a

*<sup>3</sup> 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

Expand Down Expand Up @@ -138,6 +141,7 @@ In summary, the supported configurations for transports are:
| ST Nucleo H743ZI <sup>1</sup> | - | - | UART |
| ST Nucleo F746ZG <sup>1</sup> | - | UART | UART |
| ST Nucleo F767ZI <sup>1</sup> | - | UART | - |
| Spresense | WiFi | - | - |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

Suggested change
| Spresense | WiFi | - | - |
| Spresense | Network | - | - |


*<sup>1</sup> Community supported, may have lack of official support*

Expand Down
12 changes: 12 additions & 0 deletions config/nuttx/spresense/build.sh
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions config/nuttx/spresense/client-colcon.meta
1 change: 1 addition & 0 deletions config/nuttx/spresense/client_uros_packages.repos
40 changes: 40 additions & 0 deletions config/nuttx/spresense/configure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#! /bin/bash
#
#

set -e
set -o nounset
set -o pipefail


# spresense use own sdk to config

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

Suggested change
# spresense use own sdk to config
# 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
49 changes: 49 additions & 0 deletions config/nuttx/spresense/create.sh
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions config/nuttx/spresense/flash.sh
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions config/nuttx/spresense/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="2">
<name>firmware</name>
<version>0.0.1</version>
<description>This is a dummy package to supply firmware build dependencies for spresense.</description>
<maintainer email="ingo.luetkebohle@de.bosch.com">Ingo Luetkebohle</maintainer>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<maintainer email="ingo.luetkebohle@de.bosch.com">Ingo Luetkebohle</maintainer>
<maintainer email="Barry.Xu@sony.com">Barry Xu</maintainer>
<maintainer email="Tomoya.Fujita@sony.com">Tomoya Fujita</maintainer>

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fujitatomoya

Thanks for your review comments. I have addressed them at 4184ad9.

<license>APL2</license>

<build_depend>gcc-arm-none-eabi</build_depend>
<build_depend>clang-tidy</build_depend>
<build_depend>clang-format</build_depend>
<build_depend>gperf</build_depend>
<build_depend>automake</build_depend>
<build_depend>nuttx_kconfig_vendor</build_depend>
<build_depend>git</build_depend>
<build_depend>openocd</build_depend>
<build_depend>ed</build_depend>

</package>
1 change: 1 addition & 0 deletions config/nuttx/spresense/supported_platforms
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
spresense
17 changes: 17 additions & 0 deletions config/nuttx/spresense/uros_packages.repos
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion scripts/build_firmware.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions scripts/configure_firmware.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/create_firmware_ws.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion scripts/flash_firmware.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down