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

346 Commits

Author SHA1 Message Date
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
Carl-Daniel Hailfinger
f8dda68359 Change msg_* macros to C99 variadic macros
The msg_* macros won't compile as is if you use more than one parameter
(i.e.

have a format string and a variable). There are two alternative styles:
GNU or C99 variadic macros. While C99 has limitations compared to the
GNU extensions, these limitations do not affect our macros, so I decided
to go with the standard way.

I adjusted whitespace a bit to have aligned values (cosmetic change).

Corresponding to flashrom svn r841.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Sean Nelson <audiohacked@gmail.com>
2010-01-09 03:22:31 +00:00
Carl-Daniel Hailfinger
4bf4e79907 Use address mask in probe_jedec
This allows us to have one common probe_jedec function instead of half a
dozen wrappers. The trick here is to have FEATURE_ADDR_FULL==0 and thus
default to unmasked addresses. That way, we only have to annotate chips
which need small address masks.

Corresponding to flashrom svn r840.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Sean Nelson <audiohacked@gmail.com>
2010-01-09 03:15:50 +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
Patrick Georgi
e48654cf70 Buspiratespi support on mingw
Corresponding to flashrom svn r832.

Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2010-01-06 22:14:39 +00:00
Patrick Georgi
3b6237dbce Multiple unrelated changes
- replace the hand written serial input flush routine with the termios one.
- serialport_discard_read isn't necessary anymore - it just wrapped
  sp_flush_incoming with no extra value.
- serialport_read and serialport_write would misbehave if read or write
  didn't process everything in one go.
- sp_flush_incoming should be #define'd out for FAKE_COMMUNICATION like
  serialport_discard_read was

Corresponding to flashrom svn r831.

Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de>
Acked-by: Sean Nelson <audiohacked@gmail.com>
2010-01-06 19:09:40 +00:00
Carl-Daniel Hailfinger
efa151eb10 Move OS-dependent serial code from buspirate_spi.c to serial.c
While at it, also rename a few functions to make it obvious
that they are generic and not specific to the Bus Pirate.

Corresponding to flashrom svn r830.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Patrick Georgi <patrick.georgi@coresystems.de>
2010-01-06 16:09:10 +00:00
Carl-Daniel Hailfinger
cc1802db50 Move generic programmer function into newly introduced programmer.c
Some programmers (most notably FT2232SPI) use fallback_* and noop_*,
but those functions lived inside internal.c and were unavailable if no
PCI-based programmers were compiled in.

Move those functions to the new file programmer.c. Thanks to Patrick
Georgi for finding this.

Corresponding to flashrom svn r829.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Patrick Georgi <patrick.georgi@coresystems.de>
2010-01-06 10:21:00 +00:00
Sean Nelson
c57a920f34 Generify jedec functions by introducing an address mask
The patch converts jedec functions into mask-based generics which can
be used for many chip provided the only changes are the addresses are
converted from 0x5555/0x2AAA to 0x555/0x2AA or similar.

The patch mostly changes jedec.c, but a few other files are changed
because they use the jedec functions within their own functions.

The patch also adds a copyright line to flashchips.c because of my
recent work in converting AMD and Atmel chips to use struct erase_block.

Corresponding to flashrom svn r828.

Signed-off-by: Sean Nelson <audiohacked@gmail.com>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2010-01-04 17:15:23 +00:00
Carl-Daniel Hailfinger
36cc1c8144 Internal.c was always compiled in because it hosted the function internal_delay()
Move that function to udelay.c and compile internal.c only if really
needed. physmap.c is only needed if the programmer is internal or a PCI
card. Make its compilation conditional.

Corresponding to flashrom svn r822.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Idwer Vollering <vidwer@gmail.com>
2009-12-24 03:11:55 +00:00
Carl-Daniel Hailfinger
552420b0d6 Factor out CLI code by moving generic stuff out of main()
Add a generic programmer list output function to be used by alternative
frontends. The interface between main() and doit is a hack and should
get a clean design, but for now it serves the purpose of shortening
main() by 120 lines. The rest of main() needs to be refactored a bit
more before moving main() away.

