chromiumos/third_party/flashrom.git
15 months agoFix destructive behavior of fast-verify with no partition args. 52/65652/2 master
Shawn Nematbakhsh [Tue, 13 Aug 2013 00:53:02 +0000 (17:53 -0700)]
Fix destructive behavior of fast-verify with no partition args.

fast-verify with no partition args (-i args) is technically incorrect,
but used in several places and is very destructive. It causes us to
assume the entire ROM contains flash_unerased_value, and then reflash
all sectors that differ.

With this change, we fall back to full verification in case
--fast-verify is incorrectly specified with no partition args.

BUG=chrome-os-partner:21836.
TEST=Manual. Run flashrom with --fast-verify + no partition args, verify
that nearly entire ROM is not reflashed.
BRANCH=Falco + Peppy factory.

Change-Id: If1e838257bcbc4e0aa4dccac7288e29510223c98
Reviewed-on: https://gerrit.chromium.org/gerrit/65652
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Queue: Shawn Nematbakhsh <shawnn@chromium.org>
Tested-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
15 months agoRead entire flash if VERIFY_PARTIAL is not used 10/64410/4 stabilize-4512.B
David Hendricks [Sat, 3 Aug 2013 00:06:16 +0000 (17:06 -0700)]
Read entire flash if VERIFY_PARTIAL is not used

In 52ddff, the rules for obtaining a reference image were modified
and centered around verify_it. However, we neglected the VERIFY_OFF
case which occurs when --noverify is used.

This patch will make it so that the VERIFY_PARTIAL (--fast-verify)
case is checked first. If not, then the entire chip is read. This
makes it so that common blocks are skipped during erase/write when
--noverify is used.

BUG=none
BRANCH=none
TEST=flashed an image using -noverify, unchanged blocks are no longer
erased and re-written.

Change-Id: I44539c5702f9bcc22ea28644f7cb30f6c531b647
Reviewed-on: https://gerrit.chromium.org/gerrit/64410
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
15 months agoAdd a size check for files specified via -i arguments 02/63502/5
David Hendricks [Fri, 26 Jul 2013 20:49:14 +0000 (13:49 -0700)]
Add a size check for files specified via -i arguments

This adds a sanity check to ensure that files used to write or verify
a specific region (via -i region:filename) are checked for size.

BUG=none
BRANCH=none
TEST=Try to update a specific region with files that are bigger and
smaller, see flashrom error out.

Change-Id: I15034d115c84c8b4bebb7e1c4136ce46ec2962b7
Reviewed-on: https://gerrit.chromium.org/gerrit/63502
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
15 months agomake args for -r/-w/-v non-positional and optional 15/60515/10 firmware-pit-4482.B
David Hendricks [Fri, 28 Jun 2013 21:33:51 +0000 (14:33 -0700)]
make args for -r/-w/-v non-positional and optional

This makes a filename following -r, -w, and -v operations non-
positional. The first argument that does not begin with a hyphen (-)
is the filename for -r/-w/-v. If no such argument exists, then
-r/-w/-v options apply to files specified for individually included
regions via -i.

This has a few side-effects:
1. It allows us to omit the ROM-sized filename entirely when a
   filename is provided for a particular region when using -i. For
   example, "flashrom -i FOO:foo.bin -r".

2. It allows, for better or worse, the filename be specified anywhere
   on the command line after the program name. Our scripts and docs
   should still specify the file after -r/-w/-v for clarity.

For our purposes, if a filename is given for every included region
(-i region:filename) then the user does not need to specify a filename
after -r/-w/-v. However, if any -i option does not specify a filename,
then a file must be specified after -r/-w/-v.

The syntax will be backwards compatible for now so that one can still
mix -i options with and without the added filename specifier for each
region.

BUG=chromium:263495
BRANCH=none
TEST=manual (see notes below)

1. Write random data to RW_UNUSED region (on snow in this case)
   without requiring an argument to -w. See that only RW_UNUSED
   is erased and written, and that verify works:
   dd if=/dev/urandom of=rw_unused.bin bs=1k count=1 conv=notrunc
   flashrom -p host -i RW_UNUSED:rw_unused.bin -w -V
   flashrom -p host -i RW_UNUSED:rw_unused.bin -v -V

2. Same as above, but specify a dummy file to test syntax
   backwards compatibility:
   dd if=/dev/urandom of=rw_unused.bin bs=1k count=1 conv=notrunc
   dd if=/dev/urandom of=random_4M.bin bs=1M count=4
   flashrom -p host -i RW_UNUSED:rw_unused.bin -w random_4M.bin -V
   flashrom -p host -i RW_UNUSED:rw_unused.bin -v random_4M.bin -V

3. Test that dumping RW_UNUSED and GBB regions without -r arg dumps
   two files and that they can be used to verify the content:
   flashrom -p host -i RW_UNUSED:rw_unused.bin -i GBB:gbb.bin -r
   flashrom -p host -i RW_UNUSED:rw_unused.bin -i GBB:gbb.bin -v

4. Same as above, but with dummy file:
   flashrom -p host -i RW_UNUSED:rw_unused.bin -i GBB:gbb.bin -r x.bin
   flashrom -p host -i RW_UNUSED:rw_unused.bin -i GBB:gbb.bin -v x.bin

Change-Id: Iefbcb7dc4fefe26f5afd1292dfd5c1687fa62803
Reviewed-on: https://gerrit.chromium.org/gerrit/60515
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
15 months agoFix whitespace errors in flashrom.c, flashchips.c, flash.h 19/62119/4
Simon Glass [Tue, 16 Jul 2013 16:13:51 +0000 (10:13 -0600)]
Fix whitespace errors in flashrom.c, flashchips.c, flash.h

These files have trailing whitespace on some lines, which is undesirable
for some editors and for using 'git am', etc.

BUG=none
BRANCH=none
TEST=manual
emerge flashrom for pit, no code changes, whitespace only.

Change-Id: Iebb5dc260fc7264671f97e01856d7367d1be6cca
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62119
Reviewed-by: David Hendricks <dhendrix@chromium.org>
15 months agoRead only as much ROM content as needed before writing 18/63118/7
David Hendricks [Tue, 23 Jul 2013 22:05:14 +0000 (15:05 -0700)]
Read only as much ROM content as needed before writing

When we are using --fast-verify we make the assumption that the
full verification is not needed. Therefore it does not make sense
to read the entire flash before writing.

This makes it so that we only read the bytes required to verify
content we are writing when --fast-verify is used.

BUG=none
BRANCH=none
TEST=See below

-  Test partial write using --fast-verify:
   flashrom -p host -r foo.bin
   dd if=/dev/urandom of=random.bin bs=1 count=16384
   flashrom -p host -i RW_ELOG:random.bin -w foo.bin --fast-verify -V
   flashrom -p host -i RW_ELOG:random.bin -v foo.bin --fast-verify -V

   # verify against full file with and without --fast-verify
   dd if=random.bin of=foo.bin bs=1 seek=$((0x3f8000)) conv=notrunc
   flashrom -p host -i RW_ELOG --fast-verify -v foo.bin -V
   flashrom -p host -i RW_ELOG -v foo.bin -V

Change-Id: Iea5f3cc140e1b30644d4452daa64709eaf03b527
Reviewed-on: https://gerrit.chromium.org/gerrit/63118
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
15 months agoupdate error message for handle_romentries() 03/63503/5
David Hendricks [Fri, 26 Jul 2013 21:03:05 +0000 (14:03 -0700)]
update error message for handle_romentries()

The error message for handle_romentries() is misleading since
it refers to partial reads, which might not be the operation the
user specified. This attempts to make it more generalized.

BUG=none
BRANCH=none
TEST=it compiles.

Change-Id: Ib59066d713d6dcf3bcc9c9d29515454349dc2e01
Reviewed-on: https://gerrit.chromium.org/gerrit/63503
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>

15 months agoremove a stray comment 15/63115/2 factory-pit-4471.B
David Hendricks [Tue, 23 Jul 2013 21:48:40 +0000 (14:48 -0700)]
remove a stray comment

This just removes a stray comment which does not actually say
anything.

BUG=none
BRANCH=none
TEST=compile tested

Change-Id: Ia49a5ece868732316f2f869f48e2a07ab0c92556
Reviewed-on: https://gerrit.chromium.org/gerrit/63115
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
16 months agoHACK: Add delay before requesting comms_status 95/62195/4 factory-4455.B stabilize-4443.B
Simon Glass [Tue, 16 Jul 2013 19:31:53 +0000 (13:31 -0600)]
HACK: Add delay before requesting comms_status

This makes flashrom work correctly, but we need to root cause the actual
failure.

BUG=chrome-os-partner:20971
BRANCH=none
TEST=manual
time ./flashrom -p ec -w ec.2.bin
flashrom v0.9.4  :  :  on Linux 3.8.11 (armv7l), built with libpci 3.1.10, GCC 4.7.x-google 20130114 (prerelease), little endian
Erasing and writing flash chip... Erasing and writing flash chip... Verifying flash... VERIFIED.
SUCCESS

real 0m24.779s
user 0m0.030s
sys 0m1.200s
localhost tmp #

Change-Id: Iaa48d074a6217df6450dc74079c65697f1237113
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62195
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
16 months agogec: assume STM32L erases to zeros instead of ones 28/62228/4
David Hendricks [Tue, 16 Jul 2013 21:32:26 +0000 (14:32 -0700)]
gec: assume STM32L erases to zeros instead of ones

This queries the chip info to obtain the EC name. If the name begins
with "stm32l" then we assume that it erases bits to zeros instead of
ones.

BUG=chrome-os-partner:20971
BRANCH=none
TEST=on pit, flashrom -p ec -w ec.bin

Change-Id: Ice117dd08af022ce48ac10c795e13b68a64d3464
Reviewed-on: https://gerrit.chromium.org/gerrit/62228
Reviewed-by: Simon Glass <sjg@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
16 months agoSupport flash chips which erase to zero 17/62117/4
Simon Glass [Tue, 16 Jul 2013 16:09:28 +0000 (10:09 -0600)]
Support flash chips which erase to zero

Some flash implementations (e.g. STM32L) erase to 0 insteaed of 0xff. Add
support for this via a feature bit.

BUG=chrome-os-partner:20971
BRANCH=none
TEST=manual
On pit, with the other change to set this feature:
flashrom -p ec -w ec.bin

See that it no longer gives erase errors, but can correctly erase the flash
and detect when the flash is erased.

Change-Id: I16d775301eb8d636393d02bdb545ba74aea52c89
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62117
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
16 months agoUse correct command result from cros_ec driver 16/62116/4
Simon Glass [Tue, 16 Jul 2013 15:36:10 +0000 (09:36 -0600)]
Use correct command result from cros_ec driver

The new cros_ec driver returns the EC command result correctly, so we must
return that correctly.

BUG=chrome-os-partner:20971
BRANCH=none
TEST=manual
On pit:
flashrom -p ec -w ec.bin

See that it now erases correctly, dutifully waiting for the EC to complete
each operation.

Need to test this on snow and link.

