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

413 Commits

Author SHA1 Message Date
Edward O'Callaghan
c9ebfad95f flashrom.c: Move write_buf_to_file() to helpers_fileio.c
Constructing a written file from a buffer is auxiliary
functionality to the core flashrom algorithms. Move
aside to decrease the overall complexity of flashrom.c

BUG=b:242246291
TEST=builds

Change-Id: Ib613e74597d4bdd689043ba93aeb6a87ec80cc14
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66646
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Evan Benn <evanbenn@google.com>
Reviewed-by: Sam McNally <sammc@google.com>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-08-25 00:25:41 +00:00
Edward O'Callaghan
3c1aa889d8 flashrom.c: Move read_buf_from_file() to helpers_fileio.c
Constructing a buffer from a read file is auxiliary
functionality to the core flashrom algorithms. Move
aside to decrease the overall complexity of flashrom.c

BUG=b:242246291
TEST=builds

Change-Id: Ia6e1eeb876722899defb5b75346d1f22c70bfbd1
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66645
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Evan Benn <evanbenn@google.com>
Reviewed-by: Sam McNally <sammc@google.com>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-08-25 00:25:12 +00:00
Edward O'Callaghan
eb1b1f6f7d flashrom.c: flatten out write_buf_to_include_args()
write_buf_to_include_args() does not need the whole flashctx,
rather it works with a fix layout and buffer. Just pass what
state is actually required.

BUG=b:242246291
TEST=builds

Change-Id: I885c4395356eef27746c66300233f07f4718ccdf
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66644
Reviewed-by: Evan Benn <evanbenn@google.com>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
Reviewed-by: Sam McNally <sammc@google.com>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-08-25 00:21:53 +00:00
Edward O'Callaghan
ac7f0c20b8 flashrom.c: flatten out read_buf_from_include_args()
read_buf_from_include_args() does not need the whole flashctx,
rather it works with a fix layout and buffer. Just pass what
state is actually required.

BUG=b:242246291
TEST=builds

Change-Id: Ieadd68895c7ba05cc3d770d304351b02622f14d7
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66633
Reviewed-by: Evan Benn <evanbenn@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
Reviewed-by: Sam McNally <sammc@google.com>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-08-25 00:21:22 +00:00
Chinmay Lonkar
1bb5ddde60 Add str extension to extract_programmer_param function name
This patch changes the function name of extract_programmer_param() to
extract_programmer_param_str() as this function name will clearly
specify that it returns the value of the given parameter as a string.

Signed-off-by: Chinmay Lonkar <chinmay20220@gmail.com>
Change-Id: Id7b9fff4d3e1de22abd31b8123a1d237cd0f5c97
Reviewed-on: https://review.coreboot.org/c/flashrom/+/65521
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-07-02 14:34:19 +00:00
Aarya Chaumal
7db2baa77d flashrom.c, flashcips.c: Test the order of erase functions
Add a check so that the erase functions for all flashchips are in
increasing order of their respective eraseblock sizes. This is required
for the implentation of the improved erasing algorithm. The patch uses
the count of eraseblocks in each erase function to determine the order
(More eraseblocks means that the function has smaller eraseblock size).
Also fix the structs in flashchips.c which were found to be not
conforming to this test.

TEST = make && ./flashrom

Change-Id: I137cb40483fa690ecc6c7eaece2d9d3f7a851bb4
Signed-off-by: Aarya Chaumal <aarya.chaumal@gmail.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/64961
Reviewed-by: Thomas Heijligen <src@posteo.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2022-06-20 10:34:43 +00:00
Nikolai Artemiev
b86ae179ad flashrom: initialize restore func count in correct place
Set `flash->chip_restore_fn_count` to zero before calling the chip's
unlock funciton in `prepare_flash_access()`.

Previously `flash->chip_restore_fn_count` was uninitialized before
calling `chip->unlock()` and subsequently reset after the dispatch by
initializing it. This caused the restore handler that is registered
within `spi_disable_blockprotect_generic()` to be lost.

