blob: a9e4408d55f0a1c84f65010e437f5d62a7de6910 [file] [log] [blame]
Simon Glass2d0423a2021-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 Glassd9778ff2020-09-05 14:50:53 -06004
Simon Glassc9af6672017-05-31 17:57:24 -06005
Simon Glass2d0423a2021-03-15 18:11:20 +13006Running U-Boot with Chromium OS verified boot
7=============================================
Simon Glassc9af6672017-05-31 17:57:24 -06008
Simon Glass4db474a2021-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 Glass2d0423a2021-03-15 18:11:20 +130013To obtain::
Simon Glassc9af6672017-05-31 17:57:24 -060014
Simon Glass2d0423a2021-03-15 18:11:20 +130015 git clone https://github.com/sjg20/u-boot.git
Simon Glass9d73e852019-01-30 20:51:20 -070016 cd u-boot
Simon Glass4db474a2021-06-27 17:51:11 -060017 git checkout cros-2021.04
Simon Glassc9af6672017-05-31 17:57:24 -060018
Simon Glass1b96da62019-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 Glass2d0423a2021-03-15 18:11:20 +130025To build for sandbox::
Simon Glass9d73e852019-01-30 20:51:20 -070026
27 UB=/tmp/b/chromeos_sandbox # U-Boot build directory
Simon Glass1b96da62019-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 Glass2d0423a2021-03-15 18:11:20 +130031 MAKEFLAGS_VBOOT=DEBUG=1 QUIET=1
Simon Glass9d73e852019-01-30 20:51:20 -070032
33Replace sandbox with another supported target.
34
35This produces $UB/image.bin which contains the firmware binaries in a SPI
36flash image.
37
Simon Glass2d0423a2021-03-15 18:11:20 +130038To run on sandbox::
Simon Glass9d73e852019-01-30 20:51:20 -070039
Simon Glass2d0423a2021-03-15 18:11:20 +130040 CROS=~/cosarm
41 IMG=$CROS/src/build/images/coral/latest/chromiumos_image.bin
Simon Glass9d73e852019-01-30 20:51:20 -070042 $UB/tpl/u-boot-tpl -d $UB/u-boot.dtb.out \
Simon Glass2d0423a2021-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 Glass9d73e852019-01-30 20:51:20 -070049
50To run on other boards:
Simon Glass2d0423a2021-03-15 18:11:20 +130051
52 - Install image.bin in the SPI flash of your device
53 - Boot your system
Simon Glassc9af6672017-05-31 17:57:24 -060054
55
Simon Glass9d73e852019-01-30 20:51:20 -070056Sandbox
57-------
Simon Glassc9af6672017-05-31 17:57:24 -060058
Simon Glass9d73e852019-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 Glassc9af6672017-05-31 17:57:24 -060062
Simon Glass9d73e852019-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.
68
Simon Glass2d0423a2021-03-15 18:11:20 +130069It is possible to run with debugging on, e.g.::
Simon Glass9d73e852019-01-30 20:51:20 -070070
71 gdb --args $UB/tpl/u-boot-tpl -d ....
72
73Breakpoints can be set in any U-Boot phase. Overall this is a good debugging
74environment for new verified-boot features.
Simon Glassc9af6672017-05-31 17:57:24 -060075
76
Simon Glass9d73e852019-01-30 20:51:20 -070077Samus
78-----
79
80Basic support is available for samus, using the chromeos_samus target. If you
Simon Glass2d0423a2021-03-15 18:11:20 +130081have an em100, use::
Simon Glass9d73e852019-01-30 20:51:20 -070082
83 sudo em100 -s -c W25Q128FW -d $UB/image.bin -t -r
84
85to write the image and then boot samus (Power-Refresh).
86
87
88Boot flow
89---------
90
91Verified 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.
94
95More details are available here:
96
97 https://www.chromium.org/chromium-os/chromiumos-design-docs/firmware-boot-and-recovery
98
99
100New uclasses
101------------
102
103Several uclasses are provided in cros/:
104
Simon Glass2d0423a2021-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 Glass9d73e852019-01-30 20:51:20 -0700119
120The existing UCLASS_CROS_EC is also used.
121
122
123Commands
Simon Glassc9af6672017-05-31 17:57:24 -0600124--------
125
Simon Glass9d73e852019-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 Glassc9af6672017-05-31 17:57:24 -0600129
Simon Glass9d73e852019-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 Glassc9af6672017-05-31 17:57:24 -0600134
Simon Glassc9af6672017-05-31 17:57:24 -0600135
Simon Glass9d73e852019-01-30 20:51:20 -0700136Config options
137--------------
Simon Glassc9af6672017-05-31 17:57:24 -0600138
Simon Glass9d73e852019-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 Glassc9af6672017-05-31 17:57:24 -0600141
Simon Glassc9af6672017-05-31 17:57:24 -0600142
Simon Glass9d73e852019-01-30 20:51:20 -0700143Device-tree config
144------------------
Simon Glassc9af6672017-05-31 17:57:24 -0600145
Simon Glass9d73e852019-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 Glassc9af6672017-05-31 17:57:24 -0600150
Simon Glassc9af6672017-05-31 17:57:24 -0600151
Simon Glass9d73e852019-01-30 20:51:20 -0700152Porting to other hardware
153-------------------------
Simon Glassc9af6672017-05-31 17:57:24 -0600154
Simon Glass9d73e852019-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 Glassc9af6672017-05-31 17:57:24 -0600159
Simon Glassc9af6672017-05-31 17:57:24 -0600160
Simon Glass9d73e852019-01-30 20:51:20 -0700161Tests
162-----
Simon Glassc9af6672017-05-31 17:57:24 -0600163
Simon Glass9d73e852019-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 Glassc9af6672017-05-31 17:57:24 -0600166
Simon Glass9d73e852019-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 Glassdc8e7a92020-09-05 14:50:52 -0600170detect problems that affect the flow or particular vboot features.
Simon Glassc9af6672017-05-31 17:57:24 -0600171
Simon Glassc9af6672017-05-31 17:57:24 -0600172
Simon Glassd9778ff2020-09-05 14:50:53 -0600173U-Boot without Chromium OS verified boot
174----------------------------------------
175
Simon Glass4db474a2021-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 Glassd9778ff2020-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 Glass9d73e852019-01-30 20:51:20 -07002037 October 2018