Commit 8fcc173a authored by aohui.li's avatar aohui.li 😋

V0.1

parents
build/
dist/
\ No newline at end of file
File added
'''
@ 功能描述:该脚本用于烧录WIT_HW30.bin文件到ESP32-C3开发板的USER_DATA块中,并检查烧录是否成功。
@Ref: https://docs.espressif.com/projects/esptool/en/latest/esp32/espefuse/scripting.html#espefuse-scripting
@Author: WIT
@Date: 2025年8月5日15:02:44
'''
from espefuse import init_commands
import json
import sys
import os
import time
def get_script_dir():
if getattr(sys, 'frozen', False):
local_dir = os.path.dirname(sys.executable)
print("frozen:", local_dir)
return local_dir
else:
print("当前路径:", os.path.dirname(os.path.abspath(__file__)))
return os.path.dirname(os.path.abspath(__file__)) # 开发环境
try:
script_dir = get_script_dir()
path = script_dir
print(f"====>path: {path}")
json_file = os.path.join(path, "config.json")
BIN = json.load(open(json_file))["bin"]
bin_file = os.path.join(path, BIN)
PORT = json.load(open(json_file))["port"]
EXPECTED_DATA = json.load(open(json_file))["expected_data"]
if PORT is None:
raise ValueError("请在config.json中配置端口")
# Connect to chip and enable batch mode
with init_commands(port=PORT, batch_mode=True) as espefuse:
# Queue multiple eFuse operations
with open(bin_file, "rb") as f:
espefuse.burn_block_data(["BLOCK_USR_DATA"], [f], offset=0)
# Execute all queued eFuse operations
espefuse.burn_all()
# Check that all eFuses are set properly
read_user_efuse = espefuse.efuses["BLOCK_USR_DATA"].get()
print("Data type:", type(read_user_efuse))
print("Read data:", read_user_efuse)
if read_user_efuse == EXPECTED_DATA:
print("\n烧录成功,即将关闭...")
time.sleep(5)
else:
print("烧录失败")
print(f"期望数据: {EXPECTED_DATA}")
print(f"实际数据: {read_user_efuse}")
input("程序检测到烧录失败,按回车键继续...")
except Exception as e:
print(f"程序执行出现异常: {e}")
import traceback
traceback.print_exc()
input("程序出现异常,按回车键退出...")
# -*- mode: python ; coding: utf-8 -*-
# 添加espefuse模块路径
import os
import espefuse
espefuse_path = os.path.dirname(espefuse.__file__)
efuse_defs_path = os.path.join(espefuse_path, 'efuse_defs')
data_files = [
(efuse_defs_path, 'espefuse/efuse_defs'),
]
a = Analysis(
['auto.py'],
pathex=[],
binaries=[],
datas=data_files, # 添加数据文件
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name='wt_efuse',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
\ No newline at end of file
{
"port": "COM111",
"bin": "WIT_HW30.bin",
"expected_data": "48 57 33 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
}
\ No newline at end of file
This diff is collapsed.
# esptool
A Python-based, open-source, platform-independent serial utility for flashing, provisioning, and interacting with Espressif SoCs.
[![Test esptool](https://github.com/espressif/esptool/actions/workflows/test_esptool.yml/badge.svg?branch=master)](https://github.com/espressif/esptool/actions/workflows/test_esptool.yml) [![Build esptool](https://github.com/espressif/esptool/actions/workflows/build_esptool.yml/badge.svg?branch=master)](https://github.com/espressif/esptool/actions/workflows/build_esptool.yml)
## Documentation
Visit the [documentation](https://docs.espressif.com/projects/esptool/) or run `esptool -h`.
## Contribute
If you're interested in contributing to esptool, please check the [contributions guide](https://docs.espressif.com/projects/esptool/en/latest/contributing.html).
## About
esptool was initially created by Fredrik Ahlberg (@[themadinventor](https://github.com/themadinventor/)), and later maintained by Angus Gratton (@[projectgus](https://github.com/projectgus/)). It is now supported by Espressif Systems. It has also received improvements from many members of the community.
## License
This document and the attached source code are released as Free Software under GNU General Public License Version 2 or later. See the accompanying [LICENSE file](https://github.com/espressif/esptool/blob/master/LICENSE) for a copy.
File added
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment