Nico Huber has posted comments on this change. ( https://review.coreboot.org/18207 )
Change subject: Free board_vendor and board_model vars before returning
......................................................................
Patch Set 3:
(1 comment)
> it seems like return 1 is the default except for a few cases. how
> about initializing ret = 1, and drop the _1 label?
Not that easy since `ret` might get overwritten in between.
https://review.coreboot.org/#/c/18207/3/internal.c
File internal.c:
Line 163: #if defined __FLASHROM_LITTLE_ENDIAN__
Well, this is a problem... `ret` wouldn't be defined otherwise.
Just remove the guard?
--
To view, visit https://review.coreboot.org/18207
To unsubscribe, visit https://review.coreboot.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I825f53702803292277b44dcb03fdc49b5dd410a8
Gerrit-PatchSet: 3
Gerrit-Project: flashrom
Gerrit-Branch: staging
Gerrit-Owner: Martin Roth <martinroth(a)google.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Patrick Georgi <pgeorgi(a)google.com>
Gerrit-Reviewer: Stefan Tauner <stefan.tauner(a)gmx.at>
Gerrit-Reviewer: build bot (Jenkins)
Gerrit-HasComments: Yes
David Hendricks has posted comments on this change. ( https://review.coreboot.org/17945 )
Change subject: Add functions to read/erase/write/verify by layout
......................................................................
Patch Set 4: Code-Review+2
(3 comments)
Better! I have a few cosmetic nits for you to consider, but overall I'd be fine with committing this as is.
FWIW for testing I'm trying to bring in some patches to handle -i region[:<filename>] syntax (https://patchwork.coreboot.org/patch/4076/) and the new test script from chromium (https://chromium.googlesource.com/chromiumos/third_party/flashrom/+/master/…). It sounds like you already did a fair amount of manual testing, too.
https://review.coreboot.org/#/c/17945/4/flashrom.c
File flashrom.c:
PS4, Line 1764: size_t
int to match num_entries?
Line 1855: /*
nit: add a newline above to separate the declarations and the body
PS4, Line 1886: newc + start - info->erase_start
Thanks for updating the offset calculation. However, it somehow didn't end up as clear as I had hoped, probably because "start" was added and so when re-reading this I had to mentally substitute "info->region_end + 1" for "start".
How about creating another variable above, rel_start or something, to store "start - info->erase_start"? That makes it even more clear that we're adding a relative address to newc and also reduces arithmetic in the function calls (same rationale for creating "start" and "len" to begin with, I presume).
--
To view, visit https://review.coreboot.org/17945
To unsubscribe, visit https://review.coreboot.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: Ic6194cea4c4c430e0cf9d586052508a865b09c86
Gerrit-PatchSet: 4
Gerrit-Project: flashrom
Gerrit-Branch: staging
Gerrit-Owner: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-Reviewer: Stefan Tauner <stefan.tauner(a)gmx.at>
Gerrit-Reviewer: build bot (Jenkins)
Gerrit-HasComments: Yes
Nico Huber has posted comments on this change. ( https://review.coreboot.org/17945 )
Change subject: Add functions to read/erase/write/verify by layout
......................................................................
Patch Set 2:
(3 comments)
I'm not sure which path to go from here. I could leave it as is,
in case tests are positive (I've fixed the curcontents patching
in the latest patch set). Or try to perfect it (e.g. by making
curcontents/newcontents completely transparent to the walk_*
functions). But I guess the ugly parts would vanish anyway, if
we tackle the erase function decision later.
https://review.coreboot.org/#/c/17945/2/flashrom.c
File flashrom.c:
PS2, Line 1773: read_by_layout(flashctx, info->curcontents)
> If we'd move this before the first try and read the current region
Should move anyway, or else we'd read again after the last
function failed.
PS2, Line 1836: const unsigned int erase_len = info->erase_end + 1 - info->erase_start;
> Are you sure info->erase_end and info->erase_start are valid here? The call
We're called by walk_eraseblocks() which sets them... generally:
something_by_layout() -- optionally sets curcontents/newcontents
walk_by_layout() -- sets region_start/region_end
walk_eraseblocks()-- sets erase_start/erase_end
per_blockfn() -- does the job
PS2, Line 1847: region_unaligned
> I tried to patch the layout in advance in the chromiumos branch, but the re
After reading your comment above, I too thought walk_eraseblocks()
would be a better place for the patching, but... the "Note" in the
comment here gives a hint that it would become more complex. We
can't patch into info->newcontents without walking the layout again
to decide which parts to patch. So I decided to introduce the `newc`
buffer which only contains the changes that will be written for the
current region.
This is not the optimal solution but, IMO, the cleaner one: 1. the
code is less complex. 2. we do things step by step. after walk_by_
layout() is done with one interation the flash chip is in the ob-
vious state: we have updated the data for all regions up to the last
iteration (without patching data for later regions in beforehand).
3. the caller of walk_by_layout() (who decides about the used per_
blockfn()) and the per_blockfn() share a contract how curcontents
and newcontents are handled. this contract is transparent to walk_
by_layout() and walk_eraseblocks() (with the exception of the re-
reading in the fallback case).
If we'd keep the `newc` buffer but move the patching up into walk_
eraseblocks(), we'd have to mess with the per_blockfn() signature
(adding a parameter for the newcontents).
--
To view, visit https://review.coreboot.org/17945
To unsubscribe, visit https://review.coreboot.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: Ic6194cea4c4c430e0cf9d586052508a865b09c86
Gerrit-PatchSet: 2
Gerrit-Project: flashrom
Gerrit-Branch: staging
Gerrit-Owner: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-Reviewer: Stefan Tauner <stefan.tauner(a)gmx.at>
Gerrit-Reviewer: build bot (Jenkins)
Gerrit-HasComments: Yes
David Hendricks has posted comments on this change. ( https://review.coreboot.org/17945 )
Change subject: Add functions to read/erase/write/verify by layout
......................................................................
Patch Set 4:
(5 comments)
a few quick comments... I need to re-review this patch later on.
https://review.coreboot.org/#/c/17945/2/flashrom.c
File flashrom.c:
PS2, Line 1647: cinfo("\nWarning: Chip content is ident
> I'm tempted but I'd rather see less global variables than more. At
SGTM. I'd also rename it to "default" or "default_layout" while we're at it, but that's your call.
PS2, Line 1721:
> could just break (both loops) in this case
Actually, I think this will need to be expanded to patch the content buffers if eraseblocks[i].size doesn't align with the targeted region (more on that below). Not sure how it will look in the end, will think about it some more...
PS2, Line 1836: * @param buffer Buffer of full chip size to read into.
Are you sure info->erase_end and info->erase_start are valid here? The caller (walk_by_layout()) doesn't initialize them.
PS2, Line 1847: c int read_erase
> Ok, trying to sort this out. In case of `-A` (noverify-all) we
I tried to patch the layout in advance in the chromiumos branch, but the result was kinda ugly and inflexible (https://chromium-review.googlesource.com/#/c/240176/). Unfortunately I never had time to go back and implement a solution that could work with different block sizes, so I ended up just assuming that the smallest size must work :-/ Like you say, it doesn't play well with the block-erase fallback.
IIRC the issue was the way contents and offsets were passed around awkwardly (and inconsistently?) to the helper functions. Passing a walk_info struct all the way down the stack should help a lot. The innermost loop in walk_eraseblocks() can use that info to patch both curcontent and newcontent with the missing parts (patch newcontent for the update, curcontent for verification later on).
Line 1929: ret = 0;
The other members should probably be initialized to 0xdeadbeef (or something out of range of usual flash chips) to help debug when somebody re-factors all of this.
--
To view, visit https://review.coreboot.org/17945
To unsubscribe, visit https://review.coreboot.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: Ic6194cea4c4c430e0cf9d586052508a865b09c86
Gerrit-PatchSet: 4
Gerrit-Project: flashrom
Gerrit-Branch: staging
Gerrit-Owner: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-Reviewer: Stefan Tauner <stefan.tauner(a)gmx.at>
Gerrit-Reviewer: build bot (Jenkins)
Gerrit-HasComments: Yes
Nico Huber has posted comments on this change. ( https://review.coreboot.org/17945 )
Change subject: Add functions to read/erase/write/verify by layout
......................................................................
Patch Set 4:
> Do you by chance have testing notes or a script handy?
No. Most testing was done manually with patch set 1 (which made it into
our products).
The current revision is untested btw.
--
To view, visit https://review.coreboot.org/17945
To unsubscribe, visit https://review.coreboot.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: Ic6194cea4c4c430e0cf9d586052508a865b09c86
Gerrit-PatchSet: 4
Gerrit-Project: flashrom
Gerrit-Branch: staging
Gerrit-Owner: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-Reviewer: Stefan Tauner <stefan.tauner(a)gmx.at>
Gerrit-Reviewer: build bot (Jenkins)
Gerrit-HasComments: No