1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-26 22:52:34 +02:00

45 Commits

Author SHA1 Message Date
Nico Huber
bcb2e5a708 Constify parameters and globals
This makes some stuff const (partially to get a more convenient
libflashrom interface).

Corresponding to flashrom svn r1639.

Signed-off-by: Nico Huber <nico.huber@secunet.com>
Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2012-12-30 01:23:17 +00:00
Stefan Tauner
b8911d6cec Fix memleaks in cli_classic.c
Frees the memory allocated for the following strings
- log file name
- layout file name
- image file name
- programmer parameter (and reset the associated global variable in flashrom.c)

Also, free the flashchip structs allocated by probe_flash.

The layout image names were not fixed due to the pending layout patches.

These bugs were found thanks to valgrind.

Corresponding to flashrom svn r1629.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2012-12-26 07:55:00 +00:00
Stefan Tauner
b226cb1662 Improve --help and friends
More clear "variable" names, better explanation if no programmer is selected etc.

Corresponding to flashrom svn r1624.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Paul Menzel <paulepanter@users.sourceforge.net>
2012-11-24 18:59:39 +00:00
Niklas Söderlund
ede2fa4d1e Remove exit calls from print_supported_chips
Propagate the error code using return values instead, but let cli_classic.c
still decide the ultimate return value of the process.
Also, remove setting the ret value again after print_supported_wiki() - 
success is the default.

Corresponding to flashrom svn r1614.

Signed-off-by: Niklas Söderlund <niso@kth.se>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2012-10-23 13:06:46 +00:00
Stefan Tauner
fd0d413537 Introduce a compile time option to select a default programmer
Heavily influenced by a discussion with (and based on code from) Peter Stuge.
Please read the comment in the Makefile before using this option.

Corresponding to flashrom svn r1607.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Peter Stuge <peter@stuge.se>
2012-09-25 21:24:55 +00:00
Carl-Daniel Hailfinger
5a7cb847f0 Make struct flashchip a field in struct flashctx instead of a complete copy
All the driver conversion work and cleanup has been done by Stefan.
flashrom.c and cli_classic.c are a joint work of Stefan and Carl-Daniel.

Corresponding to flashrom svn r1579.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2012-08-25 01:17:58 +00:00
Carl-Daniel Hailfinger
4e3391f505 Always require the --programmer parameter if any flash chip access is requested
Fix a few man page oddities as well.

Corresponding to flashrom svn r1552.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2012-07-22 12:01:43 +00:00
Carl-Daniel Hailfinger
1c15548888 Add logfile support
Usage: flashrom --output logfile.txt

Logfile output has at least dbg2 verbosity or screen verbosity,
whichever is greater.

Corresponding to flashrom svn r1540.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Tested on Linux, Windows and FreeBSD.
Acked-by: Idwer Vollering <vidwer@gmail.com>
2012-06-06 09:17:06 +00:00
Carl-Daniel Hailfinger
901a3ba023 Convert printf to msg_* where appropriate
Clean up cli_output.c to be more readable.
Use enum instead of #define for message levels.
Kill a few exit(0) calls.
Print the command line arguments in verbose mode.
Move actions (--list-supported etc.) after argument sanity checks.
Reduce the number of code paths which have their own
programmer_shutdown().

Corresponding to flashrom svn r1536.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2012-05-14 22:54:58 +00:00
Carl-Daniel Hailfinger
b428e97cb1 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.

Corresponding to flashrom svn r1496.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2012-02-16 20:31:25 +00:00
Carl-Daniel Hailfinger
4628445ccb Postpone layout file reading
Layout file reading should happen after option parsing like all other
file accesses.
Guard against multiple --layout parameters.

Followup fix for r1483: Remove -m short option from getopt.

Corresponding to flashrom svn r1484.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2012-01-11 02:10:11 +00:00
Carl-Daniel Hailfinger
2d927fbd7b Replace --mainboard with -p internal:mainboard
NOTE:
The --list-supported-wiki output changed to use -p internal:mainboard=
instead of -m
The --list-supported output changed the heading of the mainboard list
from

