README.chromium 6.8 KB

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