Bin Meng | a856e93 | 2019-07-18 00:34:13 -0700 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | .. sectionauthor:: Bin Meng <bmeng.cn@gmail.com> |
| 3 | |
| 4 | Coreboot |
| 5 | ======== |
| 6 | |
| 7 | Build Instructions for U-Boot as coreboot payload |
| 8 | ------------------------------------------------- |
| 9 | Building U-Boot as a coreboot payload is just like building U-Boot for targets |
| 10 | on other architectures, like below:: |
| 11 | |
| 12 | $ make coreboot_defconfig |
| 13 | $ make all |
| 14 | |
| 15 | Test with coreboot |
| 16 | ------------------ |
| 17 | For testing U-Boot as the coreboot payload, there are things that need be paid |
| 18 | attention to. coreboot supports loading an ELF executable and a 32-bit plain |
| 19 | binary, as well as other supported payloads. With the default configuration, |
| 20 | U-Boot is set up to use a separate Device Tree Blob (dtb). As of today, the |
| 21 | generated u-boot-dtb.bin needs to be packaged by the cbfstool utility (a tool |
| 22 | provided by coreboot) manually as coreboot's 'make menuconfig' does not provide |
| 23 | this 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 Glass | 9846390 | 2022-10-20 18:22:39 -0600 | [diff] [blame] | 29 | Make sure 0x1110000 matches CONFIG_TEXT_BASE, which is the symbol address |
Bin Meng | a856e93 | 2019-07-18 00:34:13 -0700 | [diff] [blame] | 30 | of _x86boot_start (in arch/x86/cpu/start.S). |
| 31 | |
| 32 | If you want to use ELF as the coreboot payload, change U-Boot configuration to |
| 33 | use CONFIG_OF_EMBED instead of CONFIG_OF_SEPARATE. |
| 34 | |
| 35 | To 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 | |
| 40 | At present it seems that for Minnowboard Max, coreboot does not pass through |
| 41 | the video information correctly (it always says the resolution is 0x0). This |
| 42 | works correctly for link though. |
Simon Glass | 538437e | 2020-05-01 07:36:10 -0600 | [diff] [blame] | 43 | |
Simon Glass | 350c0df | 2023-09-19 21:00:02 -0600 | [diff] [blame] | 44 | You can run via QEMU using:: |
| 45 | |
| 46 | qemu-system-x86_64 -bios build/coreboot.rom -serial mon:stdio |
| 47 | |
| 48 | The `-serial mon:stdio` part shows both output in the display and on the |
| 49 | console. It is optional. You can add `nographic` as well to *only* get console |
| 50 | output. |
| 51 | |
| 52 | To 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 | |
| 59 | Then you can scan it with `scsi scan` and access it normally. |
| 60 | |
| 61 | To use 4GB of memory, typically necessary for booting Linux distros, add |
| 62 | `-m 4GB`. |
| 63 | |
Simon Glass | 538437e | 2020-05-01 07:36:10 -0600 | [diff] [blame] | 64 | 64-bit U-Boot |
| 65 | ------------- |
| 66 | |
| 67 | In addition to the 32-bit 'coreboot' build there is a 'coreboot64' build. This |
| 68 | produces an image which can be booted from coreboot (32-bit). Internally it |
| 69 | works by using a 32-bit SPL binary to switch to 64-bit for running U-Boot. It |
Simon Glass | 04ecda0 | 2023-09-19 21:00:03 -0600 | [diff] [blame] | 70 | can be useful for running UEFI applications, for example with the coreboot |
| 71 | build in `$CBDIR`:: |
Simon Glass | 538437e | 2020-05-01 07:36:10 -0600 | [diff] [blame] | 72 | |
Simon Glass | 04ecda0 | 2023-09-19 21:00:03 -0600 | [diff] [blame] | 73 | 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 Glass | e74d0ec | 2021-06-27 17:51:08 -0600 | [diff] [blame] | 85 | |
Simon Glass | d60fb7a | 2023-07-30 11:15:19 -0600 | [diff] [blame] | 86 | CBFS access |
| 87 | ----------- |
| 88 | |
| 89 | You 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 Glass | e74d0ec | 2021-06-27 17:51:08 -0600 | [diff] [blame] | 120 | |
| 121 | Memory 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 Glass | 9846390 | 2022-10-20 18:22:39 -0600 | [diff] [blame] | 133 | 1110000 CONFIG_TEXT_BASE (start address of U-Boot code, before reloc) |
Simon Glass | e74d0ec | 2021-06-27 17:51:08 -0600 | [diff] [blame] | 134 | 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 Glass | b6b33d1 | 2023-05-04 16:55:03 -0600 | [diff] [blame] | 140 | |
| 141 | |
| 142 | Debug UART |
| 143 | ---------- |
| 144 | |
| 145 | It is possible to enable the debug UART with coreboot. To do this, use the |
| 146 | info 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 | |
| 161 | Here you can see that the UART base is fe03e000, regwidth is 4 (1 << 2) and the |
| 162 | input 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 Glass | c60e6a2 | 2023-08-11 12:17:43 -0600 | [diff] [blame] | 169 | |
| 170 | coreboot in CI |
| 171 | -------------- |
| 172 | |
| 173 | CI runs tests using a pre-built coreboot image. This ensures that U-Boot can |
| 174 | boot as a coreboot payload, based on a known-good build of coreboot. |
| 175 | |
| 176 | To 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. |