Change-Id: Iaa892e6949c505d5ae843e4c8adb8d3b492bc72d
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62116
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
16 months agogec: use EC's max_data_read size as the page_size. 15/62115/3
Simon Glass [Tue, 16 Jul 2013 15:33:35 +0000 (09:33 -0600)]
gec: use EC's max_data_read size as the page_size.

At present flashrom always uses a 64-byte write block size, which
has worked in the past. Pit uses 128 bytes, so hard-coding 64 will
no longer work.

The long-term solution will be to query this in a new EC command. But
until that is fully implemented we can use the programmer's
max_data_read value (the max_data_write value may be changed depending
on optimal write sizes and such).

BUG=chrome-os-partner:20971
BRANCH=none
TEST=tested on pit (using follow-up patches) and performance tested on
link, spring, snow

On pit, it now writes correctly, although there is still a failure when it
switches images (until the other patches in the series go in).

Change-Id: I154210cc7ed1f4db901b285a6f6aaa00b0104d91
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62115
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
16 months agore-factor handle_partial_read() for overlapping regions 11/61811/2
David Hendricks [Sat, 13 Jul 2013 02:44:45 +0000 (19:44 -0700)]
re-factor handle_partial_read() for overlapping regions

This change makes handle_partial_read() work for overlapping regions.
The current implementation sets the next "start" of each iteration
equal to the end of the romimage processed in the current iteration.
This is desireable for writes since it will avoid writing the same
content multiple times, but is undesireable for reads.

For example, if R1 occupies 0x0000-0xffff and an overlapping region
R2 occupies 0x8000-0xffff, then R2 will not be written out using
"-i R1:R1.bin -i R2:R2.bin" since the loop will process R1 and set
"start" at 0x10000 for the next iteration, thereby missing R2.

So instead, this patch makes handle_partial_reads() iterate over
all regions independently and read + write them if they are
included.

BUG=none
BRANCH=pit
TEST=tested on snow (see notes below)

Snow firmware 4256.0.2013_06_12_1528 has a region with two names,
RW_SHARED aka SHARED_DATA, at offset 0x3f8000-3fffff.

Use the following command to test:
flashrom -p host -i RW_SHARED:r1.bin -i SHARED_DATA:r2.bin -r foo.bin

With ToT r2.bin is not written. With the patch, both r1.bin and r2.bin are
written.

Change-Id: Ic34cfe99c2dcd8a448054324e2207920b9b86e4c
Reviewed-on: https://gerrit.chromium.org/gerrit/61811
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
16 months agofix misprinted fmap debug output 12/61812/2
David Hendricks [Sat, 13 Jul 2013 03:03:01 +0000 (20:03 -0700)]
fix misprinted fmap debug output

The fmap debug output shows offsets for the beginning and end
of each region. However, the end is printed as "size". Oops.

BUG=none
BRANCH=none
TEST=Ran in verbose mode using a -i option, "added fmap region" lines
showed "end" instead of "size" for the final value printed.

Change-Id: I59d2d2f874be400d63b93c0c70150a0ac9816d7e
Reviewed-on: https://gerrit.chromium.org/gerrit/61812
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
16 months agogec: query write size from EC 44/61644/3
David Hendricks [Fri, 12 Jul 2013 02:02:13 +0000 (19:02 -0700)]
gec: query write size from EC

Up until now we have had hard-coded write sizes for the CrOS EC for
each interface. Although kludgey, this allowed us to deal with
size constraints when using the different interfaces.

This patch queries the EC to obtain the optimal write size. This
will allow us to obtain the optimal write size for any CrOS EC
used on any physical interface and with any firmware version.

Querying takes place after the EC is discovered and after the
EC jumps to a different copy in case the protocol changes and
defines a different write size.

BUG=none
BRANCH=pit
TEST=Switched to/from old and new images on spring, snow, and link
where the old image used v2 protocol and new image uses v3.

Change-Id: I5a28f33df05dbca6bdf6cd4d69b246b2e7649812
Reviewed-on: https://gerrit.chromium.org/gerrit/61644
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
16 months agode-constify opaque programmer struct 43/61643/2
David Hendricks [Thu, 11 Jul 2013 23:12:58 +0000 (16:12 -0700)]
de-constify opaque programmer struct

This removes const from opaque programmers so that we may change
their members at runtime, for example, if we want to change
max_data_read and max_data_write parameters.

BUG=none
BRANCH=pit
TEST=compile tested

Change-Id: I517aebf703ebca471d8c72e45386cf291a391dd8
Reviewed-on: https://gerrit.chromium.org/gerrit/61643
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
16 months agogec: import latest EC commands header 42/61642/6
David Hendricks [Thu, 11 Jul 2013 04:07:48 +0000 (21:07 -0700)]
gec: import latest EC commands header

This imports the CrOS EC commands header as of EC firmware eb8920c
A few constants used for max_data_read and max_data_write sizes were
renamed or removed and have been replaced with equivalent values.

The most important difference is that ec_params_flash_write has been
re-formed to remove the hard-coded 64-byte data payload. Now the
struct only defines offset and size. Some code has been added to
gec_write() to create a packet consisting of the new struct followed
by the data.

BUG=none
BRANCH=pit
TEST=updated EC images on link, snow, and spring.

Change-Id: I6c9ca18cf7632532af05e638da5c897970de9b69
Reviewed-on: https://gerrit.chromium.org/gerrit/61642
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
16 months agoOnly write back emulated image if modified 33/61533/2 factory-pit-4390.B firmware-falco_peppy-4389.B firmware-leon-4389.26.B firmware-wolf-4389.24.B
Simon Glass [Thu, 11 Jul 2013 04:10:11 +0000 (21:10 -0700)]
Only write back emulated image if modified

When the image is not modified, there is no point in writing it back.
In fact we may not have file permissions to do so.

BUG=none
BRANCH=none
TEST=manual
Try reading and writing flash in a file that we don't have access to:

$ ls -l /build/peach_pit/firmware/image-peach-pit.bin
-rw-r--r-- 1 root root 4194304 Jul 10 21:01 /build/peach_pit/firmware/image-peach-pit.bin
$ /usr/sbin/\flashrom -p dummy:emulate=VARIABLE_SIZE,size=auto,image=/build/peach_pit/firmware/image-peach-pit.bin --ignore-lock -r all
flashrom v0.9.4  :  :  on Linux 3.2.5-gg1236 (x86_64), built with libpci 3.1.10, GCC 4.7.x-google 20130114 (prerelease), little endian
Reading flash... SUCCESS
$ /usr/sbin/\flashrom -p dummy:emulate=VARIABLE_SIZE,size=auto,image=/build/peach_pit/firmware/image-peach-pit.bin --ignore-lock -w all
flashrom v0.9.4  :  :  on Linux 3.2.5-gg1236 (x86_64), built with libpci 3.1.10, GCC 4.7.x-google 20130114 (prerelease), little endian
Erasing and writing flash chip... Verifying flash... VERIFIED.
SUCCESS

Now edit the file (change a few bytes):

/usr/sbin/\flashrom -p dummy:emulate=VARIABLE_SIZE,size=auto,image=/build/peach_pit/firmware/image-peach-pit.bin --ignore-lock -w all
flashrom v0.9.4  :  :  on Linux 3.2.5-gg1236 (x86_64), built with libpci 3.1.10, GCC 4.7.x-google 20130114 (prerelease), little endian
Erasing and writing flash chip... Verifying flash... VERIFIED.
SUCCESS
/build/peach_pit/firmware/image-peach-pit.bin: Permission denied

(flashrom tries to write it back and fails)

Change-Id: If1e027e5d164312b44b18e8d7c0787879e8d7b99
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/61533
Reviewed-by: David Hendricks <dhendrix@chromium.org>
16 months agoUse region info to determine if erase/write violates access policy 43/60843/4
Simon Glass [Mon, 1 Jul 2013 09:08:53 +0000 (18:08 +0900)]
Use region info to determine if erase/write violates access policy

Rather than get an error when we try to erase the wrong regions,
track the region that the EC is in using region information
provided by EC_CMD_FLASH_REGION_INFO.

This should also reduce transaction overhead substantially, which
may improve performance especially over I2C.

This is a combination of 60636 and 60319.

BUG=chrome-os-partner:20395
BRANCH=none
TEST=tested on link, snow, and spring by writing new image
with this CL, reading it back using ToT flashrom, and diffing the
images to see there is no corruption.

Change-Id: I15d62a337f62c0f05ff93344b072a7d66defb44d
Reviewed-on: https://gerrit.chromium.org/gerrit/60843
Reviewed-by: Simon Glass <sjg@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
16 months agoAdd a -x option to extract regions from a flash image 61/60861/2
Simon Glass [Wed, 3 Jul 2013 13:08:17 +0000 (22:08 +0900)]
Add a -x option to extract regions from a flash image

The -i option combined with -r allows reading a particular region from
a flash image. It is sometimes convenient to be able to read out all images.
Add a -x option to do this. The resulting files are named after their region
names in the image.

BUG=chromium:256912
BRANCH=none
TEST=manual

sudo flashrom -p dummy:emulate=VARIABLE_SIZE,size=auto,image=/build/peach_pit \
/firmware/image-peach-pit.bin -x --ignore-lock

See that a collection of files appears in the currect directly.

Use:

gbb_utility --rootkey=rootkey.bin GBB

to check that the GBB looks correct.

Change-Id: I8e942c312467ae77dff04be415fb4d213b0f17c4
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/60861
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
16 months agoAdd support for auto-sizing of emulated ROMs 60/60860/2
Simon Glass [Wed, 3 Jul 2013 13:05:21 +0000 (22:05 +0900)]
Add support for auto-sizing of emulated ROMs

At present the flash size must be specified in command lines like:

   flashrom -p dummy:emulate=VARIABLE_SIZE,size=4M,image=xxx

In this case if there is an existing image, we can simply read that image
to figure out the size. So add a 'size=auto' option to make this more
convenient for the user.

BUG=chromium:256912
BRANCH=none
TEST=manual

sudo flashrom -p dummy:emulate=VARIABLE_SIZE,size=auto,image=/build/peach_pit \
/firmware/image-peach-pit.bin -x --ignore-lock

See that it no longer gives an error, but correctly decides on a 4MB image
size, and then completes the operation.

Change-Id: I4e738893ed0f106d75114de70eff1d599c7ed4e7
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/60860
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
16 months agoAdd a function to read the flash region information 35/60635/5
Simon Glass [Mon, 1 Jul 2013 09:07:34 +0000 (18:07 +0900)]
Add a function to read the flash region information

This is read in a few places, so put the code in a function.

BUG=chrome-os-partner:20395
BRANCH=none
TEST=manual
On pit:
Use flashrom to read and write the EC, which unfortunately fails.

Change-Id: I1ee718234860b63ca1d4e2778efdce844cee686d
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/60635

16 months agoKeep track of the current EC image 34/60634/4
Simon Glass [Mon, 1 Jul 2013 09:03:33 +0000 (18:03 +0900)]
Keep track of the current EC image

We can keep track of the EC image, and thus avoid 'permission denied' errors
when we try to write to the wrong one.

BUG=chrome-os-partner:20395
BRANCH=none
TEST=manual
On pit:
Use flashrom to read and write the EC, which unfortunately fails.

Change-Id: I1a5a5b160d969501edbc9a190e362210b1d86301
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/60634

