Author: stefanct
Date: Thu Feb 16 21:55:27 2012
New Revision: 1497
URL: http://flashrom.org/trac/flashrom/changeset/1497
Log:
Manpage improvements.
The sections describing the various options of the internal and dummy
programmers have grown out of proportions. This patch adds some headlines
to devide the unrelated topics a bit (with .TP commands). The previous indented
paragraphs for the various programmers were transformed to subsections (.SS).
Also, rephrase the documention related to laptops completely to make it
less redundant and more informative.
Document the laptop=this_is_not_a_laptop internal programmer parameter
Change the contact info in the bugs section by removing the trac
reference and adding IRC (and the pastebin) instead.
Remove some superfluous white space and a .RE (restore indentation) command.
Signed-off-by: Stefan Tauner <stefan.tauner(a)student.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006(a)gmx.net>
Modified:
trunk/flashrom.8
Modified: trunk/flashrom.8
==============================================================================
--- trunk/flashrom.8 Thu Feb 16 21:31:25 2012 (r1496)
+++ trunk/flashrom.8 Thu Feb 16 21:55:27 2012 (r1497)
@@ -1,4 +1,4 @@
-.TH FLASHROM 8 "Jul 25, 2011"
+.TH FLASHROM 8 "Feb 15, 2012"
.SH NAME
flashrom \- detect, read, write, verify and erase flash chips
.SH SYNOPSIS
@@ -223,8 +223,11 @@
colon. While some programmers take arguments at fixed positions, other
programmers use a key/value interface in which the key and value is separated
by an equal sign and different pairs are separated by a comma or a colon.
-.TP
+.SS
.BR "internal " programmer
+.TP
+.B Board Enables
+.sp
Some mainboards require to run mainboard specific code to enable flash erase
and write support (and probe support on old systems with parallel flash).
The mainboard brand and model (if it requires specific code) is usually
@@ -275,17 +278,22 @@
enable is going to fail. In any case (success or failure), please report to
the flashrom mailing list, see below.
.sp
+.TP
+.B Coreboot
+.sp
On systems running coreboot, flashrom checks whether the desired image matches
your mainboard. This needs some special board ID to be present in the image.
If flashrom detects that the image you want to write and the current board
do not match, it will refuse to write the image unless you specify
.sp
.B " flashrom \-p internal:boardmismatch=force"
+.TP
+.B ITE IT87 Super I/O
.sp
If your mainboard uses an ITE IT87 series Super I/O for LPC<->SPI flash bus
translation, flashrom should autodetect that configuration. If you want to
set the I/O base port of the IT87 series SPI controller manually instead of
-using the value provided by the BIOS, use the
+using the value provided by the BIOS, use the
.sp
.B " flashrom \-p internal:it87spiport=portnum"
.sp
@@ -295,6 +303,9 @@
flashrom doesn't detect an active IT87 LPC<->SPI bridge, please send a bug
report so we can diagnose the problem.
.sp
+.TP
+.B Intel chipsets
+.sp
If you have an Intel chipset with an ICH8 or later southbridge with SPI flash
attached, and if a valid descriptor was written to it (e.g. by the vendor), the
chipset provides an alternative way to access the flash chip(s) named
@@ -346,6 +357,8 @@
.sp
Example:
.B "flashrom \-p internal:fwh_idsel=0x001122334567"
+.TP
+.B Laptops
.sp
Using flashrom on laptops is dangerous and may easily make your hardware
unusable (see also the
@@ -353,21 +366,31 @@
section). The embedded controller (EC) in these
machines often interacts badly with flashing.
.B http://www.flashrom.org/Laptops
-has more information. If flash is shared with the EC, erase is guaranteed to
-brick your laptop and write is very likely to brick your laptop.
-Chip read and probe may irritate your EC and cause fan failure, backlight
-failure, sudden poweroff, and other nasty effects.
-flashrom will attempt to detect laptops and abort immediately for safety
-reasons.
-If you want to proceed anyway at your own risk, use
+has more information. For example the EC firmware sometimes resides on the same
+flash chip as the host firmware. While flashrom tries to change the contents of
+that memory the EC might need to fetch new instructions or data from it and
+could stop working correctly. Probing for and reading from the chip may also
+irritate your EC and cause fan failure, backlight failure, sudden poweroff, and
+other nasty effects. flashrom will attempt to detect if it is running on a
+laptop and abort immediately for safety reasons if it clearly identifies the
+host computer as one. If you want to proceed anyway at your own risk, use
.sp
.B " flashrom \-p internal:laptop=force_I_want_a_brick"
.sp
-You have been warned.
-.sp
We will not help you if you force flashing on a laptop because this is a really
dumb idea.
-.TP
+.sp
+You have been warned.
+.sp
+Currently we rely on the chassis type encoded in the DMI/SMBIOS data to detect
+laptops. Some vendors did not implement those bits correctly or set them to
+generic and/or dummy values. flashrom will then issue a warning and bail out
+like above. In this case you can use
+.sp
+.B " flashrom \-p internal:laptop=this_is_not_a_laptop"
+.sp
+to tell flashrom (at your own risk) that it does not running on a laptop.
+.SS
.BR "dummy " programmer
The dummy programmer operates on a buffer in memory only. It provides a safe
and fast way to test various aspects of flashrom and is mainly used in
@@ -409,6 +432,8 @@
.sp
Example:
.B "flashrom -p dummy:emulate=SST25VF040.REMS"
+.TP
+.B Persistent images
.sp
If you use flash chip emulation, flash image persistence is available as well
by using the
@@ -422,6 +447,8 @@
.sp
Example:
.B "flashrom -p dummy:emulate=M25P10.RES,image=dummy.bin"
+.TP
+.B SPI write chunk size
.sp
If you use SPI flash chip emulation for a chip which supports SPI page write
with the default opcode, you can set the maximum allowed write chunk size with
@@ -436,6 +463,8 @@
Example:
.sp
.B " flashrom -p dummy:emulate=M25P10.RES,spi_write_256_chunksize=5"
+.TP
+.B SPI blacklist
.sp
To simulate a programmer which refuses to send certain SPI commands to the
flash chip, you can specify a blacklist of SPI commands with the
@@ -448,6 +477,9 @@
commandlist may be up to 512 characters (256 commands) long.
Implementation note: flashrom will detect an error during command execution.
.sp
+.TP
+.B SPI ignorelist
+.sp
To simulate a flash chip which ignores (doesn't support) certain SPI commands,
you can specify an ignorelist of SPI commands with the
.sp
@@ -458,7 +490,7 @@
command 0x03 (READ) and command 0x02 (WRITE). commandlist may be up to 512
characters (256 commands) long.
Implementation note: flashrom won't detect an error during command execution.
-.TP
+.SS
.BR "nic3com" , " nicrealtek" , " nicsmc1211" , " nicnatsemi" , " nicintel\
" , " nicintel_spi" , " gfxnvidia" , " ogp_spi" , " drkaiser" , " satasii\
" , " satamv" ", and " atahpt " programmers
@@ -480,7 +512,7 @@
.sp
Example:
.B "flashrom \-p nic3com:pci=05:04.0"
-.TP
+.SS
.BR "ft2232_spi " programmer
An optional parameter specifies the controller
type and interface/port it should support. For that you have to use the
@@ -501,7 +533,7 @@
.B 4232H
and the default interface is
.BR B .
-.TP
+.SS
.BR "serprog " programmer
A mandatory parameter specifies either a serial
device/baud combination or an IP/port combination for communication with the
@@ -517,7 +549,7 @@
instead. More information about serprog is available in
.B serprog-protocol.txt
in the source distribution.
-.TP
+.SS
.BR "buspirate_spi " programmer
A required
.B dev
@@ -533,7 +565,7 @@
can be
.BR 30k ", " 125k ", " 250k ", " 1M ", " 2M ", " 2.6M ", " 4M " or " 8M
(in Hz). The default is the maximum frequency of 8 MHz.
-.TP
+.SS
.BR "dediprog " programmer
An optional
.B voltage
@@ -549,7 +581,7 @@
can be
.BR 0V ", " 1.8V ", " 2.5V ", " 3.5V
or the equivalent in mV.
-.TP
+.SS
.BR "rayer_spi " programmer
The default I/O base address used for the parallel port is 0x378 and you can use
the optional
@@ -579,9 +611,9 @@
.BR "http://rayer.ic.cz/elektro/spipgm.htm " .
The schematic of the Xilinx DLC 5 was published at
.BR "http://www.xilinx.com/itp/xilinx4/data/docs/pac/appendixb.html " .
-.TP
+.SS
.BR "ogp_spi " programmer
-The flash ROM chip to access must be specified with the
+The flash ROM chip to access must be specified with the
.B rom
parameter.
.sp
@@ -665,25 +697,37 @@
.B "/etc/rc.securelevel"
and rebooting, or rebooting into single user mode.
.SH BUGS
-Please report any bugs at
-.sp
-.B " http://www.flashrom.org/trac/flashrom/newticket"
-.sp
-or on the flashrom mailing list at
+Please report any bugs to the flashrom mailing list at
.B "<flashrom(a)flashrom.org>"
.sp
We recommend to subscribe first at
.sp
.B " http://www.flashrom.org/mailman/listinfo/flashrom"
.sp
-Using flashrom on laptops is dangerous and may easily make your hardware
-unusable unless you can desolder the flash chip and have a full flash chip
-backup. This is caused by the embedded controller (EC) present in many laptops,
-which interacts badly with any flash attempts. This is a hardware limitation
-and flashrom will attempt to detect it and abort immediately for safety reasons.
-.sp
-More information about flashrom on laptops is available from
+Many of the developers communicate via the
+.B "#flashrom"
+IRC channel on
+.BR chat.freenode.net .
+You are welcome to join and ask questions, send us bug and success reports there
+too. Please provide a way to contact you later (e.g. a mail address) and be
+patient if there is no immediate reaction. Also, we provide a pastebin service
+at
+.B http://paste.flashrom.org
+that is very useful when you want to share logs etc. without spamming the
+channel.
+.SS
+.B Laptops
.sp
+Using flashrom on laptops is dangerous and may easily make your hardware
+unusable. flashrom will attempt to detect if it is running on a laptop and abort
+immediately for safety reasons. Please see the detailed discussion of this topic
+and associated flashrom options in the
+.B Laptops
+paragraph in the
+.B internal programmer
+subsection of the
+.B PROGRAMMER SPECIFIC INFO
+section.
.B " http://www.flashrom.org/Laptops"
.SS
One-time programmable (OTP) memory and unique IDs
@@ -697,7 +741,6 @@
.sp
Similar to OTP memories are unique, factory programmed, unforgeable IDs.
They are not modifiable by the user at all.
-.RE
.SH LICENSE
.B flashrom
is covered by the GNU General Public License (GPL), version 2. Some files are
The sections describing the various options of the internal and dummy
programmers have grown out of proportions. This patch adds some headlines
to devide the unrelated topics a bit (with .TP commands). The previous indented
paragraphs for the various programmers were transformed to subsections (.SS).
Also, rephrase the documention related to laptops completely to make it
less redundant and more informative.
Document the laptop=this_is_not_a_laptop internal programmer parameter
Change the contact info in the bugs section by removing the trac
reference and adding IRC (and the pastebin) instead.
Remove some superfluous white space.
Signed-off-by: Stefan Tauner <stefan.tauner(a)student.tuwien.ac.at>
---
flashrom.8 | 111 +++++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 77 insertions(+), 34 deletions(-)
diff --git a/flashrom.8 b/flashrom.8
index 76aacba..782f30b 100644
--- a/flashrom.8
+++ b/flashrom.8
@@ -1,4 +1,4 @@
-.TH FLASHROM 8 "Jul 25, 2011"
+.TH FLASHROM 8 "Feb 15, 2012"
.SH NAME
flashrom \- detect, read, write, verify and erase flash chips
.SH SYNOPSIS
@@ -223,8 +223,11 @@ parameters. These parameters are separated from the programmer name by a
colon. While some programmers take arguments at fixed positions, other
programmers use a key/value interface in which the key and value is separated
by an equal sign and different pairs are separated by a comma or a colon.
-.TP
+.SS
.BR "internal " programmer
+.TP
+.B Board Enables
+.sp
Some mainboards require to run mainboard specific code to enable flash erase
and write support (and probe support on old systems with parallel flash).
The mainboard brand and model (if it requires specific code) is usually
@@ -275,17 +278,22 @@ has been written because it is known that writing/erasing without the board
enable is going to fail. In any case (success or failure), please report to
the flashrom mailing list, see below.
.sp
+.TP
+.B Coreboot
+.sp
On systems running coreboot, flashrom checks whether the desired image matches
your mainboard. This needs some special board ID to be present in the image.
If flashrom detects that the image you want to write and the current board
do not match, it will refuse to write the image unless you specify
.sp
.B " flashrom \-p internal:boardmismatch=force"
+.TP
+.B ITE IT87 Super I/O
.sp
If your mainboard uses an ITE IT87 series Super I/O for LPC<->SPI flash bus
translation, flashrom should autodetect that configuration. If you want to
set the I/O base port of the IT87 series SPI controller manually instead of
-using the value provided by the BIOS, use the
+using the value provided by the BIOS, use the
.sp
.B " flashrom \-p internal:it87spiport=portnum"
.sp
@@ -295,6 +303,9 @@ is the I/O port number (must be a multiple of 8). In the unlikely case
flashrom doesn't detect an active IT87 LPC<->SPI bridge, please send a bug
report so we can diagnose the problem.
.sp
+.TP
+.B Intel chipsets
+.sp
If you have an Intel chipset with an ICH8 or later southbridge with SPI flash
attached, and if a valid descriptor was written to it (e.g. by the vendor), the
chipset provides an alternative way to access the flash chip(s) named
@@ -346,6 +357,8 @@ settings. The default value for ICH7 is given in the example below.
.sp
Example:
.B "flashrom \-p internal:fwh_idsel=0x001122334567"
+.TP
+.B Laptops
.sp
Using flashrom on laptops is dangerous and may easily make your hardware
unusable (see also the
@@ -353,21 +366,31 @@ unusable (see also the
section). The embedded controller (EC) in these
machines often interacts badly with flashing.
.B http://www.flashrom.org/Laptops
-has more information. If flash is shared with the EC, erase is guaranteed to
-brick your laptop and write is very likely to brick your laptop.
-Chip read and probe may irritate your EC and cause fan failure, backlight
-failure, sudden poweroff, and other nasty effects.
-flashrom will attempt to detect laptops and abort immediately for safety
-reasons.
-If you want to proceed anyway at your own risk, use
+has more information. For example the EC firmware sometimes resides on the same
+flash chip as the host firmware. While flashrom tries to change the contents of
+that memory the EC might need to fetch new instructions or data from it and
+could stop working correctly. Probing for and reading from the chip may also
+irritate your EC and cause fan failure, backlight failure, sudden poweroff, and
+other nasty effects. flashrom will attempt to detect if it is running on a
+laptop and abort immediately for safety reasons if it clearly identifies the
+host computer as one. If you want to proceed anyway at your own risk, use
.sp
.B " flashrom \-p internal:laptop=force_I_want_a_brick"
.sp
-You have been warned.
-.sp
We will not help you if you force flashing on a laptop because this is a really
dumb idea.
-.TP
+.sp
+You have been warned.
+.sp
+Currently we rely on the chassis type encoded in the DMI/SMBIOS data to detect
+laptops. Some vendors did not implement those bits correctly or set them to
+generic and/or dummy values. flashrom will then issue a warning and bail out
+like above. In this case you can use
+.sp
+.B " flashrom \-p internal:laptop=this_is_not_a_laptop"
+.sp
+to tell flashrom (at your own risk) that it does not running on a laptop.
+.SS
.BR "dummy " programmer
The dummy programmer operates on a buffer in memory only. It provides a safe
and fast way to test various aspects of flashrom and is mainly used in
@@ -409,6 +432,8 @@ vendor):
.sp
Example:
.B "flashrom -p dummy:emulate=SST25VF040.REMS"
+.TP
+.B Persistent images
.sp
If you use flash chip emulation, flash image persistence is available as well
by using the
@@ -422,6 +447,8 @@ where the chip contents on flashrom shutdown are written to.
.sp
Example:
.B "flashrom -p dummy:emulate=M25P10.RES,image=dummy.bin"
+.TP
+.B SPI write chunk size
.sp
If you use SPI flash chip emulation for a chip which supports SPI page write
with the default opcode, you can set the maximum allowed write chunk size with
@@ -436,6 +463,8 @@ is the number of bytes (min. 1, max. 256).
Example:
.sp
.B " flashrom -p dummy:emulate=M25P10.RES,spi_write_256_chunksize=5"
+.TP
+.B SPI blacklist
.sp
To simulate a programmer which refuses to send certain SPI commands to the
flash chip, you can specify a blacklist of SPI commands with the
@@ -448,6 +477,9 @@ controller refuses to run command 0x03 (READ) and command 0x02 (WRITE).
commandlist may be up to 512 characters (256 commands) long.
Implementation note: flashrom will detect an error during command execution.
.sp
+.TP
+.B SPI ignorelist
+.sp
To simulate a flash chip which ignores (doesn't support) certain SPI commands,
you can specify an ignorelist of SPI commands with the
.sp
@@ -458,7 +490,7 @@ SPI commands. If commandlist is e.g. 0302, the emulated flash chip will ignore
command 0x03 (READ) and command 0x02 (WRITE). commandlist may be up to 512
characters (256 commands) long.
Implementation note: flashrom won't detect an error during command execution.
-.TP
+.SS
.BR "nic3com" , " nicrealtek" , " nicsmc1211" , " nicnatsemi" , " nicintel\
" , " nicintel_spi" , " gfxnvidia" , " ogp_spi" , " drkaiser" , " satasii\
" , " satamv" ", and " atahpt " programmers
@@ -480,7 +512,7 @@ is the PCI function number of the desired device.
.sp
Example:
.B "flashrom \-p nic3com:pci=05:04.0"
-.TP
+.SS
.BR "ft2232_spi " programmer
An optional parameter specifies the controller
type and interface/port it should support. For that you have to use the
@@ -501,7 +533,7 @@ The default model is
.B 4232H
and the default interface is
.BR B .
-.TP
+.SS
.BR "serprog " programmer
A mandatory parameter specifies either a serial
device/baud combination or an IP/port combination for communication with the
@@ -517,7 +549,7 @@ syntax and for IP, you have to use
instead. More information about serprog is available in
.B serprog-protocol.txt
in the source distribution.
-.TP
+.SS
.BR "buspirate_spi " programmer
A required
.B dev
@@ -533,7 +565,7 @@ where
can be
.BR 30k ", " 125k ", " 250k ", " 1M ", " 2M ", " 2.6M ", " 4M " or " 8M
(in Hz). The default is the maximum frequency of 8 MHz.
-.TP
+.SS
.BR "dediprog " programmer
An optional
.B voltage
@@ -549,7 +581,7 @@ where
can be
.BR 0V ", " 1.8V ", " 2.5V ", " 3.5V
or the equivalent in mV.
-.TP
+.SS
.BR "rayer_spi " programmer
The default I/O base address used for the parallel port is 0x378 and you can use
the optional
@@ -579,9 +611,9 @@ More information about the RayeR hardware is available at
.BR "http://rayer.ic.cz/elektro/spipgm.htm " .
The schematic of the Xilinx DLC 5 was published at
.BR "http://www.xilinx.com/itp/xilinx4/data/docs/pac/appendixb.html " .
-.TP
+.SS
.BR "ogp_spi " programmer
-The flash ROM chip to access must be specified with the
+The flash ROM chip to access must be specified with the
.B rom
parameter.
.sp
@@ -665,25 +697,37 @@ in
.B "/etc/rc.securelevel"
and rebooting, or rebooting into single user mode.
.SH BUGS
-Please report any bugs at
-.sp
-.B " http://www.flashrom.org/trac/flashrom/newticket"
-.sp
-or on the flashrom mailing list at
+Please report any bugs to the flashrom mailing list at
.B "<flashrom(a)flashrom.org>"
.sp
We recommend to subscribe first at
.sp
.B " http://www.flashrom.org/mailman/listinfo/flashrom"
.sp
-Using flashrom on laptops is dangerous and may easily make your hardware
-unusable unless you can desolder the flash chip and have a full flash chip
-backup. This is caused by the embedded controller (EC) present in many laptops,
-which interacts badly with any flash attempts. This is a hardware limitation
-and flashrom will attempt to detect it and abort immediately for safety reasons.
-.sp
-More information about flashrom on laptops is available from
+Many of the developers communicate via the
+.B "#flashrom"
+IRC channel on
+.BR chat.freenode.net .
+You are welcome to join and ask questions, send us bug and success reports there
+too. Please provide a way to contact you later (e.g. a mail address) and be
+patient if there is no immediate reaction. Also, we provide a pastebin service
+at
+.B http://paste.flashrom.org
+that is very useful when you want to share logs etc. without spamming the
+channel.
+.SS
+.B Laptops
.sp
+Using flashrom on laptops is dangerous and may easily make your hardware
+unusable. flashrom will attempt to detect if it is running on a laptop and abort
+immediately for safety reasons. Please see the detailed discussion of this topic
+and associated flashrom options in the
+.B Laptops
+paragraph in the
+.B internal programmer
+subsection of the
+.B PROGRAMMER SPECIFIC INFO
+section.
.B " http://www.flashrom.org/Laptops"
.SS
One-time programmable (OTP) memory and unique IDs
@@ -697,7 +741,6 @@ printed when they are detected.
.sp
Similar to OTP memories are unique, factory programmed, unforgeable IDs.
They are not modifiable by the user at all.
-.RE
.SH LICENSE
.B flashrom
is covered by the GNU General Public License (GPL), version 2. Some files are
--
1.7.1
Author: hailfinger
Date: Thu Feb 16 21:31:25 2012
New Revision: 1496
URL: http://flashrom.org/trac/flashrom/changeset/1496
Log:
Reenable forced read
Forced read functionality was disabled when programmer registration was
merged in r1475.
We now support registering more than one controller at once for each bus
type. This can happen e.g. if one SPI controller has an attached flash
chip and one controller doesn't. In such a case we rely on the probe
mechanism to find exactly one chip, and the probe mechanism will
remember which controller/bus the flash chip is attached to. A forced
read does not have the luxury of knowing which compatible controller to
use, so this case is handled by always picking the first one. That may
or may not be the correct one, but there is no way (yet) to specify
which controller a flash chip is attached to.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006(a)gmx.net>
Acked-by: Stefan Tauner <stefan.tauner(a)student.tuwien.ac.at>
Modified:
trunk/cli_classic.c
Modified: trunk/cli_classic.c
==============================================================================
--- trunk/cli_classic.c Thu Feb 16 02:43:06 2012 (r1495)
+++ trunk/cli_classic.c Thu Feb 16 21:31:25 2012 (r1496)
@@ -168,7 +168,7 @@
struct flashctx *fill_flash;
const char *name;
int namelen, opt, i, j;
- int startchip = 0, chipcount = 0, option_index = 0, force = 0;
+ int startchip = -1, chipcount = 0, option_index = 0, force = 0;
#if CONFIG_PRINT_WIKI == 1
int list_supported_wiki = 0;
#endif
@@ -456,11 +456,27 @@
printf("Note: flashrom can never write if the flash "
"chip isn't found automatically.\n");
}
-#if 0 // FIXME: What happens for a forced chip read if multiple compatible programmers are registered?
if (force && read_it && chip_to_probe) {
+ struct registered_programmer *pgm;
+ int compatible_programmers = 0;
printf("Force read (-f -r -c) requested, pretending "
"the chip is there:\n");
- startchip = probe_flash(0, &flashes[0], 1);
+ /* This loop just counts compatible controllers. */
+ for (j = 0; j < registered_programmer_count; j++) {
+ pgm = ®istered_programmers[j];
+ if (pgm->buses_supported & flashes[0].bustype)
+ compatible_programmers++;
+ }
+ if (compatible_programmers > 1)
+ printf("More than one compatible controller "
+ "found for the requested flash chip, "
+ "using the first one.\n");
+ for (j = 0; j < registered_programmer_count; j++) {
+ pgm = ®istered_programmers[j];
+ startchip = probe_flash(pgm, 0, &flashes[0], 1);
+ if (startchip != -1)
+ break;
+ }
if (startchip == -1) {
printf("Probing for flash chip '%s' failed.\n",
chip_to_probe);
@@ -471,7 +487,6 @@
"contain garbage.\n");
return read_flash_to_file(&flashes[0], filename);
}
-#endif
ret = 1;
goto out_shutdown;
} else if (!chip_to_probe) {
Am 16.02.2012 02:30 schrieb Idwer Vollering:
> 2012/2/16 Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006(a)gmx.net>:
>> > MinGW uses standard Windows C libraries and those apparently don't
>> > support %hhx for sscanf into a uint8_t. SCNx8 isn't available either.
>> >
>> > Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006(a)gmx.net>
> Acked-by: Idwer Vollering <vidwer(a)gmail.com>
Thanks, committed in r1495.
Regards,
Carl-Daniel
--
http://www.hailfinger.org/
Author: hailfinger
Date: Thu Feb 16 02:43:06 2012
New Revision: 1495
URL: http://flashrom.org/trac/flashrom/changeset/1495
Log:
Workaround missing %hhx support in MinGW sscanf
MinGW uses standard Windows C libraries and those apparently don't
support %hhx for sscanf into a uint8_t. SCNx8 isn't available either.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006(a)gmx.net>
Acked-by: Idwer Vollering <vidwer(a)gmail.com>
Modified:
trunk/dummyflasher.c
Modified: trunk/dummyflasher.c
==============================================================================
--- trunk/dummyflasher.c Thu Feb 16 02:13:00 2012 (r1494)
+++ trunk/dummyflasher.c Thu Feb 16 02:43:06 2012 (r1495)
@@ -199,7 +199,12 @@
}
}
for (i = 0; i < spi_blacklist_size; i++) {
- sscanf(tmp + i * 2, "%2hhx", &spi_blacklist[i]);
+ unsigned int tmp2;
+ /* SCNx8 is apparently not supported by MSVC (and thus
+ * MinGW), so work around it with an extra variable
+ */
+ sscanf(tmp + i * 2, "%2x", &tmp2);
+ spi_blacklist[i] = (uint8_t)tmp2;
}
msg_pdbg("SPI blacklist is ");
for (i = 0; i < spi_blacklist_size; i++)
@@ -230,7 +235,12 @@
}
}
for (i = 0; i < spi_ignorelist_size; i++) {
- sscanf(tmp + i * 2, "%2hhx", &spi_ignorelist[i]);
+ unsigned int tmp2;
+ /* SCNx8 is apparently not supported by MSVC (and thus
+ * MinGW), so work around it with an extra variable
+ */
+ sscanf(tmp + i * 2, "%2x", &tmp2);
+ spi_ignorelist[i] = (uint8_t)tmp2;
}
msg_pdbg("SPI ignorelist is ");
for (i = 0; i < spi_ignorelist_size; i++)
MinGW uses standard Windows C libraries and those apparently don't
support %hhx for sscanf into a uint8_t. SCNx8 isn't available either.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006(a)gmx.net>
Index: flashrom-mingw_workaround_broken_sscanf_uint8t/dummyflasher.c
===================================================================
--- flashrom-mingw_workaround_broken_sscanf_uint8t/dummyflasher.c (Revision 1492)
+++ flashrom-mingw_workaround_broken_sscanf_uint8t/dummyflasher.c (Arbeitskopie)
@@ -199,7 +199,12 @@
}
}
for (i = 0; i < spi_blacklist_size; i++) {
- sscanf(tmp + i * 2, "%2hhx", &spi_blacklist[i]);
+ unsigned int tmp2;
+ /* SCNx8 is apparently not supported by MSVC (and thus
+ * MinGW), so work around it with an extra variable
+ */
+ sscanf(tmp + i * 2, "%2x", &tmp2);
+ spi_blacklist[i] = (uint8_t)tmp2;
}
msg_pdbg("SPI blacklist is ");
for (i = 0; i < spi_blacklist_size; i++)
@@ -230,7 +235,12 @@
}
}
for (i = 0; i < spi_ignorelist_size; i++) {
- sscanf(tmp + i * 2, "%2hhx", &spi_ignorelist[i]);
+ unsigned int tmp2;
+ /* SCNx8 is apparently not supported by MSVC (and thus
+ * MinGW), so work around it with an extra variable
+ */
+ sscanf(tmp + i * 2, "%2x", &tmp2);
+ spi_ignorelist[i] = (uint8_t)tmp2;
}
msg_pdbg("SPI ignorelist is ");
for (i = 0; i < spi_ignorelist_size; i++)
--
http://www.hailfinger.org/
Am 16.02.2012 00:58 schrieb Stefan Tauner:
> This includes not only the notorious read-only flash descriptors and locked ME
> regions, but also the more rarely used PRs (Protected Ranges).
> The user can enforce write support by specifying ich_spi_force=yes in the
> programmer options, but we don't tell him the exact syntax interactively. He
> has to read it up in the man page.
>
> Signed-off-by: Stefan Tauner <stefan.tauner(a)student.tuwien.ac.at>
> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006(a)gmx.net>
The Intel rant seems to be missing... I thought you only wanted to move it.
> diff --git a/flashrom.8 b/flashrom.8
> index e5f9a29..76aacba 100644
> --- a/flashrom.8
> +++ b/flashrom.8
> @@ -315,6 +315,21 @@ important opcodes are inaccessible due to lockdown; or if more than one flash
> chip is attached). The other options (swseq, hwseq) select the respective mode
> (if possible).
> .sp
> +ICH8 and later southbridges may also have locked address ranges of different
> +kinds if a valid descriptor was written to it. The flash address space is then
> +partitioned in multiple so called "Flash Regions" containing the host firmware,
> +the ME firmware and so on respectively. The flash descriptor can also specify up
> +to 5 so called "Protected Regions", which are freely chosen address ranges
> +independent from the aforementioned "Flash Regions". All of them can be write
> +and/or read protected individually. If flashrom detects such a lock it will
> +disable write support unless the user forces it with the
> +.sp
> +.B " flashrom \-p internal:ich_spi_force=yes"
> +.sp
> +syntax. If this leads to erase or write accesses to the flash it would most
> +probably bring it into an inconsistent and unbootable state and we will not
> +provide any support in such a case.
> +.sp
> If you have an Intel chipset with an ICH6 or later southbridge and if you want
> to set specific IDSEL values for a non-default flash chip or an embedded
> controller (EC), you can use the
> diff --git a/ichspi.c b/ichspi.c
> index 163ecf1..711f46c 100644
> --- a/ichspi.c
> +++ b/ichspi.c
> @@ -1444,11 +1445,16 @@ static void do_ich9_spi_frap(uint32_t frap, int i)
> if (base > limit) {
> /* this FREG is disabled */
> msg_pdbg("%s region is unused.\n", region_names[i]);
> - return;
> + return 0;
> }
>
> - msg_pdbg("0x%08x-0x%08x is %s\n", base, (limit | 0x0fff),
> + msg_pdbg("0x%08x-0x%08x is %s.\n", base, (limit | 0x0fff),
> access_names[rwperms]);
> + if (rwperms == 0x3)
> + return 0;
> +
> + msg_pinfo("WARNING: %s region is not fully accessible.\n", region_names[i]);
Odd. For FRAP, the _pinfo message just says "not fully accessible", but
for PR, the _pinfo message mentions the actual read/write protection.
Not terribly important to fix, just a small inconsistency I noticed.
> + return 1;
> }
>
> /* In contrast to FRAP and the master section of the descriptor the bits
> @@ -1460,21 +1466,25 @@ static void do_ich9_spi_frap(uint32_t frap, int i)
> #define ICH_PR_PERMS(pr) (((~((pr) >> PR_RP_OFF) & 1) << 0) | \
> ((~((pr) >> PR_WP_OFF) & 1) << 1))
>
> -static void prettyprint_ich9_reg_pr(int i)
> +/* returns 0 if range is unused (i.e. r/w) */
> +static int ich9_handle_pr(int i)
> {
> - static const char *const access_names[4] = {
> - "locked", "read-only", "write-only", "read-write"
> + static const char *const access_names[3] = {
> + "locked", "read-only", "write-only"
> };
> uint8_t off = ICH9_REG_PR0 + (i * 4);
> uint32_t pr = mmio_readl(ich_spibar + off);
> - int rwperms = ICH_PR_PERMS(pr);
> + unsigned int rwperms = ICH_PR_PERMS(pr);
>
> - msg_pdbg2("0x%02X: 0x%08x (PR%u", off, pr, i);
> - if (rwperms != 0x3)
> - msg_pdbg2(")\n0x%08x-0x%08x is %s\n", ICH_FREG_BASE(pr),
> - ICH_FREG_LIMIT(pr) | 0x0fff, access_names[rwperms]);
> - else
> - msg_pdbg2(", unused)\n");
> + if (rwperms == 0x3) {
> + msg_pdbg2("0x%02X: 0x%08x (PR%u is unused)\n", off, pr, i);
> + return 0;
> + }
> +
> + msg_pdbg("0x%02X: 0x%08x ", off, pr);
> + msg_pinfo("WARNING: PR%u: 0x%08x-0x%08x is %s.\n", i, ICH_FREG_BASE(pr),
> + ICH_FREG_LIMIT(pr) | 0x0fff, access_names[rwperms]);
> + return 1;
> }
>
> /* Set/Clear the read and write protection enable bits of PR register @i
> @@ -1537,6 +1547,8 @@ int ich_init_spi(struct pci_dev *dev, uint32_t base, void *rcrb,
> uint16_t spibar_offset, tmp2;
> uint32_t tmp;
> char *arg;
> + int ich_spi_force = 0;
> + int ich_spi_has_locks = 0;
Rename to ich_spi_has_region_locks or ich_spi_has_locked_regions or
somesuch. Otherwise there is possibility for confusion between
ich_spi_has_locks and ichspi_lock.
> int desc_valid = 0;
> struct ich_descriptors desc = {{ 0 }};
> enum ich_spi_mode {
> @@ -1665,17 +1693,36 @@ int ich_init_spi(struct pci_dev *dev, uint32_t base, void *rcrb,
> msg_pdbg("BRWA 0x%02x, ", ICH_BRWA(tmp));
> msg_pdbg("BRRA 0x%02x\n", ICH_BRRA(tmp));
>
> - /* Decode and print FREGx and FRAP registers */
> + /* Handle FREGx and FRAP registers */
> for (i = 0; i < 5; i++)
> - do_ich9_spi_frap(tmp, i);
> + ich_spi_has_locks |= ich9_handle_frap(tmp, i);
> }
>
> - /* try to disable PR locks before printing them */
> - if (!ichspi_lock)
> - for (i = 0; i < 5; i++)
> + for (i = 0; i < 5; i++) {
> + /* if not locked down try to disable PR locks first */
> + if (!ichspi_lock)
> ich9_set_pr(i, 0, 0);
> - for (i = 0; i < 5; i++)
> - prettyprint_ich9_reg_pr(i);
> + ich_spi_has_locks |= ich9_handle_pr(i);
> + }
> +
> + if (ich_spi_has_locks) {
>
Thanks for working tirelessly to get this code into an excellent shape!
Regards,
Carl-Daniel
--
http://www.hailfinger.org/
Author: stefanct
Date: Thu Feb 16 02:13:00 2012
New Revision: 1494
URL: http://flashrom.org/trac/flashrom/changeset/1494
Log:
ichspi.c: warn user and disable writes when a protected address range is detected.
This includes not only the notorious read-only flash descriptors and locked ME
regions, but also the more rarely used PRs (Protected Ranges).
The user can enforce write support by specifying ich_spi_force=yes in the
programmer options, but we don't tell him the exact syntax interactively. He
has to read it up in the man page.
Signed-off-by: Stefan Tauner <stefan.tauner(a)student.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006(a)gmx.net>
Modified:
trunk/flashrom.8
trunk/ichspi.c
Modified: trunk/flashrom.8
==============================================================================
--- trunk/flashrom.8 Thu Feb 16 00:40:23 2012 (r1493)
+++ trunk/flashrom.8 Thu Feb 16 02:13:00 2012 (r1494)
@@ -315,6 +315,21 @@
chip is attached). The other options (swseq, hwseq) select the respective mode
(if possible).
.sp
+ICH8 and later southbridges may also have locked address ranges of different
+kinds if a valid descriptor was written to it. The flash address space is then
+partitioned in multiple so called "Flash Regions" containing the host firmware,
+the ME firmware and so on respectively. The flash descriptor can also specify up
+to 5 so called "Protected Regions", which are freely chosen address ranges
+independent from the aforementioned "Flash Regions". All of them can be write
+and/or read protected individually. If flashrom detects such a lock it will
+disable write support unless the user forces it with the
+.sp
+.B " flashrom \-p internal:ich_spi_force=yes"
+.sp
+syntax. If this leads to erase or write accesses to the flash it would most
+probably bring it into an inconsistent and unbootable state and we will not
+provide any support in such a case.
+.sp
If you have an Intel chipset with an ICH6 or later southbridge and if you want
to set specific IDSEL values for a non-default flash chip or an embedded
controller (EC), you can use the
Modified: trunk/ichspi.c
==============================================================================
--- trunk/ichspi.c Thu Feb 16 00:40:23 2012 (r1493)
+++ trunk/ichspi.c Thu Feb 16 02:13:00 2012 (r1494)
@@ -1421,7 +1421,8 @@
#define ICH_BRWA(x) ((x >> 8) & 0xff)
#define ICH_BRRA(x) ((x >> 0) & 0xff)
-static void do_ich9_spi_frap(uint32_t frap, int i)
+/* returns 0 if region is unused or r/w */
+static int ich9_handle_frap(uint32_t frap, int i)
{
static const char *const access_names[4] = {
"locked", "read-only", "write-only", "read-write"
@@ -1436,19 +1437,26 @@
int offset = ICH9_REG_FREG0 + i * 4;
uint32_t freg = mmio_readl(ich_spibar + offset);
- msg_pdbg("0x%02X: 0x%08x (FREG%i: %s)\n",
- offset, freg, i, region_names[i]);
-
base = ICH_FREG_BASE(freg);
limit = ICH_FREG_LIMIT(freg);
if (base > limit) {
/* this FREG is disabled */
- msg_pdbg("%s region is unused.\n", region_names[i]);
- return;
+ msg_pdbg2("0x%02X: 0x%08x FREG%i: %s region is unused.\n",
+ offset, freg, i, region_names[i]);
+ return 0;
+ }
+ msg_pdbg("0x%02X: 0x%08x ", offset, freg);
+ if (rwperms == 0x3) {
+ msg_pdbg("FREG%i: %s region (0x%08x-0x%08x) is %s.\n", i,
+ region_names[i], base, (limit | 0x0fff),
+ access_names[rwperms]);
+ return 0;
}
- msg_pdbg("0x%08x-0x%08x is %s\n", base, (limit | 0x0fff),
- access_names[rwperms]);
+ msg_pinfo("FREG%i: WARNING: %s region (0x%08x-0x%08x) is %s.\n", i,
+ region_names[i], base, (limit | 0x0fff),
+ access_names[rwperms]);
+ return 1;
}
/* In contrast to FRAP and the master section of the descriptor the bits
@@ -1460,21 +1468,25 @@
#define ICH_PR_PERMS(pr) (((~((pr) >> PR_RP_OFF) & 1) << 0) | \
((~((pr) >> PR_WP_OFF) & 1) << 1))
-static void prettyprint_ich9_reg_pr(int i)
+/* returns 0 if range is unused (i.e. r/w) */
+static int ich9_handle_pr(int i)
{
- static const char *const access_names[4] = {
- "locked", "read-only", "write-only", "read-write"
+ static const char *const access_names[3] = {
+ "locked", "read-only", "write-only"
};
uint8_t off = ICH9_REG_PR0 + (i * 4);
uint32_t pr = mmio_readl(ich_spibar + off);
- int rwperms = ICH_PR_PERMS(pr);
+ unsigned int rwperms = ICH_PR_PERMS(pr);
- msg_pdbg2("0x%02X: 0x%08x (PR%u", off, pr, i);
- if (rwperms != 0x3)
- msg_pdbg2(")\n0x%08x-0x%08x is %s\n", ICH_FREG_BASE(pr),
- ICH_FREG_LIMIT(pr) | 0x0fff, access_names[rwperms]);
- else
- msg_pdbg2(", unused)\n");
+ if (rwperms == 0x3) {
+ msg_pdbg2("0x%02X: 0x%08x (PR%u is unused)\n", off, pr, i);
+ return 0;
+ }
+
+ msg_pdbg("0x%02X: 0x%08x ", off, pr);
+ msg_pinfo("PR%u: WARNING: 0x%08x-0x%08x is %s.\n", i, ICH_FREG_BASE(pr),
+ ICH_FREG_LIMIT(pr) | 0x0fff, access_names[rwperms]);
+ return 1;
}
/* Set/Clear the read and write protection enable bits of PR register @i
@@ -1537,6 +1549,8 @@
uint16_t spibar_offset, tmp2;
uint32_t tmp;
char *arg;
+ int ich_spi_force = 0;
+ int ich_spi_rw_restricted = 0;
int desc_valid = 0;
struct ich_descriptors desc = {{ 0 }};
enum ich_spi_mode {
@@ -1631,6 +1645,22 @@
}
free(arg);
+ arg = extract_programmer_param("ich_spi_force");
+ if (arg && !strcmp(arg, "yes")) {
+ ich_spi_force = 1;
+ msg_pspew("ich_spi_force enabled.\n");
+ } else if (arg && !strlen(arg)) {
+ msg_perr("Missing argument for ich_spi_force.\n");
+ free(arg);
+ return ERROR_FATAL;
+ } else if (arg) {
+ msg_perr("Unknown argument for ich_spi_force: \"%s\" "
+ "(not \"yes\").\n", arg);
+ free(arg);
+ return ERROR_FATAL;
+ }
+ free(arg);
+
tmp2 = mmio_readw(ich_spibar + ICH9_REG_HSFS);
msg_pdbg("0x04: 0x%04x (HSFS)\n", tmp2);
prettyprint_ich9_reg_hsfs(tmp2);
@@ -1665,17 +1695,36 @@
msg_pdbg("BRWA 0x%02x, ", ICH_BRWA(tmp));
msg_pdbg("BRRA 0x%02x\n", ICH_BRRA(tmp));
- /* Decode and print FREGx and FRAP registers */
+ /* Handle FREGx and FRAP registers */
for (i = 0; i < 5; i++)
- do_ich9_spi_frap(tmp, i);
+ ich_spi_rw_restricted |= ich9_handle_frap(tmp, i);
}
- /* try to disable PR locks before printing them */
- if (!ichspi_lock)
- for (i = 0; i < 5; i++)
+ for (i = 0; i < 5; i++) {
+ /* if not locked down try to disable PR locks first */
+ if (!ichspi_lock)
ich9_set_pr(i, 0, 0);
- for (i = 0; i < 5; i++)
- prettyprint_ich9_reg_pr(i);
+ ich_spi_rw_restricted |= ich9_handle_pr(i);
+ }
+
+ if (ich_spi_rw_restricted) {
+ msg_pinfo("Please send a verbose log to "
+ "flashrom(a)flashrom.org if this board is not "
+ "listed on\n"
+ "http://flashrom.org/Supported_hardware#Supported_mainboards "
+ "yet.\n");
+ if (!ich_spi_force)
+ programmer_may_write = 0;
+ msg_pinfo("Writes have been disabled. You can enforce "
+ "write support with the\nich_spi_force "
+ "programmer option, but it will most likely "
+ "harm your hardware!\nIf you force flashrom "
+ "you will get no support if something "
+ "breaks.\n");
+ if (ich_spi_force)
+ msg_pinfo("Continuing with write support "
+ "because the user forced us to!\n");
+ }
tmp = mmio_readl(ich_spibar + ICH9_REG_SSFS);
msg_pdbg("0x90: 0x%02x (SSFS)\n", tmp & 0xff);