diff --git a/internal/fwsign/fwsign.go b/internal/fwsign/fwsign.go index 5b98d36..a27f21a 100644 --- a/internal/fwsign/fwsign.go +++ b/internal/fwsign/fwsign.go @@ -66,11 +66,13 @@ const ( TargetESP uint8 = 3 TargetBridge uint8 = 6 // the Wi-Fi bridge's firmware (4 and 5, ca and tls, are not signed) TargetGW2 uint8 = 7 // gateware image 2, the sensor emulation image (gateware v54+) + // 8 is a Wi-Fi bridge's identity certificate, never an update. + TargetXIP uint8 = 9 // code the pod runs from its W25Q (blob-xip.bin, firmware 4.0.2+) ) -var targetNames = []string{"firmware", "gw0", "gw1", "esp", "", "", "bridge", "gw2"} +var targetNames = []string{"firmware", "gw0", "gw1", "esp", "", "", "bridge", "gw2", "", "xip"} -// TargetByName maps "firmware", "gw0", "gw1", "esp", "bridge", "gw2" to its number. +// TargetByName maps "firmware", "gw0", "gw1", "esp", "bridge", "gw2", "xip" to its number. func TargetByName(name string) (uint8, bool) { for i, n := range targetNames { if n != "" && n == name { diff --git a/internal/fwsign/fwsign_test.go b/internal/fwsign/fwsign_test.go index 3a8556f..b584371 100644 --- a/internal/fwsign/fwsign_test.go +++ b/internal/fwsign/fwsign_test.go @@ -156,6 +156,12 @@ func TestTargetNames(t *testing.T) { t.Fatalf("bridge: %d %v", n, ok) } // 4 and 5 (ca, tls) are not signed targets: no name, and "" maps to nothing. + if n, ok := TargetByName("xip"); !ok || TargetXIP != 9 || n != TargetXIP || TargetName(9) != "xip" { + t.Errorf("xip: TargetByName = %d, %v; TargetName(9) = %q", n, ok, TargetName(9)) + } + if _, ok := TargetByName(""); ok { + t.Error("the unused target numbers have names") + } if n, ok := TargetByName("gw2"); !ok || TargetGW2 != 7 || n != TargetGW2 || TargetName(7) != "gw2" { t.Fatalf("gw2: %d %v", n, ok) }