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