BUG=b:228945411
BRANCH=none
TEST=enable wp; flashrom -w; check wp still enabled.

Change-Id: I4c7df424bd2ae2b5fb2a2ab6b47a3c9ff3233acf
Signed-off-by: Nikolai Artemiev <nartemiev@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/63881
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
2022-05-23 00:24:32 +00:00
Edward O'Callaghan
9d869c447d flashrom.c: Make need_erase() helper static local
The need_erase() helper is only used within flashrom.c

Change-Id: Ic0946bb109fca2fc18e15eefa11cccea284ded0b
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/64369
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-by: Thomas Heijligen <src@posteo.de>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
2022-05-17 02:20:34 +00:00
Edward O'Callaghan
086f0c8e4f flashrom: Drop read_flash_to_file() usage
Aspire towards a goal of making cli_classic more of just
a user of libflashrom than having quasi-parallel paths in
flashrom.c

This converts remaining read_flash_to_file() usage to the
do_read() provider wrapper around libflashrom.

BUG=b:208132085
TEST=`
sudo ./flashrom -p ft2232_spi:type=232H,divisor=1000 -f -r out -c W25X05
Flashrom output:

No EEPROM/flash device found.
Force read (-f -r -c) requested, pretending the chip is there:
Assuming Winbond flash chip "W25X05" (64 kB, SPI) on ft2232_spi.
Please note that forced reads most likely contain garbage.
Block protection could not be disabled!
Reading flash... done.
Data read:

xxd out-1khz
00000000: 0000 07ff ffff e000 0000 7fff fffe 0000  ................
00000010: 0007 ffff ffe0 0000 007f ffff fe00 0000  ................
00000020: 07ff ffff e000 0000 7fff fffe 0000 0007  ................
00000030: ffff ffe0 0000 007f ffff fe00 0000 0fff  ................
xxd out-100khz
00000000: b6db 6db6 db6d b6db 6db6 db6d b6db 6db6  ..m..m..m..m..m.
00000010: db6d b6db 6db6 db6d b6db 6db6 db6d b6db  .m..m..m..m..m..
00000020: 6db6 db6d b6db 6db6 db24 9249 2492 4924  m..m..m..$.I$.I$
00000030: 9249 2492 4924 9249 2492 4924 9249 2492  .I$.I$.I$.I$.I$.
`

Change-Id: I4b690b688acf9d5deb46e8642a252a2132ea8c73
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Tested-by: Nikolai Artemiev <nartemiev@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/59291
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2022-05-13 02:34:43 +00:00
Evan Benn
1866deb06d libflashrom: Move documentation to header
The doxygen documentation was in the libflashrom.c file. Move the
documentation to the libflashrom.h file. This allows foreign function
interface binding generators (eg rust bindgen) that operate on the .h
file to generate documentation for the target language. Some doxygen
errors were also corrected, mostly undocumented or wrongly labeled
parameters.

To test, I have diffed and inspected the doxygen documentation before
and after the change. All functions are documented the same, and the
structs and enums are now also included in the docs.

Change-Id: I856b74d5bfea13722539be15496755a95e701eea
Signed-off-by: Evan Benn <evanbenn@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/63903
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
2022-05-06 01:00:37 +00:00
Martin Roth
0f388acaba Global cleanup: Fix a few spelling errors
Just a trivial patch to fix a few errors found by codespell.

Here's the command I used:
codespell -S subprojects,out \
-L fwe,dout,tast,crate,parms,claus,nt,nd,te,truns,trun

Signed-off-by: Martin Roth <gaumless@gmail.com>
Change-Id: I4e3b277f220fa70dcab21912c30f1d26d9bd8749
Reviewed-on: https://review.coreboot.org/c/flashrom/+/62840
Reviewed-by: Felix Singer <felixsinger@posteo.net>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Elyes Haouas <ehaouas@noos.fr>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2022-05-03 05:23:23 +00:00
Thomas Heijligen
d200173a1d flashrom.c: remove unused include
getopt.h is only needed in cli_classic.c

