Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(615)

Issue 6025013: Add flashmap (fmap) support to Flashrom (Closed)

Created:
9 years, 11 months ago by dhendrix
Modified:
9 years, 5 months ago
Base URL:
svn://coreboot.org/flashrom/trunk
Visibility:
Public.

Description

Add flashmap (fmap) support to Flashrom This adds flashmap parsing to Flashrom. If an fmap data structure is found, entries will be added to flashrom's internal rom layout. BUG=chromium-os:115 TEST=Tested on Alex Testing methodology is similar to what was used in the -i argument patch (git hash d0ea9e), except now fmap data was present in the original bios image: - Partial write test (automated script) - Manual partial reads test by reading 4K chunks from ROM and comparing against original BIOS image file and also inspecting the chip-sized file. - Ensure final chip-size image is generated properly by omitting :file from one of the -i arguments. - Full read if no -i options are used when fmap is present - Entire chip written if no -i option is specified and fmap is present. Same holds true if a layout file is specified by no regions are included. A command like "flashrom -w bios.bin" or "flashrom -l layout.txt -w bios.bin" will consistently write the full image to ROM. - Specifying a non-existent region caused flashrom to fail (expected result). TODO: Automate all of the above.

Patch Set 1 #

Total comments: 16

Patch Set 2 : Fixes as per Louis' comments #

Patch Set 3 : add debug statements #

Total comments: 2

Patch Set 4 : added a missing memset() #

Patch Set 5 : do not include fmap-specified regions by default #

Patch Set 6 : %lx -> 0x%lx #

Total comments: 10

Patch Set 7 : optimize fmap_find #

Patch Set 8 : clarify a comment #

Patch Set 9 : minor fix for >80 cols #

Patch Set 10 : fix a >80col issue #

Patch Set 11 : fix a corner case when the area length is zero #

Patch Set 12 : fix a stupid typo #

Total comments: 11

Patch Set 13 : respond to comments #

Total comments: 4

Patch Set 14 : move add_fmap_entries() call to doit() and make fmap_find() work without oldcontents #

Patch Set 15 : fix a comment #

Total comments: 6

Patch Set 16 : further optimizations to fmap_find #

Patch Set 17 : tweak fmap_find() further #

Patch Set 18 : inspect include_args[0] instead of romimages counter to check if user wants to read/write full image #

Patch Set 19 : remove a superfluous debug message #

Unified diffs Side-by-side diffs Delta from patch set Stats (+271 lines, -7 lines) Patch
M Makefile View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M flash.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +1 line, -0 lines 0 comments Download
M flashrom.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +6 lines, -0 lines 0 comments Download
A fmap.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +88 lines, -0 lines 0 comments Download
A fmap.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +108 lines, -0 lines 0 comments Download
M layout.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 5 chunks +67 lines, -6 lines 0 comments Download

Messages

