From 545b034328f48b1d15cddac851ea6e0753ac4efa Mon Sep 17 00:00:00 2001 From: wyhong <30567533+wy-hh@users.noreply.github.com> Date: Tue, 6 Aug 2024 21:09:43 +0800 Subject: [PATCH] [Bouffalo Lab] Update gcc toolchain and flash tool of docker image (#34621) * [Bouffalo Lab] Update toolchain and docker image * fix restyled * only contain changes on docker image --- .../docker/images/base/chip-build/version | 2 +- .../stage-2/chip-build-bouffalolab/Dockerfile | 11 ++- .../stage-2/chip-build-bouffalolab/setup.sh | 69 ++++++++++++------- .../vscode/chip-build-vscode/Dockerfile | 5 -- .../flashing/bouffalolab_firmware_utils.py | 0 5 files changed, 51 insertions(+), 36 deletions(-) mode change 100644 => 100755 integrations/docker/images/stage-2/chip-build-bouffalolab/setup.sh mode change 100644 => 100755 scripts/flashing/bouffalolab_firmware_utils.py diff --git a/integrations/docker/images/base/chip-build/version b/integrations/docker/images/base/chip-build/version index 9f538399a5cf06..c797fa2a19186b 100644 --- a/integrations/docker/images/base/chip-build/version +++ b/integrations/docker/images/base/chip-build/version @@ -1 +1 @@ -67 : [ESP32] Update esp-idf to v5.3 +68 : [Bouffalo Lab] Update gcc toolchain and flash tool diff --git a/integrations/docker/images/stage-2/chip-build-bouffalolab/Dockerfile b/integrations/docker/images/stage-2/chip-build-bouffalolab/Dockerfile index ad099fc48b6ef3..be286425ae905a 100644 --- a/integrations/docker/images/stage-2/chip-build-bouffalolab/Dockerfile +++ b/integrations/docker/images/stage-2/chip-build-bouffalolab/Dockerfile @@ -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 diff --git a/integrations/docker/images/stage-2/chip-build-bouffalolab/setup.sh b/integrations/docker/images/stage-2/chip-build-bouffalolab/setup.sh old mode 100644 new mode 100755 index 44e353432ccab8..1052d6c6d6774a --- a/integrations/docker/images/stage-2/chip-build-bouffalolab/setup.sh +++ b/integrations/docker/images/stage-2/chip-build-bouffalolab/setup.sh @@ -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 @@ -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 diff --git a/integrations/docker/images/vscode/chip-build-vscode/Dockerfile b/integrations/docker/images/vscode/chip-build-vscode/Dockerfile index df6018847acb59..6bde4b8cb8431f 100644 --- a/integrations/docker/images/vscode/chip-build-vscode/Dockerfile +++ b/integrations/docker/images/vscode/chip-build-vscode/Dockerfile @@ -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 diff --git a/scripts/flashing/bouffalolab_firmware_utils.py b/scripts/flashing/bouffalolab_firmware_utils.py old mode 100644 new mode 100755