blob: a9e4408d55f0a1c84f65010e437f5d62a7de6910 [file] [log] [blame]
Simon Glass8dfb1352021-03-15 18:11:20 +13001.. SPDX-License-Identifier: GPL-2.0+
2.. Copyright 2020 Google LLC
3.. sectionauthor:: Simon Glass <sjg@chromium.org>
Simon Glass5e73d3c2020-09-05 14:50:53 -06004
Simon Glass26784fc2017-05-31 17:57:24 -06005
Simon Glass8dfb1352021-03-15 18:11:20 +13006Running U-Boot with Chromium OS verified boot
7=============================================
Simon Glass26784fc2017-05-31 17:57:24 -06008
Simon Glass42220072021-06-27 17:51:11 -06009Note: Once you use the source below you can obtain extra documentation with
10'make htmldocs'. See the 'Internal Documentation' link, under
11'Chromium OS-specific doc'.
12
Simon Glass8dfb1352021-03-15 18:11:20 +130013To obtain::
Simon Glass26784fc2017-05-31 17:57:24 -060014
Simon Glass8dfb1352021-03-15 18:11:20 +130015 git clone https://github.com/sjg20/u-boot.git
Simon Glassa20a7b72019-01-30 20:51:20 -070016 cd u-boot
Simon Glass42220072021-06-27 17:51:11 -060017 git checkout cros-2021.04
Simon Glass26784fc2017-05-31 17:57:24 -060018
Simon Glass4872d932019-07-10 11:04:13 -060019 cd ..
20 git clone https://chromium.googlesource.com/chromiumos/platform/vboot_reference
21 cd vboot_reference
22 git checkout 45964294
23 # futility: updater: Correct output version for Snow
24
Simon Glass8dfb1352021-03-15 18:11:20 +130025To build for sandbox::
Simon Glass26784fc2017-05-31 17:57:24 -060026
Simon Glassa20a7b72019-01-30 20:51:20 -070027 UB=/tmp/b/chromeos_sandbox # U-Boot build directory
Simon Glass4872d932019-07-10 11:04:13 -060028 cd u-boot
29 make O=$UB chromeos_sandbox_defconfig
30 make O=$UB -j20 -s VBOOT_SOURCE=/path/to/vboot_reference \
Simon Glass8dfb1352021-03-15 18:11:20 +130031 MAKEFLAGS_VBOOT=DEBUG=1 QUIET=1
Simon Glass26784fc2017-05-31 17:57:24 -060032
Simon Glassa20a7b72019-01-30 20:51:20 -070033Replace sandbox with another supported target.
Simon Glass26784fc2017-05-31 17:57:24 -060034
Simon Glassa20a7b72019-01-30 20:51:20 -070035This produces $UB/image.bin which contains the firmware binaries in a SPI
36flash image.
Simon Glass26784fc2017-05-31 17:57:24 -060037
Simon Glass8dfb1352021-03-15 18:11:20 +130038To run on sandbox::
Simon Glass26784fc2017-05-31 17:57:24 -060039
Simon Glass8dfb1352021-03-15 18:11:20 +130040 CROS=~/cosarm
41 IMG=$CROS/src/build/images/coral/latest/chromiumos_image.bin
Simon Glassa20a7b72019-01-30 20:51:20 -070042 $UB/tpl/u-boot-tpl -d $UB/u-boot.dtb.out \
Simon Glass8dfb1352021-03-15 18:11:20 +130043 -L6 -c "host bind 0 $IMG; vboot go auto" \
44 -l -w -s state.dtb -r -n -m $UB/ram
45
46 $UB/tpl/u-boot-tpl -d $UB/u-boot.dtb.out -L6 -l \
47 -c "host bind 0 $IMG; vboot go auto" -w -s $UB/state.dtb -r -n -m $UB/mem
48
Simon Glass26784fc2017-05-31 17:57:24 -060049
Simon Glassa20a7b72019-01-30 20:51:20 -070050To run on other boards:
Simon Glass26784fc2017-05-31 17:57:24 -060051
Simon Glass8dfb1352021-03-15 18:11:20 +130052 - Install image.bin in the SPI flash of your device
53 - Boot your system
54
Simon Glass26784fc2017-05-31 17:57:24 -060055
Simon Glassa20a7b72019-01-30 20:51:20 -070056Sandbox
57-------
Simon Glass26784fc2017-05-31 17:57:24 -060058
Simon Glassa20a7b72019-01-30 20:51:20 -070059Most Chromium OS development with U-Boot is undertaken using sandbox. There is
60a sandbox target available (chromeos_sandbox) which allows running U-Boot on
61a Linux machine completion with emulations of the display, TPM, disk, etc.
Simon Glass26784fc2017-05-31 17:57:24 -060062
Simon Glassa20a7b72019-01-30 20:51:20 -070063Running sandbox starts TPL, which contains the first phase of vboot, providing
64a device tree and binding a Chromium OS disk image for use to find kernels
65(any Chromium OS image will do). It also saves driver state between U-Boot
66phases into state.dtb and will automatically ensure that memory is shared
67between all phases. TPL will jump to SPL and then on to U-Boot proper.
Simon Glass26784fc2017-05-31 17:57:24 -060068
Simon Glass8dfb1352021-03-15 18:11:20 +130069It is possible to run with debugging on, e.g.::
Simon Glass26784fc2017-05-31 17:57:24 -060070
Simon Glassa20a7b72019-01-30 20:51:20 -070071 gdb --args $UB/tpl/u-boot-tpl -d ....
Simon Glass26784fc2017-05-31 17:57:24 -060072
Simon Glassa20a7b72019-01-30 20:51:20 -070073Breakpoints can be set in any U-Boot phase. Overall this is a good debugging
74environment for new verified-boot features.
Simon Glass26784fc2017-05-31 17:57:24 -060075
Simon Glass26784fc2017-05-31 17:57:24 -060076
Simon Glassa20a7b72019-01-30 20:51:20 -070077Samus
78-----
Simon Glass26784fc2017-05-31 17:57:24 -060079
Simon Glassa20a7b72019-01-30 20:51:20 -070080Basic support is available for samus, using the chromeos_samus target. If you
Simon Glass8dfb1352021-03-15 18:11:20 +130081have an em100, use::
Simon Glass26784fc2017-05-31 17:57:24 -060082
Simon Glassa20a7b72019-01-30 20:51:20 -070083 sudo em100 -s -c W25Q128FW -d $UB/image.bin -t -r
Simon Glass26784fc2017-05-31 17:57:24 -060084
Simon Glassa20a7b72019-01-30 20:51:20 -070085to write the image and then boot samus (Power-Refresh).
Simon Glass26784fc2017-05-31 17:57:24 -060086
Simon Glass26784fc2017-05-31 17:57:24 -060087
Simon Glassa20a7b72019-01-30 20:51:20 -070088Boot flow
89---------
Simon Glass26784fc2017-05-31 17:57:24 -060090
Simon Glassa20a7b72019-01-30 20:51:20 -070091Verified boot starts in TPL, which selects the A or B SPL, which in turn selects
92the A or B U-Boot. Then this jumps to the selected kernel. If anything goes
93wrong, the device reboots and the recovery SPL and U-Boot are used instead.
Simon Glass26784fc2017-05-31 17:57:24 -060094
Simon Glassa20a7b72019-01-30 20:51:20 -070095More details are available here:
Simon Glass26784fc2017-05-31 17:57:24 -060096
Simon Glassa20a7b72019-01-30 20:51:20 -070097 https://www.chromium.org/chromium-os/chromiumos-design-docs/firmware-boot-and-recovery
Simon Glass26784fc2017-05-31 17:57:24 -060098
99
Simon Glassa20a7b72019-01-30 20:51:20 -0700100New uclasses
101------------
Simon Glass3421e002017-05-31 17:57:36 -0600102
Simon Glassa20a7b72019-01-30 20:51:20 -0700103Several uclasses are provided in cros/:
Simon Glass3421e002017-05-31 17:57:36 -0600104
Simon Glass8dfb1352021-03-15 18:11:20 +1300105UCLASS_CROS_AUX_FW
106 Chrome OS auxiliary firmware
107
108UCLASS_CROS_FWSTORE
109 Chrome OS firmware storage
110
111UCLASS_CROS_NVDATA
112 Chrome OS non-volatile data device
113
114UCLASS_CROS_VBOOT_EC
115 Chrome OS vboot EC operations
116
117UCLASS_CROS_VBOOT_FLAG
118 Chrome OS verified boot flag
Simon Glass3421e002017-05-31 17:57:36 -0600119
Simon Glassa20a7b72019-01-30 20:51:20 -0700120The existing UCLASS_CROS_EC is also used.
Simon Glass3421e002017-05-31 17:57:36 -0600121
Simon Glass3421e002017-05-31 17:57:36 -0600122
Simon Glassa20a7b72019-01-30 20:51:20 -0700123Commands
124--------
Simon Glass3421e002017-05-31 17:57:36 -0600125
Simon Glassa20a7b72019-01-30 20:51:20 -0700126A new 'vboot' command is provided to run particular vboot stages. The most
127useful command is 'vboot go auto', which continues where the last stage left
128off.
Simon Glass3421e002017-05-31 17:57:36 -0600129
Simon Glassa20a7b72019-01-30 20:51:20 -0700130Note that TPL and SPL do not supports commands as yet, so the vboot code is
131called directly from the SPL boot devices (BOOT_DEVICE_CROS_VBOOT). See
132cros_load_image_tpl() and cros_load_image_spl() which both call
133vboot_run_auto().
Simon Glass3421e002017-05-31 17:57:36 -0600134
Simon Glass3421e002017-05-31 17:57:36 -0600135
Simon Glassa20a7b72019-01-30 20:51:20 -0700136Config options
137--------------
Simon Glass3421e002017-05-31 17:57:36 -0600138
Simon Glassa20a7b72019-01-30 20:51:20 -0700139The main option is CONFIG_CHROMEOS, which enables a wide array of other options
140so that the required features are present.
Simon Glass3421e002017-05-31 17:57:36 -0600141
Simon Glass3421e002017-05-31 17:57:36 -0600142
Simon Glassa20a7b72019-01-30 20:51:20 -0700143Device-tree config
144------------------
Simon Glass3421e002017-05-31 17:57:36 -0600145
Simon Glassa20a7b72019-01-30 20:51:20 -0700146Various options are available which control the operation of verified boot.
147See cros/dts/bindings/config.txt for details. Most config is handled at run-
148time, although build-time config (with Kconfig) could also be added fairly
149easily.
Simon Glass3421e002017-05-31 17:57:36 -0600150
Simon Glass3421e002017-05-31 17:57:36 -0600151
Simon Glassa20a7b72019-01-30 20:51:20 -0700152Porting to other hardware
153-------------------------
Simon Glass3421e002017-05-31 17:57:36 -0600154
Simon Glassa20a7b72019-01-30 20:51:20 -0700155A basic port to samus (Chromebook Pixel 2015) is in a basic working state,
156using the chromeos_samus target. Patches will likely be forthcoming in early
1572019. Ports to an ARM board and coreboot (for x86 Chromebooks) are in the
158dreaming state.
Simon Glass3421e002017-05-31 17:57:36 -0600159
Simon Glass26784fc2017-05-31 17:57:24 -0600160
Simon Glassa20a7b72019-01-30 20:51:20 -0700161Tests
162-----
Simon Glass26784fc2017-05-31 17:57:24 -0600163
Simon Glassa20a7b72019-01-30 20:51:20 -0700164Chromium OS firmware has a very limited set of tests. The tests that originally
165existed in U-Boot were not brought over to coreboot or depthcharge.
Simon Glass26784fc2017-05-31 17:57:24 -0600166
Simon Glassa20a7b72019-01-30 20:51:20 -0700167The U-Boot tests ('make check') do operate, but at present there are no
168Chromium OS tests available. These will hopefully come together over time. Of
169course the above sandbox feature provides a sort of functional test and can
Simon Glass0167f192020-09-05 14:50:52 -0600170detect problems that affect the flow or particular vboot features.
Simon Glass26784fc2017-05-31 17:57:24 -0600171
172
Simon Glass5e73d3c2020-09-05 14:50:53 -0600173U-Boot without Chromium OS verified boot
174----------------------------------------
175
Simon Glass42220072021-06-27 17:51:11 -0600176The following script can be used to boot a Chrome OS image on coral. It is
177defined as the boot command in mainline::
Simon Glass5e73d3c2020-09-05 14:50:53 -0600178
179 # Read the image header and obtain the address of the kernel
180 # The offset 4f0 is defined by verified boot and may change for other
181 # Chromebooks
182 read mmc 2:2 100000 0 80; setexpr loader *001004f0;
183
184 # Get the kernel size and calculate the number of blocks (0x200 bytes each)
185 setexpr size *00100518; setexpr blocks $size / 200;
186
187 # Read the full kernel and calculate the address of the setup block
188 read mmc 2:2 100000 80 $blocks; setexpr setup $loader - 1000;
189
190 # Locate the command line
191 setexpr cmdline $loader - 2000;
192
193 # Start the zboot process with the loaded kernel, setup block and cmdline
194 zboot start 100000 0 0 0 $setup $cmdline;
195
196 # Load the kernel, fix up the 'setup' block, dump information
197 zboot load; zboot setup; zboot dump
198
199 # Boot into Chrome OS
200 zboot go
201
202
Simon Glassa20a7b72019-01-30 20:51:20 -07002037 October 2018