Corresponding to flashrom svn r821.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Sean Nelson <audiohacked@gmail.com>
2009-12-24 02:15:55 +00:00
Carl-Daniel Hailfinger
14e100c933 SuperI/O detection now happens unconditionally and before the chipset enable
We could run it after chipset enable, but it definitely has to happen
before board enable because the board enable usually accesses the
SuperI/O. With this patch, it is possible to add a struct superio to the
board enable table for more accurate matching in case subsystem IDs are
ambiguous. This patch focuses on the generic infrastructure aspect and
on support for IT8712F/IT8716F.

Thanks go to Adrian Glaubitz and Ward Vandewege for testing.

Corresponding to flashrom svn r813.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Luc Verhaegen <libv@skynet.be>
Acked-by: Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
2009-12-22 23:42:04 +00:00
Carl-Daniel Hailfinger
63ce4bb0d2 Clarify comment about how to enter chip erase functions in struct block_eraser
Reported by Sean Nelson.

Corresponding to flashrom svn r811.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2009-12-22 13:04:53 +00:00
Carl-Daniel Hailfinger
5d5c072422 Split hardware access, OS abstraction and chip drivers out of flash.h
This patch is only the first step, but it hopefully will make working
with the code and especially porting to new platforms easier.

Subsequent patches should move #includes for the newly created files
hwaccess.h and chipdrivers.h from flash.h to the files which need them.
Programmers should live in a separate header file as well.

Tested-by: Idwer Vollering <vidwer@gmail.com>

Corresponding to flashrom svn r799.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Sean Nelson <audiohacked@gmail.com>
2009-12-14 03:32:24 +00:00
Carl-Daniel Hailfinger
66ef4e5ff3 Internal (onboard) programming was the only feature which could not be disabled
Make various pieces of code conditional on support for internal
programming. Code shared between PCI device programmers and onboard
programming is now conditional as well.

It is now possible to build only with dummy support:
make CONFIG_INTERNAL=no CONFIG_NIC3COM=no CONFIG_SATASII=no
CONFIG_DRKAISER=no CONFIG_SERPROG=no CONFIG_FT2232SPI=no

This allows building for a specific use case only, and it also
facilitates porting to a new architecture because it is possible to
focus on highlevel code only.

Note: Either internal or dummy programmer needs to be compiled in due to
the current behaviour of always picking a default programmer if -p is
not specified. Picking an arbitrary external programmer as default  
wouldn't make sense.

Build and runtime tested in all 1024 possible build combinations. The
only failures are by design as mentioned above.

Corresponding to flashrom svn r797.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Sean Nelson <audiohacked@gmail.com>
2009-12-13 22:28:00 +00:00
Michael Karcher
1c296ca8bc Use common jedec functionality where appropriate
The deleted function in en29f002a.c is reintroduced as
write_by_byte_jedec in jedec.c as it contains no chip-specific
instructions. It is not yet used in other chip drivers, as key addresses
(0x2AAA/0x5555) are often specified with less bits. After crosschecking
datasheets, most of the fixmes can probably be resolved as indicated in
them, causing significant code reduction.

The common JEDEC code for bytewise programming does not program 0xFF
at all. The chips that had a dedicated bytewise flash function which
has been changed to write_jedec_1 thus changed flashing behaviour
and the "write" test flag has been removed. This applies to: AMD
Am29F002BB/Am29F002NBB AMD Am29F002BT/Am29F002NBT (TEST_OK_PREW before)
AMIC A29002B AMIC A29002T (TEST_OK_PREW before) EON EN29F002(A)(N)B EON
EN29F002(A)(N)T (TEST_OK_PREW before) Macronix MX29F001B (TEST_OK_PREW
before) Macronix MX29F001T (TEST_OK_PREW before) Macronix MX29F002B
Macronix MX29F002T (TEST_OK_PREW before) Macronix MX29LV040