Change-Id: I09b3233a128582bc98c5af77b6c89bd49984800e
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/63412
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
2022-04-13 11:46:58 +00:00
Thomas Heijligen
a2be4c9dc6 print_buildinfo: remove unreachable print of libpci version
The libpci header is neither directly nor indirectly included in
flashrom.c. `PCILIB_VERSION` is therefore never set and the following
print statement is dead code. Since libpci is the only library in
buildinfo, Drop it.

Change-Id: I0b5dbf3bd82a2ffe64b73881383e92f7dad4c382
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/62833
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2022-04-13 11:31:03 +00:00
Edward O'Callaghan
55aa056c74 flashrom.c: Move do_*() helpers into cli_classic.c
These helpers are only used by the CLI logic and so we localise
them here to move towards cli_classic being a pure libflashrom
user.

BUG=b:208132085
TEST=`make`

Change-Id: If1112155e2421e0178fd73f847cbb80868387433
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/60070
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2022-01-27 04:48:13 +00:00
Edward O'Callaghan
103b139cf7 flashrom.c: Make {read,write}_buf_from_include_args() public
This allows for moving all the do_*() helper functions
use for the cli from flashrom.c within static local functions
in cli_classic.c

BUG=b:208132085
TEST=`make`

Change-Id: Ia0abec655a682ca449d0e8ba620886a2d616b86d
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/60069
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2022-01-27 04:46:54 +00:00
Edward O'Callaghan
35547ed3af flashrom: Convert do_read() into a libflashrom user
Aspire towards a goal of making cli_classic more of just
a user of libflashrom than having quasi-parallel paths in
flashrom.c

This converts the do_read() provider wrapper into a pure
libflashrom user.

BUG=b:208132085
TEST=`$ sudo ./flashrom -p internal -r /tmp/bios.bin`
TEST=`$ sudo ./flashrom -p internal -l /tmp/layout -i FOO -r /tmp/foo.bin`

Change-Id: Id2addadb891c482ee3f69da806062d7a88776675
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/60430
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2022-01-22 00:05:24 +00:00
Edward O'Callaghan
7a2d7efd83 cli_classic.c: Convert do_erase() to libflashrom call
Inline emergency_help_message() to cli_classic call site.
This leaves do_erase() a redudant wrapper and moves us a step
closer to cli_classic as a pure libflashrom user by using
flashrom_flash_erase().

BUG=b:208132085
TEST=`flashrom -E`

Change-Id: I8566164e7dbad69cf478b24208014f10fb99e4d0
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/60068
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2022-01-22 00:04:00 +00:00
Daniel Campello
f136a2a69c flashrom.c: extract operation only uses layout files
This change fixes a bug on handling the extract operation. The extract
operation reads out the layout regions to filenames corresponding to the
respective layout region names.  read_flash_to_file() does this work via
write_buf_to_include_args(). This change makes the call to
write_buf_to_file() optional as it is still required for -r (read
operation) but not for -x (extract operation).

BUG=b:209512852
TEST=flashrom -x

Fixes: commit ce983bccaab450d358854494f15c2d8a1846d56b
Change-Id: Ibc9a4e2966385863345f06662521d6d0e4685121
Signed-off-by: Daniel Campello <campello@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/59921
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
2022-01-21 04:50:19 +00:00
Thomas Heijligen
64b9e3f59e hwaccess: move mmio functions into hwaccess_physmap
The mmio_le/be_read/writex functions are used for raw memory access.
Bundle them with the physmap functions.

Change-Id: I313062b078e89630c703038866ac93c651f0f49a
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/61160
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2022-01-20 16:51:01 +00:00
Thomas Heijligen
b8f364bece physmap: rename to hwaccess_physmap, create own header
Line up physmap with the other hwaccess related code.

