feat(firmware): support rocking-horse workbench delivery

This commit is contained in:
Miayui
2026-09-22 11:15:13 +08:00
parent ba5dfcd6da
commit 4d99702acd
13 changed files with 250 additions and 29 deletions
+27 -13
View File
@@ -11,10 +11,15 @@ param(
[ValidateSet(0, 1)]
[int]$Ventilation = 1,
[ValidateSet(0, 1)]
[int]$Heating = 1
[int]$Heating = 1,
[ValidateSet(0, 1)]
[int]$RockingHorse = $PositionControl
)
$ErrorActionPreference = 'Stop'
if ($RockingHorse -eq 1 -and $PositionControl -eq 0) {
throw 'Rocking-horse mode requires -PositionControl 1.'
}
$repositoryCandidate = if ($RepositoryRoot) {
$RepositoryRoot
} else {
@@ -142,23 +147,29 @@ try {
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 */
"@
# Preserve dependency checks and derived switches (including THERMAL).
$featureProfile = [System.IO.File]::ReadAllText($featureProfilePath)
$featureValues = [ordered]@{
SEAT_FEATURE_POSITION_CONTROL = $PositionControl
SEAT_FEATURE_VENTILATION = $Ventilation
SEAT_FEATURE_HEATING = $Heating
SEAT_FEATURE_ROCKING_HORSE = $RockingHorse
}
foreach ($entry in $featureValues.GetEnumerator()) {
$pattern = '(?m)^#define\s+' + $entry.Key + '\s+\([01]\)'
if (-not [regex]::IsMatch($featureProfile, $pattern)) {
throw "Firmware feature switch is missing: $($entry.Key)"
}
$featureProfile = [regex]::Replace(
$featureProfile, $pattern, "#define $($entry.Key) ($($entry.Value))"
)
}
[System.IO.File]::WriteAllText(
$featureProfilePath,
$featureProfile,
[System.Text.UTF8Encoding]::new($false)
)
Write-Host "Feature profile: position=$PositionControl ventilation=$Ventilation heating=$Heating"
Write-Host "Feature profile: position=$PositionControl ventilation=$Ventilation heating=$Heating rocking_horse=$RockingHorse"
$stagedProject = Join-Path $stagingProjectRoot 'IAR\Seat_Controller_demo.ewp'
Invoke-IarBuild -ProjectPath $stagedProject
@@ -170,6 +181,9 @@ try {
Join-Path $repositoryFirmware "IAR\$Configuration\Exe"
}
New-Item -ItemType Directory -Path $artifactOutput -Force | Out-Null
Copy-BuildArtifact -Source $featureProfilePath -Destination (
Join-Path $artifactOutput 'seat_feature_profile.h'
)
foreach ($artifact in @('Seat_Controller_demo.hex', 'Seat_Controller_demo.out')) {
$sourceArtifact = Join-Path $stagedExe $artifact
if (-not (Test-Path -LiteralPath $sourceArtifact -PathType Leaf)) {