Similar analysis should be performed for the read id stuff.

Corresponding to flashrom svn r785.

Signed-off-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
Acked-by: Sean Nelson <audiohacked@gmail.com>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2009-11-27 17:49:42 +00:00
Michael Karcher
972cec282c Refine support for the JEDEC Software Data Protection
This patch removes the extremely dangerous unprotect_jedec function
which is not used at all within flashrom code, and renames the
misleadingly named protect_jedec function to start_program_jedec.

Calls to protect_jedec after flashing are removed, because a) on LPC
chips, the command sent by protoct_jedec is not even in the datasheet
and b) on parallel chips, the block write command issued before already
contained the software protection sequence, so software protection is
definitely enabled.

This patch also removes two clones of protect_jedec

Background: JEDEC Software Data Protection started as an optional
feature, which was disabled on the first single-voltage-flash chips.
The software data protection is the need to prefix a write with a magic
"write enable" command, while without write protection every write
access into the chip's address space modifies flash content. This magic
write enable command also tells the flash chip that the programmer
obviously support sending write-enable commands and turns off the "any
write modifies flash content" mode. There also exist a two-command (6
writes) sequence that disables Software Data Protection completey, which
should only ever be used to prepare updating with a device that can't
handle software data protection.

Corresponding to flashrom svn r783.

Signed-off-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
Acked-by: Sean Nelson <audiohacked@gmail.com>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2009-11-26 14:50:52 +00:00
Carl-Daniel Hailfinger
d5b28fae1d Add the ability to set Bus Pirate SPI speed via the command line
Example usage:
flashrom -p buspiratespi:spispeed=2.6MHz,dev=/dev/foo
flashrom -p buspiratespi:dev=/dev/foo,spispeed=2.6M

Refactor programmer option parsing (this allows cleanups in other
programmers as well).

Increase SPI read size from 8 to 12 bytes (current single-transaction
limit of the Bus Pirate raw SPI protocol).

Add Bus Pirate to the list of programmers supporting 4 byte RDID.

Add Bus Pirate syntax to the man page.

Tested-by: Sean Nelson <audiohacked@gmail.com>