Vendor Board   Status  Required option
to
Vendor Board   Status  Required value for
                       -p internal:mainboard=

Fix lb_vendor_dev_from_string() not to write to the supplied string.

Corresponding to flashrom svn r1483.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2012-01-04 00:48:27 +00:00
Louis Yung-Chieh Lo
9bcf2684d7 Add deferred --image processing
The general idea and most of the code are based on the following
commits in the chromiumos flashrom tree:

Corresponding to flashrom svn r1482.

8fc0740356ca15d02fb1c65ab43b10844f148c3b
bb9049c66ca55e0dc621dd2c70b5d2cb6e5179bf
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>

and the main part:
d0ea9ed71e7f86bb8e8db2ca7c32a96de25343d8
Signed-off-by: David Hendricks <dhendrix@chromium.org>

This implementation does not defer the processing until doit(), but after the
argument parsing loop only (doit() should not contain argument checks).

This allows to specify -i and -l parameters in any order.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: David Hendricks <dhendrix@google.com>
2011-12-25 09:12:16 +00:00
Michael Karcher
222bf1013f Fix programmer-centric probe (patch v2)
As reported by Stefan Tauner on IRC, the new programmer-centric logic
is broken by re-using occupied members of the flashes array when changing
to the next programmer. This fixes it.

patch v2:
  prevent probing one chip per programmer even if the array is full. Using
  a do-while loop was a bad idea.

Corresponding to flashrom svn r1479.

Signed-off-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2011-12-22 23:27:03 +00:00
Carl-Daniel Hailfinger
c40cff7b86 Have all programmer init functions register bus masters/programmers
All programmer types (Parallel, SPI, Opaque) now register themselves
into a generic programmer list and probing is now programmer-centric
instead of chip-centric.
Registering multiple SPI/... masters at the same time is now possible
without any problems. Handling multiple flash chips is still unchanged,
but now we have the infrastructure to deal with "dual BIOS" and "one
flash behind southbridge and one flash behind EC" sanely.

A nice side effect is that this patch kills quite a few global variables
and improves the situation for libflashrom.

Hint for developers:
struct {spi,par,opaque}_programmer now have a void *data pointer to
store any additional programmer-specific data, e.g. hardware
configuration info.

Note:
flashrom -f -c FOO -r forced_read.bin
does not work anymore. We have to find an architecturally clean way to
solve this.

Corresponding to flashrom svn r1475.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
2011-12-20 00:19:29 +00:00
Carl-Daniel Hailfinger
63fd9026f1 Use struct flashctx instead of struct flashchip for flash chip access
Struct flashchip is used only for the flashchips array and for
operations which do not access hardware, e.g. printing a list of
supported flash chips.

struct flashctx (flash context) contains all data available in
struct flashchip, but it also contains runtime information like
mapping addresses. struct flashctx is expected to grow additional
members over time, a prime candidate being programmer info.
struct flashctx contains all of struct flashchip with identical
member layout, but struct flashctx has additional members at the end.

The separation between struct flashchip/flashctx shrinks the memory
requirement of the big flashchips array and allows future extension
of flashctx without having to worry about bloat.

Corresponding to flashrom svn r1473.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
2011-12-14 22:25:15 +00:00
Carl-Daniel Hailfinger
eaacd2d4e7 Register Parallel/LPC/FWH programmers the same way SPI programmers are registered
All programmers are now calling programmer registration functions and
direct manipulations of buses_supported are not needed/possible anymore.

Note: Programmers without parallel/LPC/FWH chip support should not call
register_par_programmer().

Additional fixes:
Set max_rom_decode.parallel for drkaiser.
Remove abuse of programmer_map_flash_region in it85spi.
Annotate several FIXMEs in it85spi.

Corresponding to flashrom svn r1463.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
2011-11-09 23:40:00 +00:00
Stefan Tauner
1d947633b6 Print out the flash chip found after the probing loop in verbose mode
This allows easier identification of the flash chip used in verbose logs.
There is no (additional) output if
* -c is used to specify a flash chip, or
* multiple chips are detected, or
* no chips are detected.