16 months agogec: move declarations specific to CrOS EC to their own file 75/60675/5
David Hendricks [Mon, 1 Jul 2013 19:21:01 +0000 (12:21 -0700)]
gec: move declarations specific to CrOS EC to their own file

This moves prototypes and a struct declaration which are used
exclusively on CrOS EC to their own file.

The underlying goal is to allow us to put CrOS-EC specific types
into the private data structure.

BUG=none
BRANCH=none
TEST=compiled locally

Change-Id: I812ab116b354c4103df684c66a6476074b580660
Reviewed-on: https://gerrit.chromium.org/gerrit/60675
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>

16 months agoUse label field in fdtmap instead of name 27/60627/2
Simon Glass [Mon, 1 Jul 2013 08:08:48 +0000 (17:08 +0900)]
Use label field in fdtmap instead of name

The name field is not the correct field to use for many of the fields - in
particular we want to use GBB instead of RO-GBB. So adjust flashrom to use
the label field instead.

BUG=chromium:256148
BRANCH=none
TEST=manual
On pit, use:

flashrom -r asc -i GBB -V

See that it finds the section called GBB, and does not find RO-GBB.

Change-Id: I2c207ded36a81dad67d0d6ef6cba94809e7b431c
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/60627
Reviewed-by: David Hendricks <dhendrix@chromium.org>
17 months agogec_dev: add shutdown callback to close cros_ec device node 25/59525/2 release-R29-4319.B
David Hendricks [Fri, 21 Jun 2013 05:14:26 +0000 (22:14 -0700)]
gec_dev: add shutdown callback to close cros_ec device node

This adds a shutdown callback to close the cros_ec device node.
Hopefully this will prevent weird issues from happening if somehow
there is a dangling file descriptor when flashrom exits.

BUG=none
BRANCH=peach_pit
TEST=run on pit

Change-Id: I05e33adfdb01970afcd13c96429bc6ac2030d3a9
Reviewed-on: https://gerrit.chromium.org/gerrit/59525
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
17 months agogec_dev: return the inbound data size instead of 0 upon success 55/59455/4
David Hendricks [Thu, 20 Jun 2013 19:42:58 +0000 (12:42 -0700)]
gec_dev: return the inbound data size instead of 0 upon success

Some commands expect the return code of the lowlevel EC command
function to reflect the inbound data length.

BUG=chrome-os-partner:19077
BRANCH=peach_pit
TEST=Tested --wp-status command on pit

Change-Id: I97c4944a79b3c207ac790bf6e00bf5afe0b4e1f4
Reviewed-on: https://gerrit.chromium.org/gerrit/59455
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>

17 months agomake flashrom default to targeting SPI bus on ARM 89/59089/4
David Hendricks [Tue, 18 Jun 2013 20:11:50 +0000 (13:11 -0700)]
make flashrom default to targeting SPI bus on ARM

This updates the logic for probing on ARM platforms a bit more so
that it "defaults" to targeting the SoC's SPI ROM.

While in there, I updated the comments and merged the two
"if (target_bus != BUS_SPI)" blocks.

BUG=none
BRANCH=none
TEST=tested "flashrom -r /tmp/foo.bin" read the host SPI rom on
     snow, spring, pit. Regression tested the "-p" options on
     all other platforms.

Change-Id: Ib5c9366838245d6039daca52150c63399490980a
Reviewed-on: https://gerrit.chromium.org/gerrit/59089
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>

17 months agoRun gec_probe_dev() before gec_probe_i2c() 14/58914/2 factory-4290.B stabilize-4287.B
Doug Anderson [Mon, 17 Jun 2013 21:45:55 +0000 (14:45 -0700)]
Run gec_probe_dev() before gec_probe_i2c()

On pit this prevents a spurious error message:
  i2c transfer failed: -1 (err: 121, Remote I/O error)
  gec_command_i2c(): linux_i2c_xfer() failed: -1

In any case, the new gec device should be preferred over the raw i2c.

BRANCH=none
BUG=chrome-os-partner:19077
TEST=Run 'flashrom -p ec -r /tmp/foo.bin' on pit and snow on kernel-next.
TEST=Run 'flashrom -p ec -r /tmp/foo.bin' on snow on kernel 3.4.

Change-Id: I1bd12689caaa8fd207f7dcd7fa49aed09bbf1fab
Reviewed-on: https://gerrit.chromium.org/gerrit/58914
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Queue: Doug Anderson <dianders@chromium.org>
Tested-by: Doug Anderson <dianders@chromium.org>
17 months agoi2c: Allow for up to 256 minor devices 12/58912/2
Doug Anderson [Mon, 17 Jun 2013 20:37:20 +0000 (13:37 -0700)]
i2c: Allow for up to 256 minor devices

This matches the kernel '#define I2C_MINORS 256'

BRANCH=none
BUG=None
TEST=On snow kernel-next I no longer get 'Invalid I2C bus 104'
when I run 'flashrom -p ec -r /tmp/foo.bin'

Change-Id: I2aeb000a48c9d609c24de9300ea5e53bbced8179
Reviewed-on: https://gerrit.chromium.org/gerrit/58912
Tested-by: Doug Anderson <dianders@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Queue: Doug Anderson <dianders@chromium.org>

17 months agoImplement programmer aliases 13/58013/6
David Hendricks [Sat, 4 May 2013 03:25:40 +0000 (20:25 -0700)]
Implement programmer aliases

This introduces the notion of a programmer alias which allows us to
simplify the "-p" option. Now a user can use "-p <alias>" where
currently supported aliases are "host" and "ec".

For example:
flashrom -p ec -r ec.bin
flashrom -p host -r host.bin

This patch also modifies various programmers to cope with both old
and new syntax:
- ENE, ChromeEC (GEC), ICH, linux_spi, and mec1308 only required
  additional checking for a user-specified alias.
- Programmers which use require chipset configuration such as
  forwarding LPC/FWH bus cycles in a shared memory region (it85xxx
  and wpce775x/npce781x) will set the chipset's target bus. This is
  sort of ugly dependency, but is necessary so they don't interfere
  with operation of other chips. They are probed fully using
  non-interfering SuperIO techniques first.

BUG=chrome-os-partner:19077, chrome-os-partner:16211
BRANCH=none
TEST=See notes below

Tested on (mario, zgb, alex, lumpy, stumpy, parrot, butterfly, stout,
snow, spring, pit, link). Note: stumpy doesn't have an EC so LPC/EC
reads were omitted from the testing below.

Test methodology:
1. Use old syntax with ToT flashrom to obtain host and EC ROMs
2. Use old syntax with this patch to obtain host and EC ROMs
3. Use new syntax with this patch to obtain host and EC ROMs
4. compare size and content to ensure the binaries for each host/EC
   set came out the same

Change-Id: Ib904e1a0088b086789d1b084cb38e55a4fff28fd
Reviewed-on: https://gerrit.chromium.org/gerrit/58013
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
17 months agoSkip Google EC if BUS_SPI given 04/58704/3
Simon Glass [Fri, 14 Jun 2013 19:47:24 +0000 (12:47 -0700)]
Skip Google EC if BUS_SPI given

This mirrors the check immediately above for the I2C-connected GEC. We need
this to be able to read from SPI flash with the 'internal' bus.

BUG=chromium:248372
BRANCH=none
TEST=manual
Run on pit:

flashrom -p internal:bus=spi -r foo2.bin

See that it now reads the SPI flash instead of the EC flash. There is no
EC traffic and the resulting file is 4MB in size.

Change-Id: Id6c1f9b59d94d947f57a839854b41deeba6acfd6
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/58704
Reviewed-by: David Hendricks <dhendrix@chromium.org>
17 months agocall gec_probe_dev() only on ARM for now 13/58613/3
David Hendricks [Fri, 14 Jun 2013 01:22:29 +0000 (18:22 -0700)]
call gec_probe_dev() only on ARM for now

This is a gross hack to ensure the CrOS EC driver is only used on ARM
(ie pit) for now. Flashrom's probing logic gets confused because the
/dev/cros_ec device is found on Link regardless of
"-p internal:bus=spi" being specified.

Fortunately this hack can be removed once programmer aliases are in,
and we can get rid of the hack for gec_probe_i2c() at the same time.

BUG=chromium:249568
BRANCH=none
TEST=tested on link and pit

Change-Id: Iddfe2760ecb0a715d18bf11c789f44773d1098e1
Reviewed-on: https://gerrit.chromium.org/gerrit/58613
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Gabe Black <gabeblack@chromium.org>
17 months agoAdd W25Q64DW ID to flashrom 58/58158/2
Nick Sanders [Tue, 11 Jun 2013 05:15:30 +0000 (22:15 -0700)]
Add W25Q64DW ID to flashrom

Add Winbond W25Q64DW chip ID and specs to flashrom.
Still very slow for writing.

BUG=none
BRANCH=none
TEST=read and flash loose W25Q64DW through dediprog.
Signed-off-by: Nick Sanders <nsanders@chromium.org>
Change-Id: Ic6eec053a2176af893dd8045fe42979f70cc1a5a
Reviewed-on: https://gerrit.chromium.org/gerrit/58158
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Nick Sanders <nsanders@chromium.org>
Tested-by: Nick Sanders <nsanders@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>

17 months agolinux_spi: add missing parens from the previous patch 45/58245/2 factory-spring-4262.B
David Hendricks [Tue, 11 Jun 2013 22:19:49 +0000 (15:19 -0700)]
linux_spi: add missing parens from the previous patch

This fixes a bug introdced in the previous patch.

BUG=none
BRANCH=none
TEST=tested on snow

Change-Id: I524ec15e2125dcb7d6335385c5fa8b103522005e
Reviewed-on: https://gerrit.chromium.org/gerrit/58245
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
17 months agoadd missing linux_i2c prototypes 78/55678/3
David Hendricks [Sat, 18 May 2013 02:21:36 +0000 (19:21 -0700)]
add missing linux_i2c prototypes

this just gets rid of some compiler warnings.

BUG=none
BRANCH=none
TEST=locally compiled

Change-Id: I6694fc5e426acadfeba35cf72e50473fc49b6274
Reviewed-on: https://gerrit.chromium.org/gerrit/55678
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
17 months agoupdate linux_spi modalias parameters 05/58005/6
David Hendricks [Wed, 5 Jun 2013 21:30:50 +0000 (14:30 -0700)]
update linux_spi modalias parameters

The modalias for SPI devices is longer than it used to be and has
a slightly different form. A current example is "spi:spidev".

This patch lengthens the maximum size and uses strstr to search for
spidev anywhere in the modalias.

BUG=none
BRANCH=none
TEST=run on peach_pit

Change-Id: I7c658b2706c98bd6b471e97d6a3203f0e8e827d5
Reviewed-on: https://gerrit.chromium.org/gerrit/58005
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
17 months agoImplement support for Google Chrome OS EC device 25/56625/4 stabilize-4255.B
Simon Glass [Fri, 24 May 2013 00:18:44 +0000 (17:18 -0700)]
Implement support for Google Chrome OS EC device

This makes use of a kernel driver to provide access to the EC, routing
all messages through the driver and letting it deal with protocol, etc.

