Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 1 | Chromium OS Support in U-Boot |
| 2 | ============================= |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 3 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 4 | Introduction |
| 5 | ------------ |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 6 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 7 | This describes how to use U-Boot with Chromium OS. Several options are |
| 8 | available: |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 9 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 10 | - Running U-Boot from the 'altfw' feature, which is available on selected |
| 11 | Chromebooks from 2019 onwards (initially Grunt). Press '1' from the |
| 12 | developer-mode screen to get into U-Boot. See here for details: |
| 13 | https://sites.google.com/a/chromium.org/dev/chromium-os/poking-around-your-chrome-os-device?pli=1 |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 14 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 15 | - Running U-Boot from the disk partition. This involves signing U-Boot and |
| 16 | placing it on the disk, for booting as a 'kernel'. See |
| 17 | README.chromium-chainload for information on this. This is the only |
| 18 | option on non-U-Boot Chromebooks from 2013 to 2018 and is somewhat |
| 19 | more involved. |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 20 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 21 | - Running U-Boot with Chromium OS verified boot. This allows U-Boot to be |
| 22 | used instead of either or both of depthcharge (a bootloader which forked |
| 23 | from U-Boot in 2013) and coreboot. See below for more information on |
| 24 | this. |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 25 | |
Simon Glass | 0167f19 | 2020-09-05 14:50:52 -0600 | [diff] [blame^] | 26 | - Running U-Boot from coreboot. This allows U-Boot to run on more devices |
| 27 | since many of them only support coreboot as the bootloader and have |
| 28 | no bare-metal support in U-Boot. For this, use the 'coreboot' target. |
| 29 | |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 30 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 31 | U-Boot with Chromium OS verified boot |
| 32 | ------------------------------------- |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 33 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 34 | To obtain: |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 35 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 36 | git clone https://github.com/sglass68/u-boot.git |
| 37 | cd u-boot |
| 38 | git checkout cros-master |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 39 | |
Simon Glass | 4872d93 | 2019-07-10 11:04:13 -0600 | [diff] [blame] | 40 | cd .. |
| 41 | git clone https://chromium.googlesource.com/chromiumos/platform/vboot_reference |
| 42 | cd vboot_reference |
| 43 | git checkout 45964294 |
| 44 | # futility: updater: Correct output version for Snow |
| 45 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 46 | To build for sandbox: |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 47 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 48 | UB=/tmp/b/chromeos_sandbox # U-Boot build directory |
Simon Glass | 4872d93 | 2019-07-10 11:04:13 -0600 | [diff] [blame] | 49 | cd u-boot |
| 50 | make O=$UB chromeos_sandbox_defconfig |
| 51 | make O=$UB -j20 -s VBOOT_SOURCE=/path/to/vboot_reference \ |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 52 | MAKEFLAGS_VBOOT=DEBUG=1 QUIET=1 |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 53 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 54 | Replace sandbox with another supported target. |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 55 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 56 | This produces $UB/image.bin which contains the firmware binaries in a SPI |
| 57 | flash image. |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 58 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 59 | To run on sandbox: |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 60 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 61 | $UB/tpl/u-boot-tpl -d $UB/u-boot.dtb.out \ |
| 62 | -L6 -c "host bind 0 $CROS/src/build/images/cheza/latest/chromiumos_image.bin; vboot go auto" \ |
| 63 | -l -w -s state.dtb -r |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 64 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 65 | To run on other boards: |
| 66 | Install image.bin in the SPI flash of your device |
| 67 | Boot your system |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 68 | |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 69 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 70 | Sandbox |
| 71 | ------- |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 72 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 73 | Most Chromium OS development with U-Boot is undertaken using sandbox. There is |
| 74 | a sandbox target available (chromeos_sandbox) which allows running U-Boot on |
| 75 | a Linux machine completion with emulations of the display, TPM, disk, etc. |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 76 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 77 | Running sandbox starts TPL, which contains the first phase of vboot, providing |
| 78 | a device tree and binding a Chromium OS disk image for use to find kernels |
| 79 | (any Chromium OS image will do). It also saves driver state between U-Boot |
| 80 | phases into state.dtb and will automatically ensure that memory is shared |
| 81 | between all phases. TPL will jump to SPL and then on to U-Boot proper. |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 82 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 83 | It is possible to run with debugging on, e.g. |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 84 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 85 | gdb --args $UB/tpl/u-boot-tpl -d .... |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 86 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 87 | Breakpoints can be set in any U-Boot phase. Overall this is a good debugging |
| 88 | environment for new verified-boot features. |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 89 | |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 90 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 91 | Samus |
| 92 | ----- |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 93 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 94 | Basic support is available for samus, using the chromeos_samus target. If you |
| 95 | have an em100, use: |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 96 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 97 | sudo em100 -s -c W25Q128FW -d $UB/image.bin -t -r |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 98 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 99 | to write the image and then boot samus (Power-Refresh). |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 100 | |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 101 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 102 | Boot flow |
| 103 | --------- |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 104 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 105 | Verified boot starts in TPL, which selects the A or B SPL, which in turn selects |
| 106 | the A or B U-Boot. Then this jumps to the selected kernel. If anything goes |
| 107 | wrong, the device reboots and the recovery SPL and U-Boot are used instead. |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 108 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 109 | More details are available here: |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 110 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 111 | https://www.chromium.org/chromium-os/chromiumos-design-docs/firmware-boot-and-recovery |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 112 | |
| 113 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 114 | New uclasses |
| 115 | ------------ |
Simon Glass | 3421e00 | 2017-05-31 17:57:36 -0600 | [diff] [blame] | 116 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 117 | Several uclasses are provided in cros/: |
Simon Glass | 3421e00 | 2017-05-31 17:57:36 -0600 | [diff] [blame] | 118 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 119 | UCLASS_CROS_AUX_FW Chrome OS auxiliary firmware |
| 120 | UCLASS_CROS_FWSTORE Chrome OS firmware storage |
| 121 | UCLASS_CROS_NVDATA Chrome OS non-volatile data device |
| 122 | UCLASS_CROS_VBOOT_EC Chrome OS vboot EC operations |
| 123 | UCLASS_CROS_VBOOT_FLAG Chrome OS verified boot flag |
Simon Glass | 3421e00 | 2017-05-31 17:57:36 -0600 | [diff] [blame] | 124 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 125 | The existing UCLASS_CROS_EC is also used. |
Simon Glass | 3421e00 | 2017-05-31 17:57:36 -0600 | [diff] [blame] | 126 | |
Simon Glass | 3421e00 | 2017-05-31 17:57:36 -0600 | [diff] [blame] | 127 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 128 | Commands |
| 129 | -------- |
Simon Glass | 3421e00 | 2017-05-31 17:57:36 -0600 | [diff] [blame] | 130 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 131 | A new 'vboot' command is provided to run particular vboot stages. The most |
| 132 | useful command is 'vboot go auto', which continues where the last stage left |
| 133 | off. |
Simon Glass | 3421e00 | 2017-05-31 17:57:36 -0600 | [diff] [blame] | 134 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 135 | Note that TPL and SPL do not supports commands as yet, so the vboot code is |
| 136 | called directly from the SPL boot devices (BOOT_DEVICE_CROS_VBOOT). See |
| 137 | cros_load_image_tpl() and cros_load_image_spl() which both call |
| 138 | vboot_run_auto(). |
Simon Glass | 3421e00 | 2017-05-31 17:57:36 -0600 | [diff] [blame] | 139 | |
Simon Glass | 3421e00 | 2017-05-31 17:57:36 -0600 | [diff] [blame] | 140 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 141 | Config options |
| 142 | -------------- |
Simon Glass | 3421e00 | 2017-05-31 17:57:36 -0600 | [diff] [blame] | 143 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 144 | The main option is CONFIG_CHROMEOS, which enables a wide array of other options |
| 145 | so that the required features are present. |
Simon Glass | 3421e00 | 2017-05-31 17:57:36 -0600 | [diff] [blame] | 146 | |
Simon Glass | 3421e00 | 2017-05-31 17:57:36 -0600 | [diff] [blame] | 147 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 148 | Device-tree config |
| 149 | ------------------ |
Simon Glass | 3421e00 | 2017-05-31 17:57:36 -0600 | [diff] [blame] | 150 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 151 | Various options are available which control the operation of verified boot. |
| 152 | See cros/dts/bindings/config.txt for details. Most config is handled at run- |
| 153 | time, although build-time config (with Kconfig) could also be added fairly |
| 154 | easily. |
Simon Glass | 3421e00 | 2017-05-31 17:57:36 -0600 | [diff] [blame] | 155 | |
Simon Glass | 3421e00 | 2017-05-31 17:57:36 -0600 | [diff] [blame] | 156 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 157 | Porting to other hardware |
| 158 | ------------------------- |
Simon Glass | 3421e00 | 2017-05-31 17:57:36 -0600 | [diff] [blame] | 159 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 160 | A basic port to samus (Chromebook Pixel 2015) is in a basic working state, |
| 161 | using the chromeos_samus target. Patches will likely be forthcoming in early |
| 162 | 2019. Ports to an ARM board and coreboot (for x86 Chromebooks) are in the |
| 163 | dreaming state. |
Simon Glass | 3421e00 | 2017-05-31 17:57:36 -0600 | [diff] [blame] | 164 | |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 165 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 166 | Tests |
| 167 | ----- |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 168 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 169 | Chromium OS firmware has a very limited set of tests. The tests that originally |
| 170 | existed in U-Boot were not brought over to coreboot or depthcharge. |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 171 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 172 | The U-Boot tests ('make check') do operate, but at present there are no |
| 173 | Chromium OS tests available. These will hopefully come together over time. Of |
| 174 | course the above sandbox feature provides a sort of functional test and can |
Simon Glass | 0167f19 | 2020-09-05 14:50:52 -0600 | [diff] [blame^] | 175 | detect problems that affect the flow or particular vboot features. |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 176 | |
| 177 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 178 | TO DO |
| 179 | ----- |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 180 | |
Simon Glass | 0167f19 | 2020-09-05 14:50:52 -0600 | [diff] [blame^] | 181 | Get the full ACPI tables working with Coral |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 182 | |
Simon Glass | 26784fc | 2017-05-31 17:57:24 -0600 | [diff] [blame] | 183 | |
Simon Glass | a20a7b7 | 2019-01-30 20:51:20 -0700 | [diff] [blame] | 184 | Simon Glass |
| 185 | sjg@chromium.org |
| 186 | 7 October 2018 |