xref: /aosp_15_r20/external/coreboot/Documentation/tutorial/flashing_firmware/index.md (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1# Flashing firmware tutorial
2
3Updating the firmware is possible using the **internal method**, where the updates
4happen from a running system, or using the **external method**, where the system
5is in a shut down state and an external programmer is attached to write into the
6flash IC.
7
8## Contents
9
10```{toctree}
11:maxdepth: 1
12
13Flashing internally <int_flashrom.md>
14Flashing firmware standalone <ext_standalone.md>
15Flashing firmware externally supplying direct power <ext_power.md>
16Flashing firmware externally without supplying direct power <no_ext_power.md>
17```
18
19## General advice
20
21* It's recommended to only flash the BIOS region.
22* Always verify the firmware image.
23* If you flash externally and have transmission errors:
24  * Use short wires
25  * Reduce clock frequency
26  * Check power supply
27  * Make sure that there are no other bus masters (EC, ME, SoC, ...)
28
29## Internal method
30
31This method using [flashrom] is available on many platforms, as long as they
32aren't locked down.
33
34There are various protection schemes that make it impossible to modify or
35replace a firmware from a running system. coreboot allows to disable these
36mechanisms, making it possible to overwrite (or update) the firmware from a
37running system.
38
39Usually you must use the **external method** once to install a retrofitted
40coreboot and then you can use the **internal method** for future updates.
41
42There are multiple ways to update the firmware:
43* Using flashrom's *internal* programmer to directly write into the firmware
44  flash IC, running on the target machine itself
45* A proprietary software to update the firmware, running on the target machine
46  itself
47* A UEFI firmware update capsule
48
49More details on flashrom's
50```{toctree}
51:maxdepth: 1
52
53internal programmer <int_flashrom.md>
54```
55
56## External method
57
58External flashing is possible on many platforms, but requires disassembling
59the target hardware. You need to buy a flash programmer, that
60exposes the same interface as your flash IC (likely SPI).
61
62Please also have a look at the mainboard-specific documentation for details.
63
64After exposing the firmware flash IC, read the schematics and use one of the
65possible methods:
66
67```{toctree}
68:maxdepth: 1
69
70Flashing firmware standalone <ext_standalone.md>
71Flashing firmware externally supplying direct power <ext_power.md>
72Flashing firmware externally without supplying direct power <no_ext_power.md>
73```
74
75**WARNING:** Using the wrong method or accidentally using the wrong pinout might
76  permanently damage your hardware!
77
78**WARNING:** Do not rely on dots *painted* on flash ICs to orient the pins!
79Any dots painted on flash ICs may only indicate if they've been tested.  Dots
80that appear in datasheets to indicate pin 1 correspond to some kind of physical
81marker, such as a drilled hole, or one side being more flat than the other.
82
83## Using a layout file
84On platforms where the flash IC is shared with other components you might want
85to write only a part of the flash IC. On Intel for example there are IFD, ME and
86GBE which don't need to be updated to install coreboot.
87To make [flashrom] only write the *bios* region, leaving Intel ME and Intel IFD
88untouched, you can use a layout file, which can be created with ifdtool and a backup
89of the original firmware.
90
91```bash
92ifdtool -f rom.layout backup.rom
93```
94
95and looks similar to:
96
97```
9800000000:00000fff fd
9900500000:00bfffff bios
10000003000:004fffff me
10100001000:00002fff gbe
102```
103
104By specifying *-l* and *-i* [flashrom] writes a single region:
105```bash
106flashrom -l rom.layout -i bios -w coreboot.rom -p <programmer>
107```
108
109## Using an IFD to determine the layout
110flashrom version 1.0 supports reading the layout from the IFD (first 4KiB of
111the ROM). You don't need to manually specify a layout it, but it only works
112under the following conditions:
113
114* Only available on Intel ICH7+
115* There's only one flash IC when flashing externally
116
117```bash
118flashrom --ifd -i bios -w coreboot.rom -p <programmer>
119```
120
121**TODO** explain FMAP regions, normal/fallback mechanism, flash lock mechanisms
122
123[flashrom]: https://www.flashrom.org/Flashrom
124