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

3377 Commits

Author SHA1 Message Date
Evan Benn
b41bb5622c flashrom_tester: Add _into_file to function names
Rename Flashrom trait function names to reflect that the data is read
to/from a file provided as an argument.

BUG=None
BRANCH=None
TEST=cargo test; cargo check

Change-Id: I0015c9bf64349a5512dbdb0ef6f3dad38aa2fd8e
Signed-off-by: Evan Benn <evanbenn@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66956
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
2022-08-26 04:46:47 +00:00
Edward O'Callaghan
1acef16895 realtek_mst_i2c_spi.c: Avoid premature initialisation
get_param()'s co-domain should either be well defined or
error and return. By prematurely initialising we can
obscure compiler warnings for unchecked error branches.

Change-Id: I50bb6db24bb74c6b492d6a0fad9d9225dbb650ac
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66911
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-08-25 18:59:17 +00:00
Nico Huber
907407830e ich_descriptors_tool/Makefile: Add missing override for CFLAGS
This allows to build `ich_descriptors_tool` with custom CFLAGS in the
environment.

Change-Id: If10f08e44141d05f0ee52615303652da576d2fc6
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66979
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-08-25 18:56:27 +00:00
Edward O'Callaghan
8f9e910eb3 parallel.c: Consoldiate parallel master registration logic
This is analogous to spi.c and opaque.c however parallel
logic was previously never consoldiated.

This free's up flashrom.c from namespace pollution.

BUG=b:242246291
TEST=builds with both make and meson.

Change-Id: Ie08e2e6c51ccef5281386bf7e3df439b91573974
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66651
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-08-25 00:29:00 +00:00
Edward O'Callaghan
16744f9e96 flashrom.c: Move write_buf_to_include_args() to cli_classic.c
The write_buf_to_include_args() helper is only ever used
by the cli frontend therefore make it static local to the
user.

BUG=b:242246291
TEST=builds

Change-Id: Ia16bf4b8e46a011aa45f98089d43904b077833a0
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66648
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:26:54 +00:00
Edward O'Callaghan
b2b154802b flashrom.c: Move read_buf_from_include_args() into cli_classic.c
The read_buf_from_include_args() helper is only ever used
by the cli frontend therefore make it static local to the
user.

BUG=b:242246291
TEST=builds

Change-Id: I9dee63d67320085e16c64eefb2723169f49f07aa
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66647
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:26:29 +00:00
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
Felix Singer
75b7455441 ichspi.c: Clean up get_ich_spi_mode_param()
Instead of checking for the variable arg in multiple compound
statements, separate it out in its own branch and return 0 if arg is
NULL.

Signed-off-by: Felix Singer <felixsinger@posteo.net>
Change-Id: Id1038568ff25cf6f0895b26921cc4a0d7bcfabb7
Reviewed-on: https://review.coreboot.org/c/flashrom/+/65248
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-08-24 20:54:07 +00:00
direstraits96
1b880756d4 Add support for motherboard Jetway P4MDPT
Add support for motherboard Jetway P4MDPT. According to the author of
this patch, reading and writing works.

Found on https://github.com/flashrom/flashrom/pull/241.

Change-Id: I494863389d2afdb745d5c83a99cd955e6a5c334d
Signed-off-by: Felix Singer <felixsinger@posteo.net>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/63919
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-08-24 10:03:40 +00:00
Adrien Destugues
43f8e021a4 nic3com: mark PCI id 9006 as supported
According to the author of this patch, this has been tested and it
worked.

Found on https://github.com/flashrom/flashrom/pull/219.

Change-Id: I88712d81b291c7ef4212bf19e284d270219fa908
Signed-off-by: Felix Singer <felixsinger@posteo.net>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/63920
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-08-24 10:02:32 +00:00
Edward O'Callaghan
80f1ea9a79 ichspi.c: Pack hwseq_data into opaque.data field
The hwseq_data struct remains to be a stack allocated
instance for now however it is referenced in the opaque_master
data field of the flash ctx. This allows for worker functions
that leverage hwseq_data state to derive state indirectly via
the flash ctx instead of directly upon the global state.

