Documentation ¶
Overview ¶
Package firmware implements the libraries and utilities which are used for remote bundles with the same name 'firmware'. Reviews for this package can be sent to tast-fw-library-reviewers@ (before tast-owners@ review).
Index ¶
- Constants
- Variables
- func CfgPlatformFromLSBBoard(board string) string
- func CheckFWTries(ctx context.Context, r *reporters.Reporter, ...) error
- func SetFWTries(ctx context.Context, d *dut.DUT, nextFW fwCommon.RWSection, tryCount uint) error
- type CBICmd
- type Config
- type ECCapability
- type ECTool
- func (ec *ECTool) BatteryCutoff(ctx context.Context) error
- func (ec *ECTool) CBI(ctx context.Context, cmd CBICmd, args ...string) (string, error)
- func (ec *ECTool) Command(ctx context.Context, args ...string) *ssh.Cmd
- func (ec *ECTool) FindBaseGpio(ctx context.Context, gpios []GpioName) (map[GpioName]string, error)
- func (ec *ECTool) ForceTabletModeAngle(ctx context.Context, tabletModeAngle, hys string) error
- func (ec *ECTool) Hash(ctx context.Context) (string, error)
- func (ec *ECTool) I2C(ctx context.Context, cmd I2CCmd, args ...string) (string, error)
- func (ec *ECTool) I2CLookup(ctx context.Context) (*I2CLookupInfo, error)
- func (ec *ECTool) SaveTabletModeAngles(ctx context.Context) (string, string, error)
- func (ec *ECTool) Version(ctx context.Context) (string, error)
- type ECToolName
- type GpioName
- type Helper
- func (h *Helper) Close(ctx context.Context) error
- func (h *Helper) CloseRPCConnection(ctx context.Context) error
- func (h *Helper) CloseServo(ctx context.Context) error
- func (h *Helper) CopyTastFilesFromDUT(ctx context.Context) error
- func (h *Helper) DisallowServices()
- func (h *Helper) DisconnectDUT(ctx context.Context) error
- func (h *Helper) DoesServerHaveTastHostFiles() bool
- func (h *Helper) EnsureDUTBooted(ctx context.Context) error
- func (h *Helper) OverridePlatform(ctx context.Context, board, model string)
- func (h *Helper) RequireBiosServiceClient(ctx context.Context) error
- func (h *Helper) RequireConfig(ctx context.Context) error
- func (h *Helper) RequirePlatform(ctx context.Context) error
- func (h *Helper) RequireRPCClient(ctx context.Context) error
- func (h *Helper) RequireRPCUtils(ctx context.Context) error
- func (h *Helper) RequireRPM(ctx context.Context) error
- func (h *Helper) RequireServo(ctx context.Context) error
- func (h *Helper) SetDUTPower(ctx context.Context, powerOn bool) error
- func (h *Helper) SetupUSBKey(ctx context.Context, cloudStorage *testing.CloudStorage) (retErr error)
- func (h *Helper) SyncTastFilesToDUT(ctx context.Context) error
- func (h *Helper) WaitConnect(ctx context.Context, opts ...WaitConnectOption) error
- func (h *Helper) WaitForPowerStates(ctx context.Context, interval, timeout time.Duration, powerStates ...string) error
- type I2CCmd
- type I2CLookupInfo
- type ModeSwitchOption
- type ModeSwitcher
- type ModeSwitcherType
- type ResetType
- type USBEnablePin
- type WaitConnectOption
Constants ¶
const ( // PowerStateTimeout is the timeout to wait for the DUT reach a powerstate. PowerStateTimeout = 20 * time.Second // PowerStateInterval is the interval to wait before polling DUT powerstate. PowerStateInterval = 250 * time.Millisecond )
Variables ¶
var ConfigFile = filepath.Join(cfgDirName, consolidatedBasename)
ConfigFile is the relative path from data/ to the .json file containing all platforms' config data. It is intended to be used in the Data field of a testing.Test declaration.
Functions ¶
func CfgPlatformFromLSBBoard ¶
CfgPlatformFromLSBBoard interprets a board name that would come from /etc/lsb-release, and returns the name of the platform whose config should be loaded.
func CheckFWTries ¶
func CheckFWTries(ctx context.Context, r *reporters.Reporter, expectedCurrentFW, expectedNextFW fwCommon.RWSection, expectedTryCount uint) error
CheckFWTries returns an error if unexpected values are found for the DUT's currently booted firmware, next firmware section to try, or number of tries. Optionally, currentFW and nextFW can each take fwCommon.RWSectionUnspecified to avoid checking that section.
func SetFWTries ¶
SetFWTries sets which firmware (A or B) the DUT should boot to next, and how many times it should try booting ino that firmware. If tryCount is 0 for a vboot2 DUT, then fw_try_count will not be modified, only fw_try_next.
Types ¶
type CBICmd ¶
type CBICmd string
CBICmd type holds commands for interacting with cbi using the ectool.
type Config ¶
type Config struct { Platform string `json:"platform"` Parent string `json:"parent"` ECCapability []ECCapability `json:"ec_capability"` ModeSwitcherType ModeSwitcherType `json:"mode_switcher_type"` PowerButtonDevSwitch bool `json:"power_button_dev_switch"` RecButtonDevSwitch bool `json:"rec_button_dev_switch"` Hibernate bool `json:"hibernate"` HasKeyboard bool `json:"has_keyboard"` RawUSBEnablePins []json.RawMessage `json:"custom_usb_enable_pins"` USBAPortCount int `json:"usb_a_port_count"` // Raw duration fields represent a quantity of seconds. // They are used during NewConfig to populate actual duration fields, which are defined below. // Generally, these raw fields should not be accessed by tests and libraries. // Nevertheless, the raw fields must be exported in order for them to be set by json.Unmarshal. RawKeypressDelay float64 `json:"keypress_delay"` RawDelayRebootToPing float64 `json:"delay_reboot_to_ping"` RawECBootToPwrButton float64 `json:"ec_boot_to_pwr_button"` RawFirmwareScreen float64 `json:"firmware_screen"` RawSerialFirmwareBootDelay float64 `json:"serial_firmware_boot_delay"` RawUSBPlug float64 `json:"usb_plug"` RawHoldPwrButtonPowerOff float64 `json:"hold_pwr_button_poweroff"` RawHoldPwrButtonPowerOn float64 `json:"hold_pwr_button_poweron"` RawHoldPwrButtonNoPowerdShutdown float64 `json:"hold_pwr_button_nopowerd_shutdown"` RawShutdown float64 `json:"shutdown"` // Actual duration fields are populated during NewConfig based on raw JSON duration values, defined above. KeypressDelay time.Duration DelayRebootToPing time.Duration ECBootToPwrButton time.Duration FirmwareScreen time.Duration SerialFirmwareBootDelay time.Duration USBPlug time.Duration HoldPwrButtonPowerOff time.Duration HoldPwrButtonPowerOn time.Duration HoldPwrButtonNoPowerdShutdown time.Duration Shutdown time.Duration // Instructions for updating AP firmware over servo APFlashCCDProgrammer string `json:"ap_flash_ccd_programmer"` APFlashCCDPreCommands []string `json:"ap_flash_ccd_pre_commands"` APFlashCCDPostCommands []string `json:"ap_flash_ccd_post_commands"` // Models maps DUT model names to overriding config JSON objects. Models map[string]json.RawMessage `json:"models"` // Holds a list of objects under the "custom_usb_enable_pins" key in the configs. USBEnablePins []USBEnablePin }
Config contains platform-specific attributes. Fields are documented in autotest/server/cros/faft/configs/DEFAULTS.json.
func NewConfig ¶
NewConfig creates a new Config matching the DUT platform. cfgFilepath should take s.DataPath(firmware.ConfigFile).
func (*Config) HasECCapability ¶
func (cfg *Config) HasECCapability(ecc ECCapability) bool
HasECCapability checks whether cfg has a certain ECCapability.
type ECCapability ¶
type ECCapability string
ECCapability represents one feature that the EC can control.
const ( ECADCECTemp ECCapability = "adc_ectemp" ECARM ECCapability = "arm" ECBattery ECCapability = "battery" ECCBI ECCapability = "cbi" ECCharging ECCapability = "charging" ECDoubleBoot ECCapability = "doubleboot" ECKeyboard ECCapability = "keyboard" ECLid ECCapability = "lid" ECPECI ECCapability = "peci" ECSmartUSBCharge ECCapability = "smart_usb_charge" ECThermal ECCapability = "thermal" ECUSB ECCapability = "usb" ECUSBPDUART ECCapability = "usbpd_uart" ECX86 ECCapability = "x86" )
These are the ECCapabilities currently described in fw-testing-configs.
type ECTool ¶
type ECTool struct {
// contains filtered or unexported fields
}
ECTool allows for interaction with the host command `ectool`.
func (*ECTool) BatteryCutoff ¶
BatteryCutoff runs the ectool batterycutoff command.
func (*ECTool) FindBaseGpio ¶
FindBaseGpio iterates through a passed in list of gpios, relevant to control on a detachable base, and checks if any one of them exists.
func (*ECTool) ForceTabletModeAngle ¶
ForceTabletModeAngle emulates rotation angles to change DUT's tablet mode setting.
func (*ECTool) I2CLookup ¶
func (ec *ECTool) I2CLookup(ctx context.Context) (*I2CLookupInfo, error)
I2CLookup runs ectool locatechip 0 0 to get Port and Address for I2C.
func (*ECTool) SaveTabletModeAngles ¶
SaveTabletModeAngles runs 'ectool motionsense tablet_mode_angle' to save the current angles for tablet mode.
type ECToolName ¶
type ECToolName string
ECToolName specifies which of the many Chromium EC based MCUs ectool will be communicated with. Some options are cros_ec, cros_fp, cros_pd, cros_scp, and cros_ish.
const ( // ECToolNameMain selects the main EC using cros_ec. ECToolNameMain ECToolName = "cros_ec" // ECToolNameFingerprint selects the FPMCU using cros_fp. ECToolNameFingerprint ECToolName = "cros_fp" )
type Helper ¶
type Helper struct { // BiosServiceClient provides bios related services such as GBBFlags manipulation. BiosServiceClient fwpb.BiosServiceClient // Board contains the DUT's board, as reported by the Platform RPC. // Currently, this is based on /etc/lsb-release's CHROMEOS_RELEASE_BOARD. Board string // Config contains a variety of platform-specific attributes. Config *Config // DUT is used for communicating with the device under test. DUT *dut.DUT // Model contains the DUT's model, as reported by the Platform RPC. // Currently, this is based on cros_config / name. Model string // Reporter reports various info from the DUT. Reporter *reporters.Reporter // RPCClient is a direct client connection to the Tast gRPC server hosted on the DUT. RPCClient *rpc.Client // RPCUtils allows the Helper to call the firmware utils RPC service. RPCUtils fwpb.UtilsServiceClient // Servo allows us to send commands to a servo device. Servo *servo.Servo // ServoProxy wraps the Servo object, and communicates with the servod instance. ServoProxy *servo.Proxy // RPM is a remote power management client. Only valid in the test lab. RPM *rpm.RPM // contains filtered or unexported fields }
Helper tracks several firmware-related objects. The recommended way to initialize the helper is to use firmware.fixture:
import (
... "chromiumos/tast/remote/firmware/fixture"
)
func init() { testing.AddTest(&testing.Test{ ... Fixture: fixture.NormalMode, }) }
func MyTest(ctx context.Context, s *testing.State) { h := s.FixtValue().(*fixture.Value).Helper if err := h.RequireServo(ctx); err != nil { s.Fatal("Failed to init servo: ", err) }
... }
func NewHelper ¶
func NewHelper(d *dut.DUT, rpcHint *testing.RPCHint, cfgFilepath, servoHostPort, dutHostname, powerunitHostname, powerunitOutlet, hydraHostname string) *Helper
NewHelper creates a new Helper object with info from testing.State. For tests that do not use a certain Helper aspect (e.g. RPC or Servo), it is OK to pass null-values (nil or "").
func NewHelperWithoutDUT ¶
NewHelperWithoutDUT creates a new Helper object with info from testing.State. The resulting Helper will be unable to ssh to the DUT.
func (*Helper) Close ¶
Close shuts down any firmware objects associated with the Helper. Generally, tests should defer Close() immediately after initializing a Helper.
func (*Helper) CloseRPCConnection ¶
CloseRPCConnection shuts down the RPC client (if present), and removes any RPC clients that the Helper was tracking.
func (*Helper) CloseServo ¶
CloseServo closes the connection to the servo, use RequireServo to open it again.
func (*Helper) CopyTastFilesFromDUT ¶
CopyTastFilesFromDUT retrieves Tast host files from the DUT and stores them locally for later use. This allows the test server to re-push Tast files to the DUT if a different OS image is booted mid-test.
func (*Helper) DisallowServices ¶
func (h *Helper) DisallowServices()
DisallowServices prevents RequireRPCClient from being used for the lifetime of this Helper.
func (*Helper) DisconnectDUT ¶
DisconnectDUT shuts down all connections to the DUT. Call this after you have powered down the DUT.
func (*Helper) DoesServerHaveTastHostFiles ¶
DoesServerHaveTastHostFiles determines whether the test server has a copy of Tast host files.
func (*Helper) EnsureDUTBooted ¶
EnsureDUTBooted checks the power state, and attempts to boot the DUT if it is off.
func (*Helper) OverridePlatform ¶
OverridePlatform sets board and model if the passed in params are not blank.
func (*Helper) RequireBiosServiceClient ¶
RequireBiosServiceClient creates a firmware.BiosServiceClient, unless one already exists. You must add `SoftwareDeps: []string{"flashrom"},` to your `testing.Test` to use this.
func (*Helper) RequireConfig ¶
RequireConfig creates a firmware.Config, unless one already exists. This requires your test to have `Data: []string{firmware.ConfigFile},` in its `testing.Test` block.
func (*Helper) RequirePlatform ¶
RequirePlatform fetches the DUT's board and model and caches them, unless they have already been cached.
func (*Helper) RequireRPCClient ¶
RequireRPCClient creates a client connection to the DUT's gRPC server, unless a connection already exists.
func (*Helper) RequireRPCUtils ¶
RequireRPCUtils creates a firmware.UtilsServiceClient, unless one already exists.
func (*Helper) RequireRPM ¶
RequireRPM creates the RPM client in h.RPM.
func (*Helper) RequireServo ¶
RequireServo creates a servo.Servo, unless one already exists.
func (*Helper) SetDUTPower ¶
SetDUTPower turns the DUT's power on or off. Uses servo v4 pd role if possible, and falls back to RPM. To use RPM the command line vars `powerunitHostname` and `powerunitOutlet` must be set. `dutHostname` can be used to override the DUT's hostname, if ssh and rpm have different names. For plugs attached to hyrda, also set var `hydraHostname`.
func (*Helper) SetupUSBKey ¶
func (h *Helper) SetupUSBKey(ctx context.Context, cloudStorage *testing.CloudStorage) (retErr error)
SetupUSBKey prepares the USB disk for a test. (Borrowed from Tauto's firmware_test.py) It checks the setup of USB disk and a valid ChromeOS test image inside. Downloads the test image if the image isn't the right version. Will break the DUT if it is currently booted off the USB drive in recovery mode.
func (*Helper) SyncTastFilesToDUT ¶
SyncTastFilesToDUT copies the test server's copy of Tast host files back onto the DUT. This is only necessary if you want to use gRPC services. TODO(gredelston): When Autotest SSP tarballs contain local Tast test bundles, refactor this code so that it pushes Tast files to the DUT via the same means as the upstream Tast framework. As of the time of this writing, that is not possible; see http://g/tast-owners/sBhC1w-ET8g.
func (*Helper) WaitConnect ¶
func (h *Helper) WaitConnect(ctx context.Context, opts ...WaitConnectOption) error
WaitConnect is similar to DUT.WaitConnect, except that it works with RO EC firmware. Pass a context with a deadline if you don't want to wait forever. If --var noSSH=true is set, this degrades to waiting for S0 + a sleep.
type I2CCmd ¶
type I2CCmd string
I2CCmd type holds commands for interacting with i2c using the ectool.
const ( // I2CRead for the 'ectool i2cread <8 | 16> <port> <addr8> <offset>' cmd. I2CRead I2CCmd = "i2cread" // I2CSpeed for the 'ectool i2cspeed <port> [speed in kHz]' cmd. I2CSpeed I2CCmd = "i2cspeed" // I2CWrite for the 'ectool i2cwrite <8 | 16> <port> <addr8> <offset> <data>' cmd. I2CWrite I2CCmd = "i2cwrite" // I2Cxfer for the 'ectool i2cxfer <port> <addr7> <read_count> [bytes...]' cmd. I2Cxfer I2CCmd = "i2cxfer" )
type I2CLookupInfo ¶
I2CLookupInfo is a way to access the port and address of the i2c.
type ModeSwitchOption ¶
type ModeSwitchOption int
ModeSwitchOption allows mode-switching methods to exhibit different behaviors.
const ( // AllowGBBForce allows the DUT to force rebooting into dev mode via GBB flags. // This way of switching is more reliable, but is not appropriate for all tests. AllowGBBForce ModeSwitchOption = iota // AssumeGBBFlagsCorrect skips setting the GBB flags when switching modes. // This can save some time if the GBB flags are known to be in the desired state. AssumeGBBFlagsCorrect ModeSwitchOption = iota // CopyTastFiles copies the Tast files from the DUT before rebooting, and writes them back to the DUT afterwards. // This is necessary if you want to use any gRPC services. CopyTastFiles ModeSwitchOption = iota // SkipModeCheckAfterReboot can be passed in as an option to ModeAwareReboot, skipping // boot mode check after resetting DUT. One instance where this can be useful is // when verifying that FWMP prevents DUT from booting into dev mode. SkipModeCheckAfterReboot ModeSwitchOption = iota // PressEnterAtToNorm presses ENTER to allow DUT to continue to boot when dev mode disabled by FWMP. PressEnterAtToNorm ModeSwitchOption = iota )
type ModeSwitcher ¶
type ModeSwitcher struct {
Helper *Helper
}
ModeSwitcher enables booting the DUT into different firmware boot modes (normal, dev, rec).
func NewModeSwitcher ¶
func NewModeSwitcher(ctx context.Context, h *Helper) (*ModeSwitcher, error)
NewModeSwitcher creates a new ModeSwitcher. It relies on a firmware Helper to track dependent objects, such as servo and RPC client.
func (*ModeSwitcher) ModeAwareReboot ¶
func (ms *ModeSwitcher) ModeAwareReboot(ctx context.Context, resetType ResetType, opts ...ModeSwitchOption) error
ModeAwareReboot resets the DUT with awareness of the DUT boot mode. Dev mode will be retained, but rec mode will default back to normal mode. This has the side-effect of disconnecting the RPC connection.
func (*ModeSwitcher) PowerOff ¶
func (ms *ModeSwitcher) PowerOff(ctx context.Context) error
PowerOff safely powers off the DUT with the "poweroff" command, then waits for the DUT to be unreachable.
func (ModeSwitcher) RebootToMode ¶
func (ms ModeSwitcher) RebootToMode(ctx context.Context, toMode fwCommon.BootMode, opts ...ModeSwitchOption) error
RebootToMode reboots the DUT into the specified boot mode. This has the side-effect of disconnecting the RPC client. Requires `SoftwareDeps: []string{"crossystem", "flashrom"},`.
type ModeSwitcherType ¶
type ModeSwitcherType string
ModeSwitcherType represents which methods the platform uses for switching between DUT boot modes.
const ( JetStreamSwitcher ModeSwitcherType = "jetstream_switcher" KeyboardDevSwitcher ModeSwitcherType = "keyboard_dev_switcher" MenuSwitcher ModeSwitcherType = "menu_switcher" TabletDetachableSwitcher ModeSwitcherType = "tablet_detachable_switcher" )
Currently, there are exactly four possible values for ModeSwitcherType.
type ResetType ¶
type ResetType string
ResetType is an enum of ways to reset a DUT: warm and cold.
const ( // WarmReset uses the Servo control power_state=warm_reset. WarmReset ResetType = "warm" // ColdReset uses the Servo control power_state=reset. // It is identical to setting the power_state to off, then on. // It also resets the EC, as by the 'cold_reset' signal. ColdReset ResetType = "cold" )
There are two ResetTypes: warm and cold.
type USBEnablePin ¶
USBEnablePin represents each object in the list in the config files for the key "custom_usb_enable_pins".
type WaitConnectOption ¶
type WaitConnectOption string
WaitConnectOption includes situations to wait to connect from.
const ( // FromHibernation alerts WaitConnect to skip // on setting servo control while DUT is still // in the process of waking up from hibernation. FromHibernation WaitConnectOption = "hibernation" )
Directories ¶
Path | Synopsis |
---|---|
Package bios contains functions to support bios manipulation via servo.
|
Package bios contains functions to support bios manipulation via servo. |
Package checkers is a collection of canonical methods to verify test-relevant information about a DUT.
|
Package checkers is a collection of canonical methods to verify test-relevant information about a DUT. |
Package fingerprint is a collection of utilities to work with the firmware on the fingerprint microcontroller (FPMCU), e.g.
|
Package fingerprint is a collection of utilities to work with the firmware on the fingerprint microcontroller (FPMCU), e.g. |
rpcdut
Package rpcdut provides a dut.DUT override that adds an additional managed RPC client connection.
|
Package rpcdut provides a dut.DUT override that adds an additional managed RPC client connection. |
Package fixture implements fixtures for firmware tests.
|
Package fixture implements fixtures for firmware tests. |
Package reporters is a collection of canonical methods to obtain test-relevant information about a DUT.
|
Package reporters is a collection of canonical methods to obtain test-relevant information about a DUT. |
Package rpm contains an xmlrpc client for the RPM server, which turns power on and off in the test lab.
|
Package rpm contains an xmlrpc client for the RPM server, which turns power on and off in the test lab. |
Package serial allows communication with serial ports.
|
Package serial allows communication with serial ports. |
Package ti50 implements remote libraries for ti50 testing.
|
Package ti50 implements remote libraries for ti50 testing. |
dutcontrol
Package dutcontrol is generated from dutcontrol.proto in the ti50 repository.
|
Package dutcontrol is generated from dutcontrol.proto in the ti50 repository. |
fixture
Package fixture provides ti50 devboard related fixtures.
|
Package fixture provides ti50 devboard related fixtures. |