Corresponding to flashrom svn r776.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Sean Nelson <audiohacked@gmail.com>
2009-11-24 18:27:10 +00:00
Carl-Daniel Hailfinger
5cca01f394 Cleanly validate ICH SPI preopcodes
The code should work on Linux/*BSD/MacOSX and relies on the serial code
implementation in serial.c. Support for additional platforms (Windows)
will have to be added to serial.c for this to work. For tests without a
Bus Pirate (or with non-functional serial code) it is possible to
#define FAKE_COMMUNICATION in buspirate_spi.c.
Thanks to Sean Nelson for the SPI mode settings code. I tweaked it a bit
to make configuration from a commandline easier should anybody want that
feature.

Tested-by: Sean Nelson <audiohacked@gmail.com>

Corresponding to flashrom svn r772.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Sean Nelson <audiohacked@gmail.com>
2009-11-24 00:20:03 +00:00
Carl-Daniel Hailfinger
e51ea10a88 Move serial handling from serprog.c to serial.c
This is the first step in enabling platform independent serprog and it
also allows other drivers to use serial port functionality without
requiring serprog.

Pure code move, no code changed.

Corresponding to flashrom svn r771.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
2009-11-23 19:20:11 +00:00
Carl-Daniel Hailfinger
a4a9bfb228 Bus Pirate support needs serial communication
Serprog already has such functionality, so it makes sense to share that.
TODO: Factor out serial communication into a separate file, have that
code be available even if serprog is not selected and make it portable
(it is very Linux-centric right now).

Corresponding to flashrom svn r768.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
2009-11-21 11:02:48 +00:00
Carl-Daniel Hailfinger
f52920581d Refactor main loop in preparation of libflashrom
To prepare for libflashrom I wanted to make the main loop more readable and more correct and factor out stuff which can be useful in libflashrom.

- Factor out printing of supported devices to print.c.
- Adjust name of wiki printing function to fit the pattern.
- Abort if the user specified --verify and --noverify at the same time.
- Check for extra parameters which don't fit commandline syntax.

Corresponding to flashrom svn r766.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
2009-11-17 09:57:34 +00:00
Carl-Daniel Hailfinger
9f46cfca38 Add support for every single SiS chipset out there
The two existing SiS chipset enables (compared to the 28 in this patch)
were refactored, and one of them was fixed.

A function to match PCI vendor/class combinations was added to generic
code.

Tested on the "Elitegroup K7S5A". Results are somewhat unexpected (some
PCI settings seem to be inaccessible, but it still works).

This is not based on any docs, but rather on detailed analysis
of existing opensource code for some of the chipsets.

Thanks to for Adrian Glaubitz testing.

Corresponding to flashrom svn r759.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
2009-11-15 17:13:29 +00:00
Carl-Daniel Hailfinger
115d390f1f Add infrastructure to check the maximum supported flash size of chipsets and mainboards
The rationale is to warn users when they, for example, try to flash
a 512KB parallel flash chip but their chipset only supports 256KB,
or they try to flash 512KB and the chipset _does_ theoretically
support 512KB but their special board doesn't wire all address lines
and thus supports only 256 KB ROM chips at maximum.

This has cost Uwe hours of debugging on some board already, until he
figured out what was going on. We should try warn our users where
possible about this.

The chipset and the chip may have more than one bus in common (e.g.
SB600 and Pm49* can both speak LPC+FWH) and on SB600/SB7x0/SB8x0 there
are different limits for LPC and FWH. The only way to tell the user
about the exact circumstances is to spew error messages per bus.

The code will issue a warning during probe (which does fail for some
chips if the size is too big) and abort before the first real
read/write/erase action. If no action is specified, the warning is
printed anyway.
That way, a user can find out why probe might not have worked, and will
be stopped before he/she gets incorrect results.

Add a bitcount function to the infrastructure.

Corresponding to flashrom svn r755.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
2009-10-31 01:53:09 +00:00
Carl-Daniel Hailfinger
3a4781e76c Make bitbang_spi naming consistent
Corresponding to flashrom svn r741.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
2009-10-01 14:51:25 +00:00
Uwe Hermann
2bc98f6c91 Add initial support for flashing some NVIDIA graphics cards
The new option is '-p gfxnvidia', rest of the interface is as usual.

I tested a successful identify and read on a "RIVA TNT2 Model 64/Model 64 Pro"
card for now, erase and write did NOT work properly so far!

Please do not attempt to write/erase cards yet, unless you can recover!

In addition to the NVIDIA handling code it was required to call
programmer_shutdown() in a lot more places, otherwise the graphics card
will be disabled in the init function, but never enabled again as the
shutdown function is not called.
The shutdown handling may be changed to use atexit() later.

Corresponding to flashrom svn r737.

Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Luc Verhaegen <libv@skynet.be>
2009-09-30 18:29:55 +00:00
Carl-Daniel Hailfinger
547872b4ea This is the bitbanging SPI driver infrastructure
If you want support for a particular piece of hardware, just fill in
a few functions in spi_bitbang_master_table. That's it.
On top of this, the RayeR SPI flasher should be supportable in ~20 LOC.

Tested, trace looks OK.

Corresponding to flashrom svn r736.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
2009-09-28 13:15:16 +00:00
Carl-Daniel Hailfinger
a06287c9a0 Switch SST49LF004A/B to block erase, remove the hack which simulated (unsupported) chip erase
Annotate SST49LF004B quirks for TBL#.

Add TEST_OK_PRW which is useful when a PREW chip gets a new erase
routine.

Change a few erase function prototypes to use unsigned int instead of
int.

Corresponding to flashrom svn r731.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Luc Verhaegen <libv@skynet.be>
2009-09-23 22:01:33 +00:00
Carl-Daniel Hailfinger
26f7e64cb1 The current ICH SPI preop handling is a hack which spews lots of warnings, but still yields correct results
With the multicommand infrastructure I introduced in r645, it became
possible to integrate ICH SPI preopcodes cleanly into the flashrom
design.

The new code checks for every opcode in a multicommand array if it is a
preopcode. If yes, it checks if the next opcode is associated with that
preopcode and in that case it simply runs the opcode because the correct
preopcode will be run automatically before the opcode.

Corresponding to flashrom svn r727.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: FENG Yu Ning <fengyuning1984@gmail.com>
2009-09-18 15:50:56 +00:00
Carl-Daniel Hailfinger
4740c6ff3c Allow to exclude each of the external programmer drivers from being compiled in
Example make commandline if you want only internal programmers:
make CONFIG_FT2232SPI=no CONFIG_SERPROG=no CONFIG_NIC3COM=no
CONFIG_SATASII=no CONFIG_DRKAISER=no CONFIG_DUMMY=no

Of course, all of the CONFIG_* symbols can be mixed and matched as
needed. CONFIG_FT2232SPI is special because even if it is enabled, make
will check if the headers are available and skip it otherwise.

Corresponding to flashrom svn r724.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
2009-09-16 10:09:21 +00:00
Carl-Daniel Hailfinger
f38431a5b2 Store block sizes and corresponding erase functions in struct flashchip
I decided to fill in the info for a
few chips to illustrate how this works both for uniform and non-uniform
sector sizes.

struct eraseblock{
int size; /* Eraseblock size */
int count; /* Number of contiguous blocks with that size */
};