This allows for unblocking further work to finally dispense
with the stack allocation in favour of a heap allocation with
a defined life-time of the driver.

BUG=b:237839418
TEST=builds

Change-Id: I2ad57d496176cf26edcd0ba40154cc6250846e33
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/65205
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Alexander Goncharov <chat@joursoir.net>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-08-24 04:11:44 +00:00
Thomas Heijligen
73e28a7472 Makefile: print dependency versions
When a library is found, then print its version in the config target.

Change-Id: Ie1ff8107311247fba9e5caa252d559447c871867
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66695
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
2022-08-23 08:42:38 +00:00
Thomas Heijligen
e4137c6913 meson: Build the ich_descriptors_tool as feature
Provide the meson option `-Dich_descriptors_tool=auto/enable/disabled`
to determin if the ich_descriptors_tool should be build or not. On
`auto` or `enabled` it will be, on `disabled` it will not be build.
This is usefull for environments where the ich_descriptors_tool is not
needed.

Change-Id: Ief65a914019f72536d563eda36bd7f2f5330bea8
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66704
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
2022-08-23 08:41:54 +00:00
Thomas Heijligen
374871c039 tree: Check properly if libusb is initialized
The dediprog, developerbox_spi and stlinkv3_spi programmers only check
if the libusb_context is not NULL after the initialization. But
following the API documentation from libusb, the context is undefined
unless the init function returns 0. Fix this by checking the return
value instead of the libusb_context to see if the initialization was
successful.

https://libusb.sourceforge.io/api-1.0/group__libusb__lib.html

Change-Id: Ia45ccd3fa2239dfccd821be46a09c86426cb22e5
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66460
Reviewed-by: Felix Singer <felixsinger@posteo.net>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2022-08-23 08:40:50 +00:00
Evan Benn
7346cda9e9 flashrom_tester: Call crossystem with write protect argument
crossystem uses flashrom to gather data on some platforms. To avoid
firmware lock deadlock, call crossystem before initialising libflashrom.
When querying hardware write protect status, provide an argument to
crossystem so that only that field is queried. This also avoids the
deadlock, and improves performance.

BUG=b:239496316
BRANCH=None
TEST=on trogdor(arm), grunt(amd), hatch(intel):
TEST=flashrom_tester --libflashrom /usr/sbin/flashrom host Coreboot_ELOG_sanity
TEST=flashrom_tester /usr/sbin/flashrom host Coreboot_ELOG_sanity

Change-Id: I7d94cfc6ccbfbec91f12151eb0004724ccfc4e00
Signed-off-by: Evan Benn <evanbenn@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/65962
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
2022-08-23 01:14:28 +00:00
Alexander Goncharov
1d38651865 drkaiser: restore flash writing access state explicitly
Instead of using reversible write (rpci_write_word) that relies on
global state, do it manually. Save original PCI config space
register contents to programmer's structure during initialization
and restore it in programmer's shutdown.

TOPIC=reduce_global_pci_state
TEST=builds

Change-Id: Ie99a7cb3e049b29e6838dd4af587eee8c3b18919
Signed-off-by: Alexander Goncharov <chat@joursoir.net>
Ticket: https://ticket.coreboot.org/issues/389
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66838
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
2022-08-22 22:03:59 +00:00
Evan Benn
66b34f8ba3 bindings/rust: Document the rust bindings
Add an explanation of the two rust libraries, and instructions for
building. Note that the bindings are not included in the tarball.

BUG=None
BRANCH=None
TEST=None

Change-Id: I05b1b5821554f8faee7728f899d51b6e8e9bf5be
Signed-off-by: Evan Benn <evanbenn@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66618
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
2022-08-19 04:38:18 +00:00
Evan Benn
401d9bfa71 bindings/rust/libflashrom: Create fat rust binding
Create a rust library wrapping libflashrom-sys in a more idiomatic rust
API.

