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.
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.
Index ¶
- func GetFlashECScript(ctx context.Context, s common_utils.ServiceAdapterInterface, prefix string) (string, error)
- func PickAndExtractECImage(ctx context.Context, s common_utils.ServiceAdapterInterface, ...) (string, error)
- func PickAndExtractMainImage(ctx context.Context, s common_utils.ServiceAdapterInterface, ...) (string, error)
- type FirmwareProvisionError
- func FirmwareMismatchPostProvisionErr(err error) *FirmwareProvisionError
- func InvalidRequestErr(err error) *FirmwareProvisionError
- func UnreachablePostProvisionErr(err error) *FirmwareProvisionError
- func UnreachablePreProvisionErr(err error) *FirmwareProvisionError
- func UpdateFirmwareFailedErr(err error) *FirmwareProvisionError
- type FirmwareService
- func (fws *FirmwareService) ActiveFirmwareVersions(ctx context.Context) (*FirmwareVersions, error)
- func (fws *FirmwareService) DeleteArchiveDirectories() error
- func (fws *FirmwareService) DownloadAndProcess(ctx context.Context, gsPath string) error
- func (fws *FirmwareService) ExtractFirmwareVersions(ctx context.Context, rwOnly bool, futilityImageArgs []string, ...) error
- func (fws *FirmwareService) FlashWithFutility(ctx context.Context, rwOnly bool, futilityImageArgs []string, ...) error
- func (fws *FirmwareService) GetBoard() string
- func (fws *FirmwareService) GetConnectionToFlashingDevice() common_utils.ServiceAdapterInterface
- func (fws *FirmwareService) GetEcRoPath() string
- func (fws *FirmwareService) GetImageMetadata(gspath string) (ImageArchiveMetadata, bool)
- func (fws *FirmwareService) GetMainRoPath() string
- func (fws *FirmwareService) GetMainRwPath() string
- func (fws *FirmwareService) GetModel() string
- func (fws *FirmwareService) GetVersions() *api.FirmwareProvisionResponse
- func (fws *FirmwareService) IsForceUpdate() bool
- func (fws *FirmwareService) IsServoUsed() bool
- func (fws *FirmwareService) PrintRequestInfo()
- func (fws *FirmwareService) ProvisionWithFlashEC(ctx context.Context, ecImage, flashECScriptPath string) error
- func (fws *FirmwareService) ReadConfigYAML(ctx context.Context) error
- func (fws *FirmwareService) RestartDut(ctx context.Context, requireServoReset bool) error
- func (fws *FirmwareService) UpdateRo() bool
- func (fws *FirmwareService) UpdateRw() bool
- type FirmwareVersions
- type ImageArchiveMetadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetFlashECScript ¶
func GetFlashECScript(ctx context.Context, s common_utils.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 common_utils.ServiceAdapterInterface, imageMetadata ImageArchiveMetadata, gsPath string, fws *FirmwareService) (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 common_utils.ServiceAdapterInterface, imageMetadata ImageArchiveMetadata, gsPath string, fws *FirmwareService) (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 FirmwareProvisionError ¶
type FirmwareProvisionError struct { Status api.InstallResponse_Status Err error }
func FirmwareMismatchPostProvisionErr ¶
func FirmwareMismatchPostProvisionErr(err error) *FirmwareProvisionError
func InvalidRequestErr ¶
func InvalidRequestErr(err error) *FirmwareProvisionError
func UnreachablePostProvisionErr ¶
func UnreachablePostProvisionErr(err error) *FirmwareProvisionError
func UnreachablePreProvisionErr ¶
func UnreachablePreProvisionErr(err error) *FirmwareProvisionError
func UpdateFirmwareFailedErr ¶
func UpdateFirmwareFailedErr(err error) *FirmwareProvisionError
func (*FirmwareProvisionError) Error ¶
func (fe *FirmwareProvisionError) Error() string
type FirmwareService ¶
type FirmwareService struct { // The name of the model's fw binary from config.yaml CorebootName string ECName string CacheServer url.URL ExpectedVersions FirmwareVersions // contains filtered or unexported fields }
FirmwareService implements ServiceInterface
func NewFirmwareService ¶
func NewFirmwareService(ctx context.Context, dutAdapter common_utils.ServiceAdapterInterface, servoClient api.ServodServiceClient, cacheServer url.URL, board, model string, useServo bool, req *api.InstallRequest) (*FirmwareService, error)
NewFirmwareService initializes a FirmwareService.
func (*FirmwareService) ActiveFirmwareVersions ¶
func (fws *FirmwareService) ActiveFirmwareVersions(ctx context.Context) (*FirmwareVersions, error)
ActiveFirmwareVersions returns the firmware versions currently running on the DUT.
func (*FirmwareService) DeleteArchiveDirectories ¶
func (fws *FirmwareService) DeleteArchiveDirectories() error
DeleteArchiveDirectories deletes files on the servo host or DUT.
func (*FirmwareService) DownloadAndProcess ¶
func (fws *FirmwareService) DownloadAndProcess(ctx context.Context, gsPath string) error
DownloadAndProcess gets ready to extract the selected archive. It doesn't actually do any downloading and should be renamed.
func (*FirmwareService) ExtractFirmwareVersions ¶
func (fws *FirmwareService) ExtractFirmwareVersions(ctx context.Context, rwOnly bool, futilityImageArgs []string, apImagePath string) error
ExtractFirmwareVersions uses futility to get the version numbers from the images.
func (*FirmwareService) FlashWithFutility ¶
func (fws *FirmwareService) FlashWithFutility(ctx context.Context, rwOnly bool, futilityImageArgs []string, apImagePath 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. apImagePath is the path to the AP image.
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() common_utils.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) GetEcRoPath ¶
func (fws *FirmwareService) GetEcRoPath() string
GetEcRoPath returns the path for the readonly portion of the EC firmware.
func (*FirmwareService) GetImageMetadata ¶
func (fws *FirmwareService) GetImageMetadata(gspath string) (ImageArchiveMetadata, bool)
GetImageMetadata returns (ImageArchiveMetadata, IsImageMetadataPresent)
func (*FirmwareService) GetMainRoPath ¶
func (fws *FirmwareService) GetMainRoPath() string
GetMainRoPath returns the path of readonly part of the AP firmware.
func (*FirmwareService) GetMainRwPath ¶
func (fws *FirmwareService) GetMainRwPath() string
GetMainRwPath returns the path of the read/write part of the AP firmware.
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) GetVersions ¶
func (fws *FirmwareService) GetVersions() *api.FirmwareProvisionResponse
GetVersions returns a FirmwareProvisionResponse with the expected firmware versions
func (*FirmwareService) IsForceUpdate ¶
func (fws *FirmwareService) IsForceUpdate() bool
IsForceUpdate returns whether an update is forced during the provisioning.
func (*FirmwareService) IsServoUsed ¶
func (fws *FirmwareService) IsServoUsed() bool
IsServoUsed returns whether servo is used during the provisioning.
func (*FirmwareService) PrintRequestInfo ¶
func (fws *FirmwareService) PrintRequestInfo()
PrintRequestInfo logs details of the provisioning operation.
func (*FirmwareService) ProvisionWithFlashEC ¶
func (fws *FirmwareService) ProvisionWithFlashEC(ctx context.Context, ecImage, flashECScriptPath string) error
ProvisionWithFlashEC flashes EC image using flash_ec script.
func (*FirmwareService) ReadConfigYAML ¶
func (fws *FirmwareService) ReadConfigYAML(ctx context.Context) error
ReadConfigYAML downloads config.yaml from the DUT and find the firmware binary names that should be used.
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
UpdateRo returns whether the read-only firmware is being operated on.
func (*FirmwareService) UpdateRw ¶
func (fws *FirmwareService) UpdateRw() bool
UpdateRw returns whether the read/write firmware is being operated on.
type FirmwareVersions ¶
type FirmwareVersions struct { AP struct { Versions struct { RO string `yaml:"ro"` RW string `yaml:"rw"` } `yaml:"versions"` } `yaml:"host"` EC struct { Versions struct { RO string `yaml:"ro"` RW string `yaml:"rw"` RWHash string } `yaml:"versions"` } `yaml:"ec"` }
FirmwareVersions holds the ro and rw versions read from a firmware binary.
type ImageArchiveMetadata ¶
type ImageArchiveMetadata struct {
ArchiveDir string
}
ImageArchiveMetadata will be the value of the map in which the key is the gsPath, so we can avoid downloading/reprocessing same archives.