Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | .. Copyright (C) 2014, Simon Glass <sjg@chromium.org> |
| 3 | .. Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com> |
Bin Meng | 9e816df | 2014-12-17 15:50:48 +0800 | [diff] [blame] | 4 | |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 5 | x86 |
| 6 | === |
Bin Meng | 9e816df | 2014-12-17 15:50:48 +0800 | [diff] [blame] | 7 | |
| 8 | This document describes the information about U-Boot running on x86 targets, |
| 9 | including supported boards, build instructions, todo list, etc. |
| 10 | |
| 11 | Status |
| 12 | ------ |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 13 | U-Boot supports running as a `coreboot`_ payload on x86. So far only Link |
Simon Glass | 273d08f | 2023-09-21 07:37:45 -0600 | [diff] [blame] | 14 | (Chromebook Pixel), Brya (Alder Lake Chromebook) and `QEMU`_ x86 targets have |
| 15 | been tested, but it should work with minimal adjustments on other x86 boards |
| 16 | since coreboot deals with most of the low-level details. |
Bin Meng | 9e816df | 2014-12-17 15:50:48 +0800 | [diff] [blame] | 17 | |
Andy Shevchenko | d31315d | 2017-07-06 14:41:53 +0300 | [diff] [blame] | 18 | U-Boot is a main bootloader on Intel Edison board. |
| 19 | |
Stoppa, Igor | c0e91a6 | 2015-08-13 16:43:35 +0300 | [diff] [blame] | 20 | U-Boot also supports booting directly from x86 reset vector, without coreboot. |
| 21 | In this case, known as bare mode, from the fact that it runs on the |
Simon Glass | 2b416fd | 2016-03-11 22:07:33 -0700 | [diff] [blame] | 22 | 'bare metal', U-Boot acts like a BIOS replacement. The following platforms |
| 23 | are supported: |
| 24 | |
Bin Meng | 0dbbf10 | 2016-05-07 07:46:36 -0700 | [diff] [blame] | 25 | - Bayley Bay CRB |
Bin Meng | 4ba7570 | 2017-08-15 22:42:02 -0700 | [diff] [blame] | 26 | - Cherry Hill CRB |
Bin Meng | 0dbbf10 | 2016-05-07 07:46:36 -0700 | [diff] [blame] | 27 | - Congatec QEVAL 2.0 & conga-QA3/E3845 |
Simon Glass | 84a49ca | 2023-09-07 09:58:21 -0600 | [diff] [blame] | 28 | - Coral (Apollo Lake - Chromebook 2017) |
Simon Glass | 2b416fd | 2016-03-11 22:07:33 -0700 | [diff] [blame] | 29 | - Cougar Canyon 2 CRB |
| 30 | - Crown Bay CRB |
| 31 | - Galileo |
Simon Glass | 84a49ca | 2023-09-07 09:58:21 -0600 | [diff] [blame] | 32 | - Link (Ivy Bridge - Chromebook Pixel) |
Simon Glass | 2b416fd | 2016-03-11 22:07:33 -0700 | [diff] [blame] | 33 | - Minnowboard MAX |
Simon Glass | 84a49ca | 2023-09-07 09:58:21 -0600 | [diff] [blame] | 34 | - Samus (Broadwell - Chromebook Pixel 2015) |
Simon Glass | 273d08f | 2023-09-21 07:37:45 -0600 | [diff] [blame] | 35 | - Coral (Apollo Lake Chromebooks circa 2017) |
Bin Meng | 0d87363 | 2018-10-13 20:52:03 -0700 | [diff] [blame] | 36 | - QEMU x86 (32-bit & 64-bit) |
Bin Meng | 9e816df | 2014-12-17 15:50:48 +0800 | [diff] [blame] | 37 | |
Simon Glass | 4a56f10 | 2015-01-27 22:13:47 -0700 | [diff] [blame] | 38 | As for loading an OS, U-Boot supports directly booting a 32-bit or 64-bit |
| 39 | Linux kernel as part of a FIT image. It also supports a compressed zImage. |
Bin Meng | 6ab240d | 2015-10-07 20:19:20 -0700 | [diff] [blame] | 40 | U-Boot supports loading an x86 VxWorks kernel. Please check README.vxworks |
Simon Glass | 273d08f | 2023-09-21 07:37:45 -0600 | [diff] [blame] | 41 | for more details. Finally, U-Boot can boot Linux distributions with a UEFI |
| 42 | interface. |
Bin Meng | 9e816df | 2014-12-17 15:50:48 +0800 | [diff] [blame] | 43 | |
Stoppa, Igor | c0e91a6 | 2015-08-13 16:43:35 +0300 | [diff] [blame] | 44 | Build Instructions for U-Boot as BIOS replacement (bare mode) |
| 45 | ------------------------------------------------------------- |
Simon Glass | 4a56f10 | 2015-01-27 22:13:47 -0700 | [diff] [blame] | 46 | Building a ROM version of U-Boot (hereafter referred to as u-boot.rom) is a |
Bin Meng | 9e816df | 2014-12-17 15:50:48 +0800 | [diff] [blame] | 47 | little bit tricky, as generally it requires several binary blobs which are not |
Bin Meng | 7378a6f | 2021-07-27 23:15:39 +0800 | [diff] [blame] | 48 | shipped in the U-Boot source tree. Due to this reason, the u-boot.rom build may |
| 49 | print some warnings if required binary blobs (e.g.: FSP) are not present. |
Bin Meng | 9e816df | 2014-12-17 15:50:48 +0800 | [diff] [blame] | 50 | |
Bin Meng | 9e816df | 2014-12-17 15:50:48 +0800 | [diff] [blame] | 51 | CPU Microcode |
| 52 | ------------- |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 53 | Modern CPUs usually require a special bit stream called `microcode`_ to be |
Bin Meng | 9e816df | 2014-12-17 15:50:48 +0800 | [diff] [blame] | 54 | loaded on the processor after power up in order to function properly. U-Boot |
| 55 | has already integrated these as hex dumps in the source tree. |
| 56 | |
Bin Meng | 5a86652 | 2015-06-23 12:18:53 +0800 | [diff] [blame] | 57 | SMP Support |
| 58 | ----------- |
| 59 | On a multicore system, U-Boot is executed on the bootstrap processor (BSP). |
| 60 | Additional application processors (AP) can be brought up by U-Boot. In order to |
| 61 | have an SMP kernel to discover all of the available processors, U-Boot needs to |
| 62 | prepare configuration tables which contain the multi-CPUs information before |
| 63 | loading the OS kernel. Currently U-Boot supports generating two types of tables |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 64 | for SMP, called Simple Firmware Interface (`SFI`_) and Multi-Processor (`MP`_) |
| 65 | tables. The writing of these two tables are controlled by two Kconfig |
Bin Meng | 45e3e81 | 2015-07-06 16:31:35 +0800 | [diff] [blame] | 66 | options GENERATE_SFI_TABLE and GENERATE_MP_TABLE. |
Bin Meng | 5a86652 | 2015-06-23 12:18:53 +0800 | [diff] [blame] | 67 | |
Bin Meng | 9e816df | 2014-12-17 15:50:48 +0800 | [diff] [blame] | 68 | Driver Model |
| 69 | ------------ |
Simon Glass | 2b416fd | 2016-03-11 22:07:33 -0700 | [diff] [blame] | 70 | x86 has been converted to use driver model for serial, GPIO, SPI, SPI flash, |
| 71 | keyboard, real-time clock, USB. Video is in progress. |
Bin Meng | 9e816df | 2014-12-17 15:50:48 +0800 | [diff] [blame] | 72 | |
| 73 | Device Tree |
| 74 | ----------- |
| 75 | x86 uses device tree to configure the board thus requires CONFIG_OF_CONTROL to |
Bin Meng | 6c6ec43 | 2015-01-06 22:14:24 +0800 | [diff] [blame] | 76 | be turned on. Not every device on the board is configured via device tree, but |
Bin Meng | 9e816df | 2014-12-17 15:50:48 +0800 | [diff] [blame] | 77 | more and more devices will be added as time goes by. Check out the directory |
| 78 | arch/x86/dts/ for these device tree source files. |
| 79 | |
Simon Glass | fc0ba2d | 2015-01-01 16:18:15 -0700 | [diff] [blame] | 80 | Useful Commands |
| 81 | --------------- |
Simon Glass | fc0ba2d | 2015-01-01 16:18:15 -0700 | [diff] [blame] | 82 | In keeping with the U-Boot philosophy of providing functions to check and |
| 83 | adjust internal settings, there are several x86-specific commands that may be |
| 84 | useful: |
| 85 | |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 86 | fsp |
| 87 | Display information about Intel Firmware Support Package (FSP). |
| 88 | This is only available on platforms which use FSP, mostly Atom. |
| 89 | iod |
| 90 | Display I/O memory |
| 91 | iow |
| 92 | Write I/O memory |
| 93 | mtrr |
| 94 | List and set the Memory Type Range Registers (MTRR). These are used to |
| 95 | tell the CPU whether memory is cacheable and if so the cache write |
| 96 | mode to use. U-Boot sets up some reasonable values but you can |
| 97 | adjust then with this command. |
Simon Glass | fc0ba2d | 2015-01-01 16:18:15 -0700 | [diff] [blame] | 98 | |
Simon Glass | c05168f | 2015-07-27 15:47:31 -0600 | [diff] [blame] | 99 | Booting Ubuntu |
| 100 | -------------- |
Simon Glass | 5382c9b | 2023-09-19 21:00:20 -0600 | [diff] [blame] | 101 | Typically U-Boot boots distributions automatically so long an `CONFIG_BOOTSTD`, |
| 102 | `CONFIG_BOOTSTD_DEFAULTS` and `CONFIG_EFI_LOADER` are enabled. See |
| 103 | :doc:`manual_boot` for how to do this manually. |
Sam Protsenko | bd7bffe | 2017-08-14 20:22:17 +0300 | [diff] [blame] | 104 | |
Bin Meng | 2e26682 | 2016-02-28 23:54:52 -0800 | [diff] [blame] | 105 | Test with SeaBIOS |
| 106 | ----------------- |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 107 | `SeaBIOS`_ is an open source implementation of a 16-bit x86 BIOS. It can run |
Bin Meng | 2e26682 | 2016-02-28 23:54:52 -0800 | [diff] [blame] | 108 | in an emulator or natively on x86 hardware with the use of U-Boot. With its |
| 109 | help, we can boot some OSes that require 16-bit BIOS services like Windows/DOS. |
| 110 | |
| 111 | As U-Boot, we have to manually create a table where SeaBIOS gets various system |
| 112 | information (eg: E820) from. The table unfortunately has to follow the coreboot |
| 113 | table format as SeaBIOS currently supports booting as a coreboot payload. |
| 114 | |
| 115 | To support loading SeaBIOS, U-Boot should be built with CONFIG_SEABIOS on. |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 116 | Booting SeaBIOS is done via U-Boot's bootelf command, like below:: |
Bin Meng | 2e26682 | 2016-02-28 23:54:52 -0800 | [diff] [blame] | 117 | |
| 118 | => tftp bios.bin.elf;bootelf |
| 119 | Using e1000#0 device |
| 120 | TFTP from server 10.10.0.100; our IP address is 10.10.0.108 |
| 121 | ... |
Bin Meng | 58e58cd | 2021-08-03 20:50:04 +0800 | [diff] [blame] | 122 | Bytes transferred = 128748 (1f6ec hex) |
| 123 | ## Starting application at 0x000fd269 ... |
| 124 | SeaBIOS (version rel-1.14.0-0-g155821a) |
Bin Meng | 2e26682 | 2016-02-28 23:54:52 -0800 | [diff] [blame] | 125 | ... |
| 126 | |
Bin Meng | 58e58cd | 2021-08-03 20:50:04 +0800 | [diff] [blame] | 127 | bios.bin.elf is the SeaBIOS image built from SeaBIOS source tree. At the time |
| 128 | being, SeaBIOS release 1.14.0 has been tested. To build the SeaBIOS image:: |
Bin Meng | 2e26682 | 2016-02-28 23:54:52 -0800 | [diff] [blame] | 129 | |
Bin Meng | 58e58cd | 2021-08-03 20:50:04 +0800 | [diff] [blame] | 130 | $ echo -e 'CONFIG_COREBOOT=y\nCONFIG_COREBOOT_FLASH=n\nCONFIG_DEBUG_SERIAL=y\nCONFIG_DEBUG_COREBOOT=n' > .config |
| 131 | $ make olddefconfig |
Bin Meng | 2e26682 | 2016-02-28 23:54:52 -0800 | [diff] [blame] | 132 | $ make |
| 133 | ... |
Bin Meng | 58e58cd | 2021-08-03 20:50:04 +0800 | [diff] [blame] | 134 | Total size: 128512 Fixed: 69216 Free: 2560 (used 98.0% of 128KiB rom) |
Bin Meng | 2e26682 | 2016-02-28 23:54:52 -0800 | [diff] [blame] | 135 | Creating out/bios.bin.elf |
| 136 | |
| 137 | Currently this is tested on QEMU x86 target with U-Boot chain-loading SeaBIOS |
| 138 | to install/boot a Windows XP OS (below for example command to install Windows). |
| 139 | |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 140 | .. code-block:: none |
| 141 | |
Bin Meng | 2e26682 | 2016-02-28 23:54:52 -0800 | [diff] [blame] | 142 | # Create a 10G disk.img as the virtual hard disk |
| 143 | $ qemu-img create -f qcow2 disk.img 10G |
| 144 | |
| 145 | # Install a Windows XP OS from an ISO image 'winxp.iso' |
| 146 | $ qemu-system-i386 -serial stdio -bios u-boot.rom -hda disk.img -cdrom winxp.iso -smp 2 -m 512 |
| 147 | |
| 148 | # Boot a Windows XP OS installed on the virutal hard disk |
| 149 | $ qemu-system-i386 -serial stdio -bios u-boot.rom -hda disk.img -smp 2 -m 512 |
| 150 | |
| 151 | This is also tested on Intel Crown Bay board with a PCIe graphics card, booting |
| 152 | SeaBIOS then chain-loading a GRUB on a USB drive, then Linux kernel finally. |
| 153 | |
Bin Meng | d5eed0d | 2016-05-11 07:45:06 -0700 | [diff] [blame] | 154 | If you are using Intel Integrated Graphics Device (IGD) as the primary display |
| 155 | device on your board, SeaBIOS needs to be patched manually to get its VGA ROM |
| 156 | loaded and run by SeaBIOS. SeaBIOS locates VGA ROM via the PCI expansion ROM |
| 157 | register, but IGD device does not have its VGA ROM mapped by this register. |
| 158 | Its VGA ROM is packaged as part of u-boot.rom at a configurable flash address |
| 159 | which is unknown to SeaBIOS. An example patch is needed for SeaBIOS below: |
| 160 | |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 161 | .. code-block:: none |
| 162 | |
| 163 | diff --git a/src/optionroms.c b/src/optionroms.c |
| 164 | index 65f7fe0..c7b6f5e 100644 |
| 165 | --- a/src/optionroms.c |
| 166 | +++ b/src/optionroms.c |
| 167 | @@ -324,6 +324,8 @@ init_pcirom(struct pci_device *pci, int isvga, u64 *sources) |
| 168 | rom = deploy_romfile(file); |
| 169 | else if (RunPCIroms > 1 || (RunPCIroms == 1 && isvga)) |
| 170 | rom = map_pcirom(pci); |
| 171 | + if (pci->bdf == pci_to_bdf(0, 2, 0)) |
| 172 | + rom = (struct rom_header *)0xfff90000; |
| 173 | if (! rom) |
| 174 | // No ROM present. |
| 175 | return; |
Bin Meng | d5eed0d | 2016-05-11 07:45:06 -0700 | [diff] [blame] | 176 | |
| 177 | Note: the patch above expects IGD device is at PCI b.d.f 0.2.0 and its VGA ROM |
| 178 | is at 0xfff90000 which corresponds to CONFIG_VGA_BIOS_ADDR on Minnowboard MAX. |
| 179 | Change these two accordingly if this is not the case on your board. |
Simon Glass | c05168f | 2015-07-27 15:47:31 -0600 | [diff] [blame] | 180 | |
Simon Glass | 5c840ef | 2015-01-27 22:13:46 -0700 | [diff] [blame] | 181 | Development Flow |
| 182 | ---------------- |
Simon Glass | 5c840ef | 2015-01-27 22:13:46 -0700 | [diff] [blame] | 183 | These notes are for those who want to port U-Boot to a new x86 platform. |
| 184 | |
| 185 | Since x86 CPUs boot from SPI flash, a SPI flash emulator is a good investment. |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 186 | The Dediprog em100 can be used on Linux. |
Simon Glass | 5c840ef | 2015-01-27 22:13:46 -0700 | [diff] [blame] | 187 | |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 188 | The em100 tool is available here: http://review.coreboot.org/p/em100.git |
Simon Glass | 5c840ef | 2015-01-27 22:13:46 -0700 | [diff] [blame] | 189 | |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 190 | On Minnowboard Max the following command line can be used:: |
Simon Glass | 5c840ef | 2015-01-27 22:13:46 -0700 | [diff] [blame] | 191 | |
| 192 | sudo em100 -s -p LOW -d u-boot.rom -c W25Q64DW -r |
| 193 | |
| 194 | A suitable clip for connecting over the SPI flash chip is here: |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 195 | http://www.dediprog.com/pd/programmer-accessories/EM-TC-8. |
Simon Glass | 5c840ef | 2015-01-27 22:13:46 -0700 | [diff] [blame] | 196 | |
| 197 | This allows you to override the SPI flash contents for development purposes. |
| 198 | Typically you can write to the em100 in around 1200ms, considerably faster |
| 199 | than programming the real flash device each time. The only important |
| 200 | limitation of the em100 is that it only supports SPI bus speeds up to 20MHz. |
| 201 | This means that images must be set to boot with that speed. This is an |
| 202 | Intel-specific feature - e.g. tools/ifttool has an option to set the SPI |
| 203 | speed in the SPI descriptor region. |
| 204 | |
| 205 | If your chip/board uses an Intel Firmware Support Package (FSP) it is fairly |
| 206 | easy to fit it in. You can follow the Minnowboard Max implementation, for |
| 207 | example. Hopefully you will just need to create new files similar to those |
| 208 | in arch/x86/cpu/baytrail which provide Bay Trail support. |
| 209 | |
| 210 | If you are not using an FSP you have more freedom and more responsibility. |
| 211 | The ivybridge support works this way, although it still uses a ROM for |
| 212 | graphics and still has binary blobs containing Intel code. You should aim to |
| 213 | support all important peripherals on your platform including video and storage. |
| 214 | Use the device tree for configuration where possible. |
| 215 | |
| 216 | For the microcode you can create a suitable device tree file using the |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 217 | microcode tool:: |
Simon Glass | 5c840ef | 2015-01-27 22:13:46 -0700 | [diff] [blame] | 218 | |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 219 | ./tools/microcode-tool -d microcode.dat -m <model> create |
Simon Glass | 5c840ef | 2015-01-27 22:13:46 -0700 | [diff] [blame] | 220 | |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 221 | or if you only have header files and not the full Intel microcode.dat database:: |
Simon Glass | 5c840ef | 2015-01-27 22:13:46 -0700 | [diff] [blame] | 222 | |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 223 | ./tools/microcode-tool -H BAY_TRAIL_FSP_KIT/Microcode/M0130673322.h \ |
| 224 | -H BAY_TRAIL_FSP_KIT/Microcode/M0130679901.h -m all create |
Simon Glass | 5c840ef | 2015-01-27 22:13:46 -0700 | [diff] [blame] | 225 | |
| 226 | These are written to arch/x86/dts/microcode/ by default. |
| 227 | |
| 228 | Note that it is possible to just add the micrcode for your CPU if you know its |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 229 | model. U-Boot prints this information when it starts:: |
Simon Glass | 5c840ef | 2015-01-27 22:13:46 -0700 | [diff] [blame] | 230 | |
| 231 | CPU: x86_64, vendor Intel, device 30673h |
| 232 | |
| 233 | so here we can use the M0130673322 file. |
| 234 | |
| 235 | If you platform can display POST codes on two little 7-segment displays on |
| 236 | the board, then you can use post_code() calls from C or assembler to monitor |
| 237 | boot progress. This can be good for debugging. |
| 238 | |
| 239 | If not, you can try to get serial working as early as possible. The early |
Stefan Roese | a377b7c | 2016-01-19 14:24:12 +0100 | [diff] [blame] | 240 | debug serial port may be useful here. See setup_internal_uart() for an example. |
Simon Glass | 5c840ef | 2015-01-27 22:13:46 -0700 | [diff] [blame] | 241 | |
Bin Meng | cdee6d9 | 2015-08-02 20:33:35 -0700 | [diff] [blame] | 242 | During the U-Boot porting, one of the important steps is to write correct PIRQ |
| 243 | routing information in the board device tree. Without it, device drivers in the |
| 244 | Linux kernel won't function correctly due to interrupt is not working. Please |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 245 | refer to U-Boot `doc <doc/device-tree-bindings/misc/intel,irq-router.txt>`_ for |
| 246 | the device tree bindings of Intel interrupt router. Here we have more details |
| 247 | on the intel,pirq-routing property below. |
| 248 | |
| 249 | .. code-block:: none |
Bin Meng | cdee6d9 | 2015-08-02 20:33:35 -0700 | [diff] [blame] | 250 | |
| 251 | intel,pirq-routing = < |
| 252 | PCI_BDF(0, 2, 0) INTA PIRQA |
| 253 | ... |
| 254 | >; |
| 255 | |
| 256 | As you see each entry has 3 cells. For the first one, we need describe all pci |
| 257 | devices mounted on the board. For SoC devices, normally there is a chapter on |
| 258 | the chipset datasheet which lists all the available PCI devices. For example on |
| 259 | Bay Trail, this is chapter 4.3 (PCI configuration space). For the second one, we |
| 260 | can get the interrupt pin either from datasheet or hardware via U-Boot shell. |
| 261 | The reliable source is the hardware as sometimes chipset datasheet is not 100% |
| 262 | up-to-date. Type 'pci header' plus the device's pci bus/device/function number |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 263 | from U-Boot shell below:: |
Bin Meng | cdee6d9 | 2015-08-02 20:33:35 -0700 | [diff] [blame] | 264 | |
| 265 | => pci header 0.1e.1 |
| 266 | vendor ID = 0x8086 |
| 267 | device ID = 0x0f08 |
| 268 | ... |
| 269 | interrupt line = 0x09 |
| 270 | interrupt pin = 0x04 |
| 271 | ... |
| 272 | |
| 273 | It shows this PCI device is using INTD pin as it reports 4 in the interrupt pin |
| 274 | register. Repeat this until you get interrupt pins for all the devices. The last |
| 275 | cell is the PIRQ line which a particular interrupt pin is mapped to. On Intel |
| 276 | chipset, the power-up default mapping is INTA/B/C/D maps to PIRQA/B/C/D. This |
| 277 | can be changed by registers in LPC bridge. So far Intel FSP does not touch those |
| 278 | registers so we can write down the PIRQ according to the default mapping rule. |
| 279 | |
| 280 | Once we get the PIRQ routing information in the device tree, the interrupt |
| 281 | allocation and assignment will be done by U-Boot automatically. Now you can |
| 282 | enable CONFIG_GENERATE_PIRQ_TABLE for testing Linux kernel using i8259 PIC and |
| 283 | CONFIG_GENERATE_MP_TABLE for testing Linux kernel using local APIC and I/O APIC. |
| 284 | |
Simon Glass | e3170a1 | 2015-08-13 10:36:17 -0600 | [diff] [blame] | 285 | This script might be useful. If you feed it the output of 'pci long' from |
| 286 | U-Boot then it will generate a device tree fragment with the interrupt |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 287 | configuration for each device (note it needs gawk 4.0.0):: |
Simon Glass | e3170a1 | 2015-08-13 10:36:17 -0600 | [diff] [blame] | 288 | |
| 289 | $ cat console_output |awk '/PCI/ {device=$4} /interrupt line/ {line=$4} \ |
| 290 | /interrupt pin/ {pin = $4; if (pin != "0x00" && pin != "0xff") \ |
| 291 | {patsplit(device, bdf, "[0-9a-f]+"); \ |
| 292 | printf "PCI_BDF(%d, %d, %d) INT%c PIRQ%c\n", strtonum("0x" bdf[1]), \ |
| 293 | strtonum("0x" bdf[2]), bdf[3], strtonum(pin) + 64, 64 + strtonum(pin)}}' |
| 294 | |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 295 | Example output:: |
| 296 | |
Simon Glass | e3170a1 | 2015-08-13 10:36:17 -0600 | [diff] [blame] | 297 | PCI_BDF(0, 2, 0) INTA PIRQA |
| 298 | PCI_BDF(0, 3, 0) INTA PIRQA |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 299 | ... |
Simon Glass | e3170a1 | 2015-08-13 10:36:17 -0600 | [diff] [blame] | 300 | |
Bin Meng | 213f6f0 | 2015-09-09 23:20:29 -0700 | [diff] [blame] | 301 | Porting Hints |
| 302 | ------------- |
| 303 | |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 304 | Quark-specific considerations |
| 305 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Bin Meng | 213f6f0 | 2015-09-09 23:20:29 -0700 | [diff] [blame] | 306 | |
| 307 | To port U-Boot to other boards based on the Intel Quark SoC, a few things need |
| 308 | to be taken care of. The first important part is the Memory Reference Code (MRC) |
| 309 | parameters. Quark MRC supports memory-down configuration only. All these MRC |
| 310 | parameters are supplied via the board device tree. To get started, first copy |
| 311 | the MRC section of arch/x86/dts/galileo.dts to your board's device tree, then |
| 312 | change these values by consulting board manuals or your hardware vendor. |
| 313 | Available MRC parameter values are listed in include/dt-bindings/mrc/quark.h. |
| 314 | The other tricky part is with PCIe. Quark SoC integrates two PCIe root ports, |
| 315 | but by default they are held in reset after power on. In U-Boot, PCIe |
| 316 | initialization is properly handled as per Quark's firmware writer guide. |
| 317 | In your board support codes, you need provide two routines to aid PCIe |
| 318 | initialization, which are board_assert_perst() and board_deassert_perst(). |
| 319 | The two routines need implement a board-specific mechanism to assert/deassert |
| 320 | PCIe PERST# pin. Care must be taken that in those routines that any APIs that |
| 321 | may trigger PCI enumeration process are strictly forbidden, as any access to |
| 322 | PCIe root port's configuration registers will cause system hang while it is |
| 323 | held in reset. For more details, check how they are implemented by the Intel |
| 324 | Galileo board support codes in board/intel/galileo/galileo.c. |
| 325 | |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 326 | coreboot |
| 327 | ^^^^^^^^ |
Simon Glass | 15318f2 | 2016-03-06 19:28:17 -0700 | [diff] [blame] | 328 | |
| 329 | See scripts/coreboot.sed which can assist with porting coreboot code into |
| 330 | U-Boot drivers. It will not resolve all build errors, but will perform common |
| 331 | transformations. Remember to add attribution to coreboot for new files added |
| 332 | to U-Boot. This should go at the top of each file and list the coreboot |
| 333 | filename where the code originated. |
| 334 | |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 335 | Debugging ACPI issues with Windows |
| 336 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Bin Meng | f2071ba | 2016-05-11 07:45:12 -0700 | [diff] [blame] | 337 | |
| 338 | Windows might cache system information and only detect ACPI changes if you |
| 339 | modify the ACPI table versions. So tweak them liberally when debugging ACPI |
| 340 | issues with Windows. |
| 341 | |
Bin Meng | 4258f80 | 2016-05-07 07:46:37 -0700 | [diff] [blame] | 342 | ACPI Support Status |
| 343 | ------------------- |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 344 | Advanced Configuration and Power Interface (`ACPI`_) aims to establish |
Bin Meng | 4258f80 | 2016-05-07 07:46:37 -0700 | [diff] [blame] | 345 | industry-standard interfaces enabling OS-directed configuration, power |
| 346 | management, and thermal management of mobile, desktop, and server platforms. |
| 347 | |
| 348 | Linux can boot without ACPI with "acpi=off" command line parameter, but |
| 349 | with ACPI the kernel gains the capabilities to handle power management. |
| 350 | For Windows, ACPI is a must-have firmware feature since Windows Vista. |
| 351 | CONFIG_GENERATE_ACPI_TABLE is the config option to turn on ACPI support in |
| 352 | U-Boot. This requires Intel ACPI compiler to be installed on your host to |
| 353 | compile ACPI DSDT table written in ASL format to AML format. You can get |
| 354 | the compiler via "apt-get install iasl" if you are on Ubuntu or download |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 355 | the source from https://www.acpica.org/downloads to compile one by yourself. |
Bin Meng | 4258f80 | 2016-05-07 07:46:37 -0700 | [diff] [blame] | 356 | |
Bin Meng | 487b8e8 | 2017-04-21 07:24:49 -0700 | [diff] [blame] | 357 | Current ACPI support in U-Boot is basically complete. More optional features |
| 358 | can be added in the future. The status as of today is: |
Bin Meng | 4258f80 | 2016-05-07 07:46:37 -0700 | [diff] [blame] | 359 | |
| 360 | * Support generating RSDT, XSDT, FACS, FADT, MADT, MCFG tables. |
| 361 | * Support one static DSDT table only, compiled by Intel ACPI compiler. |
Bin Meng | 487b8e8 | 2017-04-21 07:24:49 -0700 | [diff] [blame] | 362 | * Support S0/S3/S4/S5, reboot and shutdown from OS. |
Bin Meng | 4258f80 | 2016-05-07 07:46:37 -0700 | [diff] [blame] | 363 | * Support booting a pre-installed Ubuntu distribution via 'zboot' command. |
Bin Meng | 65b2e9e | 2016-05-11 07:45:08 -0700 | [diff] [blame] | 364 | * Support installing and booting Ubuntu 14.04 (or above) from U-Boot with |
| 365 | the help of SeaBIOS using legacy interface (non-UEFI mode). |
| 366 | * Support installing and booting Windows 8.1/10 from U-Boot with the help |
| 367 | of SeaBIOS using legacy interface (non-UEFI mode). |
Bin Meng | 4258f80 | 2016-05-07 07:46:37 -0700 | [diff] [blame] | 368 | * Support ACPI interrupts with SCI only. |
| 369 | |
Bin Meng | 4258f80 | 2016-05-07 07:46:37 -0700 | [diff] [blame] | 370 | Features that are optional: |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 371 | |
Bin Meng | 4258f80 | 2016-05-07 07:46:37 -0700 | [diff] [blame] | 372 | * Dynamic AML bytecodes insertion at run-time. We may need this to support |
| 373 | SSDT table generation and DSDT fix up. |
| 374 | * SMI support. Since U-Boot is a modern bootloader, we don't want to bring |
| 375 | those legacy stuff into U-Boot. ACPI spec allows a system that does not |
| 376 | support SMI (a legacy-free system). |
| 377 | |
Bin Meng | edf8240 | 2016-05-25 19:19:12 -0700 | [diff] [blame] | 378 | ACPI was initially enabled on BayTrail based boards. Testing was done by booting |
Bin Meng | 65b2e9e | 2016-05-11 07:45:08 -0700 | [diff] [blame] | 379 | a pre-installed Ubuntu 14.04 from a SATA drive. Installing Ubuntu 14.04 and |
| 380 | Windows 8.1/10 to a SATA drive and booting from there is also tested. Most |
| 381 | devices seem to work correctly and the board can respond a reboot/shutdown |
| 382 | command from the OS. |
Simon Glass | 15318f2 | 2016-03-06 19:28:17 -0700 | [diff] [blame] | 383 | |
Bin Meng | edf8240 | 2016-05-25 19:19:12 -0700 | [diff] [blame] | 384 | For other platform boards, ACPI support status can be checked by examining their |
| 385 | board defconfig files to see if CONFIG_GENERATE_ACPI_TABLE is set to y. |
| 386 | |
Bin Meng | 487b8e8 | 2017-04-21 07:24:49 -0700 | [diff] [blame] | 387 | The S3 sleeping state is a low wake latency sleeping state defined by ACPI |
| 388 | spec where all system context is lost except system memory. To test S3 resume |
| 389 | with a Linux kernel, simply run "echo mem > /sys/power/state" and kernel will |
| 390 | put the board to S3 state where the power is off. So when the power button is |
| 391 | pressed again, U-Boot runs as it does in cold boot and detects the sleeping |
| 392 | state via ACPI register to see if it is S3, if yes it means we are waking up. |
| 393 | U-Boot is responsible for restoring the machine state as it is before sleep. |
| 394 | When everything is done, U-Boot finds out the wakeup vector provided by OSes |
| 395 | and jump there. To determine whether ACPI S3 resume is supported, check to |
| 396 | see if CONFIG_HAVE_ACPI_RESUME is set for that specific board. |
| 397 | |
| 398 | Note for testing S3 resume with Windows, correct graphics driver must be |
| 399 | installed for your platform, otherwise you won't find "Sleep" option in |
| 400 | the "Power" submenu from the Windows start menu. |
| 401 | |
Simon Glass | 669881b | 2016-07-17 01:23:45 -0600 | [diff] [blame] | 402 | EFI Support |
| 403 | ----------- |
| 404 | U-Boot supports booting as a 32-bit or 64-bit EFI payload, e.g. with UEFI. |
Bin Meng | 706db82 | 2018-06-12 08:36:13 -0700 | [diff] [blame] | 405 | This is enabled with CONFIG_EFI_STUB to boot from both 32-bit and 64-bit |
| 406 | UEFI BIOS. U-Boot can also run as an EFI application, with CONFIG_EFI_APP. |
Bin Meng | 9cf307a | 2018-06-27 20:38:05 -0700 | [diff] [blame] | 407 | The CONFIG_EFI_LOADER option, where U-Boot provides an EFI environment to |
Bin Meng | 706db82 | 2018-06-12 08:36:13 -0700 | [diff] [blame] | 408 | the kernel (i.e. replaces UEFI completely but provides the same EFI run-time |
Bin Meng | 9cf307a | 2018-06-27 20:38:05 -0700 | [diff] [blame] | 409 | services) is supported too. For example, we can even use 'bootefi' command |
| 410 | to load a 'u-boot-payload.efi', see below test logs on QEMU. |
| 411 | |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 412 | .. code-block:: none |
| 413 | |
Bin Meng | 9cf307a | 2018-06-27 20:38:05 -0700 | [diff] [blame] | 414 | => load ide 0 3000000 u-boot-payload.efi |
| 415 | 489787 bytes read in 138 ms (3.4 MiB/s) |
| 416 | => bootefi 3000000 |
| 417 | Scanning disk ide.blk#0... |
| 418 | Found 2 disks |
| 419 | WARNING: booting without device tree |
| 420 | ## Starting EFI application at 03000000 ... |
| 421 | U-Boot EFI Payload |
| 422 | |
| 423 | |
| 424 | U-Boot 2018.07-rc2 (Jun 23 2018 - 17:12:58 +0800) |
| 425 | |
| 426 | CPU: x86_64, vendor AMD, device 663h |
| 427 | DRAM: 2 GiB |
| 428 | MMC: |
| 429 | Video: 1024x768x32 |
| 430 | Model: EFI x86 Payload |
| 431 | Net: e1000: 52:54:00:12:34:56 |
| 432 | |
| 433 | Warning: e1000#0 using MAC address from ROM |
| 434 | eth0: e1000#0 |
| 435 | No controllers found |
| 436 | Hit any key to stop autoboot: 0 |
Simon Glass | 669881b | 2016-07-17 01:23:45 -0600 | [diff] [blame] | 437 | |
Simon Glass | 2bf76a7 | 2023-09-19 21:00:18 -0600 | [diff] [blame] | 438 | See :doc:`../../develop/uefi/u-boot_on_efi` and :doc:`../../develop/uefi/uefi` |
| 439 | for details of EFI support in U-Boot. |
Simon Glass | 669881b | 2016-07-17 01:23:45 -0600 | [diff] [blame] | 440 | |
Simon Glass | 802d88e | 2020-04-26 09:13:01 -0600 | [diff] [blame] | 441 | Chain-loading |
| 442 | ------------- |
Simon Glass | 273d08f | 2023-09-21 07:37:45 -0600 | [diff] [blame] | 443 | U-Boot can be chain-loaded from another bootloader, such as |
| 444 | :doc:`../../board/coreboot/index` coreboot or |
| 445 | :doc:`../../board/intel/slimbootloader`. Typically this is done by building for |
| 446 | targets 'coreboot' or 'slimbootloader'. |
Simon Glass | 802d88e | 2020-04-26 09:13:01 -0600 | [diff] [blame] | 447 | |
| 448 | For example, at present we have a 'coreboot' target but this runs very |
| 449 | different code from the bare-metal targets, such as coral. There is very little |
| 450 | in common between them. |
| 451 | |
| 452 | It is useful to be able to boot the same U-Boot on a device, with or without a |
| 453 | first-stage bootloader. For example, with chromebook_coral, it is helpful for |
| 454 | testing to be able to boot the same U-Boot (complete with FSP) on bare metal |
| 455 | and from coreboot. It allows checking of things like CPU speed, comparing |
| 456 | registers, ACPI tables and the like. |
| 457 | |
| 458 | To do this you can use ll_boot_init() in appropriate places to skip init that |
| 459 | has already been done by the previous stage. This works by setting a |
| 460 | GD_FLG_NO_LL_INIT flag when U-Boot detects that it is running from another |
| 461 | bootloader. |
| 462 | |
| 463 | With this feature, you can build a bare-metal target and boot it from |
| 464 | coreboot, for example. |
| 465 | |
| 466 | Note that this is a development feature only. It is not intended for use in |
| 467 | production environments. Also it is not currently part of the automated tests |
| 468 | so may break in the future. |
| 469 | |
Simon Glass | 31d187d | 2020-11-05 06:32:10 -0700 | [diff] [blame] | 470 | SMBIOS tables |
| 471 | ------------- |
| 472 | |
| 473 | To generate SMBIOS tables in U-Boot, for use by the OS, enable the |
| 474 | CONFIG_GENERATE_SMBIOS_TABLE option. The easiest way to provide the values to |
| 475 | use is via the device tree. For details see |
Simon Glass | 2bf76a7 | 2023-09-19 21:00:18 -0600 | [diff] [blame] | 476 | :download:`smbios.txt <../../device-tree-bindings/sysinfo/smbios.txt>`. |
Simon Glass | 31d187d | 2020-11-05 06:32:10 -0700 | [diff] [blame] | 477 | |
Bin Meng | 9e816df | 2014-12-17 15:50:48 +0800 | [diff] [blame] | 478 | TODO List |
| 479 | --------- |
Bin Meng | 9e816df | 2014-12-17 15:50:48 +0800 | [diff] [blame] | 480 | - Audio |
| 481 | - Chrome OS verified boot |
Bin Meng | 9e816df | 2014-12-17 15:50:48 +0800 | [diff] [blame] | 482 | |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 483 | .. _coreboot: http://www.coreboot.org |
| 484 | .. _QEMU: http://www.qemu.org |
| 485 | .. _microcode: http://en.wikipedia.org/wiki/Microcode |
| 486 | .. _SFI: http://simplefirmware.org |
| 487 | .. _MP: http://www.intel.com/design/archives/processors/pro/docs/242016.htm |
Bin Meng | 89ad2bb | 2019-07-18 00:34:26 -0700 | [diff] [blame] | 488 | .. _SeaBIOS: http://www.seabios.org/SeaBIOS |
| 489 | .. _ACPI: http://www.acpi.info |