BUG=b:230545739
BRANCH=None
TEST=cargo test

Change-Id: Ie3bcfde40dc475f6a9439ccab8e2446967f7d6dd
Signed-off-by: Evan Benn <evanbenn@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/65281
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2022-08-19 04:37:43 +00:00
Evan Benn
06d32e1147 bindings/rust/libflashrom-sys: Create thin rust bindgen binding
Use bindgen to create a rust library that calls into libflashrom using
FFI.

BUG=b:230545739
BRANCH=None
TEST=cargo test

Change-Id: I36ba70de2bca8f83d2fdd6fd4c9b7c28a11624ee
Signed-off-by: Evan Benn <evanbenn@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/65280
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2022-08-19 04:37:21 +00:00
Evan Benn
6c1b0acc4c flashrom_tester: Fix cmd read_region to read only the region
read_region for the CLI implementation was writing a file the size of
the whole flash, with only the region filled with real data. Now write
only the region to the file. This fixes the Coreboot_ELOG_sanity test
which regressed in 4342cc0f14e2945d7642e75e44346c13ca23089b.

BUG=b:241486407
BRANCH=None
TEST=flashrom_tester /usr/sbin/flashrom host Coreboot_ELOG_sanity

Change-Id: I97ff8c71861f1d0282a7d6173e196e3d0b41d746
Signed-off-by: Evan Benn <evanbenn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/flashrom/+/3812722
Tested-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66588
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
2022-08-18 03:50:40 +00:00
Evan Benn
41d0de0ad8 flashrom_tester: Write a newline with the wp prompt
Write a newline after the hardware write protect prompt. Automated tests
read stdout and wait for this message, and split on newline, so write a
newline.

Also modify the function to not be recursive. Try to handle a closed
input correctly - panicing in that case. Behaviour is now to wait for
a newline instead of for 1 character.

BUG=b:240512896
BRANCH=None
TEST=tast run localhost:2222 firmware.FlashromTester
TEST=flashrom_tester < /dev/null
TEST=flashrom_tester; type some things, hold enter, then close stdin

Change-Id: I07ec242ca0d41787030d5d27fc88d78ed884d746
Signed-off-by: Evan Benn <evanbenn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/flashrom/+/3809595
Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66587
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
2022-08-18 03:49:35 +00:00
Nico Huber
cd4a62a784 spi25_statusreg: Fix checks for FEATURE_WRSR_EXT3
FEATURE_WRSR_EXT3 contains multiple bits, hence we need to check
for all of them.

Change-Id: I188911890361999cd8cca9b6405f57a91075f6b4
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reported-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66712
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-08-17 19:41:46 +00:00
Thomas Heijligen
99eca0899b cmocka: Drop as meson subproject
Depend exclusive on the cmocka package provided by the build
environment. Cmocka is widely available in Linux distributions and BSD
systems. Besides that, it is suboptimal to fetch own dependencies in the
build process. Most packaging systems even forbid fetching additional
assets at build time.

Change-Id: I751c85d5f72e47356113cf55dfbaec73cbd8028c
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66696
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: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
2022-08-17 18:49:59 +00:00
Thomas Heijligen
4ad591bcdc parade_lspcon: Rename PAGE_SIZE to avoid redefinition
PAGE_SIZE is defined in musl libc include/limits.h as _GNU_SOURCE
_BSD_DOURCE or _XOPEN_SOURCE

Change-Id: Ib6162f87f021f0085073253b73528bbe0737a48e
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66745
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: Peter Marheine <pmarheine@chromium.org>
2022-08-17 18:49:40 +00:00
Edward O'Callaghan
6a3988b6cd ichspi.c: Make ich_hwseq_wait_for_cycle_complete() take addr_mask as arg
Move towards functions depending less on globals.

BUG=b:237839418
TEST=builds

Change-Id: I7c02a33c0984f24efcaff967c496880d70922575
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/65204
Reviewed-by: Alexander Goncharov <chat@joursoir.net>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-08-15 12:45:59 +00:00
Edward O'Callaghan
456be2ad7a ichspi.c: Fix ich_hwseq_get_erase_block_size() type signature
Move towards functions depending less on globals.

