Simon Glass | 2d0423a | 2021-03-15 18:11:20 +1300 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | .. Copyright 2020 Google LLC |
| 3 | .. sectionauthor:: Simon Glass <sjg@chromium.org> |
Simon Glass | d9778ff | 2020-09-05 14:50:53 -0600 | [diff] [blame] | 4 | |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 5 | |
Simon Glass | 2d0423a | 2021-03-15 18:11:20 +1300 | [diff] [blame] | 6 | Running U-Boot with Chromium OS verified boot |
| 7 | ============================================= |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 8 | |
Simon Glass | 4db474a | 2021-06-27 17:51:11 -0600 | [diff] [blame] | 9 | Note: 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 Glass | 2d0423a | 2021-03-15 18:11:20 +1300 | [diff] [blame] | 13 | To obtain:: |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 14 | |
Simon Glass | 2d0423a | 2021-03-15 18:11:20 +1300 | [diff] [blame] | 15 | git clone https://github.com/sjg20/u-boot.git |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 16 | cd u-boot |
Simon Glass | 4db474a | 2021-06-27 17:51:11 -0600 | [diff] [blame] | 17 | git checkout cros-2021.04 |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 18 | |
Simon Glass | 1b96da6 | 2019-07-10 11:04:13 -0600 | [diff] [blame] | 19 | 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 Glass | 2d0423a | 2021-03-15 18:11:20 +1300 | [diff] [blame] | 25 | To build for sandbox:: |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 26 | |
| 27 | UB=/tmp/b/chromeos_sandbox # U-Boot build directory |
Simon Glass | 1b96da6 | 2019-07-10 11:04:13 -0600 | [diff] [blame] | 28 | cd u-boot |
| 29 | make O=$UB chromeos_sandbox_defconfig |
| 30 | make O=$UB -j20 -s VBOOT_SOURCE=/path/to/vboot_reference \ |
Simon Glass | 2d0423a | 2021-03-15 18:11:20 +1300 | [diff] [blame] | 31 | MAKEFLAGS_VBOOT=DEBUG=1 QUIET=1 |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 32 | |
| 33 | Replace sandbox with another supported target. |
| 34 | |
| 35 | This produces $UB/image.bin which contains the firmware binaries in a SPI |
| 36 | flash image. |
| 37 | |
Simon Glass | 2d0423a | 2021-03-15 18:11:20 +1300 | [diff] [blame] | 38 | To run on sandbox:: |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 39 | |
Simon Glass | 2d0423a | 2021-03-15 18:11:20 +1300 | [diff] [blame] | 40 | CROS=~/cosarm |
| 41 | IMG=$CROS/src/build/images/coral/latest/chromiumos_image.bin |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 42 | $UB/tpl/u-boot-tpl -d $UB/u-boot.dtb.out \ |
Simon Glass | 2d0423a | 2021-03-15 18:11:20 +1300 | [diff] [blame] | 43 | -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 Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 49 | |
| 50 | To run on other boards: |
Simon Glass | 2d0423a | 2021-03-15 18:11:20 +1300 | [diff] [blame] | 51 | |
| 52 | - Install image.bin in the SPI flash of your device |
| 53 | - Boot your system |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 54 | |
| 55 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 56 | Sandbox |
| 57 | ------- |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 58 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 59 | Most Chromium OS development with U-Boot is undertaken using sandbox. There is |
| 60 | a sandbox target available (chromeos_sandbox) which allows running U-Boot on |
| 61 | a Linux machine completion with emulations of the display, TPM, disk, etc. |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 62 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 63 | Running sandbox starts TPL, which contains the first phase of vboot, providing |
| 64 | a 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 |
| 66 | phases into state.dtb and will automatically ensure that memory is shared |
| 67 | between all phases. TPL will jump to SPL and then on to U-Boot proper. |
| 68 | |
Simon Glass | 2d0423a | 2021-03-15 18:11:20 +1300 | [diff] [blame] | 69 | It is possible to run with debugging on, e.g.:: |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 70 | |
| 71 | gdb --args $UB/tpl/u-boot-tpl -d .... |
| 72 | |
| 73 | Breakpoints can be set in any U-Boot phase. Overall this is a good debugging |
| 74 | environment for new verified-boot features. |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 75 | |
| 76 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 77 | Samus |
| 78 | ----- |
| 79 | |
| 80 | Basic support is available for samus, using the chromeos_samus target. If you |
Simon Glass | 2d0423a | 2021-03-15 18:11:20 +1300 | [diff] [blame] | 81 | have an em100, use:: |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 82 | |
| 83 | sudo em100 -s -c W25Q128FW -d $UB/image.bin -t -r |
| 84 | |
| 85 | to write the image and then boot samus (Power-Refresh). |
| 86 | |
| 87 | |
| 88 | Boot flow |
| 89 | --------- |
| 90 | |
| 91 | Verified boot starts in TPL, which selects the A or B SPL, which in turn selects |
| 92 | the A or B U-Boot. Then this jumps to the selected kernel. If anything goes |
| 93 | wrong, the device reboots and the recovery SPL and U-Boot are used instead. |
| 94 | |
| 95 | More details are available here: |
| 96 | |
| 97 | https://www.chromium.org/chromium-os/chromiumos-design-docs/firmware-boot-and-recovery |
| 98 | |
| 99 | |
| 100 | New uclasses |
| 101 | ------------ |
| 102 | |
| 103 | Several uclasses are provided in cros/: |
| 104 | |
Simon Glass | 2d0423a | 2021-03-15 18:11:20 +1300 | [diff] [blame] | 105 | UCLASS_CROS_AUX_FW |
| 106 | Chrome OS auxiliary firmware |
| 107 | |
| 108 | UCLASS_CROS_FWSTORE |
| 109 | Chrome OS firmware storage |
| 110 | |
| 111 | UCLASS_CROS_NVDATA |
| 112 | Chrome OS non-volatile data device |
| 113 | |
| 114 | UCLASS_CROS_VBOOT_EC |
| 115 | Chrome OS vboot EC operations |
| 116 | |
| 117 | UCLASS_CROS_VBOOT_FLAG |
| 118 | Chrome OS verified boot flag |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 119 | |
| 120 | The existing UCLASS_CROS_EC is also used. |
| 121 | |
| 122 | |
| 123 | Commands |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 124 | -------- |
| 125 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 126 | A new 'vboot' command is provided to run particular vboot stages. The most |
| 127 | useful command is 'vboot go auto', which continues where the last stage left |
| 128 | off. |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 129 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 130 | Note that TPL and SPL do not supports commands as yet, so the vboot code is |
| 131 | called directly from the SPL boot devices (BOOT_DEVICE_CROS_VBOOT). See |
| 132 | cros_load_image_tpl() and cros_load_image_spl() which both call |
| 133 | vboot_run_auto(). |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 134 | |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 135 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 136 | Config options |
| 137 | -------------- |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 138 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 139 | The main option is CONFIG_CHROMEOS, which enables a wide array of other options |
| 140 | so that the required features are present. |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 141 | |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 142 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 143 | Device-tree config |
| 144 | ------------------ |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 145 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 146 | Various options are available which control the operation of verified boot. |
| 147 | See cros/dts/bindings/config.txt for details. Most config is handled at run- |
| 148 | time, although build-time config (with Kconfig) could also be added fairly |
| 149 | easily. |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 150 | |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 151 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 152 | Porting to other hardware |
| 153 | ------------------------- |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 154 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 155 | A basic port to samus (Chromebook Pixel 2015) is in a basic working state, |
| 156 | using the chromeos_samus target. Patches will likely be forthcoming in early |
| 157 | 2019. Ports to an ARM board and coreboot (for x86 Chromebooks) are in the |
| 158 | dreaming state. |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 159 | |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 160 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 161 | Tests |
| 162 | ----- |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 163 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 164 | Chromium OS firmware has a very limited set of tests. The tests that originally |
| 165 | existed in U-Boot were not brought over to coreboot or depthcharge. |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 166 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 167 | The U-Boot tests ('make check') do operate, but at present there are no |
| 168 | Chromium OS tests available. These will hopefully come together over time. Of |
| 169 | course the above sandbox feature provides a sort of functional test and can |
Simon Glass | dc8e7a9 | 2020-09-05 14:50:52 -0600 | [diff] [blame] | 170 | detect problems that affect the flow or particular vboot features. |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 171 | |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 172 | |
Simon Glass | d9778ff | 2020-09-05 14:50:53 -0600 | [diff] [blame] | 173 | U-Boot without Chromium OS verified boot |
| 174 | ---------------------------------------- |
| 175 | |
Simon Glass | 4db474a | 2021-06-27 17:51:11 -0600 | [diff] [blame] | 176 | The following script can be used to boot a Chrome OS image on coral. It is |
| 177 | defined as the boot command in mainline:: |
Simon Glass | d9778ff | 2020-09-05 14:50:53 -0600 | [diff] [blame] | 178 | |
| 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 Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 203 | 7 October 2018 |