Corresponding to flashrom svn r1436.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
2011-09-11 22:08:58 +00:00
Carl-Daniel Hailfinger
2e681601b1 Change programmer selection in cli and generic code
Bugfix: Do not accept multiple conflicting --programmer selections.
Restriction: Do not accept multiple --programmer selections even if
  there is no conflict.
Unexport the programmer variable.
programmer_init requires the programmer as first parameter.
The default programmer selection is now part of cli_classic.

Corresponding to flashrom svn r1433.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2011-09-08 00:00:29 +00:00
Uwe Hermann
394ee78325 Move the main() function from flashrom.c to cli_classic.c
The file flashrom.c is part of libflashrom and should thus not contain a
main() function, that would break compilation of all frontends using
libflashrom. Also, cli_classic.c is the right place anyway, as it's the
main() of the CLI tool.

Rename the simple wrapper cli_classic() in cli_classic.c to main(), as
it's not really needed.

Corresponding to flashrom svn r1417.

Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2011-08-20 14:14:22 +00:00
Carl-Daniel Hailfinger
082c8b559c Fixup of r1397
- Mixing uninitialized and initialized local variables leads to
  confusion.
- ft2232_spi error cases should have gotten some error handling, and
  that's the reason the curly braces were there.
- Fixing typos/wording in some places would have been nice given that
  those places were touched anyway.

Corresponding to flashrom svn r1413.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2011-08-15 19:54:20 +00:00
Uwe Hermann
91f4afa110 Random whitespace and coding-style fixes
Also, indentation fixes, e.g. due to conversion to msg_*, use ARRAY_SIZE
where possible, wrap overly long line, etc.

Compile-tested. There should be no functional changes.

Corresponding to flashrom svn r1397.

Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
2011-07-28 08:13:25 +00:00
Stefan Tauner
716e09848a Add a bunch of new/tested stuff and various small changes 5
- mark EN25F80 as fully tested
  http://www.flashrom.org/pipermail/flashrom/2011-July/007329.html
- mark W25Q16 as fully tested
  http://www.flashrom.org/pipermail/flashrom/2011-July/007151.html
- mark W39V040A as fully tested
  http://www.flashrom.org/pipermail/flashrom/2011-July/007161.html
- mark Pm25LV040 as fully tested
  reported by TL1 on IRC
- mark W49F002U/N as fully tested
  http://paste.flashrom.org/view.php?id=733g
- mark W39V080FA as fully tested
  http://www.flashrom.org/pipermail/flashrom/2011-July/007225.html

- add ASUS P4S533-X to the list of supported boards
  http://www.flashrom.org/pipermail/flashrom/2011-July/007200.html
- add ASUS M4A785TD-V EVO to the list of supported boards
  http://www.flashrom.org/pipermail/flashrom/2011-July/007329.html
- add GA-945PL-S3P (rev. 6.6) to the list of supported boards
  reported by TL1 on IRC
- add MS-7142 (K8MM-V) to the list of supported boards
  http://www.flashrom.org/pipermail/flashrom/2011-July/007161.html
- add MS-7369 (K9N Neo V2) to the list of supported boards
  http://www.flashrom.org/pipermail/flashrom/2011-July/007181.html
- add X7DBT-INF to the list of supported boards
  http://www.flashrom.org/pipermail/flashrom/2011-July/007225.html

- mark SiS 645DX chipset enable as OK
  http://www.flashrom.org/pipermail/flashrom/2011-July/007200.html
- mark SiS 651 chipset enable as OK
  http://paste.flashrom.org/view.php?id=733

- move intel_ich_gpio34_raise to the correct line(s)
- change the output of unlock_w39_fwh_block from 0x%x to 0x%08x
- fix output for untested chipset enables (missing space)
- reorder the board enable in print.c entry for GA-8SIMLH added in r1385.
- minor other fixes

- fix output for multiple found flash chips by adding quotes and commas
- similarly fix output of "Found/Assuming" chips

