xref: /aosp_15_r20/external/flashrom/doc/user_docs/misc_notes.rst (revision 0d6140be3aa665ecc836e8907834fcd3e3b018fc)
1=====================
2Misc notes and advice
3=====================
4
5This document contains miscellaneous and unstructured (and mostly, legacy) notes and advice about using flashrom.
6
7Command set tricks for parallel and LPC chips
8=============================================
9
10This is only mentioned in very few datasheets, but it applies to some parallel (and some LPC) chips.
11
12Upper address bits of commands are ignored if they are not mentioned explicitly. If a datasheet specifies the following sequence::
13
14   chip_writeb(0xAA, bios + 0x555);
15   chip_writeb(0x55, bios + 0x2AA);
16   chip_writeb(0x90, bios + 0x555);
17
18then it is quite likely the following sequence will work as well::
19
20   chip_writeb(0xAA, bios + 0x5555);
21   chip_writeb(0x55, bios + 0x2AAA);
22   chip_writeb(0x90, bios + 0x5555);
23
24However, if the chip datasheet specifies addresses like ``0x5555``, you can't shorten them to ``0x555``.
25
26To summarize, replacing short addresses with long addresses usually works, but the other way round usually fails.
27
28flashrom doesn't work on my board, what can I do?
29=================================================
30
31* First of all, check if your chipset, ROM chip, and mainboard are supported
32  (see :doc:`/supported_hw/index`).
33* If your board has a jumper for BIOS flash protection (check the manual), disable it.
34* Should your BIOS menu have a BIOS flash protection option, disable it.
35* If you run flashrom on Linux and see messages about ``/dev/mem``, see next section.
36* If you run flashrom on OpenBSD, you might need to obtain raw access permission by setting
37  ``securelevel = -1`` in ``/etc/rc.securelevel`` and rebooting, or rebooting into single user mode.
38
39What can I do about /dev/mem errors?
40====================================
41
42* If flashrom tells you ``/dev/mem mmap failed: Operation not permitted``:
43
44  * Most common at the time of writing is a Linux kernel option, ``CONFIG_IO_STRICT_DEVMEM``,
45    that prevents even the root user from accessing hardware from user-space if the resource is unknown
46    to the kernel or a conflicting kernel driver reserved it. On Intel systems, this is most often ``lpc_ich``,
47    so ``modprobe -r lpc_ich`` can help. A more invasive solution is to try again after rebooting
48    with ``iomem=relaxed`` in the kernel command line.
49
50  * Some systems with incorrect memory reservations (e.g. E820 map) may have the same problem
51    even with ``CONFIG_STRICT_DEVMEM``. In that case ``iomem=relaxed`` in the kernel command line may help too.
52
53* If it tells you ``/dev/mem mmap failed: Resource temporarily unavailable``:
54
55  * This may be an issue with PAT (e.g. if the memory flashrom tries to map is already mapped
56    in an incompatible mode). Try again after rebooting with nopat in the kernel command line.
57
58* If you see this message ``Can't mmap memory using /dev/mem: Invalid argument``:
59
60  * Your flashrom is very old, better update it. If the issue persists, try the kernel options mentioned above.
61
62* Generally, if your version of flashrom is very old, an update might help.
63  Flashrom has less strict requirements now and works on more systems without having to change the kernel.
64
65Connections
66===========
67
68Using In-System programming requires some means to connect the external programmer to the flash chip.
69
70Note that some external flashers (like the Openmoko debug board) lack a connector,
71so they do requires some soldering to be used. Some other don't. For instance the buspirate has a pin connector on it.
72
73Programmer <-> Removable chip connection
74----------------------------------------
75
76A breadboard can be used to connect Dual in-line 8 pins chips to the programmer, as they they fit well into it.
77
78Programmer <-> Clip connection
79------------------------------
80
81If your programmer has a pin connector, and that you want to avoid soldering, you can use
82**Short** `Jump Wires <https://en.wikipedia.org/wiki/Jump_wire>`_ to connect it to a clip.
83They usually can be found on some electronic shops.
84
85Other issues
86-------------
87
88* Wires length and connection quality: Long wires, and bad connection can create some issues, so avoid them.
89
90  * The maximum wires length is very dependent on your setup, so try to have the shortest wires possible.
91  * If you can't avoid long wires and if you're flash chip is SPI, then lowering the SPI clock could make
92    it work in some cases. Many programmers do support such option (Called spispeed with most of them, or divisor with ft2232_spi).
93
94* When soldering wires, the wire tend to break near the soldering point. To avoid such issue,
95  you have to prevent the wires from bending near the soldering point.
96  To do that `Heat-shrink_tubing <https://en.wikipedia.org/wiki/Heat-shrink_tubing>`_ or similar methods can be used.
97
98Common problems
99===============
100
101The following describes problems commonly found when trying to access flash chips in systems
102that are not designed properly for this job, e.g. ad-hoc setups to flash in-system
103(TODO add a doc for in-system-specific problems).
104
105Symptoms indicating you may have at least one of these are for example inconsistent reads or probing results.
106This happens basically because the analog electrical waveforms representing the digital information
107get too distorted to by interpreted correctly all the time. Depending on the cause different steps can be tried.
108
109* Not all input pins are connected to the correct voltage level/output pin of the programmer.
110  Always connect all input pins of ICs!
111
112* The easiest thing to try is lowering the (SPI) clock frequency if your programmer supports it.
113  That way the waveforms have more time to settle before being sampled by the receiver which might be enough.
114  Depending on the design of the driver and receiver as well as the actual communication path
115  this might not change anything as well.
116
117* Wires are too long. Shortening them to a few cm (i.e. < 20, the lesser the better) might help.
118
119* The impedances of the wires/traces do not match the impedances of the input pins
120  (of either the circuit/chip on the mainboard or the external programmer).
121  Try using shorter wires, adding small (<100 Ohm) series resistors or parallel capacitors (<20pF)
122  as near as possible to the input pins (this includes also the MISO line which ends near the programmer)\
123  and/or ask someone who has experience with high frequency electronics.
124
125* The supply voltage of the flash chip is not stable enough. Try adding a 0.1 µF - 1 µF (ceramic) capacitor
126  between the flash chip's VCC and GND pins as near as possible to the chip.
127
128Live CD
129=========
130
131A Live CD containing flashrom provides a user with a stable work environment to read, write and verify a flash device on any supported hardware.
132
133It can help avoid Linux installation issues, which can be a hassle for some users.
134
135flashrom is already shipped in some of the Live CDs, see below. *Please note, some of these ship very old versions of flashrom*.
136
137* `SystemRescueCd <http://www.sysresccd.org/>`_ has been including flashrom since about version 2.5.1.
138
139* `grml <http://grml.org/>`_
140
141  * Note: You need the full grml ISO, "small" (and "medium") ISOs do not contain flashrom.
142  * Note: Some releases (e.g. 2011.12) did not contain flashrom.
143
144* `Parted Magic <http://partedmagic.com/>`_
145
146* `Hiren's BootCD <http://www.hirensbootcd.org/>`_
147
148   * When you select "Linux based rescue environment (Parted Magic 6.7)" and then "Live with default settings",
149     you have access to a system which has flashrom.
150