- DB720Flasher: WPF .NET 9 GUI 플래셔 - 멀티모델 프로파일(flash.json + 빌트인 DB720/DB402S/DB400S/DB400Q/DB300eM) - 포트 자동감지(JTAG 우선, 유령 포트 자동 회피), esptool v5 동봉 - flash_app.ps1 / flash_full.ps1 / list_ports.ps1: 기존 PowerShell 키트 - profiles/: 모델별 flash.json 템플릿 - firmware/flash.json: DB720 모델 설정 (서명 실펌웨어 .bin 은 repo 제외) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
77 lines
4.5 KiB
PowerShell
77 lines
4.5 KiB
PowerShell
# =====================================================================
|
|
# DB720 (ESP32-P4) 전체 적재 — 경우 A: 부트로더가 비었을 때 (full flash)
|
|
# =====================================================================
|
|
# 언제 쓰나
|
|
# - flash가 통째로 지워졌거나(erase_flash 후) 부트로더(0x2000)가 비어 부팅이 안 될 때.
|
|
# - 서명 부트로더까지 다시 써서 보드를 처음부터 살린다(서명 5종 전부).
|
|
#
|
|
# ★★★ eFuse 경고 (비가역) ★★★
|
|
# 이 빌드는 secure_RELEASE(실 eFuse 전제) 서명본이다.
|
|
# - 이미 secure boot eFuse가 구워진 보드(.230 등) → 같은 서명 부트로더를 다시 쓰는 것이라 안전(복구).
|
|
# - eFuse가 아직 안 구워진 보드 → 이걸 full flash하면 첫 부팅에 eFuse가 "영구로" 구워진다(비가역 brick 위험).
|
|
# => eFuse 미굽힘 보드의 최초 프로비저닝은 secure_DEV(가상 eFuse) 빌드로 해야 한다. 여기선 쓰지 말 것.
|
|
#
|
|
# ★ 앱이 여러 개일 때 — firmware\ 안의 앱 .bin 을 -App 으로 지정한다(미지정+여러개면 목록 후 멈춤).
|
|
# ★ 적재 방식 — 영역을 "하나씩" 개별 esptool 호출로 쓴다(SDM 다중영역 한 번에 쓰면 중간 실패, 2026-06-22 실증).
|
|
#
|
|
# 연결: USB-JTAG(보드의 COM4 자리). COM 번호 바뀌면 .\list_ports.ps1 로 확인.
|
|
# =====================================================================
|
|
|
|
param(
|
|
[string]$Port = "COM4",
|
|
[string]$App = "" # 앱 bin 파일명 (firmware\ 안). 비우면 자동 선택
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
$fw = Join-Path $here "firmware"
|
|
|
|
$Python = "C:\Users\jyheo\.espressif\python_env\idf5.5_py3.13_env\Scripts\python.exe"
|
|
if (-not (Test-Path $Python)) { $Python = "python" }
|
|
|
|
$baud = "115200"
|
|
$common = @("--chip","esp32p4","-p",$Port,"-b",$baud,
|
|
"--before","default_reset","--after","no_reset","--connect-attempts","30","--no-stub")
|
|
|
|
# ---- 앱 선택 ------------------------------------------------------------
|
|
$support = @("bootloader.bin","partition-table.bin","ota_data_initial.bin","www_fs.bin")
|
|
$apps = @(Get-ChildItem (Join-Path $fw "*.bin") -ErrorAction SilentlyContinue | Where-Object { $support -notcontains $_.Name })
|
|
if ($App) {
|
|
$appPath = Join-Path $fw $App
|
|
if (-not (Test-Path $appPath)) { Write-Host "✗ 앱 없음: $appPath" -ForegroundColor Red; exit 1 }
|
|
} elseif ($apps.Count -eq 1) {
|
|
$appPath = $apps[0].FullName
|
|
} elseif ($apps.Count -eq 0) {
|
|
Write-Host "✗ firmware\ 에 앱 bin 이 없습니다." -ForegroundColor Red; exit 1
|
|
} else {
|
|
Write-Host "여러 앱이 있습니다 — -App 으로 하나를 지정하세요:" -ForegroundColor Yellow
|
|
$apps | ForEach-Object { Write-Host " $($_.Name)" }
|
|
Write-Host "예: .\flash_full.ps1 -Port $Port -App $($apps[0].Name)" -ForegroundColor Gray
|
|
exit 1
|
|
}
|
|
|
|
# ---- 영역별 개별 적재 함수 ----------------------------------------------
|
|
function Flash-Region([string]$off, [string]$file) {
|
|
Write-Host "[flash] $off $(Split-Path -Leaf $file)" -ForegroundColor Cyan
|
|
& $Python -m esptool @common write_flash --flash_mode dio --flash_size 16MB --flash_freq 80m $off $file
|
|
if ($LASTEXITCODE -ne 0) { Write-Host "✗ $off write 실패 (rc=$LASTEXITCODE)" -ForegroundColor Red; exit 1 }
|
|
}
|
|
|
|
Write-Host "============================================================" -ForegroundColor Yellow
|
|
Write-Host " DB720 FULL FLASH (경우 A — 부트로더 비었을 때)" -ForegroundColor Yellow
|
|
Write-Host " Port=$Port App=$(Split-Path -Leaf $appPath) Python=$Python" -ForegroundColor Yellow
|
|
Write-Host " ★ eFuse 미굽힘 보드면 첫 부팅에 영구 굽힘 — 위 경고 확인" -ForegroundColor Red
|
|
Write-Host "============================================================" -ForegroundColor Yellow
|
|
|
|
# 서명 5종 — 각 영역 개별 호출 (부트로더 0x2000 포함)
|
|
Flash-Region "0x2000" (Join-Path $fw "bootloader.bin")
|
|
Flash-Region "0x10000" (Join-Path $fw "partition-table.bin")
|
|
Flash-Region "0x11000" (Join-Path $fw "ota_data_initial.bin")
|
|
Flash-Region "0x20000" $appPath
|
|
Flash-Region "0x420000" (Join-Path $fw "www_fs.bin")
|
|
|
|
Write-Host "[reset] hard_reset (SDM 탈출)" -ForegroundColor Cyan
|
|
& $Python -c "from esptool.targets.esp32p4 import ESP32P4ROM; r=ESP32P4ROM('$Port'); r.connect('default_reset'); r.hard_reset(); print('hard_reset OK')"
|
|
|
|
Write-Host "✓ FULL FLASH 완료 — 부팅 확인은 COM2(디버그 콘솔)에서 ![0081!] 응답/배너로." -ForegroundColor Green
|