Corresponding to flashrom svn r1386.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
the last two points are
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
everything else is
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
2011-07-25 20:38:52 +00:00
Stefan Tauner
1a30d50ad8 Fix a bug breaking layout file handling in r1373
Florian Zumbiehl discovered that we have broken the -i switch in the
last commit resulting in self-contradictory output:
http://paste.flashrom.org/view.php?id=707

Corresponding to flashrom svn r1374.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2011-07-19 07:58:06 +00:00
Carl-Daniel Hailfinger
d5660141ec Fix and clean up cli_classic.c
Don't ignore -i if it is specified before -l
Check if image mentioned by -i is present in layout file
Consolidate duplicated programmer_shutdown calls
Kill outdated comments
Finish parameter checking before -L/-z is executed

Corresponding to flashrom svn r1373.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: David Hendricks <dhendrix@google.com>
2011-07-15 23:47:45 +00:00
David Hendricks
8bb2021d77 Use shutdown callback mechanism to shutdown programmers
This patch attempts to resolve some programmer shutdown ordering issues
by having the programmer init functions register shutdown callbacks explicitly
wherever it makes most sense. Before, assumptions were made that could lead to
the internal programmer's state changing before the external programmer could be
shut down properly. Now, each programmer cleans up after itself and (hopefully)
performs each operation in the correct order.

As a side-effect, this patch gives us a better usage model for reverse
operations such as rpci_* and rmmio_*. In the long-run, this should make
reversing the initialization process easier to understand, less tedious, and
less error-prone.

In short, this patch does the following:
- Registers a shutdown callback during initialization for each programmer.
- Kills the .shutdown function pointer from programmer_entry struct. Also,
  make most shutdown functions static.
- Adds a few minor clean-ups and corrections (e.g. missing physunmap() calls).

TODO: Remove forward declaration of serprog_shutdown() (added to simplify diff)

Corresponding to flashrom svn r1338.

Signed-off-by: David Hendricks <dhendrix@google.com>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2011-06-14 01:35:36 +00:00
Carl-Daniel Hailfinger
064bbc9f37 Fix multiple detection of the same chip
r1293 introduced a bug which caused probing to loop at the first found
chip.

Corresponding to flashrom svn r1296.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Idwer Vollering <vidwer@gmail.com>
2011-05-07 19:19:36 +00:00
Carl-Daniel Hailfinger
4c82318e4a Constify flashchips array
This moves 99.5% of the .data section to .rodata (which ends up in .text).

Corresponding to flashrom svn r1293.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2011-05-04 00:39:50 +00:00
Peter Huewe
73f8ec8b1e Fix sparse warning: Using plain integer as NULL pointer
This patch fixes the "using plain integer as NULL pointer" warnings
generated by running sparse on the flashrom source.

Corresponding to flashrom svn r1255.

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
Acked-by: Mathias Krause <mathias.krause@secunet.com>
Acked-by: Stefan Reinauer <stepan@coreboot.org>
2011-01-24 19:15:51 +00:00
Mathias Krause
a60faab83e Convince compilers to put constant data into the .rodata section
This patch reduces the stack usage by declaring 'const' stack variables
as 'static const' so they end up in the .rodata section instead of being
copied from there to the stack for every invocation of the corresponding
function.

As a plus we end up in having a smaller binary as the "copy from .rodata
to stack" code isn't emitted by the compiler any more (roughly -100
bytes).

Corresponding to flashrom svn r1252.

Signed-off-by: Mathias Krause <mathias.krause@secunet.com>
Acked-by: Stefan Reinauer <stepan@coreboot.org>
2011-01-17 07:50:42 +00:00
Carl-Daniel Hailfinger
a73fb4983d Refine -L output to include all programmer modules
Flashrom -L output did not contain a list of programmers nor were
all programmers listed. Fix it and mention at least the name of each
programmer. Wiki output is unchanged, and will need separate fixups.

