diff --git a/.github/workflows/examples-bouffalolab.yaml b/.github/workflows/examples-bouffalolab.yaml index 12b033b791f900..d6cd5c7cb84252 100644 --- a/.github/workflows/examples-bouffalolab.yaml +++ b/.github/workflows/examples-bouffalolab.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: ghcr.io/project-chip/chip-build-bouffalolab:54 + image: ghcr.io/project-chip/chip-build-bouffalolab:67 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/examples/lighting-app/bouffalolab/bl702l/with_pw_rpc.gni b/examples/lighting-app/bouffalolab/bl702l/with_pw_rpc.gni index 5d7ce27c99df3d..1f2c048b4fce70 100644 --- a/examples/lighting-app/bouffalolab/bl702l/with_pw_rpc.gni +++ b/examples/lighting-app/bouffalolab/bl702l/with_pw_rpc.gni @@ -21,5 +21,9 @@ import("${chip_root}/config/bouffalolab/common/lib/pw_rpc/pw_rpc.gni") import("${chip_root}/examples/platform/bouffalolab/bl702l/args.gni") chip_enable_pw_rpc = true -chip_build_pw_trace_lib = false -#pw_trace_BACKEND = "$dir_pw_trace_tokenized" + +# pigweed updated to a1bd248 makes compile conversion errors; +# it seems riscv gcc (version > 10) can fixes this issue. +# let's disable strict warnings for RPC enabled for now. +remove_default_configs = [ "$dir_pw_build:strict_warnings" ] +treat_warnings_as_errors = false diff --git a/integrations/docker/images/base/chip-build/version b/integrations/docker/images/base/chip-build/version index ba77442b28dc23..a55cf17dc15a1c 100644 --- a/integrations/docker/images/base/chip-build/version +++ b/integrations/docker/images/base/chip-build/version @@ -1 +1 @@ -66 : [Telink] Update Docker image (Zephyr update) +67 : [Bouffalo Lab] Update Docker image 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..4534c92c7ad190 --- a/integrations/docker/images/stage-2/chip-build-bouffalolab/setup.sh +++ b/integrations/docker/images/stage-2/chip-build-bouffalolab/setup.sh @@ -6,28 +6,36 @@ CURRENT_DIR=$( pwd ) -SDK_ROOT=/opt/bouffalolab_sdk -# Currently, only setup toolchain under $SDK_ROOT -TOOLCHAIN_SETUP_ROOT=$SDK_ROOT/toolchain +user=`stat -c %U $0` -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 +SDK_ROOT=/opt/bouffalolab_sdk + +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 +45,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" - rm -rf "$TOOLCHAIN_SETUP_ROOT/$toolchain_zip" - if [ -f "$TOOLCHAIN_SETUP_ROOT/$path"/chmod755.sh ]; then - cd "$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"/$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 index 402f0453936741..3a07e7f6427571 --- a/scripts/flashing/bouffalolab_firmware_utils.py +++ b/scripts/flashing/bouffalolab_firmware_utils.py @@ -20,6 +20,7 @@ import re import shutil import sys +import subprocess import coloredlogs import firmware_utils @@ -55,7 +56,7 @@ } }, 'xtal': { - 'help': 'XTAL for board', + 'help': 'XTAL configuration for bl iot sdk', 'default': None, 'argparse': { 'metavar': 'XTAL', @@ -131,7 +132,8 @@ def get_boot_image(self, config_path, boot2_image): for root, dirs, files in os.walk(config_path, topdown=False): for name in files: - logging.info("get_boot_image {} {}".format(root, boot2_image)) + if "boot2" not in name.lower(): + continue if boot2_image: return os.path.join(root, boot2_image) else: @@ -166,34 +168,29 @@ def actions(self): """Perform actions on the device according to self.option.""" self.log(3, 'Options:', self.option) - try: - import bflb_iot_tool - import bflb_iot_tool.__main__ - - version_target_str = "1.8.6" - version_target = version_target_str.split('.') - version_target = "".join(["%03d" % int(var) for var in version_target]) - - version_current_str = importlib.metadata.version("bflb_iot_tool") - version_current = version_current_str.split('.') - version_current = "".join(["%03d" % int(var) for var in version_current]) - - if version_current < version_target: - raise Exception("bflb_iot_tool {} version is less than {}".format(version_current_str, version_target_str)) + tool_path = os.environ.get('BOUFFALOLAB_SDK_ROOT') + "/flashtool/BouffaloLabDevCube-v1.9.0" + bflb_tools_dict = { + "linux": {"flash_tool": "bflb_iot_tool-ubuntu"}, + "win32": {"flash_tool": "bflb_iot_tool.exe"}, + "darwin": {"flash_tool": "bflb_iot_tool-macos"}, + } + try: + flashtool_exe = tool_path + "/" + bflb_tools_dict[sys.platform]["flash_tool"] except Exception as e: + raise Exception("Do NOT support {} operating system to program firmware.".format(sys.platform)) - logging.error('Please try the following command to setup or upgrade Bouffalo Lab environment:') - logging.error('source scripts/activate.sh -p bouffalolab') - logging.error('Or') - logging.error('source scripts/bootstrap.sh -p bouffalolab') - - logging.error('If upgrade bflb_iot_tool failed, try pip uninstall bflb_iot_tool first.') + if not os.path.exists(flashtool_exe): + logging.fatal('*' * 80) + logging.error('Flashtool is not installed, or environment variable BOUFFALOLAB_SDK_ROOT is not exported.') + logging.fatal('\tPlease make sure Bouffalo Lab SDK installs as below:') + logging.fatal('\t\t./integrations/docker/images/stage-2/chip-build-bouffalolab/setup.sh') + logging.fatal('\tPlease make sure BOUFFALOLAB_SDK_ROOT exports before building as below:') + logging.fatal('\t\texport BOUFFALOLAB_SDK_ROOT="your install path"') + logging.fatal('*' * 80) raise Exception(e) - tool_path = os.path.dirname(bflb_iot_tool.__file__) - options_keys = BOUFFALO_OPTIONS["configuration"].keys() arguments = [__file__] work_dir = None @@ -218,6 +215,7 @@ def actions(self): boot2_image = None command_args = {} + for (key, value) in dict(vars(self.option)).items(): if self.option.build and value: @@ -246,7 +244,7 @@ def actions(self): else: arg = ("--{}={}".format(key, value)).strip() - arguments.append(arg) + arguments = arguments + arg.split('=') if key == "chipname": chip_name = value @@ -303,7 +301,7 @@ def actions(self): arguments.append(boot2_image) os.chdir(work_dir) - arguments[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', arguments[0]) + arguments[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', flashtool_exe) sys.argv = arguments if ota_output_folder: @@ -311,8 +309,12 @@ def actions(self): shutil.rmtree(ota_output_folder) os.mkdir(ota_output_folder) - logging.info("Arguments {}".format(arguments)) - bflb_iot_tool.__main__.run_main() + logging.info("Arguments {}".format(" ".join(arguments))) + process = subprocess.Popen(arguments, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + while process.poll() is None: + line = process.stdout.readline().decode('utf-8').rstrip() + if line: + logging.info(line) if ota_output_folder: ota_images = os.listdir(ota_output_folder)