BUG=b:237839418
TEST=builds

Change-Id: Id1de6eb184340b3cac8a6bdbb94c22c8e37d8d2c
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/65203
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
Reviewed-by: Alexander Goncharov <chat@joursoir.net>
2022-08-15 12:45:39 +00:00
Edward O'Callaghan
61f0206644 ichspi.c: Let ich_hwseq_set_addr() take addr_mask as a argument
Move towards functions depending less on globals.

BUG=b:237839418
TEST=builds

Change-Id: I891119fd9ed528f6b3578b7a84f66f1b058500e1
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/65202
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Alexander Goncharov <chat@joursoir.net>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-08-15 12:45:10 +00:00
Felix Singer
d4a46375da pickit2_spi.c: Use one variable to store raw parameter values
Currently, each programmer parameter has their own temp variable to
store their raw value into it. That's not needed since these variables
are only used for a short time to do some configuration and stay unused
then. Thus, use only one variable for all of them.

Signed-off-by: Felix Singer <felixsinger@posteo.net>
Change-Id: Ib4ebc0e6354aad007145e1b0a761d9011c59ff7c
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66571
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-08-14 23:49:58 +00:00
Felix Singer
fddcc379dc linux_spi.c: Use one variable to store raw parameter values
Currently, each programmer parameter has their own temp variable to
store their raw value into it. That's not needed since these variables
are only used for a short time to do some configuration and stay unused
then. Thus, use only one variable for all of them.

Signed-off-by: Felix Singer <felixsinger@posteo.net>
Change-Id: I31e0baa2c5800c722a9ba853bcd40d71ed343f6d
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66568
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-08-14 23:47:09 +00:00
Felix Singer
5c644d86ef linux_mtd.c: Rename variable param to param_str
Rename the variable param to param_str to indicate that this is the raw
string representation.

Signed-off-by: Felix Singer <felixsinger@posteo.net>
Change-Id: I78a207f11b964424a85e693f0004a33ee7de2e7e
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66567
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-08-14 23:42:17 +00:00
Felix Singer
a063073dc5 digilent_spi.c: Rename variable p to param_str
That's not a very meaningful name and it makes searching within the code
hard. Thus, rename the variable to `param_str`.

Signed-off-by: Felix Singer <felixsinger@posteo.net>
Change-Id: I88a78b612d4d2373943f8daa1b6b6d89329405c2
Reviewed-on: https://review.coreboot.org/c/flashrom/+/65928
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-08-14 23:41:26 +00:00
Felix Singer
a93c2e7d1e stlinkv3_spi.c: Use one variable to store raw parameter values
Currently, each programmer parameter has their own temp variable to
store their raw value into it. That's not needed since these variables
are only used for a short time to do some configuration and stay unused
then. Thus, use only one variable for all of them.

Signed-off-by: Felix Singer <felixsinger@posteo.net>
Change-Id: I548bb2e0786be0af20114e6bf1450c5fedb83d23
Reviewed-on: https://review.coreboot.org/c/flashrom/+/65910
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-08-14 23:39:54 +00:00
Felix Singer
bcdfcaf9b0 realtek_mst_i2c_spi.c: Use one variable to store raw parameter values
Currently, each programmer parameter has their own temp variable to
store their raw value into it. That's not needed since these variables
are only used for a short time to do some configuration and stay unused
then. Thus, use only one variable for all of them.

Signed-off-by: Felix Singer <felixsinger@posteo.net>
Change-Id: I48502161add9b59d97f5eeb46f5984c075ad924a
Reviewed-on: https://review.coreboot.org/c/flashrom/+/65909
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
2022-08-14 23:38:12 +00:00
Felix Singer
ca4608db6f sb600spi.c: Use one variable to store raw parameter values
Currently, each programmer parameter has their own temp variable to
store their raw value into it. That's not needed since these variables
are only used for a short time to do some configuration and stay unused
then. Thus, use only one variable for all of them.

