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

[Bouffalo Lab] Update gcc toolchain and flash tool of docker image #34621

Merged
merged 3 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion integrations/docker/images/base/chip-build/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
67 : [ESP32] Update esp-idf to v5.3
68 : [Bouffalo Lab] Update gcc toolchain and flash tool
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ ARG VERSION=1
FROM ghcr.io/project-chip/chip-build:${VERSION}
LABEL org.opencontainers.image.source https://github.com/project-chip/connectedhomeip

RUN apt update -y \
&& apt install vim -fy \
&& apt clean \
&& pip3 install --break-system-packages bflb-iot-tool==1.8.6 \
&& : # last line
RUN apt update

RUN apt install picocom curl -y
RUN apt install netcat-traditional -y

COPY setup.sh /tmp

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

Expand Down
69 changes: 45 additions & 24 deletions integrations/docker/images/stage-2/chip-build-bouffalolab/setup.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,33 +1,40 @@
#!/usr/bin/env bash

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

user=$(stat -c %U "$0")

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
echo "Please input path to install toolchain, or type Enter to install under $SDK_ROOT"
read TOOLCHAIN_SETUP_ROOT
if [[ ${TOOLCHAIN_SETUP_ROOT} == "" ]]; then
TOOLCHAIN_SETUP_ROOT=$SDK_ROOT
fi
echo "Toolchain will install under $TOOLCHAIN_SETUP_ROOT"
flash_tool_postfix=

flash_tool=BouffaloLabDevCube-v1.9.0
flash_tool_url=https://dev.bouffalolab.com/media/upload/download/$flash_tool.zip
thead_toolchain=gcc_t-head_v2.6.1
thead_toolchain_url=https://codeload.github.com/bouffalolab/toolchain_gcc_t-head_linux/zip/c4afe91cbd01bf7dce525e0d23b4219c8691e8f0
thead_toolchain_unzip=toolchain_gcc_t-head_linux-c4afe91cbd01bf7dce525e0d23b4219c8691e8f0

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"
"toolchain/riscv" "https://dev.bouffalolab.com/media/upload/download/toolchain_riscv_sifive_linux64.zip" Linux toolchain_riscv_sifive_linux
"toolchain/t-head-riscv" "$thead_toolchain_url" "$thead_toolchain" "$thead_toolchain_unzip"
"flashtool" "$flash_tool_url" "$flash_tool" ""
)
flash_tool_postfix=ubuntu
elif [[ "$OSTYPE" == "darwin"* ]]; then
toolchains_url=(
"riscv/Darwin" "https://dev.bouffalolab.com/media/upload/download/toolchain_riscv_sifive_macos.zip" "toolchain_riscv_sifive_macos"
"toolchain/riscv/Darwin" "https://dev.bouffalolab.com/media/upload/download/toolchain_riscv_sifive_macos.zip"
)
flash_tool_postfix=macos
else
echo "Not support for ""$OSTYPE"
fi
Expand All @@ -37,30 +44,44 @@ if [ ! -d "$TOOLCHAIN_SETUP_ROOT" ]; then
fi
rm -rf "$TOOLCHAIN_SETUP_ROOT"/*.zip

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

if [ -d "$TOOLCHAIN_SETUP_ROOT/$path/$out" ]; then
continue
fi
rm -rf "$TOOLCHAIN_SETUP_ROOT/$path"
mkdir -p "$TOOLCHAIN_SETUP_ROOT/$path"

wget -P "$TOOLCHAIN_SETUP_ROOT"/ "$url"
toolchain_zip=$(basename "$url")
toolchain_zip=$(find "$TOOLCHAIN_SETUP_ROOT" -maxdepth 1 -name *"$toolchain_zip"*)
toolchain_zip=$(basename "$toolchain_zip")
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"

unzip -q "$TOOLCHAIN_SETUP_ROOT/$toolchain_zip" -d "$TOOLCHAIN_SETUP_ROOT/$path/tmp"
mv "$TOOLCHAIN_SETUP_ROOT/$path/tmp/$unzip_name" "$TOOLCHAIN_SETUP_ROOT/$path/$out"

rm -rf "$TOOLCHAIN_SETUP_ROOT/$path"/tmp
rm -rf "$TOOLCHAIN_SETUP_ROOT/$toolchain_zip"

if [ -f "$TOOLCHAIN_SETUP_ROOT/$path"/chmod755.sh ]; then
cd "$TOOLCHAIN_SETUP_ROOT/$path"/
if [ -f "$TOOLCHAIN_SETUP_ROOT/$path"/"$out"/chmod755.sh ]; then
cd "$TOOLCHAIN_SETUP_ROOT/$path"/"$out"
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"
chmod +x "$TOOLCHAIN_SETUP_ROOT/flashtool/$flash_tool/BLDevCube-$flash_tool_postfix"
chmod +x "$TOOLCHAIN_SETUP_ROOT/flashtool/$flash_tool/bflb_iot_tool-$flash_tool_postfix"

if [[ "$user" == "root" ]]; then
chmod a+wr "$TOOLCHAIN_SETUP_ROOT/flashtool/$flash_tool" -R
else
chown "$user" "$TOOLCHAIN_SETUP_ROOT/flashtool/$flash_tool"/ -R
fi
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,6 @@ RUN set -x \
&& rm -rf /var/lib/apt/lists/ \
&& : # last line

# Required for the Bouffalolab platform
RUN set -x \
&& pip3 install --break-system-packages bflb-iot-tool==1.8.6 \
&& : # last line

ENV PATH $PATH:/usr/lib/kotlinc/bin
ENV AMEBA_PATH=/opt/ameba/ambd_sdk_with_chip_non_NDA
ENV ANDROID_HOME=/opt/android/sdk
Expand Down
Empty file modified scripts/flashing/bouffalolab_firmware_utils.py
100644 → 100755
Empty file.
Loading