186 lines
7.2 KiB
Python
186 lines
7.2 KiB
Python
|
|
#!/usr/bin/env python3
|
|||
|
|
# -*- coding: utf-8 -*-
|
|||
|
|
"""Assemble portable K1 artist tone-update kit + zip for handoff."""
|
|||
|
|
from __future__ import annotations
|
|||
|
|
|
|||
|
|
import shutil
|
|||
|
|
import zipfile
|
|||
|
|
from datetime import datetime
|
|||
|
|
from pathlib import Path
|
|||
|
|
|
|||
|
|
REPO = Path(__file__).resolve().parents[3] # 一诺国际吉他 (tools->proj->Code->repo)
|
|||
|
|
# __file__ = .../YNGJ.../tools/build_artist_kit.py → parents[0]=tools [1]=proj [2]=Code [3]=repo
|
|||
|
|
PROJ = Path(__file__).resolve().parents[1]
|
|||
|
|
TOOLS = Path(__file__).resolve().parent
|
|||
|
|
|
|||
|
|
|
|||
|
|
def main() -> None:
|
|||
|
|
# Fix REPO: tools -> project -> Code -> 一诺国际吉他
|
|||
|
|
repo = TOOLS.parents[1] # Code's parent? TOOLS.parent=proj, TOOLS.parents[1]=Code, [2]=repo
|
|||
|
|
repo = TOOLS.parents[2]
|
|||
|
|
proj = TOOLS.parent
|
|||
|
|
day = datetime.now().strftime("%Y%m%d")
|
|||
|
|
kit_name = f"K1_音师音色更新工具_{day}"
|
|||
|
|
out_root = repo / "tools" / "out"
|
|||
|
|
out_root.mkdir(parents=True, exist_ok=True)
|
|||
|
|
kit = out_root / kit_name
|
|||
|
|
if kit.exists():
|
|||
|
|
shutil.rmtree(kit)
|
|||
|
|
kit.mkdir(parents=True)
|
|||
|
|
|
|||
|
|
baseline = kit / "基线"
|
|||
|
|
drop = kit / "投放"
|
|||
|
|
outdir = kit / "输出"
|
|||
|
|
baseline.mkdir()
|
|||
|
|
drop.mkdir()
|
|||
|
|
outdir.mkdir()
|
|||
|
|
|
|||
|
|
shutil.copy2(TOOLS / "tone_artist_pack.py", kit / "tone_artist_pack.py")
|
|||
|
|
|
|||
|
|
bat = """@echo off
|
|||
|
|
chcp 65001 >nul
|
|||
|
|
setlocal
|
|||
|
|
cd /d "%~dp0"
|
|||
|
|
|
|||
|
|
echo.
|
|||
|
|
echo ========================================
|
|||
|
|
echo K1 音师音色更新工具 (USB / SoundWalkerIAP)
|
|||
|
|
echo 依赖: 仅 Python 3,无需 pip / 无需 J-Link
|
|||
|
|
echo ========================================
|
|||
|
|
echo.
|
|||
|
|
|
|||
|
|
where python >nul 2>&1
|
|||
|
|
if errorlevel 1 (
|
|||
|
|
echo [错误] 未找到 python。请安装 Python 3,安装时勾选 Add python.exe to PATH。
|
|||
|
|
echo 下载: https://www.python.org/downloads/
|
|||
|
|
pause
|
|||
|
|
exit /b 1
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
echo 默认读取「投放」目录中的 1.bin 2.bin 3.bin
|
|||
|
|
echo 也可传参,例如: 音师更新音色.bat --bin1 .\\1.bin --bin2 .\\2.bin --bin3 .\\3.bin
|
|||
|
|
echo.
|
|||
|
|
|
|||
|
|
python "%~dp0tone_artist_pack.py" --open %*
|
|||
|
|
set ERR=%ERRORLEVEL%
|
|||
|
|
echo.
|
|||
|
|
if not "%ERR%"=="0" (
|
|||
|
|
echo 打包失败。查看: python "%~dp0tone_artist_pack.py" -h
|
|||
|
|
pause
|
|||
|
|
exit /b %ERR%
|
|||
|
|
)
|
|||
|
|
echo 完成。请打开「输出\\音师音色包_日期」按 请这样刷.txt 用 SoundWalkerIAP 刷机。
|
|||
|
|
pause
|
|||
|
|
exit /b 0
|
|||
|
|
"""
|
|||
|
|
(kit / "音师更新音色.bat").write_text(bat, encoding="utf-8", newline="\r\n")
|
|||
|
|
|
|||
|
|
ziliao = next(
|
|||
|
|
p
|
|||
|
|
for p in repo.iterdir()
|
|||
|
|
if p.is_dir() and (p / "logo.bin").is_file() and (p / "Charg.bin").is_file()
|
|||
|
|
)
|
|||
|
|
shutil.copy2(ziliao / "logo.bin", baseline / "logo.bin")
|
|||
|
|
shutil.copy2(ziliao / "Charg.bin", baseline / "Charg.bin")
|
|||
|
|
shutil.copy2(proj / "tools" / "out" / "ui0902_res.bin", baseline / "ui0902_res.bin")
|
|||
|
|
|
|||
|
|
iap = repo / "升级" / "MCU主控升级"
|
|||
|
|
shutil.copy2(iap / "SoundWalkerIAP.exe", kit / "SoundWalkerIAP.exe")
|
|||
|
|
doc = iap / "升级步骤.docx"
|
|||
|
|
if doc.is_file():
|
|||
|
|
shutil.copy2(doc, kit / "升级步骤.docx")
|
|||
|
|
|
|||
|
|
src0909 = repo / "Doc" / "音色文件" / "0909"
|
|||
|
|
for n in ("1.bin", "2.bin", "3.bin"):
|
|||
|
|
shutil.copy2(src0909 / n, drop / n)
|
|||
|
|
(drop / "说明.txt").write_text(
|
|||
|
|
"请把新的 1.bin / 2.bin / 3.bin 放到本目录(覆盖即可),然后双击上一级「音师更新音色.bat」。\n"
|
|||
|
|
"\n"
|
|||
|
|
"也可用命令指定任意路径:\n"
|
|||
|
|
" 音师更新音色.bat --bin1 路径\\1.bin --bin2 路径\\2.bin --bin3 路径\\3.bin\n",
|
|||
|
|
encoding="utf-8",
|
|||
|
|
newline="\n",
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
(kit / "使用说明.txt").write_text(
|
|||
|
|
"\n".join(
|
|||
|
|
[
|
|||
|
|
"K1 音师音色更新工具 — 使用说明",
|
|||
|
|
"================================",
|
|||
|
|
"",
|
|||
|
|
"【需要准备】",
|
|||
|
|
" 1. 安装 Python 3(https://www.python.org/downloads/ ,勾选 Add to PATH)",
|
|||
|
|
" 只需标准库,不用 pip 装任何包",
|
|||
|
|
" 2. 本工具包(解压到任意目录,如桌面)",
|
|||
|
|
" 3. 吉他 + USB 线(SoundWalkerIAP 升级,不需要 J-Link)",
|
|||
|
|
"",
|
|||
|
|
"【目录说明】",
|
|||
|
|
" 投放\\ ← 把新的 1.bin 2.bin 3.bin 放这里",
|
|||
|
|
" 基线\\ ← logo / Charg / UI 底图(勿改)",
|
|||
|
|
" 输出\\ ← 打包结果(自动生成)",
|
|||
|
|
" 音师更新音色.bat",
|
|||
|
|
" tone_artist_pack.py",
|
|||
|
|
" SoundWalkerIAP.exe",
|
|||
|
|
" 升级步骤.docx",
|
|||
|
|
" 使用说明.txt ← 本文件",
|
|||
|
|
"",
|
|||
|
|
"【日常步骤】",
|
|||
|
|
" 1. 用新文件覆盖 投放\\1.bin、2.bin、3.bin",
|
|||
|
|
" 2. 双击「音师更新音色.bat」",
|
|||
|
|
" 3. 在弹出的「输出\\音师音色包_日期」里:",
|
|||
|
|
" - 打开 SoundWalkerIAP.exe",
|
|||
|
|
" - 吉他进入 USB 升级模式(见 升级步骤.docx)",
|
|||
|
|
" - 擦除外部 Flash",
|
|||
|
|
" - 把 extflash_ALL_artist_*.res 烧到地址 0x00000000",
|
|||
|
|
" 4. 退出升级模式,重启试听",
|
|||
|
|
"",
|
|||
|
|
"【命令参数示例】",
|
|||
|
|
" 音师更新音色.bat",
|
|||
|
|
" 音师更新音色.bat --drop 投放",
|
|||
|
|
" 音师更新音色.bat --bin1 .\\投放\\1.bin --bin2 .\\投放\\2.bin --bin3 .\\投放\\3.bin",
|
|||
|
|
" 音师更新音色.bat --bin1 D:\\我的音色\\1.bin --bin2 D:\\我的音色\\2.bin --bin3 D:\\我的音色\\3.bin",
|
|||
|
|
" python tone_artist_pack.py -h",
|
|||
|
|
"",
|
|||
|
|
"【生成的包格式】(与开发正式发布的 ALL.res 相同)",
|
|||
|
|
" 0x00000000 logo.bin",
|
|||
|
|
" 0x0000CB70 Charg.bin",
|
|||
|
|
" 0x0001B8F0 1.bin(节奏)",
|
|||
|
|
" 0x0009D07D 2.bin(本地曲,≤41KB)",
|
|||
|
|
" 0x000A71AC 3.bin(万能)",
|
|||
|
|
" 0x00100000 UI 界面图",
|
|||
|
|
"",
|
|||
|
|
"【注意】",
|
|||
|
|
" - 必须刷 ALL.res,不要只刷单独的 1/2/3.bin(否则模式选择花屏)",
|
|||
|
|
" - 一般只需刷外部 Flash,不用重刷 MCU 固件",
|
|||
|
|
" - 若增删本地曲目或改曲名,需联系开发同步固件后再测",
|
|||
|
|
" - 「投放」里已带示例 1/2/3.bin,可先双击 bat 试跑流程",
|
|||
|
|
"",
|
|||
|
|
"【出问题】",
|
|||
|
|
" - 提示找不到 python → 安装 Python 3 并勾选 PATH,重开窗口",
|
|||
|
|
" - DAB/大小校验失败 → 检查 bin 是否完整,2.bin 是否超过 41KB",
|
|||
|
|
" - 其它问题把黑色窗口全文截图发给开发",
|
|||
|
|
"",
|
|||
|
|
]
|
|||
|
|
),
|
|||
|
|
encoding="utf-8",
|
|||
|
|
newline="\n",
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
zip_path = out_root / f"{kit_name}.zip"
|
|||
|
|
if zip_path.exists():
|
|||
|
|
zip_path.unlink()
|
|||
|
|
with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as zf:
|
|||
|
|
for f in kit.rglob("*"):
|
|||
|
|
if f.is_file():
|
|||
|
|
zf.write(f, f.relative_to(out_root).as_posix())
|
|||
|
|
|
|||
|
|
print(f"KIT {kit}")
|
|||
|
|
print(f"ZIP {zip_path}")
|
|||
|
|
print(f"ZIP size = {zip_path.stat().st_size} bytes")
|
|||
|
|
for p in sorted(kit.iterdir()):
|
|||
|
|
print(f" {p.name}")
|
|||
|
|
|
|||
|
|
|
|||
|
|
if __name__ == "__main__":
|
|||
|
|
main()
|