struct eraseblock doesn't correspond with a single erase block, but with
a group of contiguous erase blocks having the same size.
Given a (top boot block) flash chip with the following weird, but
real-life structure:

top
16384
8192
8192
32768
65536
65536
65536
65536
65536
65536
65536
bottom

we get the following encoding:
{65536,7},{32768,1},{8192,2},{16384,1}

Although the number of blocks is bigger than 4, the number of block
groups is only 4. If you ever add some flash chips with more than 4
contiguous block groups, the definition will not fit into the 4-member
array anymore and gcc will recognize that and error out. No undetected
overflow possible. In that case, you simply increase array size a bit.
For modern flash chips with uniform erase block size, you only need one
array member anyway.

Of course data types will need to be changed if you ever get flash chips
with more than 2^30 erase blocks, but even with the lowest known erase
granularity of 256 bytes, these flash chips will have to have a size of
a quarter Terabyte. I'm pretty confident we won't see such big EEPROMs
in the near future (or at least not attached in a way that makes
flashrom usable). For SPI chips, we even have a guaranteed safety factor
of 4096 over the maximum SPI chip size (which is 2^24). And if such a
big flash chip has uniform erase block size, you could even split it
among the 4 array members. If you change int count to unsigned int
count, the storable size doubles. So with a split and a slight change of
data type, the maximum ROM chip size is 2 Terabytes.

Since many chips have multiple block erase functions where the
eraseblock layout depends on the block erase function, this patch
couples the block erase functions with their eraseblock layouts.
struct block_eraser {
  struct eraseblock{
    unsigned int size; /* Eraseblock size */
    unsigned int count; /* Number of contiguous blocks with that size */
  } eraseblocks[NUM_ERASEREGIONS];
  int (*block_erase) (struct flashchip *flash, unsigned int blockaddr, unsigned int blocklen);
} block_erasers[NUM_ERASEFUNCTIONS];

Corresponding to flashrom svn r719.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
2009-09-05 02:30:58 +00:00
TURBO J
b0912c0adb Add support for parallel flash on Dr. Kaiser PC-Waechter PCI devices
The vendor sold different designs under that name, the patch works with
the one that has an Actel FPGA as PCI-to-Flash bridge.

The Flash chip is a "Macronix MX29F001B" (128 KB, parallel) soldered
directly to the PCB.
Flash operations (PROBE, READ, ERASE, WRITE) work as expected.

Corresponding to flashrom svn r712.