Signed-off-by: Felix Singer <felixsinger@posteo.net>
Change-Id: I247012523c5e864ddb9e1e635df51e4311e5d5c5
Reviewed-on: https://review.coreboot.org/c/flashrom/+/65908
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-08-14 23:36:25 +00:00
Felix Singer
03bb6f77fb dediprog.c: Use one variable to store raw parameter values
Currently, each programmer parameter has their own temp variable to
store their raw value into it. That's not needed since these variables
are only used for a short time to do some configuration and stay unused
then. Thus, use only one variable for all of them.

Signed-off-by: Felix Singer <felixsinger@posteo.net>
Change-Id: I198c0da88bfc01fe15280cbd58d2ef27564c1dbc
Reviewed-on: https://review.coreboot.org/c/flashrom/+/65886
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2022-08-14 23:32:18 +00:00
Felix Singer
e6fec98ba3 dummyflasher.c: Remove unnecessary empty line
Signed-off-by: Felix Singer <felixsinger@posteo.net>
Change-Id: I28db5ec721e77a34396cd77fbe6ed85b38c7098e
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66569
Reviewed-by: Thomas Heijligen <src@posteo.de>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2022-08-14 23:22:26 +00:00
Felix Singer
f44a70ff8c cli_classic.c: Make use of bool type in the main function
Use the bool type instead of integer in the main function where
possible, since this represents the purpose of some variables much
better. Also, then we don't have to use the "!!" operator to turn any
number into one or zero, which is used as an equivalent to true and
false.

Also, since we have booleans and integers now, slightly change the
ordering of the variable declarations, so that the integers come before
the booleans.

Tested some parameters using the following commands:

flashrom -L

flashrom -p dummy

flashrom -p dummy:emulate=SST25VF040.REMS,image=foo2 -c "SST25LF040A" --progress -v foo1

flashrom -p dummy:emulate=SST25VF040.REMS,image=foo2 -c "SST25LF040A" --progress -w foo1

flashrom -p dummy:emulate=SST25VF040.REMS,image=foo2 -c "SST25LF040A" --progress -r foo1

flashrom -p dummy:emulate=SST25VF040.REMS,image=foo2 -c "SST25LF040A" --progress -E

Signed-off-by: Felix Singer <felixsinger@posteo.net>
Change-Id: I06572da040e12ac88f8e5fc39f60a9e212b86bd7
Reviewed-on: https://review.coreboot.org/c/flashrom/+/64564
Reviewed-by: Evan Benn <evanbenn@google.com>
Reviewed-by: Thomas Heijligen <src@posteo.de>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Alexander Goncharov <chat@joursoir.net>
2022-08-14 22:28:26 +00:00
Evan Benn
9944a8a8a7 MAINTAINERS: Add Evan Benn for flashrom_tester
BUG=None
BRANCH=None
TEST=../coreboot/util/scripts/get_maintainer.pl -f util/flashrom_tester/build.rs

Change-Id: Ibc7f77b7f8ba2f078d7edf47843a0d7cb288ab9e
Signed-off-by: Evan Benn <evanbenn@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66624
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2022-08-14 22:25:44 +00:00
Thomas Heijligen
edb5198d24 Makefile: Fix build for Windows
Mark programmers requiring RAW_MEM_ACCESS, X86_IO_PORT and X86_MSR as
unsupported on Windows

TEST=Buils on Cygwin (Windows 11, amd64, gcc 11.3.0)

Change-Id: If70691a9eae40c394a06d11349bedefa40586f4a
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66546
Reviewed-by: Felix Singer <felixsinger@posteo.net>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2022-08-12 17:37:09 +00:00
Felix Singer
1392a08c50 tests/realtek_mst_i2c_spi.c: Fix macro closing comment
Signed-off-by: Felix Singer <felixsinger@posteo.net>
Change-Id: I7b130c58305f4a8b2afbfdb7dcead9d6535d98af
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66509
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-08-10 23:53:56 +00:00
Anastasia Klimchuk
e18a528c6b tests: Test allow_brick is required for i2c programmers init
Add tests for i2c programmers that assert that initialisation fails
when allow_brick parameter is not provided.

