chainload.rst 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. .. SPDX-License-Identifier: GPL-2.0+
  2. .. Copyright 2020 Google LLC
  3. Running U-Boot from coreboot on Chromebooks
  4. ===========================================
  5. U-Boot can be used as a secondary boot loader in a few situations such as from
  6. UEFI and coreboot (see README.x86). Recent Chromebooks use coreboot even on
  7. ARM platforms to start up the machine.
  8. This document aims to provide a guide to booting U-Boot on a Chromebook. It
  9. is only a starting point, and there are many guides on the interwebs. But
  10. placing this information in the U-Boot tree should make it easier to find for
  11. those who use U-Boot habitually.
  12. Most of these platforms are supported by U-Boot natively, but it is risky to
  13. replace the ROM unless you have a servo board and cable to restore it with.
  14. For all of these the standard U-Boot build instructions apply. For example on
  15. ARM::
  16. sudo apt install gcc-arm-linux-gnueabi
  17. mkdir b
  18. make O=b/nyan_big CROSS_COMPILE=arm-linux-gnueabi- nyan-big_defconfig all
  19. You can obtain the vbutil_kernel utility here:
  20. https://drive.google.com/open?id=0B7WYZbZ9zd-3dHlVVXo4VXE2T0U
  21. Snow (Samsung ARM Chromebook)
  22. -----------------------------
  23. See here:
  24. https://www.chromium.org/chromium-os/firmware-porting-guide/using-nv-u-boot-on-the-samsung-arm-chromebook
  25. Nyan-big
  26. --------
  27. Compiled based on information here::
  28. https://lists.denx.de/pipermail/u-boot/2015-March/209530.html
  29. https://git.collabora.com/cgit/user/tomeu/u-boot.git/commit/?h=nyan-big
  30. https://lists.denx.de/pipermail/u-boot/2017-May/289491.html
  31. https://github.com/chromeos-nvidia-androidtv/gnu-linux-on-acer-chromebook-13#copy-data-to-the-sd-card
  32. 1. Build U-Boot
  33. Steps::
  34. mkdir b
  35. make -j8 O=b/nyan-big CROSS_COMPILE=arm-linux-gnueabi- nyan-big_defconfig all
  36. 2. Select a .its file
  37. Select something from doc/chromium which matches your board, or create your
  38. own.
  39. Note that the device tree node is required, even though it is not actually
  40. used by U-Boot. This is because the Chromebook expects to pass it to the
  41. kernel, and crashes if it is not present.
  42. 3. Build and sign an image
  43. Steps::
  44. ./b/nyan-big/tools/mkimage -f doc/chromium/files/nyan-big.its u-boot-chromium.fit
  45. echo test >dummy.txt
  46. vbutil_kernel --arch arm \
  47. --keyblock doc/chromium/files/devkeys/kernel.keyblock \
  48. --signprivate doc/chromium/files/devkeys/kernel_data_key.vbprivk \
  49. --version 1 --config dummy.txt --vmlinuz u-boot-chromium.fit \
  50. --bootloader dummy.txt --pack u-boot.kpart
  51. 4. Prepare an SD card
  52. Steps::
  53. DISK=/dev/sdc # Replace with your actual SD card device
  54. sudo cgpt create $DISK
  55. sudo cgpt add -b 34 -s 32768 -P 1 -S 1 -t kernel $DISK
  56. sudo cgpt add -b 32802 -s 2000000 -t rootfs $DISK
  57. sudo gdisk $DISK # Enter command 'w' to write a protective MBR to the disk
  58. 5. Write U-Boot to the SD card
  59. Steps::
  60. sudo dd if=u-boot.kpart of=/dev/sdc1; sync
  61. 6. Start it up
  62. Reboot the device in dev mode. Make sure that you have USB booting enabled. To
  63. do this, login as root (via Ctrl-Alt-forward_arrow) and type
  64. 'enable_dev_usb_boot'. You only need to do this once.
  65. Reboot the device with the SD card inserted. Press Clrl-U at the developer
  66. mode screen. It should show something like the following on the display::
  67. U-Boot 2017.07-00637-g242eb42-dirty (May 22 2017 - 06:14:21 -0600)
  68. Model: Acer Chromebook 13 CB5-311
  69. Board: Google/NVIDIA Nyan-big, ID: 1
  70. Net: No ethernet found.
  71. Hit any key to stop autoboot: 0
  72. Tegra124 (Nyan-big) #
  73. 7. Known problems
  74. On the serial console the word MMC is chopped at the start of the line::
  75. C: sdhci@700b0000: 2, sdhci@700b0400: 1, sdhci@700b0600: 0
  76. This is likely due to some problem with change-over of the serial driver
  77. during relocation (or perhaps updating the clock setup in board_init()).
  78. 9. Notes
  79. To check that you copied the u-boot.its file correctly, use these commands.
  80. You should see that the data at 0x100 in u-boot-chromium.fit is the first few
  81. bytes of U-Boot::
  82. hd u-boot-chromium.fit |head -20
  83. ...
  84. 00000100 b8 00 00 ea 14 f0 9f e5 14 f0 9f e5 14 f0 9f e5 |................|
  85. hd b/nyan-big/u-boot.bin |head
  86. 00000000 b8 00 00 ea 14 f0 9f e5 14 f0 9f e5 14 f0 9f e5 |................|
  87. The 'data' property of the FIT is set up to start at offset 0x100 bytes into
  88. the file. The change to CONFIG_SYS_TEXT_BASE is also an offset of 0x100 bytes
  89. from the load address. If this changes, you either need to modify U-Boot to be
  90. fully relocatable, or expect it to hang.
  91. chromebook_jerry
  92. ----------------
  93. The instruction are similar to those for Nyan with changes as noted below:
  94. 1. Patch U-Boot
  95. Open include/configs/rk3288_common.h
  96. Change::
  97. #define CONFIG_SYS_TEXT_BASE 0x00100000
  98. to::
  99. #define CONFIG_SYS_TEXT_BASE 0x02000100
  100. 2. Build U-Boot
  101. Steps::
  102. mkdir b
  103. make -j8 O=b/chromebook_jerry CROSS_COMPILE=arm-linux-gnueabi- \
  104. chromebook_jerry_defconfig all
  105. 3. See above
  106. 4. Build and sign an image
  107. Steps::
  108. ./b/chromebook_jerry/tools/mkimage -f doc/chromium/chromebook_jerry.its \
  109. u-boot-chromium.fit
  110. echo test >dummy.txt
  111. vbutil_kernel --arch arm \
  112. --keyblock doc/chromium/files/devkeys/kernel.keyblock \
  113. --signprivate doc/chromium/files/devkeys/kernel_data_key.vbprivk \
  114. --version 1 --config dummy.txt --vmlinuz u-boot-chromium.fit \
  115. --bootloader dummy.txt --pack u-boot.kpart
  116. 5. See above
  117. 6. See above
  118. 7. Start it up
  119. Reboot the device in dev mode. Make sure that you have USB booting enabled. To
  120. do this, login as root (via Ctrl-Alt-forward_arrow) and type
  121. 'enable_dev_usb_boot'. You only need to do this once.
  122. Reboot the device with the SD card inserted. Press Clrl-U at the developer
  123. mode screen. It should show something like the following on the display::
  124. U-Boot 2017.05-00649-g72acdbf-dirty (May 29 2017 - 14:57:05 -0600)
  125. Model: Google Jerry
  126. Net: Net Initialization Skipped
  127. No ethernet found.
  128. Hit any key to stop autoboot: 0
  129. 8. Known problems
  130. None as yet.
  131. 9. Notes
  132. None as yet.
  133. Other notes
  134. -----------
  135. flashrom
  136. ~~~~~~~~
  137. Used to make a backup of your firmware, or to replace it.
  138. See: https://www.chromium.org/chromium-os/packages/cros-flashrom
  139. coreboot
  140. ~~~~~~~~
  141. Coreboot itself is not designed to actually boot an OS. Instead, a program
  142. called Depthcharge is used. This originally came out of U-Boot and was then
  143. heavily hacked and modified such that is is almost unrecognisable. It does
  144. include a very small part of the U-Boot command-line interface but is not
  145. usable as a general-purpose boot loader.
  146. In addition, it has a very unusual design in that it does not do device init
  147. itself, but instead relies on coreboot. This is similar to (in U-Boot) having
  148. a SPI driver with an empty probe() method, relying on whatever was set up
  149. beforehand. It can be quite hard to figure out between these two code bases
  150. what settings are actually used. When chain-loading into U-Boot we must be
  151. careful to reinit anything that U-Boot expects. If not, some peripherals (or
  152. the whole machine) may not work. This makes the process of chainloading more
  153. complicated than it could be on some platforms.
  154. Finally, it supports only a subset of the U-Boot's FIT format. In particular
  155. it uses a fixed address to load the FIT and does not support load/exec
  156. addresses. This means that U-Boot must be able to boot from whatever
  157. address Depthcharge happens to use (it is the CONFIG_KERNEL_START setting
  158. in Depthcharge). In practice this means that the data in the kernel@1 FIT node
  159. (see above) must start at the same address as U-Boot's CONFIG_SYS_TEXT_BASE.