Total messages: 22 (0 generated)
dhendrix
9 years, 11 months ago (2010-12-30 02:37:27 UTC) #1
Louis
Thanks for adding this sweet function for user. I'd like to see this convenient feature ...
9 years, 11 months ago (2010-12-30 02:57:08 UTC) #2
dhendrix
Thanks for the review! The CL definitely needs further testing and consideration for various usage ...
9 years, 11 months ago (2010-12-31 00:47:02 UTC) #3
dhendrix
fyi -- i have done some testing using modified a Mario BIOS image to mark ...
9 years, 11 months ago (2010-12-31 02:37:39 UTC) #4
Louis
Thanks for replying. Please kindly see my comments inlined. :-) http://codereview.chromium.org/6025013/diff/1/layout.c File layout.c (right): http://codereview.chromium.org/6025013/diff/1/layout.c#newcode204 ...
9 years, 11 months ago (2010-12-31 09:13:30 UTC) #5
stefanreinauer
LGTM
9 years, 9 months ago (2011-03-04 00:04:17 UTC) #6
dhendrix
Let's revisit this now that we have an actual usage case. Stefan is re-working some ...
9 years, 9 months ago (2011-03-04 00:06:17 UTC) #7
Louis
Time flies. The requirement for flashrom changed a little. Now we need a fast read ...
9 years, 9 months ago (2011-03-04 00:40:59 UTC) #8
dhendrix
http://codereview.chromium.org/6025013/diff/24007/fmap.c File fmap.c (right): http://codereview.chromium.org/6025013/diff/24007/fmap.c#newcode43 fmap.c:43: long int fmap_find(const uint8_t *image, size_t image_len) On 2011/03/04 ...
9 years, 9 months ago (2011-03-04 08:04:46 UTC) #9
Louis
LGTM except few minor issues. Please feel free to submit after refine them and fully ...
9 years, 9 months ago (2011-03-04 11:01:13 UTC) #10
dhendrix
http://codereview.chromium.org/6025013/diff/30003/layout.c File layout.c (right): http://codereview.chromium.org/6025013/diff/30003/layout.c#newcode235 layout.c:235: On 2011/03/04 11:01:13, Louis wrote: > strcpy(rom_entries[romimages].file, ""); Done. ...
9 years, 9 months ago (2011-03-04 21:46:33 UTC) #11
Louis
Did you accidentally include code from CL 6625011? http://codereview.chromium.org/6025013/diff/31010/layout.c File layout.c (right): http://codereview.chromium.org/6025013/diff/31010/layout.c#newcode52 layout.c:52: static ...
9 years, 9 months ago (2011-03-04 23:33:16 UTC) #12
dhendrix
One more big iteration on this CL :-) Now add_fmap_entries is called from doit(). The ...
9 years, 9 months ago (2011-03-05 00:25:30 UTC) #13
Louis
SuperB. I like your fmap->read() way! Some suggestion inlined. Could you use 'time flashrom' to ...
9 years, 9 months ago (2011-03-05 01:05:01 UTC) #14
dhendrix
9 years, 9 months ago (2011-03-05 02:34:01 UTC) #15
dhendrix
http://codereview.chromium.org/6025013/diff/34007/fmap.c File fmap.c (right): http://codereview.chromium.org/6025013/diff/34007/fmap.c#newcode50 fmap.c:50: unsigned int strides[] = { 64 * 1024, 4 ...
9 years, 9 months ago (2011-03-05 02:34:14 UTC) #16
dhendrix
9 years, 9 months ago (2011-03-05 02:42:55 UTC) #17
dhendrix
I tweaked fmap_find() a little further. Now it only reads 8 bytes for the signature ...
9 years, 9 months ago (2011-03-05 02:43:56 UTC) #18
Louis
Amazing. Now we reduce from 4.998s --> 1.273sec. Pretty impressive. :-) By the way, Stefan ...
9 years, 9 months ago (2011-03-06 09:34:51 UTC) #19
Stefan Reinauer
Alternatively, we could ignore .included if the counter is zero. Whatever is easier.
9 years, 9 months ago (2011-03-07 18:58:58 UTC) #20
dhendrix
On 2011/03/07 18:58:58, Stefan Reinauer wrote: > Alternatively, we could ignore .included if the counter ...
9 years, 9 months ago (2011-03-08 03:34:37 UTC) #21
dhendrix
9 years, 9 months ago (2011-03-08 05:13:31 UTC) #22
On 2011/03/08 03:34:37, dhendrix wrote:
> On 2011/03/07 18:58:58, Stefan Reinauer wrote:
> > Alternatively, we could ignore .included if the counter is zero. Whatever is
> > easier.
> 
> Yep, good call. Only now that we have the patch for adding -i arguments to an
> array, we can check if (!include_args[0]).
> 
> Preliminary results look good. I'll post some testing results soon.

Okay, I finally finished all the tests and everything looked good! See the
updated CL description for some details. I don't want to drag this CL on any
longer, especially since Stefan needs it, so I'll go ahead and commit it based
on earlier feedback.

There are a couple outstanding issues:
- The strides used for searching for the fmap signature in ROM should be
automatically generated, based on the algorithm Louis described earlier.

- I tried using the FMAP file in sysfs that is exported via ACPI in Chrome OS,
but hit a situation where the file read back a weird value. We should add
support for using that file once we figure out exactly how...

Powered by Google App Engine
This is Rietveld 408576698