Example of logs from test run:

[ RUN      ] parade_lspcon_no_allow_brick_test_success
Testing init error path for programmer=parade_lspcon with params: bus=254 ...
... init failed with error code -1 as expected
[       OK ] parade_lspcon_no_allow_brick_test_success

BUG=b:181803212
TEST=ninja test

Change-Id: I382f563016502f3342131d5f9c0de41dc665b03a
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66508
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-08-10 23:53:11 +00:00
Anastasia Klimchuk
4adfd99d78 tests: Add function to test programmer init error paths
New function tests an error path for programmer initialisation,
and expects programmer init to fail with given error code.

BUG=b:181803212
TEST=ninja test

Change-Id: Icc59396e604d74442852b4bbd575440df3347c3f
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66507
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-08-10 23:53:00 +00:00
Alexander Goncharov
02f43e89ba atahpt: restore flash access state explicitly
Instead of using reversible write (rpci_write_long) that relies on
global state, do it manually. Save original PCI config space
register contents to programmer's structure during initialization
and restore it in programmer's shutdown.

TOPIC=reduce_global_pci_state
TEST=builds

Change-Id: I9996bb4d71801034e66ba0c233846e19fa29224d
Signed-off-by: Alexander Goncharov <chat@joursoir.net>
Ticket: https://ticket.coreboot.org/issues/389
Reviewed-on: https://review.coreboot.org/c/flashrom/+/65386
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-08-09 23:19:15 +00:00
Felix Singer
db026ea281 test_build.sh: Build all programmers individually using Make
While testing CB:63724, which reworks the Meson build system, it showed
that some programmers have dependency issues, which were invisible since
test_build.sh builds flashrom with all programmers enabled and thus all
sources are included. Building flashrom with each programmer
individually made these issues visible.

However, as commit 877b7741fcf9 and commit b6a439e45ef2 show, the Make
build system also had some similar issues, which were invisible for the
same reason.

Thus, in addition to building all programmers at once using the Make
build system, build each programmer individually.

Also, when clang analyzer is used, it's not needed to run it on each
programmer individually. Just return after flashrom was built with all
programmers enabled in this case.

An equivalent patch for the Meson build system is made separately.

Signed-off-by: Felix Singer <felixsinger@posteo.net>
Change-Id: I3bacb3ba9c6708f1e7ef5a111290d0ea3af36f1d
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66094
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2022-08-09 21:28:22 +00:00
Veronika Kremneva
ce971c6ce4 Makefile.d/arch_test.h: Add detection for ARC64 architecture
Change-Id: I8707394871994f600b345d76614c5689fd081db4
Signed-off-by: Veronika Kremneva <kremneva@synopsys.com>
Signed-off-by: Felix Singer <felixsinger@posteo.net>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/63896
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2022-08-09 14:16:06 +00:00
Anton Samsonov
bd72307a46 Makefile: Add support for Elbrus (e2k) architecture
Signed-off-by: Anton Samsonov <devel@zxlab.ru>
Change-Id: Ifc834e943ae93c59447afc86454b22ca662d3ef6
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66426
Reviewed-by: Thomas Heijligen <src@posteo.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2022-08-09 11:38:18 +00:00
Thomas Heijligen
ef4eb1714b Makefile: fix rebuild issues
Flashrom does no longer rebuild everything if `make` is executed.
Now the rule  config  will run, if needed, before any ‘.o’ is built,
but no ‘.o’ will be built because there is no config file.

https://www.gnu.org/software/make/manual/make.html#Prerequisite-Types

Change-Id: Ie9225b79c0eb27cb041654d703cde5efc769cbf2
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66130
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
Reviewed-by: Idwer Vollering <vidwer@gmail.com>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2022-08-09 09:34:37 +00:00