Signed-off-by: TURBO J <turboj@gmx.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
2009-09-02 23:00:46 +00:00
Carl-Daniel Hailfinger
f5fb51c4ba Adept layout handling to new programmer infrastructure and fix off-by-one error
Flashrom has the ability to use layout files with romentries, but
this feature was not adapted to the programmer infrastructure and had
undefined behaviour for flasher!=internal. The romentry handling had an
off-by-one error which caused all copies to end up one byte short. Fix
these issues.

Corresponding to flashrom svn r694.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
2009-08-19 15:19:18 +00:00
Carl-Daniel Hailfinger
3426ef6ab8 If FT2232H SPI is not enabled, it should be compiled out completely
We can't remove ft2232_spi.o from unconditional OBJS yet due to our
makefile structure (make features), but this patch adds #ifdefs around
all FT2232H code, so the net effect is the same.

Corresponding to flashrom svn r691.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
2009-08-19 13:27:58 +00:00
Stefan Reinauer
173e3eaabe Support rdmsr/wrmsr operations on FreeBSD
So far, AMD Geode LX is the only user of this infrastructure. It needs
/dev/cpu0 from ports/sysutils on FreeBSD during runtime on Geode LX.

Corresponding to flashrom svn r690.

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Idwer Vollering <vidwer@gmail.com>
Acked-by: <putlinuxonit@gmail.com>
2009-08-19 10:46:23 +00:00
Carl-Daniel Hailfinger
6be741114d Allow to compile out serprog completely
If CONFIG_SERPROG is not set, no stubs and no data of serprog will
remain.

Side benefit: This kills a few dozen lines of code.

r678, r679 and r680 made this possible. Once "Only list available
programers in usage()" is committed, even the usage message will be
adjusted automatically.

Corresponding to flashrom svn r681.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
2009-08-12 16:17:41 +00:00
Carl-Daniel Hailfinger
37fc469ca2 Add a new field for the names of programmers and use it to match against user input
Use programmer.name to match the --programmer parameter instead of
hardcoding the name of every single programmer in main().

-p dummyfoo won't be mistaken for -p dummy anymore.

Corresponding to flashrom svn r680.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
2009-08-12 14:34:35 +00:00
Carl-Daniel Hailfinger
ef58a9ce3f Use a common parameter variable for all programmers
This allows us to reduce #ifdef clauses a lot if we compile out some
programmers completely.

Corresponding to flashrom svn r679.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
2009-08-12 13:32:56 +00:00
Carl-Daniel Hailfinger
415e513d90 Add fallback functions for programmer shutdown and memory mapping and fix FT2232 and IT87
FT2232 and IT87 programmers used functions of the dummy programmer
instead of fallback functions.

The dummy programmer is a "real" programmer with possible side effects
and its functions should not be abused by other programmers. Make
FT2232 and IT87 use official fallback functions instead. Create
fallback_shutdown(). Create fallback_chip_writeb(). Convert the
programmer #defines to an enum.

Corresponding to flashrom svn r678.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
2009-08-12 11:39:29 +00:00
Stefan Reinauer
8fa64816ae Fix up MSR handling to support more OSes than Linux.
Corresponding to flashrom svn r677.

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2009-08-12 09:27:45 +00:00
Carl-Daniel Hailfinger
116081a224 Replace remaining explicit erases in SPI programmer drivers with auto-erases
Some SPI chip drivers and the generic 1-byte SPI chip write functions
didn't include the automatic erase present in other chip drivers.

Since the majority is definitely auto-erase, change the remaining
explicit-erase cases to be auto-erase as well.

Corresponding to flashrom svn r673.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Carlos Arnau Perez <cemede@gmail.com>
2009-08-10 02:29:21 +00:00
Carl-Daniel Hailfinger
db41c59e3b Releasing IO permissions was done by hand everywhere
Use a proper abstraction. Kill unneeded #include statements.

