Documentation ¶
Overview ¶
Copyright 2022 The ChromiumOS Authors Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Last step of FirmwareService State Machine. Cleans up temporary folders and reboots the DUT.
First step of FirmwareService State Machine. Installs RW firmware.
First step of FirmwareService State Machine. Installs RW firmware.
Index ¶
- Constants
- func GetFlashECScript(ctx context.Context, s services.ServiceAdapterInterface, prefix string) (string, error)
- func PickAndExtractECImage(ctx context.Context, s services.ServiceAdapterInterface, ...) (string, error)
- func PickAndExtractMainImage(ctx context.Context, s services.ServiceAdapterInterface, ...) (string, error)
- type FirmwarePostInstallState
- type FirmwarePrepareState
- type FirmwareService
- func (fws *FirmwareService) CleanupOnFailure(states []services.ServiceState, executionErr error) error
- func (fws FirmwareService) FlashWithFutility(ctx context.Context, rwOnly bool, futilityImageArgs []string) error
- func (fws *FirmwareService) GetBoard() string
- func (fws FirmwareService) GetConnectionToFlashingDevice() services.ServiceAdapterInterface
- func (fws *FirmwareService) GetFirstState() services.ServiceState
- func (fws *FirmwareService) GetModel() string
- func (fws *FirmwareService) PrintRequestInfo()
- func (fws FirmwareService) ProvisionWithFlashEC(ctx context.Context, ecImage, flashECScriptPath string) error
- func (fws *FirmwareService) RestartDut(ctx context.Context, requireServoReset bool) error
- func (fws *FirmwareService) UpdateRo() bool
- func (fws *FirmwareService) UpdateRw() bool
- type FirmwareUpdateRoState
- type FirmwareUpdateRwState
- type ImageArchiveMetadata
Constants ¶
const CurlWithRetriesArgsFW = "-S -s -v -# -C - --retry 3 --retry-delay 60"
const FirmwarePathTmp = "/tmp/fw-provisioning-service/"
const PostInstallStateName = "Post Install (cleanup/reboot)"
const PrepareStateName = "Firmware Prepare (download/extract archives)"
const UpdateRoStateName = "Firmware Update RO"
const UpdateRwStateName = "Firmware Update RW"
Variables ¶
This section is empty.
Functions ¶
func GetFlashECScript ¶
func GetFlashECScript(ctx context.Context, s services.ServiceAdapterInterface, prefix string) (string, error)
GetFlashECScript finds flash_ec script locally and returns path to it. If flash_ec is not found, download the latest version with git to |prefix|, and return path to downloaded flash_ec.
func PickAndExtractECImage ¶
func PickAndExtractECImage(ctx context.Context, s services.ServiceAdapterInterface, imageMetadata ImageArchiveMetadata, board, model string) (string, error)
PickAndExtractECImage uses provided list of |filesInArchive| to pick an EC image to use, extracts only it, and returns a path to extracted image. board and model(aka variant) are optional.
func PickAndExtractMainImage ¶
func PickAndExtractMainImage(ctx context.Context, s services.ServiceAdapterInterface, imageMetadata ImageArchiveMetadata, board, model string) (string, error)
PickAndExtractMainImage uses provided list of |filesInArchive| to pick a main image to use, extracts only it, and returns a path to extracted image. board and model(aka variant) are optional.
Types ¶
type FirmwarePostInstallState ¶
type FirmwarePostInstallState struct {
// contains filtered or unexported fields
}
FirmwarePostInstallState cleans up temporary folders and reboots the DUT.
func (FirmwarePostInstallState) Execute ¶
func (s FirmwarePostInstallState) Execute(ctx context.Context) error
Execute deletes all folders with firmware image archives.
func (FirmwarePostInstallState) Name ¶
func (s FirmwarePostInstallState) Name() string
func (FirmwarePostInstallState) Next ¶
func (s FirmwarePostInstallState) Next() services.ServiceState
type FirmwarePrepareState ¶
type FirmwarePrepareState struct {
// contains filtered or unexported fields
}
func (FirmwarePrepareState) Execute ¶
func (s FirmwarePrepareState) Execute(ctx context.Context) error
FirmwarePrepareState downloads and extracts every image from the request. The already downloaded images will not be downloaded and extracted again.
func (FirmwarePrepareState) Name ¶
func (s FirmwarePrepareState) Name() string
func (FirmwarePrepareState) Next ¶
func (s FirmwarePrepareState) Next() services.ServiceState
type FirmwareService ¶
type FirmwareService struct {
// contains filtered or unexported fields
}
FirmwareService inherits ServiceInterface
func NewFirmwareService ¶
func NewFirmwareService(ctx context.Context, dut *lab_api.Dut, dutClient api.DutServiceClient, servoClient api.ServodServiceClient, req *api.InstallFirmwareRequest) (*FirmwareService, error)
func NewFirmwareServiceFromExistingConnection ¶
func NewFirmwareServiceFromExistingConnection(ctx context.Context, dut *lab_api.Dut, connection services.ServiceAdapterInterface, servoClient api.ServodServiceClient, req *api.InstallFirmwareRequest) (*FirmwareService, error)
NewFirmwareServiceFromExistingConnection is equivalent to the above constructor, but recycles a ServiceAdapter. Generally useful for tests.
func (*FirmwareService) CleanupOnFailure ¶
func (fws *FirmwareService) CleanupOnFailure(states []services.ServiceState, executionErr error) error
CleanupOnFailure is called if one of service's states failes to Execute() and currenly cleans up the temporary files.
func (FirmwareService) FlashWithFutility ¶
func (fws FirmwareService) FlashWithFutility(ctx context.Context, rwOnly bool, futilityImageArgs []string) error
FlashWithFutility flashes the DUT using "futility" tool. futility will be run with "--mode=recovery". if |rwOnly| is true, futility will flash only RW regions. if |rwOnly| is false, futility will flash both RW and RO regions. futilityArgs must include argument(s) that provide path(s) to the images.
If flashing over ssh, simply calls runFutility(). If flashing over servo, also runs pre- and post-flashing dut-controls.
func (*FirmwareService) GetBoard ¶
func (fws *FirmwareService) GetBoard() string
GetBoard returns board of the DUT to provision. Returns empty string if board is not known.
func (FirmwareService) GetConnectionToFlashingDevice ¶
func (fws FirmwareService) GetConnectionToFlashingDevice() services.ServiceAdapterInterface
GetConnectionToFlashingDevice returns connection to the device that stores the firmware image and runs futility. Returns connection to ServoHost if fws.useServo, connection to DUT otherwise.
func (*FirmwareService) GetFirstState ¶
func (fws *FirmwareService) GetFirstState() services.ServiceState
GetFirstState returns the first state of this state machine
func (*FirmwareService) GetModel ¶
func (fws *FirmwareService) GetModel() string
GetModel returns model of the DUT to provision. Returns empty string if model is not known.
func (*FirmwareService) PrintRequestInfo ¶
func (fws *FirmwareService) PrintRequestInfo()
func (FirmwareService) ProvisionWithFlashEC ¶
func (fws FirmwareService) ProvisionWithFlashEC(ctx context.Context, ecImage, flashECScriptPath string) error
ProvisionWithFlashEC flashes EC image using flash_ec script.
func (*FirmwareService) RestartDut ¶
func (fws *FirmwareService) RestartDut(ctx context.Context, requireServoReset bool) error
RestartDut restarts the DUT using one of the available mechanisms. Preferred restart method is to send "power_state:reset" command to servod. If servod restarting failed/not available in the environment, then this function will try to SSH to the DUT and run `restart`, if |requireServoReset| is false. If |requireServoReset| is True, restart over SSH will not be attempted, and the function will return an error.
func (*FirmwareService) UpdateRo ¶
func (fws *FirmwareService) UpdateRo() bool
func (*FirmwareService) UpdateRw ¶
func (fws *FirmwareService) UpdateRw() bool
type FirmwareUpdateRoState ¶
type FirmwareUpdateRoState struct {
// contains filtered or unexported fields
}
FirmwareUpdateRoState updates firmware with write protection disabled.
func (FirmwareUpdateRoState) Execute ¶
func (s FirmwareUpdateRoState) Execute(ctx context.Context) error
Execute flashes firmware with write-protection disabled using futility.
func (FirmwareUpdateRoState) Name ¶
func (s FirmwareUpdateRoState) Name() string
func (FirmwareUpdateRoState) Next ¶
func (s FirmwareUpdateRoState) Next() services.ServiceState
type FirmwareUpdateRwState ¶
type FirmwareUpdateRwState struct {
// contains filtered or unexported fields
}
FirmwareUpdateRwState updates firmware with write protection disabled.
func (FirmwareUpdateRwState) Execute ¶
func (s FirmwareUpdateRwState) Execute(ctx context.Context) error
Execute flashes firmware using futility with write-protection enabled.
func (FirmwareUpdateRwState) Name ¶
func (s FirmwareUpdateRwState) Name() string
func (FirmwareUpdateRwState) Next ¶
func (s FirmwareUpdateRwState) Next() services.ServiceState
type ImageArchiveMetadata ¶
type ImageArchiveMetadata struct {
// contains filtered or unexported fields
}
ImageArchiveMetadata will be the value of the map in which the key is the gsPath, so we can avoid downloading/reprocessing same archives.
func DownloadAndProcessArchive ¶
func DownloadAndProcessArchive(ctx context.Context, s services.ServiceAdapterInterface, gsPath string) (*ImageArchiveMetadata, error)
DownloadAndProcessArchive downloads image from gsPath onto whatever device is connected to |s|. Returns ImageArchiveMetadata with metadata about the archive.
func MakeImageArchiveMetadata ¶
func MakeImageArchiveMetadata(archivePath string, archiveDir string, listOfFiles []string) *ImageArchiveMetadata
func (*ImageArchiveMetadata) IncludesFile ¶
func (m *ImageArchiveMetadata) IncludesFile(filename string) bool