feat: add seat firmware workbench and OTA delivery

This commit is contained in:
vee
2026-09-16 17:55:30 +08:00
parent 3eeca2ea75
commit ab8e43050c
70 changed files with 22594 additions and 316 deletions
+76 -9
View File
@@ -4,7 +4,14 @@ param(
[string]$Profile = 'combined',
[string]$Configuration = 'rev_d',
[string]$RepositoryRoot = '',
[string]$IarBuild = ''
[string]$IarBuild = '',
[string]$OutputDirectory = '',
[ValidateSet(0, 1)]
[int]$PositionControl = 1,
[ValidateSet(0, 1)]
[int]$Ventilation = 1,
[ValidateSet(0, 1)]
[int]$Heating = 1
)
$ErrorActionPreference = 'Stop'
@@ -69,9 +76,46 @@ function Write-ImageSummary {
if (-not (Test-Path -LiteralPath $ImagePath -PathType Leaf)) {
throw "Build completed but HEX image was not found: $ImagePath"
}
$hash = Get-FileHash -LiteralPath $ImagePath -Algorithm SHA256
# Use the .NET primitive directly. Some locked-down PowerShell hosts do not
# expose Get-FileHash even though the Utility module is otherwise present.
$stream = [System.IO.File]::OpenRead($ImagePath)
try {
$algorithm = [System.Security.Cryptography.SHA256]::Create()
try {
$hashBytes = $algorithm.ComputeHash($stream)
}
finally {
$algorithm.Dispose()
}
}
finally {
$stream.Dispose()
}
$hashValue = [System.BitConverter]::ToString($hashBytes).Replace('-', '').ToLowerInvariant()
Write-Host "Seat_Controller_demo HEX: $ImagePath"
Write-Host "Seat_Controller_demo SHA256: $($hash.Hash.ToLowerInvariant())"
Write-Host "Seat_Controller_demo SHA256: $hashValue"
}
function Copy-BuildArtifact {
param(
[string]$Source,
[string]$Destination
)
$lastError = $null
for ($attempt = 1; $attempt -le 6; $attempt++) {
try {
Copy-Item -LiteralPath $Source -Destination $Destination -Force
return
}
catch [System.IO.IOException] {
$lastError = $_
if ($attempt -lt 6) {
Start-Sleep -Milliseconds (150 * $attempt)
}
}
}
throw $lastError
}
# Preserve the IAR project's original ../../common and ../../tviibh8m layout
@@ -97,23 +141,46 @@ try {
New-Item -ItemType Junction -Path (Join-Path $stagingRootFull 'common') -Target $vendorCommon | Out-Null
New-Item -ItemType Junction -Path (Join-Path $stagingRootFull 'tviibh8m') -Target $vendorDevice | Out-Null
$featureProfilePath = Join-Path $stagingProjectRoot 'Config\seat_feature_profile.h'
$featureProfile = @"
#ifndef SEAT_FEATURE_PROFILE_H
#define SEAT_FEATURE_PROFILE_H
/* Generated by tools/build_seat_firmware.ps1 for this build only. */
#define SEAT_FEATURE_POSITION_CONTROL ($PositionControl)
#define SEAT_FEATURE_VENTILATION ($Ventilation)
#define SEAT_FEATURE_HEATING ($Heating)
#endif /* SEAT_FEATURE_PROFILE_H */
"@
[System.IO.File]::WriteAllText(
$featureProfilePath,
$featureProfile,
[System.Text.UTF8Encoding]::new($false)
)
Write-Host "Feature profile: position=$PositionControl ventilation=$Ventilation heating=$Heating"
$stagedProject = Join-Path $stagingProjectRoot 'IAR\Seat_Controller_demo.ewp'
Invoke-IarBuild -ProjectPath $stagedProject
$stagedExe = Join-Path $stagingProjectRoot "IAR\$Configuration\Exe"
$repositoryExe = Join-Path $repositoryFirmware "IAR\$Configuration\Exe"
New-Item -ItemType Directory -Path $repositoryExe -Force | Out-Null
$artifactOutput = if ($OutputDirectory) {
[System.IO.Path]::GetFullPath($OutputDirectory)
} else {
Join-Path $repositoryFirmware "IAR\$Configuration\Exe"
}
New-Item -ItemType Directory -Path $artifactOutput -Force | Out-Null
foreach ($artifact in @('Seat_Controller_demo.hex', 'Seat_Controller_demo.out')) {
$sourceArtifact = Join-Path $stagedExe $artifact
if (-not (Test-Path -LiteralPath $sourceArtifact -PathType Leaf)) {
throw "IAR build did not produce $sourceArtifact"
}
Copy-Item -LiteralPath $sourceArtifact -Destination (
Join-Path $repositoryExe $artifact
) -Force
Copy-BuildArtifact -Source $sourceArtifact -Destination (
Join-Path $artifactOutput $artifact
)
}
Write-ImageSummary -ImagePath (
Join-Path $repositoryExe 'Seat_Controller_demo.hex'
Join-Path $artifactOutput 'Seat_Controller_demo.hex'
)
}
finally {