Corresponding to flashrom svn r1199.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
2010-10-06 23:48:34 +00:00
Stefan Reinauer
18430a08aa Remove duplicate includes from the code
Corresponding to flashrom svn r1196.

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2010-10-06 02:56:44 +00:00
Carl-Daniel Hailfinger
9ad4255b5e Delay between probe and subsequent operations
Some flash chips need time to exit ID mode, and while we take care of
correct timing for the matching probe, subsequent probes may have
totally different timing, and that can lead to garbage responses from
the flash chip during the first accesses after the probe sequence is
done.
Delay 100 ms between the last probe and any subsequent operation.
To ensure maximum correctness, we would have to reset the chip first in
case the last probe function left the chip in an undefined (non-read)
state. That will be possible once struct flashchip has a .reset
function.

This fixes unstable erase/read/write for some flahs chips on nic3com and
possible other use cases as well.

Thanks to Maciej Pijanka for reporting the issue and testing patches.

Corresponding to flashrom svn r1172.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
2010-09-15 10:20:16 +00:00
Carl-Daniel Hailfinger
5b997c3ed6 Split off programmer.h from flash.h
Programmer specific functions are of absolutely no interest to any file
except those dealing with programmer specific actions (special SPI
commands and the generic core).

The new header structure is as follows (and yes, improvements are
possible):
flashchips.h  flash chip IDs
chipdrivers.h  chip-specific read/write/... functions
flash.h  common header for all stuff that doesn't fit elsewhere
hwaccess.h hardware access functions
programmer.h  programmer specific functions
coreboot_tables.h  header from coreboot, internal programmer only
spi.h SPI command definitions

Corresponding to flashrom svn r1112.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
2010-07-27 22:41:39 +00:00
Carl-Daniel Hailfinger
1748c5701f Print an error message on read errors and abort instead of proceeding anyway
Improve error checking in file write, chip read and chip verify.
Refactor the read routines a bit to split reading from file writing.

Log for a failed read:
[...]
Found chip "Winbond W25x16" (2048 KB, SPI) at physical address
0xffe00000.
Reading flash... Invalid OPCODE 0x03
Read operation failed!
FAILED.

Corresponding to flashrom svn r1079.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stephen Kou <stephen@hyarros.com>
2010-07-13 23:56:13 +00:00
Carl-Daniel Hailfinger
ad3cc55e13 Kill global variables, constants and functions if local scope suffices
Constify variables where possible.
Initialize programmer-related variables explicitly in programmer_init to
allow running programmer_init from a clean state after
programmer_shutdown.
Prohibit registering programmer shutdown functions before init or after
shutdown.
Kill some dead code.
Rename global variables with namespace-polluting names.
Use a previously unused locking helper function in sst49lfxxxc.c.

This is needed for libflashrom.

Effects on the binary size of flashrom are minimal (300 bytes
shrinkage), but the data section shrinks by 4384 bytes, and that's a
good thing if flashrom is operating in constrained envionments.

Corresponding to flashrom svn r1068.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
2010-07-03 11:02:10 +00:00
Uwe Hermann
2db77a03ef Make the 'flashrom --help' output look a bit nicer
Only print "flashrom" as the program name unconditionally, not the full path
and program name (e.g. "/home/foo/bar/baz/flashrom" or on Windows
"C:\Foo\Bar\Whatever\flashrom.exe"). The path or exact executable name is
not really useful to print here, if you managed to run --help you already
know it, and it just makes the output look ugly.

Also, add a missing newline to make the output look nicer.

Finally, revert the "CONFIG_PRINT_WIKI ?= yes" change which accidentally
slipped into r1029.

