blob: 3ef563b71dc964e5de2e34f369d0bcc5b69e8727 [file] [log] [blame]
Bin Menga856e932019-07-18 00:34:13 -07001.. SPDX-License-Identifier: GPL-2.0+
2.. sectionauthor:: Bin Meng <bmeng.cn@gmail.com>
3
4Coreboot
5========
6
7Build Instructions for U-Boot as coreboot payload
8-------------------------------------------------
9Building U-Boot as a coreboot payload is just like building U-Boot for targets
10on other architectures, like below::
11
12 $ make coreboot_defconfig
13 $ make all
14
15Test with coreboot
16------------------
17For testing U-Boot as the coreboot payload, there are things that need be paid
18attention to. coreboot supports loading an ELF executable and a 32-bit plain
19binary, as well as other supported payloads. With the default configuration,
20U-Boot is set up to use a separate Device Tree Blob (dtb). As of today, the
21generated u-boot-dtb.bin needs to be packaged by the cbfstool utility (a tool
22provided by coreboot) manually as coreboot's 'make menuconfig' does not provide
23this capability yet. The command is as follows::
24
25 # in the coreboot root directory
26 $ ./build/util/cbfstool/cbfstool build/coreboot.rom add-flat-binary \
27 -f u-boot-dtb.bin -n fallback/payload -c lzma -l 0x1110000 -e 0x1110000
28
Simon Glass98463902022-10-20 18:22:39 -060029Make sure 0x1110000 matches CONFIG_TEXT_BASE, which is the symbol address
Bin Menga856e932019-07-18 00:34:13 -070030of _x86boot_start (in arch/x86/cpu/start.S).
31
32If you want to use ELF as the coreboot payload, change U-Boot configuration to
33use CONFIG_OF_EMBED instead of CONFIG_OF_SEPARATE.
34
35To enable video you must enable these options in coreboot:
36
37 - Set framebuffer graphics resolution (1280x1024 32k-color (1:5:5))
38 - Keep VESA framebuffer
39
40At present it seems that for Minnowboard Max, coreboot does not pass through
41the video information correctly (it always says the resolution is 0x0). This
42works correctly for link though.
Simon Glass538437e2020-05-01 07:36:10 -060043
Simon Glass350c0df2023-09-19 21:00:02 -060044You can run via QEMU using::
45
46 qemu-system-x86_64 -bios build/coreboot.rom -serial mon:stdio
47
48The `-serial mon:stdio` part shows both output in the display and on the
49console. It is optional. You can add `nographic` as well to *only* get console
50output.
51
52To run with a SATA drive called `$DISK`::
53
54 qemu-system-x86_64 -bios build/coreboot.rom -serial mon:stdio \
55 -drive id=disk,file=$DISK,if=none \
56 -device ahci,id=ahci \
57 -device ide-hd,drive=disk,bus=ahci.0
58
59Then you can scan it with `scsi scan` and access it normally.
60
61To use 4GB of memory, typically necessary for booting Linux distros, add
62`-m 4GB`.
63
Simon Glass538437e2020-05-01 07:36:10 -06006464-bit U-Boot
65-------------
66
67In addition to the 32-bit 'coreboot' build there is a 'coreboot64' build. This
68produces an image which can be booted from coreboot (32-bit). Internally it
69works by using a 32-bit SPL binary to switch to 64-bit for running U-Boot. It
Simon Glass04ecda02023-09-19 21:00:03 -060070can be useful for running UEFI applications, for example with the coreboot
71build in `$CBDIR`::
Simon Glass538437e2020-05-01 07:36:10 -060072
Simon Glass04ecda02023-09-19 21:00:03 -060073 DISK=ubuntu-23.04-desktop-amd64.iso
74 CBDIR=~/coreboot/build
75
76 cp $CBDIR/coreboot.rom.in coreboot.rom
77 cbfstool coreboot.rom add-flat-binary -f u-boot-x86-with-spl.bin \
78 -n fallback/payload -c lzma -l 0x1110000 -e 0x1110000
79
80 qemu-system-x86_64 -m 2G -smp 4 -bios coreboot.rom \
81 -drive id=disk,file=$DISK,if=none \
82 -device ahci,id=ahci \
83 -device ide-hd,drive=disk,bus=ahci.0 \
84
Simon Glasse74d0ec2021-06-27 17:51:08 -060085
Simon Glassd60fb7a2023-07-30 11:15:19 -060086CBFS access
87-----------
88
89You can use the 'cbfs' commands to access the Coreboot filesystem::
90
91 => cbfsinit
92 => cbfsinfo
93
94 CBFS version: 0x31313132
95 ROM size: 0x100000
96 Boot block size: 0x4
97 CBFS size: 0xffdfc
98 Alignment: 64
99 Offset: 0x200
100
101 => cbfsls
102 size type name
103 ------------------------------------------
104 32 cbfs header cbfs master header
105 16720 17 fallback/romstage
106 53052 17 fallback/ramstage
107 398 raw config
108 715 raw revision
109 117 raw build_info
110 4044 raw fallback/dsdt.aml
111 640 cmos layout cmos_layout.bin
112 17804 17 fallback/postcar
113 335797 payload fallback/payload
114 607000 null (empty)
115 10752 bootblock bootblock
116
117 12 file(s)
118
119 =>
Simon Glasse74d0ec2021-06-27 17:51:08 -0600120
121Memory map
122----------
123
124 ========== ==================================================================
125 Address Region at that address
126 ========== ==================================================================
127 ffffffff Top of ROM (and last byte of 32-bit address space)
128 7a9fd000 Typical top of memory available to U-Boot
129 (use cbsysinfo to see where memory range 'table' starts)
130 10000000 Memory reserved by coreboot for mapping PCI devices
131 (typical size 2151000, includes framebuffer)
132 1920000 CONFIG_SYS_CAR_ADDR, fake Cache-as-RAM memory, used during startup
Simon Glass98463902022-10-20 18:22:39 -0600133 1110000 CONFIG_TEXT_BASE (start address of U-Boot code, before reloc)
Simon Glasse74d0ec2021-06-27 17:51:08 -0600134 110000 CONFIG_BLOBLIST_ADDR (before being relocated)
135 100000 CONFIG_PRE_CON_BUF_ADDR
136 f0000 ACPI tables set up by U-Boot
137 (typically redirects to 7ab10030 or similar)
138 500 Location of coreboot sysinfo table, used during startup
139 ========== ==================================================================
Simon Glassb6b33d12023-05-04 16:55:03 -0600140
141
142Debug UART
143----------
144
145It is possible to enable the debug UART with coreboot. To do this, use the
146info from the cbsysinfo command to locate the UART base. For example::
147
148 => cbsysinfo
149 ...
150 Serial I/O port: 00000000
151 base : 00000000
152 pointer : 767b51bc
153 type : 2
154 base : fe03e000
155 baud : 0d115200
156 regwidth : 4
157 input_hz : 0d1843200
158 PCI addr : 00000010
159 ...
160
161Here you can see that the UART base is fe03e000, regwidth is 4 (1 << 2) and the
162input clock is 1843200. So you can add the following CONFIG options::
163
164 CONFIG_DEBUG_UART=y
165 CONFIG_DEBUG_UART_BASE=fe03e000
166 CONFIG_DEBUG_UART_CLOCK=1843200
167 CONFIG_DEBUG_UART_SHIFT=2
168 CONFIG_DEBUG_UART_ANNOUNCE=y
Simon Glassc60e6a22023-08-11 12:17:43 -0600169
170coreboot in CI
171--------------
172
173CI runs tests using a pre-built coreboot image. This ensures that U-Boot can
174boot as a coreboot payload, based on a known-good build of coreboot.
175
176To update the `coreboot.rom` file which is used:
177
178#. Build coreboot with `CONFIG_LINEAR_FRAMEBUFFER=y`. If using `make menuconfig`
179 this is under
180 `Devices ->Display->Framebuffer mode->Linear "high resolution" framebuffer`.
181
182#. Compress the resulting `coreboot.rom`::
183
184 xz -c /path/to/coreboot/build/coreboot.rom >coreboot.rom.xz
185
186#. Upload the file to Google drive
187
188#. Send a patch to change the file ID used by wget in the CI yaml files.