纳入固件源码、屏幕组件、nand_xfer 工具和文档。忽略本机构建产物、sdkconfig,以及含本机路径的依赖锁。 Co-authored-by: Cursor <cursoragent@cursor.com>
39 lines
2.5 KiB
PowerShell
39 lines
2.5 KiB
PowerShell
$ErrorActionPreference = 'Stop'
|
|
$project = $PSScriptRoot
|
|
$env:IDF_PATH = if ($env:IDF_PATH) { $env:IDF_PATH } else { 'E:\Espressif\frameworks\esp-idf-v5.5.4' }
|
|
$env:IDF_TOOLS_PATH = if ($env:IDF_TOOLS_PATH) { $env:IDF_TOOLS_PATH } else { 'E:\Espressif' }
|
|
$env:IDF_PYTHON_ENV_PATH = if ($env:IDF_PYTHON_ENV_PATH) { $env:IDF_PYTHON_ENV_PATH } else { 'E:\Espressif\python_env\idf5.5_py3.11_env' }
|
|
$env:IDF_TARGET = 'esp32p4'
|
|
$env:PYTHON = Join-Path $env:IDF_PYTHON_ENV_PATH 'Scripts\python.exe'
|
|
$env:IDF_PYTHON = $env:PYTHON
|
|
$ninja = Get-ChildItem (Join-Path $env:IDF_TOOLS_PATH 'tools\ninja') -Directory | Sort-Object Name -Descending | Select-Object -First 1
|
|
$cmake = Get-ChildItem (Join-Path $env:IDF_TOOLS_PATH 'tools\cmake') -Directory | Sort-Object Name -Descending | Select-Object -First 1
|
|
$riscv = Get-ChildItem (Join-Path $env:IDF_TOOLS_PATH 'tools\riscv32-esp-elf') -Directory | Sort-Object Name -Descending | Select-Object -First 1
|
|
$toolDirs = @($ninja.FullName, (Join-Path $cmake.FullName 'bin'), (Join-Path $riscv.FullName 'riscv32-esp-elf\bin'))
|
|
if (@($toolDirs | Where-Object { -not (Test-Path $_) }).Count) { throw 'ESP-IDF build tools not installed.' }
|
|
$env:PATH = ($toolDirs -join ';') + ';' + $env:PATH
|
|
$csv = (Resolve-Path (Join-Path $project '..\partitions.csv')).Path.Replace('\','/')
|
|
$config = Join-Path $project 'sdkconfig'
|
|
# sdkconfig is generated/ignored; the actual partition table is always the parent project CSV.
|
|
if (Test-Path $config) {
|
|
$text = [System.IO.File]::ReadAllText($config)
|
|
$text = [regex]::Replace($text, '(?m)^CONFIG_PARTITION_TABLE_CUSTOM_FILENAME=.*$', 'CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="' + $csv + '"')
|
|
$text = [regex]::Replace($text, '(?m)^CONFIG_PARTITION_TABLE_FILENAME=.*$', 'CONFIG_PARTITION_TABLE_FILENAME="' + $csv + '"')
|
|
[System.IO.File]::WriteAllText($config,$text)
|
|
} else {
|
|
$defaults = Join-Path $project 'sdkconfig.defaults'
|
|
$text = [System.IO.File]::ReadAllText($defaults)
|
|
$text = [regex]::Replace($text, '(?m)^CONFIG_PARTITION_TABLE_CUSTOM_FILENAME=.*$', 'CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="' + $csv + '"')
|
|
[System.IO.File]::WriteAllText($config,$text)
|
|
}
|
|
Push-Location $project
|
|
try {
|
|
$ErrorActionPreference = 'Continue'
|
|
& $env:PYTHON (Join-Path $env:IDF_PATH 'tools\idf.py') -B build_release app
|
|
$result = $LASTEXITCODE
|
|
$ErrorActionPreference = 'Stop'
|
|
if ($result -ne 0) { throw "App build failed: $result" }
|
|
} finally { Pop-Location }
|
|
$app = Join-Path $project 'build_release\nand_xfer.bin'
|
|
Write-Host "App image: $app"
|