Change-Id: Ieba6f4e94cfc3e668fcb8b3c978de5908aed2592
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/60113
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-12-22 22:53:47 +00:00
Edward O'Callaghan
43f998274f flashrom.c: Validate before allocate in verify_range()
Simplify a goto away for free'ing a buffer by validating
before attempting to allocate.

BUG=none
TEST=builds

Change-Id: Iae886f203d1c59ae9a89421f7483a4ec3f747256
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/59372
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2021-12-15 13:54:09 +00:00
Simon Buhrow
04a9243f08 flashrom.c: Delete obsolete comment
Change-Id: Ibd53fe34c05f87d7ecc0d6eee6463f9da3a174d4
Signed-off-by: Simon Buhrow <simon.buhrow@posteo.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58742
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
2021-11-07 14:46:11 +00:00
Angel Pons
7d42fb38ff Replace freenode references
The flashrom project no longer uses freenode. To avoid having outdated
man pages in the future, the contact methods are now listed in the wiki.

Change-Id: I75e8f43c50dc4c3feede0250334a877cdaac8103
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/56031
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
2021-07-21 22:56:53 +00:00
Edward O'Callaghan
9420043986 flashrom.c: Reorder read_by_layout() to avoid forward decl
Help make groking flashrom.c fractionaly easier.

BUG=none
BRANCH=none
TEST=builds

Change-Id: Ifd6c152e3a1d84b59a876997e543127387f24d40
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/56297
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2021-07-16 02:10:54 +00:00
Edward O'Callaghan
9fa68b0cfd flashrom.c: Reorder check_block_eraser() to avoid forward decl
Help make groking flashrom.c fractionaly easier.

BUG=none
BRANCH=none
TEST=builds

Change-Id: I0906a6e581ce5135b58f6acc6339908dfa770a59
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/56296
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2021-07-16 02:10:40 +00:00
Edward O'Callaghan
4ebe65c733 flashrom.c: Make extract_param() static local
The function is only ever used within flashrom.c.

BUG=none
BRANCH=none
TEST=builds

Change-Id: I81f1cdb9df98c151201390edeb69c74defe7881f
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/56295
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2021-07-16 02:10:07 +00:00
Nico Huber
7f48053172 layout: Rework normalize_romentries() API
Rename it to layout_sanity_checks() as that is what it does and
let it work on the currently active layout instead of the global
layout.

Change-Id: Ifae3480d4bd68c939c291f05734544e93f00306c
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/54285
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2021-06-26 15:59:00 +00:00
Nico Huber
78d9c7d02c layout: Drop count parameter of flashrom_layout_new()
Change-Id: I22c180c9971068b1ae101845ce88484c6842b852
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/33544
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2021-06-26 15:57:21 +00:00
Nico Huber
a1afc84156 Pass layout directly to verify_by_layout()
It used the current layout from the flash context, before. This made
it necessary to replace the pointer on-the-fly. Passing the layout
directly, works without that stunt.

Change-Id: Id496deec85c18bdfe968df6a798b626eb9cfbed5
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/33520
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2021-06-26 15:55:57 +00:00
Nico Huber
c32c8dc8af layout: Introduce flashrom_layout_new()
It initializes an empty layout. Currently the maximum number of entries
has to be specified, which will vanish once we use dynamic allocation
per entry.

We replace the two special cases `single_layout` and `ich_layout` with
dynamically allocated layouts. As a result, we have to take care to
release the `default_layout` in a flashctx once we are done with it.

Change-Id: I2ae7246493ff592e631cce924777925c7825e398
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/33543
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
2021-06-26 15:54:51 +00:00
Nico Huber
f394fcec0d layout: Introduce flashrom_layout_add_region()
Adds a region to an existing layout, as long as there is space.

Change-Id: I50d473d0d5d1fb38bd6f9ae3d7127e9ea66a94e1
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/33517
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2021-06-26 15:54:22 +00:00
Nico Huber
7ebd578100 layout: Add capacity field
Use it to keep track of the size of the `entries` array. An interim
solution until we have dynamic allocation.