BUG=chrome-os-partner:19077
BRANCH=none
TEST=manual
$ sudo FEATURES=test sudo -E emerge flashrom

On pit (terribly slow unfortunately):

time ./flashrom -r /tmp/asc
flashrom v0.9.4  :  :  on Linux 3.8.0+ (armv7l), built with libpci 3.1.10, GCC 4.7.x-google 20130114 (prerelease), little endian
Reading flash... SUCCESS

real 0m19.767s
user 0m0.030s
sys 0m0.190s

Use hexdump to check that the image has ARM assembler, readable strings
and there are two binaries inside it.

time ./flashrom -w /tmp/asc
flashrom v0.9.4  :  :  on Linux 3.8.0+ (armv7l), built with libpci 3.1.10, GCC 4.7.x-google 20130114 (prerelease), little endian
Erasing and writing flash chip... Verifying flash... VERIFIED.
SUCCESS

real 0m43.184s
user 0m0.045s
sys 0m0.525s

Change-Id: I81dcd6b04fbb467adfeb83f9ddd16cf3a0fe571e
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56625

18 months agokb94x: Make EC reset error handling on write more robust. 85/51385/4
Shawn Nematbakhsh [Thu, 16 May 2013 00:07:13 +0000 (17:07 -0700)]
kb94x: Make EC reset error handling on write more robust.

Prior to writing data to the SPI ROM, it's necessary to send kb94x to a
reset state, otherwise the system will behave in unpredictable ways.
Previously, our error checking prior to issuing SPI write commands was
not sufficient. Upon error, we continued with the write anyway, which
led to incomplete flashes and bricked platforms.

The follow changes are implemented here:

- Make three attempts at resume / reset before giving up.
- Place the EC state status back to IDLE upon failure, so the next write
  attempt will always attempt another reset. This should ensure that the
  EC is always in a reset state before any SPI write occurs.

BUG=chrome-os-partner:19105.
TEST=Manual. Verify AU success for 1000 trials on Butterfly.
BRANCH=Butterfly.

Change-Id: Ifbdab1e750702f3d492c7946d87196798fee733d
Reviewed-on: https://gerrit.chromium.org/gerrit/51385
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Queue: Shawn Nematbakhsh <shawnn@chromium.org>
Tested-by: Shawn Nematbakhsh <shawnn@chromium.org>
18 months agoCorrect fdtmap code which scans over sub-nodes 41/51241/2
Simon Glass [Wed, 15 May 2013 01:51:37 +0000 (18:51 -0700)]
Correct fdtmap code which scans over sub-nodes

There was a break instead of a continue in this code, meaning it stops
when it reaches a sub-node. Fix this, and a compiler warning about malloc().

BUG=chrome-os-partner:19409
BRANCH=none
TEST=:manual
FEATURES=test sudo -E emerge flashrom
On snow:

$ /tmp/flashrom -p linux_spi:dev=/dev/spidev1.0 -r /tmp/x -i RO_VPD
flashrom v0.9.4  :  :  on Linux 3.8.0+ (armv7l), built with libpci 3.1.10, GCC 4.7.x-google 20130114 (prerelease), little endian
Unable to open FDT property fmap-offset
Reading flash... SUCCESS

See that it correctly finds the region now.

Change-Id: Ibef3212b4d61bf3fec831a912c9f95825867d050
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/51241
Reviewed-by: David Hendricks <dhendrix@chromium.org>
18 months agoAdd addition test for final region of fdtmap 40/51240/2
Simon Glass [Wed, 15 May 2013 01:47:54 +0000 (18:47 -0700)]
Add addition test for final region of fdtmap

Add a test which uses the last region of fdtmap. At the same time, improve
the code which prints out failure information and use InsertData() instead
of ad-hoc code to insert data into the image.

BUG=chrome-os-partner:19409
BRANCH=none
TEST=:manual
FEATURES=test sudo -E emerge flashrom

Change-Id: I938a69dfc3e40403734057caff6ae2bea475c785
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/51240
Reviewed-by: David Hendricks <dhendrix@chromium.org>
18 months agoRevert "Add a ROM caching buffer" 53/51053/3 factory-4128.B factory-spring-4131.B
David Hendricks [Mon, 13 May 2013 23:05:36 +0000 (16:05 -0700)]
Revert "Add a ROM caching buffer"

This reverts commit 363152461dfdc8cb67c826addd77469046c3c297

Change-Id: Ic5e21e713aaba9a72d3dbdd2d2639a0bda9b0593
See: https://code.google.com/p/chromium/issues/detail?id=240284
Reviewed-on: https://gerrit.chromium.org/gerrit/51053
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
18 months agoRevert "add missing "void" return type from cache_invalidate()" 52/51052/2
David Hendricks [Mon, 13 May 2013 23:05:25 +0000 (16:05 -0700)]
Revert "add missing "void" return type from cache_invalidate()"

This reverts commit 66e651d7cd6cd8ab0af037cafc0caded84f953b0

Change-Id: Ic8c9a0c082907c448a9a7df1bc0077e1ffc566b7
See: https://code.google.com/p/chromium/issues/detail?id=240284
Reviewed-on: https://gerrit.chromium.org/gerrit/51052
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
18 months agoadd missing "void" return type from cache_invalidate() 06/50906/2
David Hendricks [Fri, 10 May 2013 22:48:32 +0000 (15:48 -0700)]
add missing "void" return type from cache_invalidate()

This adds a missing return type. GCC did not complain when
emerge-${OVERLAY} was used, but errs out when building for the
host machine.

BUG=none
BRANCH=none
TEST=locally compiled for host machine.

Change-Id: I61aa08c7c404dcead484e90d282f4703a84e99a4
Reviewed-on: https://gerrit.chromium.org/gerrit/50906
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
18 months agoAdd a ROM caching buffer 31/49131/7
David Hendricks [Sat, 27 Apr 2013 00:32:34 +0000 (17:32 -0700)]
Add a ROM caching buffer

This adds a caching buffer to reduce the time for repeated reads.
This is intended to improve worst-case scenario performance of
flashrom where sections of the ROM may be read more than once. This
typically happens when searching for a flashmap, especially if the
flashmap is aligned on a low power-of-2 boundary.

The method is dead-simple: Keep a copy of anything which has been read
from ROM in a buffer and track the entries in another buffer of the
same size. read_flash() will check if the bytes requested have been
cached and, if so, will simply memcpy the bytes into the user-supplied
buffer. Erase and write operations will "invalidate" bytes from the
cache.

BRANCH=all
BUG=chrome-os-partner:18851
TEST=See notes below

Partial reads were tested using util/partial_reads.sh script.
Partial writes were tested as follows:
1. create test image
dd if=/dev/urandom of=random_128k.bin bs=1k count=128
cp ec-ec-3833.B test.bin
dd if=random_128k.bin of=test.bin bs=1 seek=$((0x10000)) \
count=$((0x4000)) conv=notrunc

2. create layout.txt
for i in `seq 0 3`; do
printf "%x:%x r%d\n" $((0x10000 + $i*0x1000)) \
$((0x10000 + $i*0x1000 + 0xfff)) $i >> layout.txt
done

3. Do partial write and verify using known-good flashrom:
./flashrom-test -p internal:bus=i2c -l layout.txt \
-i r0 -i r1 -i r2 -i r3 -V -w test.bin
flashrom -p internal:bus=i2c -v test.bin

To measure performance impact, a partial read of the EC_RW section
(0x10000 to 0x1ffff) on spring-3833.B firmware was done. The FMAP
for this firmware image is located at 0xcf40 and thus takes many
iterations to find using the binary search algorithm.

Results:
- Full read of all 128KB: ~21.5s
- Partial read of EC_RW using ToT flashrom: ~28.5s
- Partial read with this patch: ~21.9s

Conclusion: ToT flashrom read most of the ROM finding the FMAP and
then re-read the EC_RW section. Using this patch, most of the EC_RW
section was cached and so only a small amount of work was needed
after finding the FMAP.

Change-Id: I534e394bb3ffdf48825960bc8a15d188708db8db
Reviewed-on: https://gerrit.chromium.org/gerrit/49131
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
18 months agouse read_flash() when searching for fmap header 22/49422/3
David Hendricks [Sat, 27 Apr 2013 02:56:42 +0000 (19:56 -0700)]
use read_flash() when searching for fmap header

read_flash() will soon be used to handle caching which will speed
things up substantially when flashmap is used (ie during partial
reads/writes).

BRANCH=none
BUG=chrome-os-partner:18851
TEST=Tested this patch on Snow. The caching stuff comes later...

Change-Id: I55f1667b7e6f1f3afc8fbd5fd0682d682c7556cb
Reviewed-on: https://gerrit.chromium.org/gerrit/49422
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
18 months agoadd a wrapper for writing to the flash 21/49421/3
David Hendricks [Sat, 27 Apr 2013 02:14:44 +0000 (19:14 -0700)]
add a wrapper for writing to the flash

This adds a wrapper around flash->write() so that higher-level policy
can be implemented for writes. For now this is a trivial wrapper,
but follow-up patches will add some caching logic that will require
this.

BUG=chrome-os-partner:18851
BRANCH=none
TEST=Tested this wrapper on spring. The cachhing stuff comes later.

Change-Id: Iab450509ad26ec3ddd6c6af004c65c6e41fb5c25
Reviewed-on: https://gerrit.chromium.org/gerrit/49421
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
18 months agogec: Don't use the pass-through bus; use force mode of i2c 49/49549/2
Doug Anderson [Mon, 29 Apr 2013 23:00:20 +0000 (16:00 -0700)]
gec: Don't use the pass-through bus; use force mode of i2c

On snow we've got a special i2c 'pass through' bus that just creates
an i2c bus that mirrors all commands sent to that bus over to the same
bus that the EC is on.

There are a couple of properties of that bus:

1. Devices on this new bus aren't marked as BUSY by Linux, so you can
   open them without force mode.
2. This new bus can be found by its name, so if you want to find the
   i2c bus that contains the ec then you can search for this bus.

We are planning to remove the 'pass through' bus on snow in kernel 3.8
and redesign it a little on other devices that need to tunnel i2c
commands to other side of the ec.  In preparation, fix flashrom not to
need the i2c pass through bus.  This is done by:

1. Open up the i2c device using "force" mode.  This is really no worse
   than what we were doing before with the pass through but at least
   is straightforward about the fact that we're talking to the EC
   behind the kernel's back.
2. Find the proper bus by looking for the EC device, not the
   pass-through bus.

BUG=chrome-os-partner:18941
BRANCH=snow
TEST=On snow with kernel-next and UPSTREAM cros-ec can read EC with
flashrom -p internal:bus=lpc -r /tmp/ec.bin

Change-Id: I41d4b9cea0b90cb210be8d65f0b8cd1909f0da85
Signed-off-by: Doug Anderson <dianders@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49549
Reviewed-by: David Hendricks <dhendrix@chromium.org>
18 months agoadd missing "break" if fmap is found 20/49420/2 stabilize-4068.0.B
David Hendricks [Wed, 24 Apr 2013 21:51:38 +0000 (14:51 -0700)]
add missing "break" if fmap is found

This adds a missing "break" which caused "no fmap present" to be
displayed even if it were found.

