feat: Support choosing different config.json (#848)

This commit is contained in:
virgil
2025-06-26 02:55:45 +08:00
committed by GitHub
parent c17bd15baa
commit f1277934d1
4 changed files with 98 additions and 15 deletions

View File

@@ -1,24 +1,30 @@
# 编译配置命令 # 编译命令
**配置编译目标为 ESP32S3** ## 一键编译
```bash
python scripts/release.py sensecap-watcher
```
## 手动配置编译
```bash ```bash
idf.py set-target esp32s3 idf.py set-target esp32s3
``` ```
**打开 menuconfig** **配置**
```bash ```bash
idf.py menuconfig idf.py menuconfig
``` ```
**选择板子** 选择板子
``` ```
Xiaozhi Assistant -> Board Type -> SenseCAP Watcher Xiaozhi Assistant -> Board Type -> SenseCAP Watcher
``` ```
watcher 中一些额外的配置项如下需要menuconfig 选择 或者拷贝放入sdkconfig.defaults中. watcher 中一些额外的配置项如下,需要menuconfig 选择.
``` ```
CONFIG_BOARD_TYPE_SENSECAP_WATCHER=y CONFIG_BOARD_TYPE_SENSECAP_WATCHER=y
@@ -29,12 +35,13 @@ CONFIG_ESPTOOLPY_FLASH_MODE_AUTO_DETECT=n
CONFIG_IDF_EXPERIMENTAL_FEATURES=y CONFIG_IDF_EXPERIMENTAL_FEATURES=y
``` ```
**编译烧入:** ## 编译烧入
```bash ```bash
idf.py build flash idf.py -DBOARD_NAME=sensecap-watcher build flash
``` ```
注意: 请特别小心处理闪存固件分区地址,以避免错误擦除 SenseCAP Watcher 的自身设备信息EUI 等),否则设备可能无法正确连接到 SenseCraft 服务器!在刷写固件之前,请务必记录设备的相关必要信息,以确保有恢复的方法!
注意: 如果当前设备出货之前是SenseCAP 固件(非小智版本),请特别小心处理闪存固件分区地址,以避免错误擦除 SenseCAP Watcher 的自身设备信息EUI 等否则设备即使恢复成SenseCAP固件也无法正确连接到 SenseCraft 服务器!所以在刷写固件之前,请务必记录设备的相关必要信息,以确保有恢复的方法!
您可以使用以下命令备份生产信息 您可以使用以下命令备份生产信息

View File

@@ -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
```

View File

@@ -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"
]
}
]
}

View File

@@ -2,6 +2,7 @@ import sys
import os import os
import json import json
import zipfile import zipfile
import argparse
# 切换到项目根目录 # 切换到项目根目录
os.chdir(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) 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 board_configs[config_name] = board_type
return board_configs return board_configs
def release(board_type, board_config): def release(board_type, board_config, config_filename="config.json"):
config_path = f"main/boards/{board_type}/config.json" config_path = f"main/boards/{board_type}/{config_filename}"
if not os.path.exists(config_path): if not os.path.exists(config_path):
print(f"跳过 {board_type} 因为 config.json 不存在") print(f"跳过 {board_type} 因为 {config_filename} 不存在")
return return
# Print Project Version # Print Project Version
@@ -119,15 +120,20 @@ def release(board_type, board_config):
print("-" * 80) print("-" * 80)
if __name__ == "__main__": 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() board_configs = get_all_board_types()
found = False found = False
for board_config, board_type in board_configs.items(): for board_config, board_type in board_configs.items():
if sys.argv[1] == 'all' or board_type == sys.argv[1]: if args.board == 'all' or board_type == args.board:
release(board_type, board_config) release(board_type, board_config, config_filename=args.config)
found = True found = True
if not found: if not found:
print(f"未找到板子类型: {sys.argv[1]}") print(f"未找到板子类型: {args.board}")
print("可用的板子类型:") print("可用的板子类型:")
for board_type in board_configs.values(): for board_type in board_configs.values():
print(f" {board_type}") print(f" {board_type}")