diff --git a/ota/raucadapter/raucadapter.go b/ota/raucadapter/raucadapter.go index bcc22409ab168089509cb1c0cb69edf7391c36b9..7810f02b3f35296c95fdb6bf7c1f020f579ef9bf 100644 --- a/ota/raucadapter/raucadapter.go +++ b/ota/raucadapter/raucadapter.go @@ -94,12 +94,11 @@ func (adapter *Adapter) SetPrimarySlot(slot boot.Slot) error { activeSlot, err := adapter.proto.QueryActive() if err != nil { if errors.Is(err, boot.ErrPristineBootConfig) && adapter.bootModeHolder.BootMode() == boot.Normal { - fmt.Printf("Ignoring RAUC set-primary %s while in pristine boot configuration\n", slot) - - return nil + fmt.Printf("System is in pristine boot configuration mode, pretending slot A is active\n") + activeSlot = boot.SlotA + } else { + return err } - - return err } switch adapter.bootModeHolder.BootMode() { @@ -149,21 +148,12 @@ func (adapter *Adapter) SlotState(slot boot.Slot) (boot.SlotState, error) { active, err := adapter.proto.QueryActive() if err != nil { - if errors.Is(err, boot.ErrPristineBootConfig) { - fmt.Printf("Forging RAUC get-state %s while in pristine boot configuration\n", slot) - - if slot == boot.SlotA { - return boot.GoodSlot, nil - } - - return boot.BadSlot, nil + if errors.Is(err, boot.ErrPristineBootConfig) && adapter.bootModeHolder.BootMode() == boot.Normal { + fmt.Printf("System is in pristine boot configuration mode, pretending slot A is active\n") + active = boot.SlotA + } else { + return boot.InvalidSlotState, err } - - return boot.InvalidSlotState, err - } - - if err != nil { - return boot.InvalidSlotState, err } if slot == active { @@ -210,14 +200,11 @@ func (adapter *Adapter) SetSlotState(slot boot.Slot, state boot.SlotState) error active, err := adapter.proto.QueryActive() if err != nil { if errors.Is(err, boot.ErrPristineBootConfig) && adapter.bootModeHolder.BootMode() == boot.Normal { - if (slot == boot.SlotA && state == boot.GoodSlot) || (slot == boot.SlotB && state == boot.BadSlot) { - fmt.Printf("Ignoring RAUC set-state %s %s while in pristine boot configuration\n", slot, state) - - return nil - } + fmt.Printf("System is in pristine boot configuration mode, pretending slot A is active\n") + active = boot.SlotA + } else { + return err } - - return err } inactive := boot.SynthesizeInactiveSlot(active)