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 | 2d0423a | 2021-03-15 18:11:20 +1300 | [diff] [blame] | 9 | To obtain:: |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 10 | |
Simon Glass | 2d0423a | 2021-03-15 18:11:20 +1300 | [diff] [blame] | 11 | git clone https://github.com/sjg20/u-boot.git |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 12 | cd u-boot |
| 13 | git checkout cros-master |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 14 | |
Simon Glass | 1b96da6 | 2019-07-10 11:04:13 -0600 | [diff] [blame] | 15 | cd .. |
| 16 | git clone https://chromium.googlesource.com/chromiumos/platform/vboot_reference |
| 17 | cd vboot_reference |
| 18 | git checkout 45964294 |
| 19 | # futility: updater: Correct output version for Snow |
| 20 | |
Simon Glass | 2d0423a | 2021-03-15 18:11:20 +1300 | [diff] [blame] | 21 | To build for sandbox:: |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 22 | |
| 23 | UB=/tmp/b/chromeos_sandbox # U-Boot build directory |
Simon Glass | 1b96da6 | 2019-07-10 11:04:13 -0600 | [diff] [blame] | 24 | cd u-boot |
| 25 | make O=$UB chromeos_sandbox_defconfig |
| 26 | make O=$UB -j20 -s VBOOT_SOURCE=/path/to/vboot_reference \ |
Simon Glass | 2d0423a | 2021-03-15 18:11:20 +1300 | [diff] [blame] | 27 | MAKEFLAGS_VBOOT=DEBUG=1 QUIET=1 |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 28 | |
| 29 | Replace sandbox with another supported target. |
| 30 | |
| 31 | This produces $UB/image.bin which contains the firmware binaries in a SPI |
| 32 | flash image. |
| 33 | |
Simon Glass | 2d0423a | 2021-03-15 18:11:20 +1300 | [diff] [blame] | 34 | To run on sandbox:: |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 35 | |
Simon Glass | 2d0423a | 2021-03-15 18:11:20 +1300 | [diff] [blame] | 36 | CROS=~/cosarm |
| 37 | IMG=$CROS/src/build/images/coral/latest/chromiumos_image.bin |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 38 | $UB/tpl/u-boot-tpl -d $UB/u-boot.dtb.out \ |
Simon Glass | 2d0423a | 2021-03-15 18:11:20 +1300 | [diff] [blame] | 39 | -L6 -c "host bind 0 $IMG; vboot go auto" \ |
| 40 | -l -w -s state.dtb -r -n -m $UB/ram |
| 41 | |
| 42 | $UB/tpl/u-boot-tpl -d $UB/u-boot.dtb.out -L6 -l \ |
| 43 | -c "host bind 0 $IMG; vboot go auto" -w -s $UB/state.dtb -r -n -m $UB/mem |
| 44 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 45 | |
| 46 | To run on other boards: |
Simon Glass | 2d0423a | 2021-03-15 18:11:20 +1300 | [diff] [blame] | 47 | |
| 48 | - Install image.bin in the SPI flash of your device |
| 49 | - Boot your system |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 50 | |
| 51 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 52 | Sandbox |
| 53 | ------- |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 54 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 55 | Most Chromium OS development with U-Boot is undertaken using sandbox. There is |
| 56 | a sandbox target available (chromeos_sandbox) which allows running U-Boot on |
| 57 | a Linux machine completion with emulations of the display, TPM, disk, etc. |
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 | Running sandbox starts TPL, which contains the first phase of vboot, providing |
| 60 | a device tree and binding a Chromium OS disk image for use to find kernels |
| 61 | (any Chromium OS image will do). It also saves driver state between U-Boot |
| 62 | phases into state.dtb and will automatically ensure that memory is shared |
| 63 | between all phases. TPL will jump to SPL and then on to U-Boot proper. |
| 64 | |
Simon Glass | 2d0423a | 2021-03-15 18:11:20 +1300 | [diff] [blame] | 65 | It is possible to run with debugging on, e.g.:: |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 66 | |
| 67 | gdb --args $UB/tpl/u-boot-tpl -d .... |
| 68 | |
| 69 | Breakpoints can be set in any U-Boot phase. Overall this is a good debugging |
| 70 | environment for new verified-boot features. |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 71 | |
| 72 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 73 | Samus |
| 74 | ----- |
| 75 | |
| 76 | 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] | 77 | have an em100, use:: |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 78 | |
| 79 | sudo em100 -s -c W25Q128FW -d $UB/image.bin -t -r |
| 80 | |
| 81 | to write the image and then boot samus (Power-Refresh). |
| 82 | |
| 83 | |
| 84 | Boot flow |
| 85 | --------- |
| 86 | |
| 87 | Verified boot starts in TPL, which selects the A or B SPL, which in turn selects |
| 88 | the A or B U-Boot. Then this jumps to the selected kernel. If anything goes |
| 89 | wrong, the device reboots and the recovery SPL and U-Boot are used instead. |
| 90 | |
| 91 | More details are available here: |
| 92 | |
| 93 | https://www.chromium.org/chromium-os/chromiumos-design-docs/firmware-boot-and-recovery |
| 94 | |
| 95 | |
| 96 | New uclasses |
| 97 | ------------ |
| 98 | |
| 99 | Several uclasses are provided in cros/: |
| 100 | |
Simon Glass | 2d0423a | 2021-03-15 18:11:20 +1300 | [diff] [blame] | 101 | UCLASS_CROS_AUX_FW |
| 102 | Chrome OS auxiliary firmware |
| 103 | |
| 104 | UCLASS_CROS_FWSTORE |
| 105 | Chrome OS firmware storage |
| 106 | |
| 107 | UCLASS_CROS_NVDATA |
| 108 | Chrome OS non-volatile data device |
| 109 | |
| 110 | UCLASS_CROS_VBOOT_EC |
| 111 | Chrome OS vboot EC operations |
| 112 | |
| 113 | UCLASS_CROS_VBOOT_FLAG |
| 114 | Chrome OS verified boot flag |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 115 | |
| 116 | The existing UCLASS_CROS_EC is also used. |
| 117 | |
| 118 | |
| 119 | Commands |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 120 | -------- |
| 121 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 122 | A new 'vboot' command is provided to run particular vboot stages. The most |
| 123 | useful command is 'vboot go auto', which continues where the last stage left |
| 124 | off. |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 125 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 126 | Note that TPL and SPL do not supports commands as yet, so the vboot code is |
| 127 | called directly from the SPL boot devices (BOOT_DEVICE_CROS_VBOOT). See |
| 128 | cros_load_image_tpl() and cros_load_image_spl() which both call |
| 129 | vboot_run_auto(). |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 130 | |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 131 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 132 | Config options |
| 133 | -------------- |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 134 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 135 | The main option is CONFIG_CHROMEOS, which enables a wide array of other options |
| 136 | so that the required features are present. |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 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 | Device-tree config |
| 140 | ------------------ |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 141 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 142 | Various options are available which control the operation of verified boot. |
| 143 | See cros/dts/bindings/config.txt for details. Most config is handled at run- |
| 144 | time, although build-time config (with Kconfig) could also be added fairly |
| 145 | easily. |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 146 | |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 147 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 148 | Porting to other hardware |
| 149 | ------------------------- |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 150 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 151 | A basic port to samus (Chromebook Pixel 2015) is in a basic working state, |
| 152 | using the chromeos_samus target. Patches will likely be forthcoming in early |
| 153 | 2019. Ports to an ARM board and coreboot (for x86 Chromebooks) are in the |
| 154 | dreaming state. |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 155 | |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 156 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 157 | Tests |
| 158 | ----- |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 159 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 160 | Chromium OS firmware has a very limited set of tests. The tests that originally |
| 161 | existed in U-Boot were not brought over to coreboot or depthcharge. |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 162 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 163 | The U-Boot tests ('make check') do operate, but at present there are no |
| 164 | Chromium OS tests available. These will hopefully come together over time. Of |
| 165 | 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] | 166 | detect problems that affect the flow or particular vboot features. |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 167 | |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 168 | |
Simon Glass | d9778ff | 2020-09-05 14:50:53 -0600 | [diff] [blame] | 169 | U-Boot without Chromium OS verified boot |
| 170 | ---------------------------------------- |
| 171 | |
Simon Glass | 2d0423a | 2021-03-15 18:11:20 +1300 | [diff] [blame] | 172 | The following script can be used to boot a Chrome OS image on coral:: |
Simon Glass | d9778ff | 2020-09-05 14:50:53 -0600 | [diff] [blame] | 173 | |
| 174 | # Read the image header and obtain the address of the kernel |
| 175 | # The offset 4f0 is defined by verified boot and may change for other |
| 176 | # Chromebooks |
| 177 | read mmc 2:2 100000 0 80; setexpr loader *001004f0; |
| 178 | |
| 179 | # Get the kernel size and calculate the number of blocks (0x200 bytes each) |
| 180 | setexpr size *00100518; setexpr blocks $size / 200; |
| 181 | |
| 182 | # Read the full kernel and calculate the address of the setup block |
| 183 | read mmc 2:2 100000 80 $blocks; setexpr setup $loader - 1000; |
| 184 | |
| 185 | # Locate the command line |
| 186 | setexpr cmdline $loader - 2000; |
| 187 | |
| 188 | # Start the zboot process with the loaded kernel, setup block and cmdline |
| 189 | zboot start 100000 0 0 0 $setup $cmdline; |
| 190 | |
| 191 | # Load the kernel, fix up the 'setup' block, dump information |
| 192 | zboot load; zboot setup; zboot dump |
| 193 | |
| 194 | # Boot into Chrome OS |
| 195 | zboot go |
| 196 | |
| 197 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 198 | TO DO |
| 199 | ----- |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 200 | |
Simon Glass | dc8e7a9 | 2020-09-05 14:50:52 -0600 | [diff] [blame] | 201 | Get the full ACPI tables working with Coral |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 202 | |
Simon Glass | c9af667 | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 203 | |
Simon Glass | 9d73e85 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 204 | 7 October 2018 |