BUG=none
BRANCH=none
TEST=tested on snow

Change-Id: Ib38a835358cabe765d4f8e3182856a8d1508bbd7
Reviewed-on: https://gerrit.chromium.org/gerrit/49420
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
19 months agoFix a bug that '-l' option is overriden by fdtmap 72/48472/2 stabilize-4035.0.B
Vic Yang [Thu, 18 Apr 2013 05:07:10 +0000 (13:07 +0800)]
Fix a bug that '-l' option is overriden by fdtmap

The count of romimages shouldn't be cleared. Otherwise the layout read
before that will be lost.

BUG=none
BRANCH=none
TEST=read VBLOCK_A section with/without layout file.

Change-Id: I07439c63e998eee46353d07b473a7eb96e9cc53c
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/48472
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
19 months agosupport building with libftdi 1.0 52/48252/4
Vincent Palatin [Tue, 16 Apr 2013 19:21:01 +0000 (12:21 -0700)]
support building with libftdi 1.0

Update the Makefile to build properly when we have only libftdi 1.0
installed.
libftdi 1.0 has a new pkg-config name and its header is no longer
including standard headers and no longer in the base include directory.

BRANCH=none
BUG=none
TEST=sudo emerge flashrom && emerge-daisy_spring flashrom
with both only libftdi1.0 installed and only libftdi 0.19 installed.

Change-Id: If8c910c44d11b4bd288ba13c55da8d06acdc67e4
Reviewed-on: https://gerrit.chromium.org/gerrit/48252
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
19 months agoflashrom: Refactor search code to look for fdtmap and fmap simultaneously 14/47214/3 stabilize-4008.0.B
Simon Glass [Wed, 3 Apr 2013 02:43:29 +0000 (19:43 -0700)]
flashrom: Refactor search code to look for fdtmap and fmap simultaneously

If there is no FDTMAP available in the image, we end up doing an exhaustive
search for it before we try looking for an FMAP. It makes more sense to look
for both at the same time, since we don't expect to have more than one in
the same image.

Adjust the code to handle this.

BUG=chromium:224871
BRANCH=none
TEST=FEATURES=test sudo -E emerge flashrom

Change-Id: I88b1ad47063f14460db8b01923a0f741457e1c09
Reviewed-on: https://gerrit.chromium.org/gerrit/47214
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Queue: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
19 months agoCorrect printf() strings in layout 13/47213/2
Simon Glass [Wed, 3 Apr 2013 03:07:23 +0000 (20:07 -0700)]
Correct printf() strings in layout

These parameters are long ints, so should use %lx.

BUG=none
BRANCH=none
TEST=FEATURES=test sudo -E emerge flashrom

Change-Id: Ie7c9f02be9ecb451a468d9f1f757f5eca0b4bfce
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47213
Reviewed-by: David Hendricks <dhendrix@chromium.org>
19 months agoAdd CONFIG_FDTMAP to read flashmap from FDT 10/43010/12
Simon Glass [Mon, 11 Feb 2013 01:00:38 +0000 (17:00 -0800)]
Add CONFIG_FDTMAP to read flashmap from FDT

Chrome OS uses a more powerful flashmap format with support for compression,
description of each section and so on. Flashrom doesn't really need this
information - it just need a section name and start/size. But by making
flashrom understand the Chrome OS format natively, we can avoid having
two copies of the flashmap in the image, with the confusion of which is
correct.

Add a new config for this option and implement it using libfdt and some
simple code from U-Boot.

BUG=chromium-os:38794
BRANCH=none
TEST=Just build it:
sudo emerge flashrom; emerge-daisy flashrom; emerge-link flashrom

Then run the unit tests:

 * Running flashrom unit tests
Testing fdtmap
dtc -O dtb -o test.dtb test.dts
sudo ../flashrom -p dummy:emulate=SST25VF032B,image=image.bin -w part.bin -i RO_ONESTOP
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded: ignored.
flashrom v0.9.4  :  :  on Linux 3.2.5-gg987 (x86_64), built with libpci 3.1.10, GCC 4.7.x-google 20120720 (prerelease), little endian
Erasing and writing flash chip... Verifying flash... VERIFIED.
SUCCESS
sudo ../flashrom -p dummy:emulate=SST25VF032B,image=image.bin -r part.bin -i RO_ONESTOP
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded: ignored.
flashrom v0.9.4  :  :  on Linux 3.2.5-gg987 (x86_64), built with libpci 3.1.10, GCC 4.7.x-google 20120720 (prerelease), little endian
Reading flash... SUCCESS
sudo rm -f part.bin
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded: ignored.
.dtc -O dtb -o test.dtb test.dts
sudo ../flashrom -p dummy:emulate=SST25VF032B,image=image.bin -w part.bin -i RO_ONESTOP
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded: ignored.
flashrom v0.9.4  :  :  on Linux 3.2.5-gg987 (x86_64), built with libpci 3.1.10, GCC 4.7.x-google 20120720 (prerelease), little endian
Erasing and writing flash chip... Verifying flash... VERIFIED.
SUCCESS
sudo ../flashrom -p dummy:emulate=SST25VF032B,image=image.bin -r part.bin -i RO_ONESTOP
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded: ignored.
flashrom v0.9.4  :  :  on Linux 3.2.5-gg987 (x86_64), built with libpci 3.1.10, GCC 4.7.x-google 20120720 (prerelease), little endian
Reading flash... SUCCESS
sudo rm -f part.bin
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded: ignored.
.dtc -O dtb -o test.dtb test.dts
sudo ../flashrom -p dummy:emulate=SST25VF032B,image=image.bin -w part.bin -i RO_ONESTOP
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded: ignored.
flashrom v0.9.4  :  :  on Linux 3.2.5-gg987 (x86_64), built with libpci 3.1.10, GCC 4.7.x-google 20120720 (prerelease), little endian
No layout info is available.
FAILED
.dtc -O dtb -o test.dtb test.dts
sudo ../flashrom -p dummy:emulate=SST25VF032B,image=image.bin -w part.bin -i RO_ONESTOP
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded: ignored.
flashrom v0.9.4  :  :  on Linux 3.2.5-gg987 (x86_64), built with libpci 3.1.10, GCC 4.7.x-google 20120720 (prerelease), little endian
No layout info is available.
FAILED
.dtc -O dtb -o test.dtb test.dts
sudo ../flashrom -p dummy:emulate=SST25VF032B,image=image.bin -w part.bin -i RO_ONESTOP
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded: ignored.
flashrom v0.9.4  :  :  on Linux 3.2.5-gg987 (x86_64), built with libpci 3.1.10, GCC 4.7.x-google 20120720 (prerelease), little endian
No layout info is available.
FAILED
.dtc -O dtb -o test.dtb test.dts
sudo ../flashrom -p dummy:emulate=SST25VF032B,image=image.bin -w part.bin -i RO_ONESTOP
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded: ignored.
flashrom v0.9.4  :  :  on Linux 3.2.5-gg987 (x86_64), built with libpci 3.1.10, GCC 4.7.x-google 20120720 (prerelease), little endian
Erasing and writing flash chip... Verifying flash... VERIFIED.
SUCCESS
sudo ../flashrom -p dummy:emulate=SST25VF032B,image=image.bin -r part.bin -i RO_ONESTOP
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded: ignored.
flashrom v0.9.4  :  :  on Linux 3.2.5-gg987 (x86_64), built with libpci 3.1.10, GCC 4.7.x-google 20120720 (prerelease), little endian
Reading flash... SUCCESS
sudo rm -f part.bin
ERROR: ld.so: object 'libsandbox.so' from LD_PRELOAD cannot be preloaded: ignored.
.
----------------------------------------------------------------------
Ran 6 tests in 14.639s

OK

Change-Id: I52044515f4fb95368d5cc4b44a51543d354f1f46
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43010

20 months agoMove flash search code into a separate file (2nd attempt) 76/45276/6 release-R27-3912.B stabilize-3912.79.B toolchainA
Simon Glass [Mon, 4 Mar 2013 23:34:46 +0000 (15:34 -0800)]
Move flash search code into a separate file (2nd attempt)

At present we have an algorithm which searches through the flash looking
for an FMAP signature. We want to use it to search for other things also,
such as an FDTMAP.

Move this useful algorithm into its own module, and adjust the API so that
callers can repeatedly call it and it will return a new offset to check,
each time. Then adjust the fmap code to use this new function.

Note: This is a re-hash of Simon's original CL. This version uses
read_flash() to avoid aborting prematurely due to searching locked
regions on Intel platforms with a management engine.

BUG=chromium-os:38794
BRANCH=none
TEST=Partial read of FRID region on Stumpy, observed ME region access
     errors being ignored.

Change-Id: I344ae9998ae65cc45b8b35024adb4bd224571814
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45276

20 months agofix get_crossystem_fmap_base() for shadow ROM vs. physical ROM 63/45263/4
David Hendricks [Tue, 12 Mar 2013 21:35:02 +0000 (14:35 -0700)]
fix get_crossystem_fmap_base() for shadow ROM vs. physical ROM

Early x86 Chrome OS platforms exposed the fmap_base as the region in
shadow ROM (in host memory address space). For portability reasons,
and due to overlapping BIOS/EC areas in shadow ROM, we stopped relying
on shadow ROM and now describe fmap_base in terms of physical ROM
offset. This broke the sanity check, however the fallback method
continued to work thus masking this problem.

BRANCH=none
BUG=chromium-os:39818
TEST=Tested on Alex (which uses shadow ROM offset) and Butterfly
     (which uses physical ROM offset)

Change-Id: I5f5405b714819a5ff0797d6709eaf6cff340fd99
Reviewed-on: https://gerrit.chromium.org/gerrit/45263
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
20 months agoadd read_flash() to do error handling for flash->read() 07/46207/5
David Hendricks [Fri, 22 Mar 2013 00:23:29 +0000 (17:23 -0700)]
add read_flash() to do error handling for flash->read()

This adds read_flash() which acts as a wrapper around flash->read().
Its purpose is to make high-level decisions such as what to do in
case of an error.

When applicable, flash->read() call sites are updated to use this
wrapper in order to simplify the code.

BUG=chromium-os:38794
BRANCH=none
TEST=tested by doing partial read on Stumpy (with ME region locked),
     saw verbose output indicating ME region access error ignored

Change-Id: I4fe2a9a88d874783fbc1007f44434f7fafd08874
Reviewed-on: https://gerrit.chromium.org/gerrit/46207
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
20 months agoRevert "Move flash search code into a separate file" 84/45184/2 factory-spring-3842.B firmware-spring-3833.B stabilize-3881.0.B
David Hendricks [Tue, 12 Mar 2013 05:41:54 +0000 (22:41 -0700)]
Revert "Move flash search code into a separate file"

This reverts commit 5ef86f092292d4d35e023c852935679ce1c5defc

Change-Id: I5bb5e99ca77a93b87b5e57175af5ad93536dc931
See: https://code.google.com/p/chromium-os/issues/detail?id=39818
Reviewed-on: https://gerrit.chromium.org/gerrit/45184
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
20 months agoMove flash search code into a separate file 79/44579/3 firmware-spring-3824.4.B firmware-spring-3824.55.B firmware-spring-3824.84.B firmware-spring-3824.B
Simon Glass [Mon, 4 Mar 2013 23:34:46 +0000 (15:34 -0800)]
Move flash search code into a separate file