Corresponding to flashrom svn r1030.

Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2010-06-04 17:07:39 +00:00
Carl-Daniel Hailfinger
71127727dc So far, we have up to 4 different names for the same thing (ignoring capitalization)
CONFIG_FT2232SPI (makefile config option)
FT2232_SPI_SUPPORT (#define)
ft2232spi (programmer name)
ft2232_spi.c (programmer file)

Use CONFIG_* with underscores for makefile config options and #defines
and kill the useless _SUPPORT idiom.
Use lowercase names with underscores for programmer names and programmer
files.

With this, you can run "grep -i ft2232_spi" and find everything related
to the ft2232_spi driver. Same applies to all other programmers.

Corresponding to flashrom svn r1023.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
2010-05-31 15:27:27 +00:00
Carl-Daniel Hailfinger
831e8f4abb Remove unneeded #include statements completely
Unistd.h was only used to get a definition of NULL in all files. Add our
own NULL #define and remove unistd.h from flash.h
stdio.h has no place in flash.h, it should be included only in files
which really need it.
Add #include statements in individual .c files where needed.

Replace a few printf with msg_* to eliminate the need for stdio.h.

Corresponding to flashrom svn r1021.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
2010-05-30 22:24:40 +00:00
Carl-Daniel Hailfinger
4988420f7d Initialize the internal delay function before running programmer init
The programmer init may need a good host delay function.

Corresponding to flashrom svn r1006.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
2010-05-22 07:10:46 +00:00
Carl-Daniel Hailfinger
8841d3e703 Fix assorted documentation, frontend and printing bugs
Change the command line interface to make file names positional.
Add more sanity checks to the command line parser.

Corresponding to flashrom svn r998.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
2010-05-15 15:04:37 +00:00
Carl-Daniel Hailfinger
270237687a One of the problems is that --force had multiple meanings
- Force chip read by faking probe success.
- Force chip access even if the chip is bigger than max decode size for
  the flash bus.
- Force erase even if erase is known bad.
- Force write even if write is known bad.
- Force writing even if cbtable tells us that this is the wrong image
  for this board.

This patch cleans up --force usage:
- Remove any suggestions to use --force for probe/read from flashrom
  output.
- Don't talk about "success" or "Found chip" if the chip is forced.
- Add a new internal programmer parameter boardmismatch=force. This
  overrides any mismatch detection from cbtable/image comparisons.
- Add a new internal programmer parameter laptop=force_I_want_a_brick.
- Adjust the documentation for --force.
- Clean up the man page a bit whereever it talks about --force or
  laptops.

Additional changes in this patch:
- Add warnings about laptops to the documentation.
- Abort if a laptop is detected. Can be overridden with the programmer
parameter mentioned above.
- Add "Portable" to the list of DMI strings indicating laptops.
- Check if a chip specified with -c is known to flashrom.
- Programmer parameter reliability and consistency fixes.
- More paranoid self-checks.
- Improve documentation.

Corresponding to flashrom svn r996.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
2010-04-28 15:22:14 +00:00
Michael Karcher
e7f3209487 Enable -Wshadow, clean code for that
This is not just for fun. We hit a real bug on BSD with the outl macros.
The macro variable tmp collided with the tmp from outer scope.

second revision, now also taking care of inb/inw/inl. While that shadowing
did not introduce bugs (yet), of course it breaks the build on BSD when
-Wshadow is enabled.

Corresponding to flashrom svn r860.

Signed-off-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
Acked-by: Luc Verhaegen <libv@skynet.be>
2010-01-12 15:36:24 +00:00
Sean Nelson
51e97d754f Converting fprintf(stderr), printf, and printf_debug into a common print interface for flashrom
It also changes so -VV will spit out highly verbose messages for
debugging. This is a minimal patch to lessen impact a later patch will
convert current printf messages to the new interface.

Corresponding to flashrom svn r835.

Signed-off-by: Sean Nelson <audiohacked@gmail.com>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2010-01-07 20:09:33 +00:00
Carl-Daniel Hailfinger
a84835a7ea Move the CLI related functions main() and cli_usage() to cli_classic.c
And rename them accordingly. For now, main() just calls cli_classic(),
but alternative frontends can be switched in main().
Annotate remaining help texts with CLI dependency inside flashrom.c with
a FIXME comment.

Now people can go and create different frontends and be happy. Please
note that any other frontend will have to sort of duplicate the probing
code in cli_classic.c. Refactoring that part of the code is possible,
but not easy because we still want to print instructive help messages
for users.

Corresponding to flashrom svn r833.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Sean Nelson <audiohacked@gmail.com>
2010-01-07 03:24:05 +00:00