Change-Id: Ib5f431bc0a72a79a53fa1376c3417942b19dd3a0
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/33516
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2021-06-26 15:53:31 +00:00
Thomas Heijligen
2376ccf00a enum programmer: not needed anymore. Remove
Change-Id: I53cdb160616911a4beea6b5e8e56d582621818a4
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/55124
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
2021-06-10 12:53:40 +00:00
Thomas Heijligen
5d25f04fd5 programmer_init: use struct programmer_entry*
Change-Id: Iacf0f25abc94a84c5d52c8d69a3e8640817b060a
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/55121
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-06-10 12:52:13 +00:00
Thomas Heijligen
4bb086423c flashrom.c libflashrom.c: replace enum programmer with size_t
Using size_t since programmer_table_size uses ARRAY_SIZE which returns
size_t.

Change-Id: Id2ad9630fbc41e98d182768b553788e069fa5095
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/55120
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-06-10 12:52:00 +00:00
Thomas Heijligen
dd8b8d5289 flashrom.c: replace enum programmer with struct programmer_entry*
Change-Id: I478c56354d5f482010bfe1560489700bc889717a
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/55119
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-06-10 12:51:49 +00:00
Thomas Heijligen
e14b2ec65c programmer_table: replace PROGRAMMER_INVALID with programmer_table_size
Change-Id: Icaaeefe001de604df9d7fdd06f05a5ed39fdbd84
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/55117
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-06-10 12:49:28 +00:00
Angel Pons
f41d24823c treewide: Drop unnecessary uses of memset/memcpy
Simply provide an initialiser or use a direct assignment instead.

Change-Id: I07385375cd8eec8a95874001b402b2c17ec09e09
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/55267
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-06-09 16:07:45 +00:00
Angel Pons
3bd47524c0 treewide: Drop most cases of sizeof(struct ...)
Spelling out the struct type name hurts readability and introduces
opportunities for bugs to happen when the pointer variable type is
changed but the corresponding sizeof is (are) not.

TEST=`make CONFIG_EVERYTHING=yes CONFIG_JLINK_SPI=no VERSION=none -j`
with and without this patch; the flashrom executable does not change.

Change-Id: Icc0b60ca6ef9f5ece6ed2a0e03600bb6ccd7dcc6
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/55266
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
2021-06-09 16:03:30 +00:00
Thomas Heijligen
dee884ebc5 programmer_table: convert entries to pointers
Allows us to move the individual entries into their respective driver files.

Change-Id: Ifbb0ee4db5a85b1cd2afeafe4dca838579f79878
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/52945
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-06-09 15:46:00 +00:00
Thomas Heijligen
9e09095877 programmer_table: move array content to an own file
Change-Id: I8e6d704e845ee4152c8676dd19dff0934fff007b
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/52944
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2021-06-09 15:44:53 +00:00
Thomas Heijligen
113f3bca1e programmer_table: add table size constant
Makes the array size known to other compilation units.

Change-Id: Idacb4b7b0dd98af8bc7cbecf567d33daafb4b24d
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/55116
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2021-06-09 15:44:33 +00:00
Thomas Heijligen
9cf3f8925b programmer_table: remove null termination
The {0} object at the end of programmer_table which corresponds
to PROGRAMMER_INVALID has no use in current code.

Change-Id: Ib63c2d2941f23a0788e26e5a5feb25d8669acb42
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/55115
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-06-09 15:44:05 +00:00
Daniel Campello
ce983bccaa cli_classic.c: add -x option for do_extract()
This change introduces a new option to extract all layout regions to
files with the name of each region (or with the provided filename via
-i region:file). It is implemented by mutating the flash layout to
include all regions and backfilling the entry->file with entry->name
(replacing spaces with underscores)

