Ubertest is a blackbox regression test for flashrom. It requires two flashrom binaries, one of which is assumed to be an older or stable version and the other which is the new version being tested.
Tests can be run on the local host or on a remote machine (via SSH). Additionally, the ubertest script supports using a secondary programmer to check the result of the primary programmer.
Ubertest supports multiple modes of operation which allow regions to be flashed selectively based on presence of a layout file or integrated layout mapping:
The tests assume that we care about 4KiB and 64KiB sector/block sizes. Some large ROMs available today only support 64KiB block erase operations, however testing on large regions can be impractical for many devices. The --small-region option may be used to restrict tests to using a smaller amount of flash memory (currently 16KiB).
For a full list of options use -h/--help.
-n/--new <path>: New (unstable) flashrom binary to test. Also see Note 1 below.
-t/--type <type>: Type of test to run:
-p/--primary-programmer: Primary programmer options, e.g. “internal”, “ch341a_spi”, etc.
Note 1: When a remote host is used these options refer to files that are on the remote host, not the local host. See Testing on a Remote Host/DUT below.
Note 2: The script will default to using ${PATH}/flashrom if no old (presumably stable) flashrom binary is specified using -o/--old.
-b/--backup-image: Backup image that will be flashed to the target ROM unconditionally when the script is done. If unspecified, the script will read the ROM first using the stable flashrom binary to obtain a backup image. If remote host is used, backup image will be copied to local host’s temporary directory in case something goes terribly wrong. Also see Note 1 below.
-o/--old <path>: Old (stable) flashrom binary to test.
--custom-hooks: This allows the user to specify a script containing functions which are run at certain points during ubertest. These functions are intended to adapt the test script to the user’s environment. For example, the user can supply their own preflash_hook() and postflash_hook() to toggle power enable for the flash chip, instruct other devices with access to the flash chip to suspend access, etc.
--local-flashrom: If a remote host and a secondary programmer are used, then a local copy of flashrom is used to control the secondary programmer. This is because the “old” and “new” binaries reside on the remote host, and the secondary programmer is controlled from the local host. This defaults to sudo which flashrom.
-m/--mode <mode>: Mode to operate in (Mandatory if single test type is chosen):
--no-clean: Do not remove temporary files if the script succeeds. Temporary files remain in the event of failure whether or not this option is used. This option is intended for developers for debugging the script.
--skip-consistency-check: By default, the script will read the ROM twice as a sanity check for consistent readings. This option is intended for developers for faster iteration, but should not be used in most cases.
--small-region: Skip parts of the tests that require a large (>16KiB currently ) region to work with. This is useful for small or densely packed firmware ROMs (especially those on microcontrollers/ECs) that do not have space for the default set of tests which may assume minimum eraseblock size of 64KB.
-v/--voltage: Supply voltage (in millivolts) for chip.
Ubertest supports testing on a remote host via SSH. A remote host is specified by IP address or hostname using the -r/--remote-host option. If used, the remote host becomes the DUT. The remote host should accept non-interactive root login from the local host.
Remote testing modifies the meaning of arguments supplied to some options. In particular, paths specified to options such as -n, -o, -l, and -b will refer to files on the remote host’s filesystem instead of the local host’s filesystem.
To use a remote host as your DUT, use the following options:
-r/--remote-host <host>: The remote host by IP address or hostname.
--ssh-port <port>: Specify SSH port to use (default: 22).
Ubertest can be used with up to two programmers. The secondary programmer is used with the old/stable version of flashrom to verify the primary programmer and new version of flashrom at each step.
TODO: Change “secondary programmer” to “external programmer”? That could simplify the script significantly, especially in cases where a remote host + external programmer is used.
To use a secondary programmer, use the following options: -s/--secondary-programmer <parameters>: Specify the secondary programmer the same way you do with -p/--primary-programmer.
The purpose of ubertest is to automate a few simple tests in a way that can be invoked in a variety of environments (see Configurations / Setup).
The “single” mode tests boils down to:
--small-region is used.There are a few possible setups (shown below) involving a local machine, a remote machine, an external programmer, and the ROM to be tested. For the example commands in each setup the command takes a set of options, MY_OPTS. Depending on the type of test and potentially the mode, MY_OPTS will be different. To get the correct MY_OPTS for a specific test (and mode), see Examples (Basic) and Examples (Advanced) below. In general, any test type/mode can be run in any configuration.
flashrom$ sh util/ubertest/ubertest.sh -p ext_prog $MY_OPTS
flashrom$ sh util/ubertest/ubertest.sh -p internal $MY_OPTS
flashrom$ sh util/ubertest/ubertest.sh -r remote_host -p internal $MY_OPTS
flashrom$ sh util/ubertest/ubertest.sh -p internal -s ext_prog $MY_OPTS
flashrom # sh util/ubertest/ubertest.sh -p internal -s ext_prog -r remote_host $MY_OPTS
In this configuration the “old” and “new” flashrom binaries will be on the remote host. However in order to control the external programmer that will be used to check the result, a local flashrom binary must be supplied using --local-flashrom.
For each region layout mode, we will assume a different set of common options in MY_OPTS. For details on the possible configurations, as well as their corresponding example commands, see Configurations / Setup above.
MY_OPTS=”-n new_flashrom -o old_flashrom -t single -m clobber”
The clobber mode test will clobber (no surprise there!) the ROM with random content. If this operation is successful, then a partial write test will be run on the entire chip in order to test corner cases.
MY_OPTS=”-n new_flashrom -o old_flashrom -t single -m layout -l layout.txt -layout-region RW”
MY_OPTS=”-n new_flashrom -o old_flashrom -t single -m descriptor --descriptor-region bios”
MY_OPTS=”-n new_flashrom -o old_flashrom -t single -m flashmap --flashmap-region RW_SECTION”
For the following test types, we will assume the set of common options MY_OPTS. For details on each configuration, as well as the corresponding example command, see Configurations / Setup above.
MY_OPTS=”-n new_flashrom -o old_flashrom -t endurance”
The endurance test will repeatedly run single Clobber Mode tests until the first failure. This is intended to test the capabilities of the flash chip. It is important to note that a full test can take a while (potentially more than a week or two) to complete. The average time for one iteration of the endurance test using a remote host with a SPI ROM operating at 50MHz is around 100 seconds. This process will likely take longer for boards with larger chip sizes, and also longer for configurations that use an external programmer. At 1 iteration every 100 seconds, which is a relatively high speed, around 6048 iterations will be run in a week (probably a little less than that because the time spent between iterations will accumulate to a significant amount).
Authors: David Hendricks dhendrix@chromium.org, Souvik Ghosh
Original document short URL: https://goo.gl/3jNoL7
Original document long URL: https://docs.google.com/document/d/1IoBR7rHXJFiahC6dGnNKqaNFfg-q89_NMHuFyiJ7JnA/edit?usp=sharing
This document is licensed under a Creative Commons Attribution 3.0 Unported License. Feel free to copy, modify, and distribute this document however you see fit with attribution to the Flashrom Community.