1 # Porting coreboot using autoport
6 For any Sandy Bridge or Ivy Bridge platform the generated result should
7 be bootable, possibly with minor fixes.
10 EC support is likely to work on Intel-based thinkpads. Other laptops are
11 likely to miss EC support. SuperIO support on desktops is more likely to
12 work out of the box than any EC.
14 ## How to use autoport
16 Enable as many devices as possible in the firmware setup of your system.
17 This is useful to detect as many devices as possible and make the port
18 more complete, as disabled devices cannot be detected.
20 Boot into target machine under any Linux-based distribution and install
21 the following tools on it:
26 * `acpidump` (part of `acpica` on some distros)
28 Clone the coreboot tree and `cd` into it. For more detailed steps, refer
29 to Rookie Guide, Lesson 1. Afterwards, run these commands:
39 sudo ./autoport --input_log=logs --make_logs --coreboot_dir=../..
41 Note: in case you have problems getting gcc and golang on the target
42 machine, you can compile the utilities on another computer and copy
43 the binaries to the target machine. You will still need the other
44 listed programs on the target machine, but you may place them in the
45 same directory as autoport.
47 Check for unknown detected PCI devices, e.g.:
49 Unknown PCI device 8086:0085, assuming removable
51 If autoport says `assuming removable`, you are fine. If it doesn't,
52 you may want to add the relevant PCI IDs to autoport. Run `lspci -nn`
53 and check which device this is using the PCI ID. Devices which are not
54 part of the chipset, such as GPUs or network cards, can be considered
55 removable, whereas devices inside the CPU or the PCH such as integrated
56 GPUs and bus controllers (SATA, USB, LPC, SMBus...) are non-removable.
58 Your board has now been added to the tree. However, do not flash it
59 in its current state. It can brick your machine. Instead, keep this
60 new port and the logs from `util/autoport/logs` somewhere safe. The
61 following steps will back up your current firmware, which is always
62 recommended, since coreboot may not boot on the first try.
64 Disassemble your computer and find the flash chip(s). Since there could be
65 more than one, this guide will refer to "flash chips" as one or more chips.
66 Refer to <https://flashrom.org/Technology> as a reference. The flash chip is
67 usually in a `SOIC-8` (2x4 pins, 200mil) or `SOIC-16` (2x8 pins) package. As
68 it can be seen on flashrom's wiki, the former package is like any other 8-pin
69 chip on the mainboard, but it is slightly larger. The latter package is much
70 easier to locate. Always make sure it is a flash chip by looking up what its
71 model, printed on it, refers to.
73 There may be a smaller flash chip for the EC on some laptops, and other chips
74 such as network cards may use similar flash chips. These should be left as-is.
77 Once located, use an external flasher to read the flash chips with `flashrom -r`.
78 Verify with `flashrom -v` several times that reading is consistent. If it is not,
79 troubleshoot your flashing setup. Save the results somewhere safe, preferably on
80 media that cannot be easily overwritten and on several devices. You may need this
81 later. The write process erases the flash chips first, and erased data on a flash
82 chip is lost for a very long time, usually forever!
84 Compile coreboot for your ported mainboard with some console enabled. The most
85 common ones are EHCI debug, serial port and SPI flash console as a last resort.
86 If your system is a laptop and has a dedicated video card, you may need to add
87 a video BIOS (VBIOS) to coreboot to be able to see any video output. Desktop
88 video cards, as well as some MXM video cards, have this VBIOS on a flash chip
89 on the card's PCB, so this step is not necessary for them.
91 Flash coreboot on the machine. On recent Intel chipsets, the flash space is split
92 in several regions. Only the one known as "BIOS region" should be flashed. If
93 there is only one flash chip present, this is best done by adding the `--ifd`
94 and `-i bios` parameters flashrom has (from v1.0 onwards) to specify what flash
95 descriptor region it should operate on. If the ME (Management Engine) region is
96 not readable, which is the case on most systems, use the `--noverify-all`
99 For systems with two flash chips, this is not so easy. It is probably better to
100 ask in coreboot or flashrom communication channels, such as via IRC or on the
103 Once flashed, try to boot. Anything is possible. If a log is generated, save it
104 and use it to address any issues. See the next section for useful information.
105 Find all the sections marked with `FIXME` and correct them.
107 Send your work to review.coreboot.org. I mean it, your effort is very appreciated.
108 Refer to Rookie Guide, Lesson 2 for instructions on how to submit a patch.
112 In order to initialize the RAM memory, coreboot needs to know its timings, which vary between
113 modules. Socketed RAM has a small EEPROM chip, which is accessible via SMBus and contains the
114 timing data. This data is usually known as SPD. Unfortunately, the SMBus addresses may not
115 correlate with the RAM slots and cannot always be detected automatically. The address map is
116 encoded in function `mainboard_get_spd` in `romstage.c`. By default, autoport uses the most
117 common map `0x50, 0x51, 0x52, 0x53` on everything except for Lenovo systems, which are known
118 to use `0x50, 0x52, 0x51, 0x53`. To detect the correct memory map, the easiest way is to boot
119 on the vendor firmware with just one module in channel 0, slot 0, and check the SMBus address
120 the EEPROM has. Under Linux, you can use these commands to see what is on SMBus:
122 $ sudo modprobe i2c-dev
123 $ sudo modprobe i2c-i801
125 i2c-0 i2c i915 gmbus ssc I2C adapter
126 i2c-1 i2c i915 gmbus vga I2C adapter
127 i2c-2 i2c i915 gmbus panel I2C adapter
128 i2c-3 i2c i915 gmbus dpc I2C adapter
129 i2c-4 i2c i915 gmbus dpb I2C adapter
130 i2c-5 i2c i915 gmbus dpd I2C adapter
131 i2c-6 i2c DPDDC-B I2C adapter
132 i2c-7 i2c DPDDC-C I2C adapter
133 i2c-8 i2c DPDDC-D I2C adapter
134 i2c-9 smbus SMBus I801 adapter at 0400 SMBus adapter
137 WARNING! This program can confuse your I2C bus, cause data loss and worse!
138 I will probe file /dev/i2c-9.
139 I will probe address range 0x03-0x77.
141 0 1 2 3 4 5 6 7 8 9 a b c d e f
142 00: -- -- -- -- -- 08 -- -- -- -- -- -- --
143 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
144 20: -- -- -- -- 24 -- -- -- -- -- -- -- -- -- -- --
145 30: 30 31 -- -- -- -- -- -- -- -- -- -- -- -- -- --
146 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
147 50: 50 -- -- -- 54 55 56 57 -- -- -- -- 5c 5d 5e 5f
148 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
149 70: -- -- -- -- -- -- -- --
151 Make sure to replace the `9` on the last command with the bus number for SMBus on
152 your system. Here, there is a module at address `0x50`. Since only one module was
153 installed on the first slot of the first channel, we know the first position of
154 the SPD array must be `0x50`. After testing all the slots, your `mainboard_get_spd`
155 should look similar to this:
157 void mainboard_get_spd(spd_raw_data *spd) {
158 read_spd(&spd[0], 0x50);
159 read_spd(&spd[1], 0x51);
160 read_spd(&spd[2], 0x52);
161 read_spd(&spd[3], 0x53);
164 Note that there should be one line per memory slot on the mainboard.
166 Note: slot labelling may be missing or unreliable. Use `inteltool` to see
167 which slots have modules in them.
169 This procedure is ideal, if your RAM is socketed. If you have soldered RAM,
170 remove any socketed memory modules and check if any EEPROM appears on SMBus.
171 If this is the case, you can proceed as if the RAM was socketed. However,
172 you may have to guess some entries if there multiple EEPROMs appear.
174 Most of the time, soldered RAM does not have an EEPROM. Instead, the SPD data is
175 inside the main flash chip where the firmware is. If this is the case, you need
176 to generate the SPD data to use with coreboot. Look at `inteltool.log`. There
177 should be something like this:
179 /* SPD matching current mode: */
181 00: 92 11 0b 03 04 00 00 09 03 52 01 08 0a 00 80 00
182 10: 6e 78 6e 32 6e 11 18 81 20 08 3c 3c 00 f0 00 00
183 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
184 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 65 00
185 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
186 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
187 60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
188 70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 6d 17
189 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
190 90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
191 a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
192 b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
193 c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
194 d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
195 e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
196 f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
198 00: 92 11 0b 03 04 00 00 09 03 52 01 08 0a 00 80 00
199 10: 6e 78 6e 32 6e 11 18 81 20 08 3c 3c 00 f0 00 00
200 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
201 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 65 00
202 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
203 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
204 60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
205 70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 6d 17
206 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
207 90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
208 a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
209 b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
210 c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
211 d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
212 e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
213 f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
215 This is not a full-fledged SPD dump, as it only lists
216 the currently-used speed configuration, and lacks info
217 such as a serial number, vendor and model. Use `xxd`
218 to create a binary file with this SPD data:
220 $ cat | xxd -r > spd.bin <<EOF
221 00: 92 11 0b 03 04 00 00 09 03 52 01 08 0a 00 80 00
222 10: 6e 78 6e 32 6e 11 18 81 20 08 3c 3c 00 f0 00 00
223 20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
224 30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 65 00
225 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
226 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
227 60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
228 70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 6d 17
229 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
230 90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
231 a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
232 b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
233 c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
234 d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
235 e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
236 f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
239 Then, move the generated file into your mainboard's directory
240 and hook it up to the build system by adding the following
241 lines to `Makefile.inc`:
243 cbfs-files-y += spd.bin
244 spd.bin-file := spd.bin
247 Now we need coreboot to use this SPD file. The following example
248 shows a hybrid configuration, in which one module is soldered and
249 the other one is socketed:
251 void mainboard_get_spd(spd_raw_data *spd)
254 size_t spd_file_len = 0;
255 /* C0S0 is a soldered RAM with no real SPD. Use stored SPD. */
256 spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_RAW,
258 if (spd_file && spd_file_len >= 128)
259 memcpy(&spd[0], spd_file, 128);
261 /* C1S0 is a physical slot. */
262 read_spd(&spd[2], 0x52);
265 If several slots are soldered there are two ways to handle them:
267 * If all use the same SPD data, use the same file for all the slots. Do
268 not forget to copy the data on all the array elements that need it.
269 * If they use different data, use several files.
271 If memory initialization is not working, in particular write training (timB)
272 on DIMM's second rank fails, try enabling rank 1 mirroring, which can't be
273 detected by inteltool. It is described by SPD field "Address Mapping from Edge
274 Connector to DRAM", byte `63` (`0x3f`). Bit 0 describes Rank 1 Mapping,
275 0 = standard, 1 = mirrored; set it to 1. Bits 1-7 are reserved.
279 `board_info.txt` is a text file used in the board status page to list all
280 the supported boards and their specifications. Most of the information
281 cannot be detected by autoport. Common entries are:
283 * `ROM package`, `ROM protocol` and `ROM socketed`:
284 These refer to the flash chips you found earlier. You can visit
285 <https://flashrom.org/Technology> for more information.
287 * `Release year`: Use the power of Internet to find that information.
288 * `Category`: This describes the type of mainboard you have.
289 Valid categories are:
290 * `desktop`. Desktops and workstations.
292 * `laptop`. Laptops, notebooks and netbooks.
293 * `half`. Embedded / PC/104 / Half-size boards.
294 * `mini`. Mini-ITX / Micro-ITX / Nano-ITX
295 * `settop`. Set-top-boxes / Thin clients.
296 * `eval`. Development / Evaluation Boards.
297 * `sbc`. Single-Board computer.
298 * `emulation`: Virtual machines and emulators. May require especial care
299 as they often behave differently from real counterparts.
300 * `misc`. Anything not fitting the categories above. Not recommended.
302 * `Flashrom support`: This means whether the internal programmer is usable.
303 If flashing coreboot internally works, this should be set to `y`. Else,
304 feel free to investigate why it is not working.
306 ### `USBDEBUG_HCD_INDEX`
308 Which controller the most easily accessible USB debug port is. On Intel,
309 1 is for `00:1d.0` and 2 is for `00:1a.0` (yes, it's reversed). Refer to
310 <https://www.coreboot.org/EHCI_Debug_Port> for more info.
312 If you are able to use EHCI debug without setting the HCD index manually,
315 ### `BOARD_ROMSIZE_KB_2048`
317 This parameter refers to the total size of the flash chips coreboot will be in.
318 This value must be correct for S3 resume to work properly. This parameter also
319 defines the size of the generated coreboot image, but that is not a major issue
320 since tools like `dd` can be used to cut fragments of a coreboot image to flash
323 This should be detected automatically, but it may not be detected properly in
324 some cases. If it was not detected, put the correct total size here to serve
325 as a sane default when configuring coreboot.
327 ### `DRAM_RESET_GATE_GPIO`
329 When the computer is suspended to RAM (ACPI S3), the RAM reset signal must not
330 reach the RAM modules. Otherwise, the computer will not resume and any opened
331 programs will be lost. This is done by powering down a MOSFET, which disconnects
332 the reset signal from the RAM modules. Most manufacturers put this gate on GPIO
333 60 but Lenovo is known to put it on GPIO 10. If suspending and resuming works,
334 this value is correct. This can also be determined from the board's schematics.
338 `mainboard_fill_gnvs` sets values in GNVS, which then ACPI makes use of for
339 various power-related functions. Normally, there is no need to modify it
340 on laptops (desktops have no "lid"!) but it makes sense to proofread it.
342 ## `gfx.ndid` and `gfx.did`
344 Those describe which video outputs are declared in ACPI tables.
345 Normally, there is no need to have these values, but if you miss some
346 non-standard video output, you can declare it there. Bit 31 is set to
347 indicate the presence of the output. Byte 1 is the type and byte 0 is
348 used for disambigution so that ID composed of byte 1 and 0 is unique.
356 ## `c*_acpower` and `c*_battery`
358 Which mwait states to match to which ACPI levels. Normally, there is no
359 need to modify anything unless your device has very special power saving
362 ## `install_intel_vga_int15_handler`
364 This is used with the Intel VGA BIOS, which is not the default option.
365 It is more error-prone than open-source graphics initialization, so do
366 not bother with this until your mainboard boots. This is a function
367 which takes four parameters:
368 1. Which type of LCD panel is connected.
373 Refer to `src/drivers/intel/gma/int15.h` to see which values can be used.
374 For desktops, there is no LCD panel directly connected to the Intel GPU,
375 so the first parameter should be `GMA_INT15_ACTIVE_LFP_NONE`. On other
376 mainboards, it depends.
380 Due to the poor state of CMOS support in coreboot, autoport does not
381 support it and this probably won't change until the format in the tree
382 improves. If you really care about CMOS options:
384 * Create files `cmos.layout` and `cmos.default`
385 * Enable `HAVE_OPTION_TABLE` and `HAVE_CMOS_DEFAULT` in `Kconfig`
389 You need to set `has_keyboard_backlight` (backlit keyboard like X230),
390 `has_power_management_beeps` (optional beeps when e.g. plugging the cord
391 in) and `has_uwb` (third MiniPCIe slot) in accordance to functions available
394 In rare cases autoport is unable to detect GPE. You can detect it from
395 dmesg or ACPI tables. Look for line in dmesg like
397 ACPI: EC: GPE = 0x11, I/O: command/status = 0x66, data = 0x62
399 This means that GPE is `0x11` in ACPI notation. This is the correct
400 value for `THINKPAD_EC_GPE`. To get the correct value for `GPE_EC_SCI`
401 you need to substract `0x10`, so value for it is `1`.
403 The pin used to wake the machine from EC is guessed. If your machine doesn't
404 wake on lid open and pressing of Fn, change `GPE_EC_WAKE`.
406 Keep `GPE_EC_WAKE` and `GPE_EC_SCI` in sync with `gpi*_routing`.
407 `gpi*_routing` matching `GPE_EC_WAKE` or `GPE_EC_SCI` is set to `2`
408 and all others are absent.
410 If your dock has LPC wires or needs some special treatement you may
411 need to add codes to initialize the dock and support code to
412 DSDT. See the `init_dock()` for `x60`, `x200` or `x201`.
414 ## EC (generic laptop)
416 Almost any laptop has an embedded controller. In a nutshell, it's a
417 small, low-powered computer designed to be used on laptops. Exact
418 functionality differs between machines. Its main functions include:
420 * Control of power and rfkill to different component
421 * Keyboard (PS/2) interface implementation
422 * Battery, AC, LID and thermal information exporting
425 autoport automatically attempts to restore the dumped config but it
426 may or may not work and may even lead to a hang or powerdown. If your
427 machine stops at `Replaying EC dump ...` try commenting EC replay out
429 autoport tries to detect if machine has PS/2 interface and if so calls
430 `pc_keyboard_init` and exports relevant ACPI objects. If detection fails
431 you may have to add them yourself
433 ACPI methods `_PTS` (prepare to sleep) and `_WAK` (wake) are executed
434 when transitioning to sleep or wake state respectively. You may need to
435 add power-related calls there to either shutdown some components or to
436 add a workaround to stop giving OS thermal info until next refresh.
438 For exporting the battery/AC/LID/hotkey/thermal info you need to write
439 `acpi/ec.asl`. For an easy example look into `apple/macbook21` or
440 `packardbell/ms2290`. For information about needed methods consult
441 relevant ACPI specs. Tracing which EC events can be done using
442 [dynamic debug](https://wiki.ubuntu.com/Kernel/Reference/ACPITricksAndTips)
444 EC GPE needs to be routed to SCI in order for OS in order to receive
445 EC events like "hotkey X pressed" or "AC plugged". autoport attempts
446 to detect GPE but in rare cases may fail. You can detect it from
447 dmesg or ACPI tables. Look for line in dmesg like
449 ACPI: EC: GPE = 0x11, I/O: command/status = 0x66, data = 0x62
451 This means that GPE is `0x11` in ACPI notation. This is the correct
454 Keep GPE in sync with `gpi*_routing`.
455 `gpi*_routing` matching `GPE - 0x10` is set to `2`
456 and all others are absent. If EC has separate wake pin
457 then this GPE needs to be routed as well