At present we have an algorithm which searches through the flash looking
for an FMAP signature. We want to use it to search for other things also,
such as an FDTMAP.

Move this useful algorithm into its own module, and adjust the API so that
callers can repeatedly call it and it will return a new offset to check,
each time. Then adjust the fmap code to use this new function.

BUG=chromium-os:38794
BRANCH=none
TEST=Manual:
sudo emerge flashrom; emerge-daisy flashrom; emerge-link flashrom
Also test flashrom on snow (flashrom -i gbb -r test.bin, to make sure it
can access sections)

Change-Id: I3c8b84a45c05719cc9536f43e324e9f82542181e
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44579
Reviewed-by: David Hendricks <dhendrix@chromium.org>
20 months agoRevert "fmap: Export the signature-finding algorithm" 78/44578/2
Simon Glass [Mon, 4 Mar 2013 23:30:10 +0000 (15:30 -0800)]
Revert "fmap: Export the signature-finding algorithm"

Actually, since we now need to deal with CRC32 in the FDTMAP case, this
exporting is no use. So choose a different approach.

BUG=chromium-os:38794
BRANCH=none
TEST=Manual:
sudo emerge flashrom; emerge-daisy flashrom; emerge-link flashrom
This reverts commit 0382d05bb208dbeced1870dea4eba3d19264f418.

Change-Id: Icdedcad453566eddfa18239b24cbc409a403060a
Reviewed-on: https://gerrit.chromium.org/gerrit/44578
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Queue: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
20 months agoAdd support for Lynx Point chipsets. 81/44281/2
Duncan Laurie [Thu, 28 Feb 2013 17:42:07 +0000 (09:42 -0800)]
Add support for Lynx Point chipsets.

This is the chipset used for Haswell systems.  The mobile/desktop
version of the chipset is not much changed from before, although
it does finally drop FWH support.

The Low Power variant of the chipset used in ULT systems has
more changes, including reducing the BBS field to 1 bit.

BUG=chrome-os-partner:18067
BRANCH=none
TEST=manual: update BIOS with flashrom on wtm2 board

Change-Id: I303a05baa80e4449e70d20adf78ebc7128b88d8e
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/44281
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
20 months agoAdd support for Macronix MX25U3235 95/44395/4
Vincent Palatin [Thu, 28 Feb 2013 23:46:14 +0000 (15:46 -0800)]
Add support for Macronix MX25U3235

Macronix MX25U3235 is a 4MB (32Mbits) 1.8v SPI flash supporting QPI.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BRANCH=none
BUG=chrome-os-partner:18084
TEST=flash reworked spring board through servo and boot it :
sudo flashrom -p ft2232_spi:type=servo-v2 -w nv_image-spring.bin
on the board, read/write firmware :
flashrom -r current_image.bin / flashrom -w current_image.bin
test the write protect :
$ dut-control fw_wp_en:on fw_wp_vref:pp1800 fw_wp:on

crossystem wpsw_cur -> 1
flashrom --wp-status -> disabled, range clear
flashrom --wp-range 0x200000 0x200000
flashrom --wp-status -> range set
flashrom --wp-enable
flashrom --wp-status -> enabled
flashrom --wp-disable -> fail
flashrom --wp-range 0 0 -> fail
flashrom --wp-status -> range set, enabled

$ dut-control fw_wp_en:off fw_wp_vref:off fw_wp:off

crossystem wpsw_cur -> 0
flashrom --wp-disable
flashrom --wp-range 0 0
flashrom --wp-status -> disabled, range clear

Change-Id: I62c7db070254ba3ec68090e783f57b25a6e8d15a
Reviewed-on: https://gerrit.chromium.org/gerrit/44395
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>

20 months agoUPSTREAM: Update Macronix MX25L512, MX25L1005, MX25L2005, MX25L4005, MX25L8005. 94/44394/2
Vincent Palatin [Thu, 28 Feb 2013 22:31:12 +0000 (14:31 -0800)]
UPSTREAM: Update Macronix MX25L512, MX25L1005, MX25L2005, MX25L4005, MX25L8005.

Update MX25L512 with references to and data about
  MX25L512E, MX25V512, MX25V512C.
Update MX25L1005 with references to and data about
  MX25L1005C, MX25L1006E.
Update MX25L2005 with references to and data about
  MX25L2005C.
Update MX25L4005 with references to and data about
  MX25L4005A, MX25L4005C.
Update MX25L8005 with references to and data about
  MX25V8005.

Bonus: add chip IDs of MX25U1635E, MX25U3235E/F, MX25U6435E/F.

Signed-off-by: Stefan Tauner <stefan.tauner@student.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@student.tuwien.ac.at>
from flashrom upstream commit r1647 by stefanct on 2013-02-02 07:35:44 -0800

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BRANCH=none
BUG=chrome-os-partner:18084
TEST=sudo emerge flashrom

Change-Id: I092d98a7e294ac51f76875fcb95601fc4ee12957
Reviewed-on: https://gerrit.chromium.org/gerrit/44394
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
21 months agofmap: Export the signature-finding algorithm 09/43009/5
Simon Glass [Mon, 11 Feb 2013 01:05:33 +0000 (17:05 -0800)]
fmap: Export the signature-finding algorithm

We want to be able to look for signatures other than FMAP, so split this
function into two parts and export both. The functionality of fmap_find()
remains the same.

Signed-off-by: Simon Glass <sjg@chromium.org>
BUG=chromium-os:38794
BRANCH=none
TEST=Manual:
1. Build it:
sudo emerge flashrom; emerge-daisy flashrom; emerge-link flashrom

2. Use flashrom on snow to read and write part of the image.

Change-Id: I9ad0be33435f042841655f4ddb9053efe08c513c
Reviewed-on: https://gerrit.chromium.org/gerrit/43009
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Queue: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
21 months agoRemove tegra2_spi driver 07/43007/4
Simon Glass [Sun, 10 Feb 2013 17:41:05 +0000 (09:41 -0800)]
Remove tegra2_spi driver

This is generating warnings so may not work. Also it directly accesses
hardware from within Linux which is not great. It really should use spidev.

We don't need this at present - if it is needed in the future it can use
the spidev support. So I suggest we remove it.

BUG=none
BRANCH=none
TEST=emerge-daisy flashrom

Change-Id: Ia901cb90ed1e093f87b493324e2fb0c3556abc9c
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43007

21 months agolinux_spi: Fix compiler warning for unchecked return value 11/43011/4
Simon Glass [Mon, 11 Feb 2013 01:13:41 +0000 (17:13 -0800)]
linux_spi: Fix compiler warning for unchecked return value

The system() commands should print an error if they fail. Add this.

BUG=none
BRANCH=none
TEST=build flashrom, see tha the warnings are gone
Run flashrom and read/write a section on snow; see that it still
works correctly (snow uses spidev).

Change-Id: I01ac2a5d7508ae0bbd541cdffc8bc61e9b56d3c1
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/43011

22 months agoStop managing powerm process. 70/41570/2 release-R26-3701.B stabilize-3658.0.0 stabilize-3701.30.0 stabilize-3701.30.0b stabilize-3701.46.B stabilize-3701.81.B stabilize-bluetooth-smart toolchain-3701.42.B
Daniel Erat [Thu, 17 Jan 2013 21:49:59 +0000 (13:49 -0800)]
Stop managing powerm process.

The powerm process doesn't do anything anymore and will be
removed soon.

BRANCH=none
BUG=chromium-os:36804
TEST=locally compiled

Change-Id: I7f8471595b35113d55d879e9067930b9e3512b55
Reviewed-on: https://gerrit.chromium.org/gerrit/41570
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Queue: Daniel Erat <derat@chromium.org>
Tested-by: Daniel Erat <derat@chromium.org>
22 months agofix some compiler warnings in writeprotect.c 30/40030/5 factory-3536.B
David Hendricks [Tue, 30 Oct 2012 18:37:57 +0000 (11:37 -0700)]
fix some compiler warnings in writeprotect.c

This fixes some errors which cause manual compilation to fail.

BRANCH=none
BUG=none
TEST=locally compiled

Change-Id: I89717a8ed89765bea0e90a05452f9047779c1d37
Reviewed-on: https://gerrit.chromium.org/gerrit/40030
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>

22 months agofix some compiler warnings in gec.c 31/40031/3
David Hendricks [Tue, 30 Oct 2012 18:39:12 +0000 (11:39 -0700)]
fix some compiler warnings in gec.c

This fixes some errors which cause manual compilation to fail.

BRANCH=none
BUG=none
TEST=locally compiled

Change-Id: I1e408b0766afefa1f9f09d4883453e7241de0c5c
Reviewed-on: https://gerrit.chromium.org/gerrit/40031
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2 years agocache result of SPI probe functions release-R25-3428.B stabilize-3428.110.0 stabilize-3428.149 stabilize-3428.149.B stabilize-3428.193 stabilize2 toolchain-3428.65.B
David Hendricks [Fri, 12 Oct 2012 00:15:48 +0000 (17:15 -0700)]
cache result of SPI probe functions

This implements a simple means of caching probe results from REMS
and RDID (3 and 4-byte versions) commands. This makes probing of
SPI ROMs slightly faster (~10-50ms) depending on which
programmer is being used.

This also factors out some common code used for RDID3/4 and REMS
functions.

BRANCH=none
BUG=chromium-os:34601
TEST=Tested on Lumpy host firmware ROM with and without the delay
     loop, IDs shown in verbose output were identical

Change-Id: I71cd2b0c8c6017760a1ed52237e203076092cd9e
Reviewed-on: https://gerrit.chromium.org/gerrit/35376
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
2 years agoAlways initialize broken_timer to 0
David Hendricks [Thu, 27 Sep 2012 05:09:26 +0000 (22:09 -0700)]
Always initialize broken_timer to 0

This fixes a regression that causes broken_timer to be set to 1 for
all types of operations (including "short" ones like --wp-status).
broken_timer should only be set explicitly by "long" operations if
CONFIG_USE_OS_TIMER is set to 0.

BRANCH=none
BUG=none
TEST=Tested on Lumpy

Change-Id: If5f206bfa7193f885ed05ed1289d416043db5063
Reviewed-on: https://gerrit.chromium.org/gerrit/34170
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
2 years agoAdd additional W25Q functions and write-protect modes
David Hendricks [Wed, 3 Oct 2012 18:03:48 +0000 (11:03 -0700)]
Add additional W25Q functions and write-protect modes

This adds basic support for secondary status register read
on W25Q. All supported chips up to this point have used
older W25-series flash chips as a template and do not necessarily
support the same features as W25Q.

Since we are now examining the SRP1 bit, additional functions
were added for write-protect enable and status operations. The
--wp-enable command-line option has been augmented with an optional
argument to take advantage of additional modes that are now available:

--wp-enable=hardware    - WP controlled by hardware pin (default)
--wp-enable=power_cycle - WP enabled until power off/on cycle
--wp-enable=permanent   - Status registers permanently locked,
                          WP permanently held in current state.

