xref: /OK3568_Linux_fs/u-boot/doc/README.chromium (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunRunning U-Boot from coreboot on Chromebooks
2*4882a593Smuzhiyun===========================================
3*4882a593Smuzhiyun
4*4882a593SmuzhiyunU-Boot can be used as a secondary boot loader in a few situations such as from
5*4882a593SmuzhiyunUEFI and coreboot (see README.x86). Recent Chromebooks use coreboot even on
6*4882a593SmuzhiyunARM platforms to start up the machine.
7*4882a593Smuzhiyun
8*4882a593SmuzhiyunThis document aims to provide a guide to booting U-Boot on a Chromebook. It
9*4882a593Smuzhiyunis only a starting point, and there are many guides on the interwebs. But
10*4882a593Smuzhiyunplacing this information in the U-Boot tree should make it easier to find for
11*4882a593Smuzhiyunthose who use U-Boot habitually.
12*4882a593Smuzhiyun
13*4882a593SmuzhiyunMost of these platforms are supported by U-Boot natively, but it is risky to
14*4882a593Smuzhiyunreplace the ROM unless you have a servo board and cable to restore it with.
15*4882a593Smuzhiyun
16*4882a593Smuzhiyun
17*4882a593SmuzhiyunFor all of these the standard U-Boot build instructions apply. For example on
18*4882a593SmuzhiyunARM:
19*4882a593Smuzhiyun
20*4882a593Smuzhiyun   sudo apt install gcc-arm-linux-gnueabi
21*4882a593Smuzhiyun   mkdir b
22*4882a593Smuzhiyun   make O=b/nyan_big CROSS_COMPILE=arm-linux-gnueabi- nyan-big_defconfig all
23*4882a593Smuzhiyun
24*4882a593SmuzhiyunYou can obtain the vbutil_kernel utility here:
25*4882a593Smuzhiyun
26*4882a593Smuzhiyun   https://drive.google.com/open?id=0B7WYZbZ9zd-3dHlVVXo4VXE2T0U
27*4882a593Smuzhiyun
28*4882a593Smuzhiyun
29*4882a593SmuzhiyunSnow (Samsung ARM Chromebook)
30*4882a593Smuzhiyun-----------------------------
31*4882a593Smuzhiyun
32*4882a593SmuzhiyunSee here:
33*4882a593Smuzhiyun
34*4882a593Smuzhiyunhttps://www.chromium.org/chromium-os/firmware-porting-guide/using-nv-u-boot-on-the-samsung-arm-chromebook
35*4882a593Smuzhiyun
36*4882a593Smuzhiyun
37*4882a593SmuzhiyunNyan-big
38*4882a593Smuzhiyun--------
39*4882a593Smuzhiyun
40*4882a593SmuzhiyunCompiled based on information here:
41*4882a593Smuzhiyunhttps://lists.denx.de/pipermail/u-boot/2015-March/209530.html
42*4882a593Smuzhiyunhttps://git.collabora.com/cgit/user/tomeu/u-boot.git/commit/?h=nyan-big
43*4882a593Smuzhiyunhttps://lists.denx.de/pipermail/u-boot/2017-May/289491.html
44*4882a593Smuzhiyunhttps://github.com/chromeos-nvidia-androidtv/gnu-linux-on-acer-chromebook-13#copy-data-to-the-sd-card
45*4882a593Smuzhiyun
46*4882a593Smuzhiyun1. Patch U-Boot
47*4882a593Smuzhiyun
48*4882a593SmuzhiyunOpen include/configs/tegra124-common.h
49*4882a593Smuzhiyun
50*4882a593SmuzhiyunChange:
51*4882a593Smuzhiyun
52*4882a593Smuzhiyun#define CONFIG_SYS_TEXT_BASE	0x80110000
53*4882a593Smuzhiyun
54*4882a593Smuzhiyunto:
55*4882a593Smuzhiyun
56*4882a593Smuzhiyun#define CONFIG_SYS_TEXT_BASE	0x81000100
57*4882a593Smuzhiyun
58*4882a593Smuzhiyun
59*4882a593Smuzhiyun2. Build U-Boot
60*4882a593Smuzhiyun
61*4882a593Smuzhiyun   mkdir b
62*4882a593Smuzhiyun   make -j8 O=b/nyan-big CROSS_COMPILE=arm-linux-gnueabi- nyan-big_defconfig all
63*4882a593Smuzhiyun
64*4882a593Smuzhiyun
65*4882a593Smuzhiyun3. Select a .its file
66*4882a593Smuzhiyun
67*4882a593SmuzhiyunSelect something from doc/chromium which matches your board, or create your
68*4882a593Smuzhiyunown.
69*4882a593Smuzhiyun
70*4882a593SmuzhiyunNote that the device tree node is required, even though it is not actually
71*4882a593Smuzhiyunused by U-Boot. This is because the Chromebook expects to pass it to the
72*4882a593Smuzhiyunkernel, and crashes if it is not present.
73*4882a593Smuzhiyun
74*4882a593Smuzhiyun
75*4882a593Smuzhiyun4. Build and sign an image
76*4882a593Smuzhiyun
77*4882a593Smuzhiyun   ./b/nyan-big/tools/mkimage -f doc/chromium/nyan-big.its u-boot-chromium.fit
78*4882a593Smuzhiyun   echo test >dummy.txt
79*4882a593Smuzhiyun   vbutil_kernel --arch arm --keyblock doc/chromium/devkeys/kernel.keyblock \
80*4882a593Smuzhiyun	--signprivate doc/chromium/devkeys/kernel_data_key.vbprivk \
81*4882a593Smuzhiyun	--version 1 --config dummy.txt --vmlinuz u-boot-chromium.fit \
82*4882a593Smuzhiyun	--bootloader dummy.txt --pack u-boot.kpart
83*4882a593Smuzhiyun
84*4882a593Smuzhiyun
85*4882a593Smuzhiyun5. Prepare an SD card
86*4882a593Smuzhiyun
87*4882a593Smuzhiyun   DISK=/dev/sdc   # Replace with your actual SD card device
88*4882a593Smuzhiyun   sudo cgpt create $DISK
89*4882a593Smuzhiyun   sudo cgpt add -b 34 -s 32768 -P 1 -S 1 -t kernel $DISK
90*4882a593Smuzhiyun   sudo cgpt add -b 32802 -s 2000000 -t rootfs $DISK
91*4882a593Smuzhiyun   sudo gdisk $DISK   # Enter command 'w' to write a protective MBR to the disk
92*4882a593Smuzhiyun
93*4882a593Smuzhiyun
94*4882a593Smuzhiyun6. Write U-Boot to the SD card
95*4882a593Smuzhiyun
96*4882a593Smuzhiyun   sudo dd if=u-boot.kpart of=/dev/sdc1; sync
97*4882a593Smuzhiyun
98*4882a593Smuzhiyun
99*4882a593Smuzhiyun7. Start it up
100*4882a593Smuzhiyun
101*4882a593SmuzhiyunReboot the device in dev mode. Make sure that you have USB booting enabled. To
102*4882a593Smuzhiyundo this, login as root (via Ctrl-Alt-forward_arrow) and type
103*4882a593Smuzhiyun'enable_dev_usb_boot'. You only need to do this once.
104*4882a593Smuzhiyun
105*4882a593SmuzhiyunReboot the device with the SD card inserted. Press Clrl-U at the developer
106*4882a593Smuzhiyunmode screen. It should show something like the following on the display:
107*4882a593Smuzhiyun
108*4882a593Smuzhiyun   U-Boot 2017.07-00637-g242eb42-dirty (May 22 2017 - 06:14:21 -0600)
109*4882a593Smuzhiyun
110*4882a593Smuzhiyun   Model: Acer Chromebook 13 CB5-311
111*4882a593Smuzhiyun   Board: Google/NVIDIA Nyan-big, ID: 1
112*4882a593Smuzhiyun
113*4882a593Smuzhiyun   Net:   No ethernet found.
114*4882a593Smuzhiyun   Hit any key to stop autoboot:  0
115*4882a593Smuzhiyun   Tegra124 (Nyan-big) #
116*4882a593Smuzhiyun
117*4882a593Smuzhiyun
118*4882a593Smuzhiyun8. Known problems
119*4882a593Smuzhiyun
120*4882a593SmuzhiyunOn the serial console the word MMC is chopped at the start of the line:
121*4882a593Smuzhiyun
122*4882a593SmuzhiyunC:   sdhci@700b0000: 2, sdhci@700b0400: 1, sdhci@700b0600: 0
123*4882a593Smuzhiyun
124*4882a593SmuzhiyunThis is likely due to some problem with change-over of the serial driver
125*4882a593Smuzhiyunduring relocation (or perhaps updating the clock setup in board_init()).
126*4882a593Smuzhiyun
127*4882a593Smuzhiyun
128*4882a593Smuzhiyun9. Notes
129*4882a593Smuzhiyun
130*4882a593SmuzhiyunTo check that you copied the u-boot.its file correctly, use these commands.
131*4882a593SmuzhiyunYou should see that the data at 0x100 in u-boot-chromium.fit is the first few
132*4882a593Smuzhiyunbytes of U-Boot:
133*4882a593Smuzhiyun
134*4882a593Smuzhiyun   hd u-boot-chromium.fit |head -20
135*4882a593Smuzhiyun   ...
136*4882a593Smuzhiyun   00000100  b8 00 00 ea 14 f0 9f e5  14 f0 9f e5 14 f0 9f e5  |................|
137*4882a593Smuzhiyun
138*4882a593Smuzhiyun   hd b/nyan-big/u-boot.bin |head
139*4882a593Smuzhiyun   00000000  b8 00 00 ea 14 f0 9f e5  14 f0 9f e5 14 f0 9f e5  |................|
140*4882a593Smuzhiyun
141*4882a593Smuzhiyun
142*4882a593SmuzhiyunThe 'data' property of the FIT is set up to start at offset 0x100 bytes into
143*4882a593Smuzhiyunthe file. The change to CONFIG_SYS_TEXT_BASE is also an offset of 0x100 bytes
144*4882a593Smuzhiyunfrom the load address. If this changes, you either need to modify U-Boot to be
145*4882a593Smuzhiyunfully relocatable, or expect it to hang.
146*4882a593Smuzhiyun
147*4882a593Smuzhiyun
148*4882a593Smuzhiyunchromebook_jerry
149*4882a593Smuzhiyun----------------
150*4882a593Smuzhiyun
151*4882a593SmuzhiyunThe instruction are similar to those for Nyan with changes as noted below:
152*4882a593Smuzhiyun
153*4882a593Smuzhiyun1. Patch U-Boot
154*4882a593Smuzhiyun
155*4882a593SmuzhiyunOpen include/configs/rk3288_common.h
156*4882a593Smuzhiyun
157*4882a593SmuzhiyunChange:
158*4882a593Smuzhiyun
159*4882a593Smuzhiyun#define CONFIG_SYS_TEXT_BASE		0x00100000
160*4882a593Smuzhiyun
161*4882a593Smuzhiyunto:
162*4882a593Smuzhiyun
163*4882a593Smuzhiyun#define CONFIG_SYS_TEXT_BASE		0x02000100
164*4882a593Smuzhiyun
165*4882a593Smuzhiyun
166*4882a593Smuzhiyun
167*4882a593Smuzhiyun2. Build U-Boot
168*4882a593Smuzhiyun
169*4882a593Smuzhiyun   mkdir b
170*4882a593Smuzhiyun   make -j8 O=b/chromebook_jerry CROSS_COMPILE=arm-linux-gnueabi- \
171*4882a593Smuzhiyun	chromebook_jerry_defconfig all
172*4882a593Smuzhiyun
173*4882a593Smuzhiyun
174*4882a593Smuzhiyun3. See above
175*4882a593Smuzhiyun
176*4882a593Smuzhiyun4. Build and sign an image
177*4882a593Smuzhiyun
178*4882a593Smuzhiyun   ./b/chromebook_jerry/tools/mkimage -f doc/chromium/chromebook_jerry.its \
179*4882a593Smuzhiyun	u-boot-chromium.fit
180*4882a593Smuzhiyun   echo test >dummy.txt
181*4882a593Smuzhiyun   vbutil_kernel --arch arm --keyblock doc/chromium/devkeys/kernel.keyblock \
182*4882a593Smuzhiyun	--signprivate doc/chromium/devkeys/kernel_data_key.vbprivk \
183*4882a593Smuzhiyun	--version 1 --config dummy.txt --vmlinuz u-boot-chromium.fit \
184*4882a593Smuzhiyun	--bootloader dummy.txt --pack u-boot.kpart
185*4882a593Smuzhiyun
186*4882a593Smuzhiyun
187*4882a593Smuzhiyun5. See above
188*4882a593Smuzhiyun
189*4882a593Smuzhiyun6. See above
190*4882a593Smuzhiyun
191*4882a593Smuzhiyun7. Start it up
192*4882a593Smuzhiyun
193*4882a593SmuzhiyunReboot the device in dev mode. Make sure that you have USB booting enabled. To
194*4882a593Smuzhiyundo this, login as root (via Ctrl-Alt-forward_arrow) and type
195*4882a593Smuzhiyun'enable_dev_usb_boot'. You only need to do this once.
196*4882a593Smuzhiyun
197*4882a593SmuzhiyunReboot the device with the SD card inserted. Press Clrl-U at the developer
198*4882a593Smuzhiyunmode screen. It should show something like the following on the display:
199*4882a593Smuzhiyun
200*4882a593Smuzhiyun   U-Boot 2017.05-00649-g72acdbf-dirty (May 29 2017 - 14:57:05 -0600)
201*4882a593Smuzhiyun
202*4882a593Smuzhiyun   Model: Google Jerry
203*4882a593Smuzhiyun   Net:   Net Initialization Skipped
204*4882a593Smuzhiyun   No ethernet found.
205*4882a593Smuzhiyun   Hit any key to stop autoboot:  0
206*4882a593Smuzhiyun
207*4882a593Smuzhiyun
208*4882a593Smuzhiyun8. Known problems
209*4882a593Smuzhiyun
210*4882a593SmuzhiyunNone as yet.
211*4882a593Smuzhiyun
212*4882a593Smuzhiyun
213*4882a593Smuzhiyun9. Notes
214*4882a593Smuzhiyun
215*4882a593SmuzhiyunNone as yet.
216*4882a593Smuzhiyun
217*4882a593Smuzhiyun
218*4882a593SmuzhiyunOther notes
219*4882a593Smuzhiyun===========
220*4882a593Smuzhiyun
221*4882a593Smuzhiyunflashrom
222*4882a593Smuzhiyun--------
223*4882a593Smuzhiyun
224*4882a593Smuzhiyun   Used to make a backup of your firmware, or to replace it.
225*4882a593Smuzhiyun
226*4882a593Smuzhiyun   See: https://www.chromium.org/chromium-os/packages/cros-flashrom
227*4882a593Smuzhiyun
228*4882a593Smuzhiyun
229*4882a593Smuzhiyuncoreboot
230*4882a593Smuzhiyun--------
231*4882a593Smuzhiyun
232*4882a593SmuzhiyunCoreboot itself is not designed to actually boot an OS. Instead, a program
233*4882a593Smuzhiyuncalled Depthcharge is used. This originally came out of U-Boot and was then
234*4882a593Smuzhiyunheavily hacked and modified such that is is almost unrecognisable. It does
235*4882a593Smuzhiyuninclude a very small part of the U-Boot command-line interface but is not
236*4882a593Smuzhiyunusable as a general-purpose boot loader.
237*4882a593Smuzhiyun
238*4882a593SmuzhiyunIn addition, it has a very unusual design in that it does not do device init
239*4882a593Smuzhiyunitself, but instead relies on coreboot. This is similar to (in U-Boot) having
240*4882a593Smuzhiyuna SPI driver with an empty probe() method, relying on whatever was set up
241*4882a593Smuzhiyunbeforehand. It can be quite hard to figure out between these two code bases
242*4882a593Smuzhiyunwhat settings are actually used. When chain-loading into U-Boot we must be
243*4882a593Smuzhiyuncareful to reinit anything that U-Boot expects. If not, some peripherals (or
244*4882a593Smuzhiyunthe whole machine) may not work. This makes the process of chainloading more
245*4882a593Smuzhiyuncomplicated than it could be on some platforms.
246*4882a593Smuzhiyun
247*4882a593SmuzhiyunFinally, it supports only a subset of the U-Boot's FIT format. In particular
248*4882a593Smuzhiyunit uses a fixed address to load the FIT and does not support load/exec
249*4882a593Smuzhiyunaddresses. This means that U-Boot must be able to boot from whatever
250*4882a593Smuzhiyunaddress Depthcharge happens to use (it is the CONFIG_KERNEL_START setting
251*4882a593Smuzhiyunin Depthcharge). In practice this means that the data in the kernel@1 FIT node
252*4882a593Smuzhiyun(see above) must start at the same address as U-Boot's CONFIG_SYS_TEXT_BASE.
253