From f1277934d1599458a918d9bade674c8e17211cf0 Mon Sep 17 00:00:00 2001 From: virgil Date: Thu, 26 Jun 2025 02:55:45 +0800 Subject: [PATCH] feat: Support choosing different config.json (#848) --- main/boards/sensecap-watcher/README.md | 23 +++++---- main/boards/sensecap-watcher/README_en.md | 53 +++++++++++++++++++++ main/boards/sensecap-watcher/config_en.json | 17 +++++++ scripts/release.py | 20 +++++--- 4 files changed, 98 insertions(+), 15 deletions(-) create mode 100644 main/boards/sensecap-watcher/README_en.md create mode 100644 main/boards/sensecap-watcher/config_en.json diff --git a/main/boards/sensecap-watcher/README.md b/main/boards/sensecap-watcher/README.md index 7693bc24..801b55e4 100644 --- a/main/boards/sensecap-watcher/README.md +++ b/main/boards/sensecap-watcher/README.md @@ -1,24 +1,30 @@ -# 编译配置命令 +# 编译命令 -**配置编译目标为 ESP32S3:** +## 一键编译 + +```bash +python scripts/release.py sensecap-watcher +``` + +## 手动配置编译 ```bash idf.py set-target esp32s3 ``` -**打开 menuconfig:** +**配置** ```bash idf.py menuconfig ``` -**选择板子:** +选择板子 ``` Xiaozhi Assistant -> Board Type -> SenseCAP Watcher ``` -watcher 中一些额外的配置项如下,需要menuconfig 选择, 或者拷贝放入sdkconfig.defaults中. +watcher 中一些额外的配置项如下,需要在menuconfig 中选择. ``` CONFIG_BOARD_TYPE_SENSECAP_WATCHER=y @@ -29,12 +35,13 @@ CONFIG_ESPTOOLPY_FLASH_MODE_AUTO_DETECT=n CONFIG_IDF_EXPERIMENTAL_FEATURES=y ``` -**编译烧入:** +## 编译烧入 ```bash -idf.py build flash +idf.py -DBOARD_NAME=sensecap-watcher build flash ``` -注意: 请特别小心处理闪存固件分区地址,以避免错误擦除 SenseCAP Watcher 的自身设备信息(EUI 等),否则设备可能无法正确连接到 SenseCraft 服务器!在刷写固件之前,请务必记录设备的相关必要信息,以确保有恢复的方法! + +注意: 如果当前设备出货之前是SenseCAP 固件(非小智版本),请特别小心处理闪存固件分区地址,以避免错误擦除 SenseCAP Watcher 的自身设备信息(EUI 等),否则设备即使恢复成SenseCAP固件也无法正确连接到 SenseCraft 服务器!所以在刷写固件之前,请务必记录设备的相关必要信息,以确保有恢复的方法! 您可以使用以下命令备份生产信息 diff --git a/main/boards/sensecap-watcher/README_en.md b/main/boards/sensecap-watcher/README_en.md new file mode 100644 index 00000000..4bc5dbaa --- /dev/null +++ b/main/boards/sensecap-watcher/README_en.md @@ -0,0 +1,53 @@ +# Build Instructions + +## One-click Build + +```bash +python scripts/release.py sensecap-watcher -c config_en.json +``` + +## Manual Configuration and Build + +```bash +idf.py set-target esp32s3 +``` + +**Configuration** + +```bash +idf.py menuconfig +``` + +Select the board: + +``` +Xiaozhi Assistant -> Board Type -> SenseCAP Watcher +``` + +There are some additional configuration options for the watcher. Please select them in menuconfig: + +``` +CONFIG_BOARD_TYPE_SENSECAP_WATCHER=y +CONFIG_ESPTOOLPY_FLASHSIZE_32MB=y +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions/v1/32m.csv" +CONFIG_BOOTLOADER_CACHE_32BIT_ADDR_QUAD_FLASH=y +CONFIG_ESPTOOLPY_FLASH_MODE_AUTO_DETECT=n +CONFIG_IDF_EXPERIMENTAL_FEATURES=y +CONFIG_LANGUAGE_EN_US=y +CONFIG_SR_WN_WN9_JARVIS_TTS=y +``` + +## Build and Flash + +```bash +idf.py -DBOARD_NAME=sensecap-watcher-en build flash +``` + +Note: If your device was previously shipped with the SenseCAP firmware (not the Xiaozhi version), please be very careful with the flash partition addresses to avoid accidentally erasing the device information (such as EUI) of the SenseCAP Watcher. Otherwise, even if you restore the SenseCAP firmware, the device may not be able to connect to the SenseCraft server correctly! Therefore, before flashing the firmware, be sure to record the necessary device information to ensure you have a way to recover it! + +You can use the following command to back up the factory information: + +```bash +# Firstly backup the factory information partition which contains the credentials for connecting the SenseCraft server +esptool.py --chip esp32s3 --baud 2000000 --before default_reset --after hard_reset --no-stub read_flash 0x9000 204800 nvsfactory.bin +``` diff --git a/main/boards/sensecap-watcher/config_en.json b/main/boards/sensecap-watcher/config_en.json new file mode 100644 index 00000000..429ac039 --- /dev/null +++ b/main/boards/sensecap-watcher/config_en.json @@ -0,0 +1,17 @@ +{ + "target": "esp32s3", + "builds": [ + { + "name": "sensecap-watcher-en", + "sdkconfig_append": [ + "CONFIG_ESPTOOLPY_FLASHSIZE_32MB=y", + "CONFIG_PARTITION_TABLE_CUSTOM_FILENAME=\"partitions/v1/32m.csv\"", + "CONFIG_BOOTLOADER_CACHE_32BIT_ADDR_QUAD_FLASH=y", + "CONFIG_ESPTOOLPY_FLASH_MODE_AUTO_DETECT=n", + "CONFIG_IDF_EXPERIMENTAL_FEATURES=y", + "CONFIG_LANGUAGE_EN_US=y", + "CONFIG_SR_WN_WN9_JARVIS_TTS=y" + ] + } + ] +} \ No newline at end of file diff --git a/scripts/release.py b/scripts/release.py index bfa88d53..beae82d3 100755 --- a/scripts/release.py +++ b/scripts/release.py @@ -2,6 +2,7 @@ import sys import os import json import zipfile +import argparse # 切换到项目根目录 os.chdir(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) @@ -64,10 +65,10 @@ def get_all_board_types(): board_configs[config_name] = board_type return board_configs -def release(board_type, board_config): - config_path = f"main/boards/{board_type}/config.json" +def release(board_type, board_config, config_filename="config.json"): + config_path = f"main/boards/{board_type}/{config_filename}" if not os.path.exists(config_path): - print(f"跳过 {board_type} 因为 config.json 不存在") + print(f"跳过 {board_type} 因为 {config_filename} 不存在") return # Print Project Version @@ -119,15 +120,20 @@ def release(board_type, board_config): print("-" * 80) if __name__ == "__main__": - if len(sys.argv) > 1: + parser = argparse.ArgumentParser() + parser.add_argument("board", nargs="?", default=None, help="板子类型或 all") + parser.add_argument("-c", "--config", default="config.json", help="指定 config 文件名,默认 config.json") + args = parser.parse_args() + + if args.board: board_configs = get_all_board_types() found = False for board_config, board_type in board_configs.items(): - if sys.argv[1] == 'all' or board_type == sys.argv[1]: - release(board_type, board_config) + if args.board == 'all' or board_type == args.board: + release(board_type, board_config, config_filename=args.config) found = True if not found: - print(f"未找到板子类型: {sys.argv[1]}") + print(f"未找到板子类型: {args.board}") print("可用的板子类型:") for board_type in board_configs.values(): print(f" {board_type}")