xref: /aosp_15_r20/external/flashrom/util/ubertest/README.md (revision 0d6140be3aa665ecc836e8907834fcd3e3b018fc)
1*0d6140beSAndroid Build Coastguard Worker# Ubertest
2*0d6140beSAndroid Build Coastguard Worker## Intro / Features
3*0d6140beSAndroid Build Coastguard Worker
4*0d6140beSAndroid Build Coastguard WorkerUbertest 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.
5*0d6140beSAndroid Build Coastguard Worker
6*0d6140beSAndroid Build Coastguard WorkerTests 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.
7*0d6140beSAndroid Build Coastguard Worker
8*0d6140beSAndroid Build Coastguard WorkerUbertest supports multiple modes of operation which allow regions to be flashed selectively based on presence of a layout file or integrated layout mapping:
9*0d6140beSAndroid Build Coastguard Worker- Clobber mode: The entire ROM can be used for testing.
10*0d6140beSAndroid Build Coastguard Worker- Layout mode: Target a region using a flashrom layout file.
11*0d6140beSAndroid Build Coastguard Worker- Descriptor mode: Target a region using an Intel flash descriptor (Intel systems)
12*0d6140beSAndroid Build Coastguard Worker- Flashmap mode: Target a region using a flashmap
13*0d6140beSAndroid Build Coastguard Worker
14*0d6140beSAndroid Build Coastguard WorkerThe 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).
15*0d6140beSAndroid Build Coastguard Worker
16*0d6140beSAndroid Build Coastguard Worker### Terminology
17*0d6140beSAndroid Build Coastguard Worker
18*0d6140beSAndroid Build Coastguard Worker- DUT: Device under test
19*0d6140beSAndroid Build Coastguard Worker- Local host: The machine which is running the script. It might also be the DUT.
20*0d6140beSAndroid Build Coastguard Worker- Remote machine: DUT controlled via SSH with primary programmer.
21*0d6140beSAndroid Build Coastguard WorkerProgrammers
22*0d6140beSAndroid Build Coastguard Worker	- Primary programmer: The programmer which will be tested using the new version of flashrom.
23*0d6140beSAndroid Build Coastguard Worker	- Secondary programmer: An optional programmer which will be used along with the old version of flashrom to verify the result of the primary programmer. This is generally assumed to be an external programmer connected to the local host e.g. via USB or serial. It may also be a secondary internal interface, for example if the DUT has a SPI ROM and both linux_spi and linux_mtd support and the developer wishes to test one against the other.
24*0d6140beSAndroid Build Coastguard Worker
25*0d6140beSAndroid Build Coastguard Worker## Basic Usage
26*0d6140beSAndroid Build Coastguard Worker
27*0d6140beSAndroid Build Coastguard WorkerFor a full list of options use `-h/--help`.
28*0d6140beSAndroid Build Coastguard Worker
29*0d6140beSAndroid Build Coastguard Worker### Mandatory Options
30*0d6140beSAndroid Build Coastguard Worker
31*0d6140beSAndroid Build Coastguard Worker`-n/--new <path>`: New (unstable) flashrom binary to test. Also see Note 1 below.
32*0d6140beSAndroid Build Coastguard Worker
33*0d6140beSAndroid Build Coastguard Worker`-t/--type <type>`: Type of test to run:
34*0d6140beSAndroid Build Coastguard Worker- Single test: A single test of the specified mode will be run. If this type is selected, then a mode must also be specified.
35*0d6140beSAndroid Build Coastguard Worker- Endurance test: The ROM will be erased/written with random content until the first failure.
36*0d6140beSAndroid Build Coastguard Worker
37*0d6140beSAndroid Build Coastguard Worker`-p/--primary-programmer`: Primary programmer options, e.g. “internal”, “ch341a_spi”, etc.
38*0d6140beSAndroid Build Coastguard Worker
39*0d6140beSAndroid Build Coastguard Worker**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.
40*0d6140beSAndroid Build Coastguard Worker
41*0d6140beSAndroid Build Coastguard Worker**Note 2**: The script will default to using ${PATH}/flashrom if no old (presumably stable) flashrom binary is specified using -o/--old.
42*0d6140beSAndroid Build Coastguard Worker
43*0d6140beSAndroid Build Coastguard Worker### Other Options
44*0d6140beSAndroid Build Coastguard Worker
45*0d6140beSAndroid Build Coastguard Worker`-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.
46*0d6140beSAndroid Build Coastguard Worker
47*0d6140beSAndroid Build Coastguard Worker`-o/--old <path>`: Old (stable) flashrom binary to test.
48*0d6140beSAndroid Build Coastguard Worker
49*0d6140beSAndroid Build Coastguard Worker`--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.
50*0d6140beSAndroid Build Coastguard Worker
51*0d6140beSAndroid Build Coastguard Worker`--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`.
52*0d6140beSAndroid Build Coastguard Worker
53*0d6140beSAndroid Build Coastguard Worker`-m/--mode <mode>`: Mode to operate in (Mandatory if single test type is chosen):
54*0d6140beSAndroid Build Coastguard Worker- Clobber mode: Any portion of the ROM may be used for testing.
55*0d6140beSAndroid Build Coastguard Worker- Layout mode: Portions specified using a layout file will be erased/written. A layout file must be provided using -l/--layout-file option. The user may specify a region to use for testing with the --layout-region option.
56*0d6140beSAndroid Build Coastguard Worker- Descriptor mode (Intel systems only): Flashrom will read the flash descriptor from the DUT’s firmware ROM to determine which region to write to. The user may specify a region to use for testing with the --descriptor-region option.
57*0d6140beSAndroid Build Coastguard Worker- Flashmap mode: Flashrom will read the flashmap from the DUT’s firmware ROM to determine which region to write to. The user may specify a region to use for testing with the --flashmap-region option.
58*0d6140beSAndroid Build Coastguard Worker
59*0d6140beSAndroid Build Coastguard Worker`--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.
60*0d6140beSAndroid Build Coastguard Worker
61*0d6140beSAndroid Build Coastguard Worker`--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.
62*0d6140beSAndroid Build Coastguard Worker
63*0d6140beSAndroid Build Coastguard Worker`--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.
64*0d6140beSAndroid Build Coastguard Worker
65*0d6140beSAndroid Build Coastguard Worker`-v/--voltage`: Supply voltage (in millivolts) for chip.
66*0d6140beSAndroid Build Coastguard Worker
67*0d6140beSAndroid Build Coastguard Worker## Testing on a Remote Host/DUT
68*0d6140beSAndroid Build Coastguard Worker
69*0d6140beSAndroid Build Coastguard WorkerUbertest 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.
70*0d6140beSAndroid Build Coastguard Worker
71*0d6140beSAndroid Build Coastguard WorkerRemote 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.
72*0d6140beSAndroid Build Coastguard Worker
73*0d6140beSAndroid Build Coastguard WorkerTo use a remote host as your DUT, use the following options:
74*0d6140beSAndroid Build Coastguard Worker
75*0d6140beSAndroid Build Coastguard Worker`-r/--remote-host <host>`: The remote host by IP address or hostname.
76*0d6140beSAndroid Build Coastguard Worker
77*0d6140beSAndroid Build Coastguard Worker`--ssh-port <port>`: Specify SSH port to use (default: 22).
78*0d6140beSAndroid Build Coastguard Worker
79*0d6140beSAndroid Build Coastguard Worker## Testing With a Secondary Programmer
80*0d6140beSAndroid Build Coastguard Worker
81*0d6140beSAndroid Build Coastguard WorkerUbertest 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.
82*0d6140beSAndroid Build Coastguard Worker
83*0d6140beSAndroid Build Coastguard WorkerTODO: Change “secondary programmer” to “external programmer”? That could simplify the script significantly, especially in cases where a remote host + external programmer is used.
84*0d6140beSAndroid Build Coastguard Worker
85*0d6140beSAndroid Build Coastguard WorkerTo use a secondary programmer, use the following options:
86*0d6140beSAndroid Build Coastguard Worker`-s/--secondary-programmer <parameters>`: Specify the secondary programmer the same way you do with -p/--primary-programmer.
87*0d6140beSAndroid Build Coastguard Worker
88*0d6140beSAndroid Build Coastguard Worker## Test methods / examples
89*0d6140beSAndroid Build Coastguard Worker
90*0d6140beSAndroid Build Coastguard WorkerThe 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).
91*0d6140beSAndroid Build Coastguard Worker
92*0d6140beSAndroid Build Coastguard WorkerThe “single” mode tests boils down to:
93*0d6140beSAndroid Build Coastguard Worker- Read the targeted section of the ROM twice to check for consistency.
94*0d6140beSAndroid Build Coastguard Worker- Test 4KiB block write capabilities:
95*0d6140beSAndroid Build Coastguard Worker- Write the lower half of a block and ensuring that data in the upper half is restored to its original state.
96*0d6140beSAndroid Build Coastguard Worker- Write over the boundary of two blocks, ensuring the data outside the targeted region is restored to its original state.
97*0d6140beSAndroid Build Coastguard Worker- Write the upper half of a block, ensuring that data in the lower half restored to its original state
98*0d6140beSAndroid Build Coastguard Worker- Write a full block.
99*0d6140beSAndroid Build Coastguard Worker- Repeat step 2 for 64KiB blocks unless `--small-region` is used.
100*0d6140beSAndroid Build Coastguard Worker
101*0d6140beSAndroid Build Coastguard Worker### Configurations / Setup
102*0d6140beSAndroid Build Coastguard WorkerThere 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.
103*0d6140beSAndroid Build Coastguard Worker
104*0d6140beSAndroid Build Coastguard Worker#### Targeting external ROM connected to an external programmer
105*0d6140beSAndroid Build Coastguard Worker
106*0d6140beSAndroid Build Coastguard Worker`flashrom$ sh util/ubertest/ubertest.sh -p ext_prog $MY_OPTS`
107*0d6140beSAndroid Build Coastguard Worker
108*0d6140beSAndroid Build Coastguard Worker![external programmer, external ROM](drawing_external_programmer_external_rom.svg)
109*0d6140beSAndroid Build Coastguard Worker
110*0d6140beSAndroid Build Coastguard Worker#### Targeting local host’s ROM using internal programmer
111*0d6140beSAndroid Build Coastguard Worker
112*0d6140beSAndroid Build Coastguard Worker`flashrom$ sh util/ubertest/ubertest.sh -p internal $MY_OPTS`
113*0d6140beSAndroid Build Coastguard Worker
114*0d6140beSAndroid Build Coastguard Worker![local programmer is dut](drawing_local_programmer_is_dut.svg)
115*0d6140beSAndroid Build Coastguard Worker
116*0d6140beSAndroid Build Coastguard Worker#### Targeting remote host's ROM using its internal programmer
117*0d6140beSAndroid Build Coastguard Worker
118*0d6140beSAndroid Build Coastguard Worker`flashrom$ sh util/ubertest/ubertest.sh -r remote_host -p internal $MY_OPTS`
119*0d6140beSAndroid Build Coastguard Worker
120*0d6140beSAndroid Build Coastguard Worker![remote host is remote dut](drawing_remote_host_is_remote_dut.svg)
121*0d6140beSAndroid Build Coastguard Worker
122*0d6140beSAndroid Build Coastguard Worker#### Targeting local host’s ROM using external programmer
123*0d6140beSAndroid Build Coastguard Worker
124*0d6140beSAndroid Build Coastguard Worker`flashrom$ sh util/ubertest/ubertest.sh -p internal -s ext_prog $MY_OPTS`
125*0d6140beSAndroid Build Coastguard Worker
126*0d6140beSAndroid Build Coastguard Worker![external programmer targeting local dut](drawing_external_programmer_local_dut.svg)
127*0d6140beSAndroid Build Coastguard Worker
128*0d6140beSAndroid Build Coastguard Worker#### Targeting remote host's ROM using its internal programmer, and checking the result using an external (secondary) programmer
129*0d6140beSAndroid Build Coastguard Worker`flashrom # sh util/ubertest/ubertest.sh -p internal -s ext_prog -r remote_host $MY_OPTS`
130*0d6140beSAndroid Build Coastguard Worker
131*0d6140beSAndroid Build Coastguard WorkerIn 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`.
132*0d6140beSAndroid Build Coastguard Worker
133*0d6140beSAndroid Build Coastguard Worker![external programmer targeting external dut](drawing_external_programmer_remote_dut.svg)
134*0d6140beSAndroid Build Coastguard Worker
135*0d6140beSAndroid Build Coastguard Worker### Examples (Basic)
136*0d6140beSAndroid Build Coastguard Worker#### Single Test
137*0d6140beSAndroid Build Coastguard Worker
138*0d6140beSAndroid Build Coastguard WorkerFor 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.
139*0d6140beSAndroid Build Coastguard Worker
140*0d6140beSAndroid Build Coastguard Worker#### Clobber Mode
141*0d6140beSAndroid Build Coastguard Worker
142*0d6140beSAndroid Build Coastguard Worker`MY_OPTS=”-n new_flashrom -o old_flashrom -t single -m clobber”`
143*0d6140beSAndroid Build Coastguard Worker
144*0d6140beSAndroid Build Coastguard WorkerThe 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.
145*0d6140beSAndroid Build Coastguard Worker
146*0d6140beSAndroid Build Coastguard Worker#### Layout Mode
147*0d6140beSAndroid Build Coastguard Worker
148*0d6140beSAndroid Build Coastguard Worker`MY_OPTS=”-n new_flashrom -o old_flashrom -t single -m layout -l layout.txt -layout-region RW”`
149*0d6140beSAndroid Build Coastguard Worker
150*0d6140beSAndroid Build Coastguard Worker#### Descriptor Mode
151*0d6140beSAndroid Build Coastguard Worker
152*0d6140beSAndroid Build Coastguard Worker`MY_OPTS=”-n new_flashrom -o old_flashrom -t single -m descriptor --descriptor-region bios”`
153*0d6140beSAndroid Build Coastguard Worker
154*0d6140beSAndroid Build Coastguard Worker#### Flashmap Mode
155*0d6140beSAndroid Build Coastguard Worker
156*0d6140beSAndroid Build Coastguard Worker`MY_OPTS=”-n new_flashrom -o old_flashrom -t single -m flashmap --flashmap-region RW_SECTION”`
157*0d6140beSAndroid Build Coastguard Worker
158*0d6140beSAndroid Build Coastguard Worker### Examples (Advanced)
159*0d6140beSAndroid Build Coastguard Worker
160*0d6140beSAndroid Build Coastguard WorkerFor 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.
161*0d6140beSAndroid Build Coastguard Worker
162*0d6140beSAndroid Build Coastguard Worker##### Endurance Test
163*0d6140beSAndroid Build Coastguard Worker`MY_OPTS=”-n new_flashrom -o old_flashrom -t endurance”`
164*0d6140beSAndroid Build Coastguard Worker
165*0d6140beSAndroid Build Coastguard WorkerThe 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).
166*0d6140beSAndroid Build Coastguard Worker
167*0d6140beSAndroid Build Coastguard Worker
168*0d6140beSAndroid Build Coastguard Worker## Document Information
169*0d6140beSAndroid Build Coastguard WorkerAuthors: David Hendricks <[email protected]>, Souvik Ghosh
170*0d6140beSAndroid Build Coastguard Worker
171*0d6140beSAndroid Build Coastguard WorkerOriginal document short URL: <https://goo.gl/3jNoL7>
172*0d6140beSAndroid Build Coastguard Worker
173*0d6140beSAndroid Build Coastguard WorkerOriginal document long URL: <https://docs.google.com/document/d/1IoBR7rHXJFiahC6dGnNKqaNFfg-q89_NMHuFyiJ7JnA/edit?usp=sharing>
174*0d6140beSAndroid Build Coastguard Worker
175*0d6140beSAndroid Build Coastguard WorkerThis 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.
176