BRANCH=stout
BUG=chrome-os-partner:14726
TEST=Tested power_cycle mode on stout (see notes below), regression
tested on Lumpy

1. Set WP range and --wp-enable=power_cycle. --wp-status shows WP
   enabled.
2. Attempt to overwrite to protected range failed.
3. Remove power and then re-insert power.
4. --wp-status shows WP disabled (range still set)
5. Attempt to overwrite to same range succeeded

Change-Id: I4d03897f6b56378affe676f800cd3b4d14cd8687
Reviewed-on: https://gerrit.chromium.org/gerrit/35084
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
2 years agoit8518: set WDT reset flag when writing ROM content (for Stout) factory-2993.B factory-3004.B
David Hendricks [Thu, 27 Sep 2012 23:39:37 +0000 (16:39 -0700)]
it8518: set WDT reset flag when writing ROM content (for Stout)

This patch adds an it8518 hack that will examine the SPI opcode to
determine if it will change ROM content and, if so, will use 0xd8
instead of 0xdd. This will cause the EC to set a flag indicating
that a watchdog reset should be done after the update.

FIXME: This is a pretty awful hack. The long-term solution is for
Flashrom to become more aware of its platform so we can apply this
stuff on a per-platform basis instead of a per-chip basis. That will
also allow us to choose the appropriate commands from the start of
execution rather than changing commands in-flight.

BRANCH=none
BUG=chrome-os-partner:14578
TEST=Regression tested on Cr48, Stout notes below

1. Write to unused space:
cp stout_ec.img stout_ec_modified.img
dd if=/dev/urandom of=stout_ec_modified.img bs=1k seek=192 count=832
flashrom -p internal:bus=lpc -w stout_ec_modified.img -V

Fan spins up and input is blocked as we see content being overwritten.
System returns to usable state afterward. In verbose log we see that
the copy_to_sram_cmd gets changed from its default once.

2. Read only:
Fan spins up, input blocked for a few seconds, read successful,
system returns to usable state, copy_to_sram_cmd is unchanged.

3. Checking write-protection
Input blocked momentarily, read successful, system returns to
usable state, copy_to_sram_cmd is unchanged.

Change-Id: I66325dc7d3f296c6755c1bc8768da1c859839ba2
Reviewed-on: https://gerrit.chromium.org/gerrit/34246
Reviewed-by: Shawn Nematbakhsh_ <shawnn@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
2 years agokb94x: enter/exit idle mode gracefully factory-2985.B
agnescheng [Wed, 26 Sep 2012 04:33:35 +0000 (12:33 +0800)]
kb94x: enter/exit idle mode gracefully

BRANCH=butterfly
ENE EC KB94X has hw limitation on WDT(maximum: 32 secs), which also
causes an interrupt at the 16th secs to wakeup EC from idle mode. This patch
implements a timer to exit idle mode when exceeding 12 secs -- EC would
be woke up by 64h port command and re-enter idle mode to continue EC ROM
reading.

BUG=chrome-os-partner:13986
TEST=manual
  VT2 console commands:
      flashrom -p internal:bus=lpc --wp-status
      flashrom -p internal:bus=lpc -r ec_bios.bin
  The fan should not spin up.

Change-Id: I449902af2afecb98cad0ef87d06264012d399edd
Reviewed-on: https://gerrit.chromium.org/gerrit/34096
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: Agnes Cheng <agnescheng@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>

2 years agoRevert "it85xx: add IRQ disable/enable hack for Stout"
David Hendricks [Fri, 21 Sep 2012 21:46:41 +0000 (14:46 -0700)]
Revert "it85xx: add IRQ disable/enable hack for Stout"

This reverts commit 36b8c992c4cf0280081a4c663644d46ceab2df32

Turns out the vendor fixed the underlying issue in the EC firmware, so this is no longer needed.

Change-Id: I4d5caeaedb7225412ce6a8aba40c40d75f9f7cba
Reviewed-on: https://gerrit.chromium.org/gerrit/33806
Reviewed-by: Shawn Nematbakhsh <shawnn@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
2 years agoit85xx: add IRQ disable/enable hack for Stout
David Hendricks [Fri, 21 Sep 2012 05:50:36 +0000 (22:50 -0700)]
it85xx: add IRQ disable/enable hack for Stout

This adds a hack to detect if we're running on Stout and, if so,
disable IRQs before doing anything and then re-enabling them at
the end.

The code flow is kind of weird since the return code for entering/
exiting scratch mode are typically ignored (!). So rather than
managing the IRQs around it85xx_{enter,exit}_scratch_rom, this
disables IRQs when we're initializing or EC and re-enabls them when
we're done with everything (it85xx_shutdown).

FIXME: This still needs some work to make it less hacky and reduce
UI jank.

BRANCH=none
BUG=chrome-os-partner:14081
TEST=EC flash read 10 times while mashing keyboard, machine remained
usable afterward (though unresponsive during the actual read)

Change-Id: Idd0cd2bcf5b595eece251ea243bd1d5a565a87e2
Reviewed-on: https://gerrit.chromium.org/gerrit/33757
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Shawn Nematbakhsh <shawnn@chromium.org>
2 years agoenable dmi_init() and force laptop_ok = 1
David Hendricks [Fri, 21 Sep 2012 05:21:54 +0000 (22:21 -0700)]
enable dmi_init() and force laptop_ok = 1

This enables DMI table scanning so we can use DMI info to apply board-
specific hacks.

It also sets laptop_ok to 1. This will go away once we have proper
laptop whitelisting enabled (hopefully next time we merge with
upstream).

BRANCH=none
BUG=chrome-os-partner:14081
TEST=Tested EC and SPI flash read on on cr48, zgb, alex, lumpy,
parrot, butterfly, and stout to ensure no unexpected DMI-related
warnings showed up.

Change-Id: I1d5048303c70995f6f4247ad819486ba704c5da5
Reviewed-on: https://gerrit.chromium.org/gerrit/33756
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Shawn Nematbakhsh <shawnn@chromium.org>
2 years agoDon't run the latest firmware copy after GEC is updated.
Louis Yung-Chieh Lo [Thu, 20 Sep 2012 02:39:35 +0000 (10:39 +0800)]
Don't run the latest firmware copy after GEC is updated.

Since the software sync is landed, we should leave the BIOS to decide
which EC firmware copy to run.

Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
BRANCH=None
BUG=chromium-os:34594
TEST=build in chroot only.

Change-Id: Id599804383eaa0d52c8554aaebcba3559630f481
Reviewed-on: https://gerrit.chromium.org/gerrit/33664
Commit-Ready: Yung-Chieh Lo <yjlou@chromium.org>
Tested-by: Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2 years agoSupport write protection of A25L040. factory-2914.B
Louis Yung-Chieh Lo [Mon, 17 Sep 2012 09:38:35 +0000 (17:38 +0800)]
Support write protection of A25L040.

Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
BRANCH=None
BUG=chrome-os-partner:14084,
TEST=on butterfly
flashrom -p internal:bus=lpc --wp-list
flashrom -p internal:bus=lpc --wp-status  # disabled, 0, 0
flashrom -p internal:bus=lpc --wp-range 0x40000 0x40000
flashrom -p internal:bus=lpc --wp-enable
flashrom -p internal:bus=lpc --wp-status  # enabled, 0x40000, 0x40000
flashrom -p internal:bus=lpc --wp-disable

Change-Id: I8c2d1281babefba8ce8640781301307eb1abc827
Reviewed-on: https://gerrit.chromium.org/gerrit/33422
Commit-Ready: Yung-Chieh Lo <yjlou@chromium.org>
Tested-by: Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2 years agoReturn error of write protection is not supported.
Louis Yung-Chieh Lo [Mon, 17 Sep 2012 09:52:20 +0000 (17:52 +0800)]
Return error of write protection is not supported.

Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
BRANCH=None
BUG=chromium-os:34430
TEST=on butterfly (with an A25L040 flash chip).
flashrom -p internal:bus=lpc --wp-status  # expect Error and returns 1

Change-Id: I960a86082f99546c32893f9113f57a5d891082e0
Reviewed-on: https://gerrit.chromium.org/gerrit/33426
Commit-Ready: Yung-Chieh Lo <yjlou@chromium.org>
Tested-by: Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2 years agoFix a bug of gec_i2c protocol v2 (e06fcaa).
Louis Yung-Chieh Lo [Tue, 11 Sep 2012 05:02:01 +0000 (13:02 +0800)]
Fix a bug of gec_i2c protocol v2 (e06fcaa).

The error return value (ret) is always overwritten by response length.
Fix it by early-return.

BUG=chrome-os-partner:13908,
BRANCH=None
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
TEST=On snow,
% flashrom -p internal:bus=lpc -w another_ec.bin   # PASS
% flashrom -p internal:bus=lpc --wp-list           # PASS

Change-Id: I2086663d8034d5b0906c6b74ddb07166ea7b18d6
Reviewed-on: https://gerrit.chromium.org/gerrit/32901
Commit-Ready: Yung-Chieh Lo <yjlou@chromium.org>
Tested-by: Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2 years agogec: Apply gec_lock for i2c too.
Louis Yung-Chieh Lo [Thu, 6 Sep 2012 06:59:49 +0000 (14:59 +0800)]
gec: Apply gec_lock for i2c too.

gec_i2c.c would configure ioctl in multiple places. This could lead race-
condition if multiple programs are running at the same time. Thus, add a
semaphore to protect it.

Also fix a nit in gec_lpc.c.

BRANCH=snow
BUG=chrome-os-partner:12207
TEST=build only.
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Change-Id: I5a229392368e3d62f378b2755ec5415940652e76
Reviewed-on: https://gerrit.chromium.org/gerrit/32368
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Ready: Yung-Chieh Lo <yjlou@chromium.org>
Tested-by: Yung-Chieh Lo <yjlou@chromium.org>
2 years agoAdd flashrom support for GD25Q64 SPI ROM.
Shawn Nematbakhsh [Sun, 2 Sep 2012 04:58:03 +0000 (21:58 -0700)]
Add flashrom support for GD25Q64 SPI ROM.

Add support for GD family of SPI ROMs. Taken from upstream change r1520.
Write protect geometry table added for GD25Q64 only.

BUG=chrome-os-partner:12103
TEST=flashrom read/write/wp operations on GD25Q64 device.
BRANCH=butterfly

Change-Id: I0f2b538c44f67c38d49920a8c852e17d271d91ff
Reviewed-on: https://gerrit.chromium.org/gerrit/32097
Commit-Ready: Shawn Nematbakhsh <shawnn@chromium.org>
Tested-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2 years agoGEC i2c upgrades protocol to v2.
Louis Yung-Chieh Lo [Thu, 30 Aug 2012 06:45:25 +0000 (14:45 +0800)]
GEC i2c upgrades protocol to v2.

(Not urgent. Not going to cherry-pick.)

There are 2 kinds of version in the EC interface and I mixed up them.

In original code, protocol v2 is used only for command v1. However, this
is not enough because some v0 commands, like EC_CMD_GET_BUILD_INFO, need
the protocol v2 for variable-length response.

So, let's go protocol v2 anyway.