Signed-off-by: Daniel Campello <campello@chromium.org>
Change-Id: I8c69223fa92cf5b50abe070f1ab9f19d3b42f6ff
Reviewed-on: https://review.coreboot.org/c/flashrom/+/52450
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
2021-05-02 23:45:43 +00:00
Daniel Campello
d4063bf3a7 flashrom.c: allow - as filename for stdin
Allows - as filename for -w/-v options. It is sometimes useful to
script flashrom and allowing it to work with pipes allows for more
flexibility in this specific use-case.

Signed-off-by: Daniel Campello <campello@chromium.org>
Change-Id: I97889cfdf7ba9a257e182c4ee2b20075cfa58d4d
Reviewed-on: https://review.coreboot.org/c/flashrom/+/52383
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
2021-04-29 23:53:21 +00:00
Daniel Campello
45d50a101e layout: Add -i <region>[:<file>] support
Add an optional sub-parameter to the -i parameter to allow building the
image to be written from multiple files. This will also allow regions to
be read from flash and written to separate image files.

This is a rebase of a patch that was ported from chromiumos. A lot of
things have changed, but the idea is the same.

Original patch by Louis Yung-Chieh Lo <yjlou@chromium.org>:
Summary: Support -i partition:file feature for both read and write.
Commit: 9c7525f
Review URL: http://codereview.chromium.org/6611015

Ported version by Stefan Tauner <stefan.tauner@student.tuwien.ac.at>
and Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>:
Summary: [PATCH 2/6] layout: Add -i <region>[:<file>] support.
Review URL: https://mail.coreboot.org/pipermail/flashrom/2013-October/011729.html

Change-Id: Ic5465659605d8431d931053967b40290195cfd99
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Signed-off-by: Stefan Tauner <stefan.tauner@student.tuwien.ac.at>
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Signed-off-by: Daniel Campello <campello@chromium.org>
Co-Authored-by: Edward O'Callaghan <quasisec@google.com>
Co-Authored-by: Daniel Campello <campello@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/23021
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Sam McNally <sammc@google.com>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
2021-04-27 23:41:53 +00:00
Edward O'Callaghan
aaf1c60043 flashrom.c: Fix up stale FIXME comment when doit() was removed
Once upon a time flashrom had a entry point function called
doit(). Excise the last mention of it here so that we may
never mention it again.

BUG=none
TEST=none

Change-Id: I40d815b7154456c323b4230cd3fed2cc2e8e3641
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/52365
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
2021-04-20 02:19:52 +00:00
Nikolai Artemiev
f745d0e6ab flashrom.c: implement chip restore callback registration
Allows drivers to register a callback function to reset the
chip state once programming has finished. This is used by
the s25f driver added in a later patch, which needs to change
the chip's sector layout to be able to write to the entire flash.

Adapted from cros flashrom at
`9c4c9a56b6a0370b383df9c75d71b3bd469e672d`.

BUG=b:153800073
BRANCH=none
TEST=builds

Change-Id: I2a522dc1fd3952793fbcad70afc6dd43850fbbc5
Signed-off-by: Nikolai Artemiev <nartemiev@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/47276
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2020-12-03 12:29:41 +00:00
Edward O'Callaghan
f95cc8f9f6 flashrom.c: Correct "raiden_debug_spi" drv name
Unfortunately raiden_debug was upstreamed with a slightly
incorrect name of "raiden_debug" whereas in ChromiumOS
it is known as "raiden_debug_spi" and so correct this to
align. This avoids confusion and divergence for a unified
future.

Change-Id: I0eca35863403c5d4adbe19b31801e8dfa072006f
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/48106
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Sam McNally <sammc@google.com>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
2020-11-30 23:26:57 +00:00
Edward O'Callaghan
732f2eeddb raiden_debug: Rename with '_DEBUG_SPI' suffix
Unfortantly raiden_debug was upstreamed with a misnaming
of the CONFIG_ make param that introduces unnecessary divergence.
Rename to 'CONFIG_RAIDEN_DEBUG_SPI' as-is downstream.

Change-Id: I07c03647c329286bb223e4dae4665704e508db2c
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/48105
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Sam McNally <sammc@google.com>
2020-11-28 04:44:22 +00:00