Corresponding to flashrom svn r672.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
2009-08-09 21:50:24 +00:00
Carl-Daniel Hailfinger
bc25f947fe Boards with coreboot have a cbtable containing vendor and board name
Flashrom tries to match these with board enable entries in its database.
If no such board enable entry exists because the board doesn't need one,
flashrom complains. Silence that complaint.

Corresponding to flashrom svn r668.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Slightly updated and
Acked-by: Stefan Reinauer <stepan@coresystems.de>
2009-07-30 13:30:17 +00:00
Carl-Daniel Hailfinger
f8555e24a4 This is a workaround for a bug in SB600 and SB700
If we only send an opcode and no additional data/address, the SPI
controller will read one byte too few from the chip. Basically, the
last byte of the chip response is discarded and will not end up in the
FIFO. It is unclear if the CS# line is set high too early as well. That
hardware bug is undocumented as of now, but I'm working with AMD to add
a detailed description of it to the errata.

Add loads of additional debugging to SB600/SB700 init.

Add explanatory comments for unintuitive code flow.

Thanks go to Uwe for testing quite a few iterations of the patch.

Kill the SB600 flash chip status register special case, which was a
somewhat misguided workaround for that hardware erratum.

Note for future added features in the SB600 SPI driver: It may be
possible to read up to 15 bytes of command response with overlapping
reads due to the ring buffer design of the FIFO if the command can be
repeated without ill effects. Same for skipping up to 7 bytes between
command and response.

Corresponding to flashrom svn r661.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
2009-07-23 01:36:08 +00:00
Carl-Daniel Hailfinger
a80cfbc3d7 Eliminate version string duplication
Corresponding to flashrom svn r659.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
2009-07-22 20:13:00 +00:00
Carl-Daniel Hailfinger
02487aa4ed Replace most of the switch cases in the spi code with lookup on a struct instead
This brings the SPI code in line with the generic programmer
infrastructure.

This patch is a reworked version of a patch by Jakob Bornecrantz.

Corresponding to flashrom svn r657.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Signed-off-by: Jakob Bornecrantz <wallbraker@gmail.com>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Jakob Bornecrantz <wallbraker@gmail.com>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
2009-07-22 15:36:50 +00:00
Carl-Daniel Hailfinger
2f1b36fb35 Convert SPI byte program to use the multicommand infrastructure
Tested-by: Jakob Bornecrantz <wallbraker@gmail.com>

Corresponding to flashrom svn r651.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Tested it on Epia-m700 worked okay.
Acked-by: Jakob Bornecrantz <wallbraker@gmail.com>
2009-07-12 12:06:18 +00:00
Carl-Daniel Hailfinger
bb297f733d Add an optional flash port parameter for IT87* SPI controllers in standalone programmer mode
If the parameter is set, the IT87* SPI driver will set the I/O base
port of the IT87* SPI controller interface to the port specified in the
parameter. Usage: flashrom -p it87spi=port=0x820

Corresponding to flashrom svn r646.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
2009-07-11 18:05:42 +00:00
Carl-Daniel Hailfinger
d0478299b1 Add SPI multicommand infrastructure
Some SPI opcodes need to be sent in direct succession after each other
without any chip deselect happening in between. A prominent example is
WREN (Write Enable) directly before PP (Page Program). Intel calls the
first opcode in such a row "preopcode".

Right now, we ignore the direct succession requirement completely and it
works pretty well because most onboard SPI masters have a timing or
heuristics which make the problem disappear.
The FT2232 SPI flasher is different. Since it is an external flasher,
timing is very different to what we can expect from onboard flashers and
this leads to failure at slow speeds.

This patch allows any function to submit multiple SPI commands in a
stream to any flasher. Support in the individual flashers isn't
implemented yet, so there is one generic function which passes the each
command in the stream one-by-one to the command functions of the
selected SPI flash driver.

Tested-by: Jakob Bornecrantz <wallbraker@gmail.com>

Corresponding to flashrom svn r645.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Jakob Bornecrantz <wallbraker@gmail.com>
2009-07-10 21:08:55 +00:00