BUG=chrome-os-partner:12636,
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
BRANCH=None
TEST=on snow, and both command v0/v1 are working on protocol v2.
flashrom -p internal:bus=lpc -r /tmp/ec.bin  ; command v0
flashrom -p internal:bus=lpc --wp-list       ; command v1
flashrom -p internal:bus=lpc --wp-status     ; command v1

Change-Id: I1899c71b9232184564eb641b49ae0011b3e45d04
Reviewed-on: https://gerrit.chromium.org/gerrit/31839
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Ready: Yung-Chieh Lo <yjlou@chromium.org>
Tested-by: Yung-Chieh Lo <yjlou@chromium.org>
2 years agoRevert "According to FMAP spec, it should be aligned to 64-byte." factory-2846.B factory-2848.B
Louis Yung-Chieh Lo [Wed, 29 Aug 2012 08:11:31 +0000 (16:11 +0800)]
Revert "According to FMAP spec, it should be aligned to 64-byte."

This reverts commit 2fc49b13d3e2fbe5db162e35bb483e76c66b1490.

BUG=chromium-os:33963,
TEST=None
BRANCH=None

Change-Id: Ibfa95baa726e31e8bded0b753b2cbee126ef4f76
Reviewed-on: https://gerrit.chromium.org/gerrit/31689
Commit-Ready: Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Tested-by: Yung-Chieh Lo <yjlou@chromium.org>
2 years agoAccording to FMAP spec, it should be aligned to 64-byte. firmware-stout-2817.B
Louis Yung-Chieh Lo [Mon, 27 Aug 2012 08:25:34 +0000 (16:25 +0800)]
According to FMAP spec, it should be aligned to 64-byte.

BUG=chrome-os-partner:13143
TEST=local build only
BRANCH=link,snow

Change-Id: I6e927a52d5296e3d7d9315781b6c7aeeb7594efe
Reviewed-on: https://gerrit.chromium.org/gerrit/31450
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Ready: Yung-Chieh Lo <yjlou@chromium.org>
Tested-by: Yung-Chieh Lo <yjlou@chromium.org>
2 years agoImprove --wp-enable for link and snow.
Louis Yung-Chieh Lo [Fri, 24 Aug 2012 06:12:21 +0000 (14:12 +0800)]
Improve --wp-enable for link and snow.

On link, we didn't take effect of RO_NOW immediately. This CL enables
RW_NOW beside RO_AT_BOOT.

On snow, the RO_NOW is not supported, thus we use ALL_NOW instead.

BUG=chrome-os-partner:12951
BRANCH=link,snow
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Change-Id: I70e2e716c583717f8d719838ccb2225bc74f3085
TEST=tested on link and snow:
;
; assert WP pin
;
flashrom -p internal:bus=lpc --wp-status   ; is disabled
flashrom -p internal:bus=lpc --wp-enable   ; expect SUCCESS
flashrom -p internal:bus=lpc --wp-range \  ; ("0 0x10000" for snow)
                                0 0x14000  ; expect SUCCESS
flashrom -p internal:bus=lpc --wp-disable  ; expect FAILED
;
; host shutdown
; on snow, this leads the EC cold reset.
;
flashrom -p internal:bus=lpc --wp-status   ; expect still enabled
                                           ; expect the EC console shows
                                           ; the RW is NOT protected.
;
; deassert WP pin and host reboot
;
flashrom -p internal:bus=lpc --wp-status   # enabled, but range is (0,0)
flashrom -p internal:bus=lpc --wp-disable  # expect SUCCESS
flashrom -p internal:bus=lpc --wp-status   # expect disabled
Reviewed-on: https://gerrit.chromium.org/gerrit/31321
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2 years agogec: add wait mechanism for in-progress commands
David Hendricks [Sat, 18 Aug 2012 04:14:48 +0000 (21:14 -0700)]
gec: add wait mechanism for in-progress commands

The EC can now indicate that a command has been accepted and is
in-progress. This was recently enabled for the flash write command:
https://gerrit.chromium.org/gerrit/#/c/30471/

This adds a retry mechanism which checks the status of the previous
command issued after an expected delay period for that command.

BRANCH=snow
BUG=none
TEST=tested on Snow using ToT EC image

Change-Id: I0c4522b351d84c13ff6873ceb85b1dce37b52efd
Reviewed-on: https://gerrit.chromium.org/gerrit/30801
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
2 years agoSwitch ENE to write mode on WREN and EWSR command firmware-butterfly-2788.B
Rong Chang [Sat, 18 Aug 2012 16:40:49 +0000 (00:40 +0800)]
Switch ENE to write mode on WREN and EWSR command

ENE EC need to switch from idle mode to reset mode on flash write.
The mode switching clears SPI rom write enable. Hence WREN and EWSR
should be added to erase/write detection.

BRANCH=parrot
BUG=chrome-os-partner:12501
TEST=manual: flashrom -p internal:bus=lpc -w ec_image.bin
  no warning/error message on sector erase
  flashrom does not try block erase

Change-Id: Ic1b7ed32d2dcfcf696673ba0bd43dc9add9865f9
Reviewed-on: https://gerrit.chromium.org/gerrit/30822
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Ready: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
2 years agoupdate EC commands header
David Hendricks [Fri, 17 Aug 2012 23:01:32 +0000 (16:01 -0700)]
update EC commands header

BRANCH=snow,link
BUG=none
TEST=locally compiled

Change-Id: Ia2f98f9527ce3c3f48612ae3dd2447f4c7663511
Reviewed-on: https://gerrit.chromium.org/gerrit/30800
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
2 years agogec_i2c should return negative value for error.
Louis Yung-Chieh Lo [Fri, 17 Aug 2012 09:34:10 +0000 (17:34 +0800)]
gec_i2c should return negative value for error.

BUG=None
TEST=Build only
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Change-Id: I17e2a5ca01a87293e7595e1c4f9e943bcb922a07
Reviewed-on: https://gerrit.chromium.org/gerrit/30680
Commit-Ready: Yung-Chieh Lo <yjlou@chromium.org>
Tested-by: Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2 years agoFix a bug of checking return value of priv->ec_command().
Louis Yung-Chieh Lo [Thu, 16 Aug 2012 05:33:36 +0000 (13:33 +0800)]
Fix a bug of checking return value of priv->ec_command().

In the EC API v1, the return value of ec_command has been redefined:
< 0, failed
>=0, success

Most of code has been refined, but missed one.

BUG=chrome-os-partner:12716
TEST=tested on link.
flashrom -p internal:bus=lpc -w two_different_ec_images.
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Change-Id: Ib713ba361d4509e20419dde7e06b054f2e3c8778
Reviewed-on: https://gerrit.chromium.org/gerrit/30520
Commit-Ready: Yung-Chieh Lo <yjlou@chromium.org>
Tested-by: Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Rong Chang <rongchang@chromium.org>
2 years agoadd Carl-Daniel to copyright line
David Hendricks [Wed, 15 Aug 2012 22:23:12 +0000 (15:23 -0700)]
add Carl-Daniel to copyright line

The SVN portions of this script were derived from the mainstream
Makefile, although modified and rearranged pretty significantly.
In any case, it's fair to add Carl-Daniel to the authors.

BUG=none
TEST=none

Change-Id: I90b35e69bb0fecfd4a26895ef559d43a0870d5f2
Reviewed-on: https://gerrit.chromium.org/gerrit/30474
Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
2 years agoSupport write protection (again).
Louis Yung-Chieh Lo [Mon, 13 Aug 2012 09:21:01 +0000 (17:21 +0800)]
Support write protection (again).

BUG=chrome-os-partner:11219
TEST=tested on link and snow:
F="flashrom -p internal:bus=lpc "
$F --wp-status            ; disabled
$F --wp-list              ; ranges supported by the EC chip
$F --wp-enable 11 22      ; random address, expect failed
$F --wp-enable 0 0x14000  ; enabled
$F --wp-enable 0 0        ; disabled
$F --wp-enable 0 0x14000  ; re-enabled again
$F --wp-disable           ; disabled again

Change-Id: I2520ea0d969338ae1d5889f54f9fa1839bbf5397
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29981
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2 years agoUpgrade to Google EC API v1 (re-send).
Louis Yung-Chieh Lo [Mon, 30 Jul 2012 10:20:39 +0000 (18:20 +0800)]
Upgrade to Google EC API v1 (re-send).

Basically this is a re-send of 1c4b784 (which is reverted in cf6e3a3),
but added extra code:

1. add an extra wait_for_ec() before outb(cmd) in v1 API.

2. don't jump if EC is running the target copy. This is to fix the bug
   that REBOOT_EC would response 2 SUCCESSes.

3. upgrade i2c to v1 as well.

4. fix a bug in original CL that forgets to negative resp_buf[0] for
   return value.

BUG=chrome-os-partner:11320
TEST=build and tested on link and snow:
F="flashrom -p internal:bus=lpc -V "
for i in `seq 0 19`; do
        $F -w ec.bin.1 || exit 1
        $F -w ec.bin.2 || exit 2
done

Change-Id: I9a1364dcbcb8e9006b9b61fd72c20491900c5a12
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29874
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2 years agoProbe ITE SuperIO/ECs conditionally
David Hendricks [Sat, 4 Aug 2012 00:38:48 +0000 (17:38 -0700)]
Probe ITE SuperIO/ECs conditionally

This forces ITE ECs and SuperIOs to be probed only if the user
specifies bus=lpc.

BUG=chrome-os-partner:12107
TEST=Tested on Stout and Mario (Cr48)

Change-Id: I446cc5b690f235b6617adcea28c9efea134fac28
Reviewed-on: https://gerrit.chromium.org/gerrit/29229
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
2 years agoAdd GEC lock mechanism.
Louis Yung-Chieh Lo [Thu, 9 Aug 2012 15:11:32 +0000 (23:11 +0800)]
Add GEC lock mechanism.

Basically re-use the big lock mechanism, but change the key value.

BUG=chrome-os-partner:12319
TEST=build and test on link.  Only build on snow.
flashrom -p internal:bus=lpc -r /tmp/1 &
flashrom -p internal:bus=lpc -r /tmp/2 &
Reading SUCCESS. /tmp/1 and /tmp/2 are identical.

Change-Id: I8b4ab2f1b84a4d6252951b0e9133da3e2f8ce47e
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29762
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2 years agoupdate license header for ipc_lock.*
David Hendricks [Thu, 9 Aug 2012 23:23:48 +0000 (16:23 -0700)]
update license header for ipc_lock.*

These sholud've been included in the previous CL for big_lock.*.

BUG=none
TEST=none

Change-Id: I23d0a4b3a2e2b9f570f9ef44809f0a2b361bd157
Reviewed-on: https://gerrit.chromium.org/gerrit/29835
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
2 years agoupdate license header for big_lock
David Hendricks [Thu, 9 Aug 2012 18:05:20 +0000 (11:05 -0700)]
update license header for big_lock

The big lock was originally intended to be dual-licensed BSD/GPLv2
as part of mosys. It was later re-licensed as plain 'ol BSD to
simplify things. Note: the csem.* files have always been plain BSD-
licensed.

BUG=none
TEST=none

Change-Id: Ic8846afd4fd9cc0526044af00a474895d9dda2ff
Reviewed-on: https://gerrit.chromium.org/gerrit/29779
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>