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 Escape(s string) string
- func ExtractFile(ctx context.Context, dut api.DutServiceClient, url, destPath string) (bool, error)
- func GetFlashECScript(ctx context.Context, s common_utils.ServiceAdapterInterface, prefix string) (string, error)
- func PickAndExtractECImage(ctx context.Context, dut api.DutServiceClient, ...) (string, error)
- func PickAndExtractMainImage(ctx context.Context, dut api.DutServiceClient, ...) (string, error)
- func RunDUTCommand(ctx context.Context, dut api.DutServiceClient, timeout time.Duration, ...) (string, string, error)
- func SwapECRWImage(ctx context.Context, dut api.DutServiceClient, apImagePath, ecImagePath string) (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) CheckForCSMESections(ctx context.Context, imagePath string) (bool, 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) GetEcRwPath() 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) ServoHostPath() string
- func (fws *FirmwareService) ServodDockerContainerName() string
- func (fws *FirmwareService) UpdateRo() bool
- func (fws *FirmwareService) UpdateRw() bool
- func (fws *FirmwareService) WaitForReconnect(ctx context.Context) error
- type FirmwareVersions
- type ImageArchiveMetadata
- type ImageCandidate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Escape ¶
Escape escapes a string so it can be safely included as an argument in a shell command line. The string is not modified if it can already be safely included.
func ExtractFile ¶
ExtractFile calls the cache server to extract a file to the DUT, and retries on 5xx http errors. Returns false, nil on 404 errors. Returns an error on all other errors.
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, dut api.DutServiceClient, 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, dut api.DutServiceClient, 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.
func RunDUTCommand ¶
func RunDUTCommand(ctx context.Context, dut api.DutServiceClient, timeout time.Duration, cmd string, args []string, stdin []byte) (string, string, error)
RunDUTCommand runs a command on the DUT and returns stdout, stderr, and an error if it failed. CAUTION: The args are concatenated with no quoting, so beware of spaces and shell chars in filenames.
func SwapECRWImage ¶
func SwapECRWImage(ctx context.Context, dut api.DutServiceClient, apImagePath, ecImagePath string) (string, error)
SwapECRWImage switches the EC RW in the AP image with the specified image. If the AP image path is blank, this will read the firmware from the flash. Returns the path to the AP image.
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 // StandaloneECName is the name of the ec binary for standalone (i.e. firmware-ec-Rxxx branches) builds. StandaloneECName string // LegacyECName is the name of the ec binary for legacy_fw (i.e. firmware-board branches) builds. LegacyECName string // DUTServer is the gRPC connection to the DUT. DUTServer api.DutServiceClient CacheServer url.URL ExpectedVersions FirmwareVersions // RestartRequired indicates that a firmware update was performed, but the DUT has not yet rebooted. RestartRequired bool // contains filtered or unexported fields }
FirmwareService implements ServiceInterface
func NewFirmwareService ¶
func NewFirmwareService(ctx context.Context, dutServer api.DutServiceClient, servoClient api.ServodServiceClient, cacheServer url.URL, board, model string, useServo bool, req *api.InstallRequest, servoConfig *labapi.Servo) (*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) CheckForCSMESections ¶
func (fws *FirmwareService) CheckForCSMESections(ctx context.Context, imagePath string) (bool, error)
CheckForCSMESections looks at the image at imagePath, and returns true if csme_unlock is supported.
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, ecImagePath 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. ecImagePath is the path to the EC 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) GetEcRwPath ¶
func (fws *FirmwareService) GetEcRwPath() string
GetEcRwPath returns the path for the read/write 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) ServoHostPath ¶
func (fws *FirmwareService) ServoHostPath() string
ServoHostPath returns the ServoHostPath to pass to servoClient
func (*FirmwareService) ServodDockerContainerName ¶
func (fws *FirmwareService) ServodDockerContainerName() string
ServodDockerContainerName returns the ServodDockerContainerName to pass to servoClient
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.
func (*FirmwareService) WaitForReconnect ¶
func (fws *FirmwareService) WaitForReconnect(ctx context.Context) error
WaitForReconnect attempts to ssh to the DUT until it connects
type FirmwareVersions ¶
type FirmwareVersions struct { AP struct { Versions struct { RO string `yaml:"ro"` RW string `yaml:"rw"` // The EC version embedded within the AP-RW image. ECRW string `yaml:"ecrw"` } `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.
type ImageCandidate ¶
func GetAPCandidateURLs ¶
func GetAPCandidateURLs(ctx context.Context, gsPath string, fws *FirmwareService) ([]ImageCandidate, error)
GetAPCandidateURLs returns a list of urls and files to extract. Try them in order.
func GetECCandidateURLs ¶
func GetECCandidateURLs(ctx context.Context, gsPath string, fws *FirmwareService) ([]ImageCandidate, error)
GetECCandidateURLs returns a list of urls and files to extract. Try them in order.