Skip to content

Commit

Permalink
[Bouffalolab] Update Dockerfile to setup compile environment for Bouf…
Browse files Browse the repository at this point in the history
…falo Lab SoC build (#23700)

* Update Dockerfile to setup toolchain for Bouffalo Lab SoC build

* Fix restyle

* Update docker image version

* setup toolchain under /opt/bouffalolab_sdk

* fix Restyle
  • Loading branch information
wy-hh authored and pull[bot] committed Jan 22, 2024
1 parent bbf6367 commit 4101928
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 7 deletions.
20 changes: 14 additions & 6 deletions integrations/docker/images/chip-build-bouffalolab/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
ARG VERSION=latest
FROM connectedhomeip/chip-build:${VERSION}

RUN set -x \
&& pip install bflb-iot-tool \
&& apt-get update \
&& apt-get install -fy \
vim \
&& : # last line
RUN apt update -y \
&& apt install vim -fy \
&& apt clean \
&& pip3 install bflb-iot-tool \
&& : # last line

COPY setup.sh /tmp

RUN cd /tmp \
&& bash setup.sh \
&& rm setup.sh \
&& : # last line

ENV BOUFFALOLAB_SDK_ROOT=/opt/bouffalolab_sdk
66 changes: 66 additions & 0 deletions integrations/docker/images/chip-build-bouffalolab/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env bash

set -x
CURRENT_DIR=$(
cd "$(dirname "$0")"
pwd
)

SDK_ROOT=/opt/bouffalolab_sdk
# Currently, only setup toolchain under $SDK_ROOT
TOOLCHAIN_SETUP_ROOT=$SDK_ROOT/toolchain

TOOLCHAIN_SYMBOLIC_LINK_PATH=""
git -C . rev-parse 2>/dev/null
if [[ "$?" == "0" ]]; then
# Examples in Bouffalo Lab IOT SDK repo expect toolchain under repo,
# let's create a symbolic link to Bouffalo Lab toolchain,
# if this script runs under repo
TOOLCHAIN_SYMBOLIC_LINK_PATH=$CURRENT_DIR/../toolchain
fi

if [[ "$OSTYPE" == "linux-gnu"* ]]; then
toolchains_url=(
"riscv/Thead_riscv/Linux_x86_64" "https://dev.bouffalolab.com/media/upload/download/toolchain_riscv_thead_linux64.zip" "toolchain_riscv_thead_linux_x86_64"
"riscv/Linux" "https://dev.bouffalolab.com/media/upload/download/toolchain_riscv_sifive_linux64.zip" "toolchain_riscv_sifive_linux"
)
elif [[ "$OSTYPE" == "darwin"* ]]; then
toolchains_url=(
"riscv/Darwin" "https://dev.bouffalolab.com/media/upload/download/toolchain_riscv_sifive_macos.zip" "toolchain_riscv_sifive_macos"
)
else
echo "Not support for ""$OSTYPE"
fi

if [ ! -d "$TOOLCHAIN_SETUP_ROOT" ]; then
mkdir -p "$TOOLCHAIN_SETUP_ROOT"
fi
rm -rf "$TOOLCHAIN_SETUP_ROOT"/*.zip

for ((i = 0; i < ${#toolchains_url[@]}; i += 3)); do
path=${toolchains_url[i]}
url=${toolchains_url[i + 1]}
output=${toolchains_url[i + 2]}

wget -P "$TOOLCHAIN_SETUP_ROOT"/ "$url"
toolchain_zip=$(basename "$url")
if [ ! -f "$TOOLCHAIN_SETUP_ROOT/$toolchain_zip" ]; then
exit 1
fi
rm -rf "$TOOLCHAIN_SETUP_ROOT/$path"
mkdir -p "$TOOLCHAIN_SETUP_ROOT/$path"
unzip "$TOOLCHAIN_SETUP_ROOT/$toolchain_zip" -d "$TOOLCHAIN_SETUP_ROOT/$path"
mv "$TOOLCHAIN_SETUP_ROOT/$path/$output"/* "$TOOLCHAIN_SETUP_ROOT/$path"
rm -rf "$TOOLCHAIN_SETUP_ROOT/$toolchain_zip"

if [ -f "$TOOLCHAIN_SETUP_ROOT/$path"/chmod755.sh ]; then
cd "$TOOLCHAIN_SETUP_ROOT/$path"/
bash chmod755.sh
cd "$CURRENT_DIR"
fi
done

if [[ "$TOOLCHAIN_SYMBOLIC_LINK_PATH" != "" ]]; then
rm -rf "$TOOLCHAIN_SYMBOLIC_LINK_PATH"
ln -s "$TOOLCHAIN_SETUP_ROOT" "$TOOLCHAIN_SYMBOLIC_LINK_PATH"
fi
4 changes: 4 additions & 0 deletions integrations/docker/images/chip-build-vscode/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ FROM connectedhomeip/chip-build-k32w:${VERSION} AS k32w
FROM connectedhomeip/chip-build-imx:${VERSION} AS imx
FROM connectedhomeip/chip-build-ti:${VERSION} AS ti
FROM connectedhomeip/chip-build-openiotsdk:${VERSION} AS openiotsdk
FROM connectedhomeip/chip-build-bouffalolab:${VERSION} AS bouffalolab
FROM connectedhomeip/chip-build:${VERSION}

# qemu-src copied over because qemu directory contains symlinks to the src
Expand Down Expand Up @@ -50,6 +51,8 @@ COPY --from=ti /opt/ti/sysconfig_1.13.0 /opt/ti/sysconfig_1.13.0
COPY --from=openiotsdk /opt/gcc-arm-none-eabi-10.3-2021.10/ /opt/gcc-arm-none-eabi-10.3-2021.10/
COPY --from=openiotsdk /opt/FVP_Corstone_SSE-300/ /opt/FVP_Corstone_SSE-300/

COPY --from=bouffalolab /opt/bouffalolab_sdk /opt/bouffalolab_sdk

# Android license file "acceping" is done by writing license hashes
# into the 'licenses' subfolder. This allows any user (in particular
# 'vscode' to accept licenses)
Expand Down Expand Up @@ -110,3 +113,4 @@ ENV TIZEN_SDK_SYSROOT $TIZEN_SDK_ROOT/platforms/tizen-$TIZEN_VERSION/mobile/root

ENV FVP_CORSTONE_300_PATH=/opt/FVP_Corstone_SSE-300
ENV ARM_GCC_TOOLCHAIN_PATH=/opt/gcc-arm-none-eabi-10.3-2021.10
ENV BOUFFALOLAB_SDK_ROOT=/opt/bouffalolab_sdk
2 changes: 1 addition & 1 deletion integrations/docker/images/chip-build/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.6.11 Version bump reason: install nodejs into chip-build image, since github js actions seem to need it.
0.6.12 Version bump reason: Update Bouffalo Lab build environment.

0 comments on commit 4101928

Please sign in to comment.