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

2860 Commits

Author SHA1 Message Date
Thomas Heijligen
d87fd9cf3d Makefile: Revise build options for Linux specific headers
Clean up the feature target by outsourcing the test to an own variable.
Change the print output and don't write to the build-details file.

This is in preparation for further changes.

Change-Id: I18fc27252afb49fa7d1f2787faee2b5b669275aa
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58627
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-11-07 16:59:40 +00:00
Thomas Heijligen
2dae0b764f Makefile: Revise utsname and clock_gettime test
Clean up the feature target by outsourcing the test to an own variable.
Change the print output and don't write to the build-details file.
HAS_CLOCK_GETTIME=no replaces DISABLE_CLOCK_GETTIME=yes

This is in preparation for further changes.

Change-Id: Ie1f43b3d5a8ad79bff3f9bbc21f359ec35abc42a
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58618
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-11-07 16:59:32 +00:00
Thomas Heijligen
47caa9ceb1 Makefile: compiler target: separate fixed text and value by a colon
Continue to use the "key: value" format like for the C compiler.
Use only shell code for TARGET_OS comparison.

Change-Id: I69959c20aa2e43ed67b3057c37e964a34cdab136
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58617
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-11-07 16:59:14 +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
Rob Barnes
211cec1d75 sb600spi: Cleanup spispeed and spireamode warnings
These warnings are printed at error level so they are displayed with
every invocation of flashrom. This clutters the flashrom output in the
usual case. Move warnings to debug level, add newline and clean up text.

TEST=Deploy to guybrush, observe messages are only seen when --verbose
is enabled
BUG=None
BRANCH=None

Change-Id: Idf5e735b9e504c943bf93a428da64976d723eb2c
Signed-off-by: Rob Barnes <robbarnes@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58529
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Raul Rangel <rrangel@chromium.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
2021-11-04 17:29:15 +00:00
Thomas Heijligen
36fa20d176 Makefile: Revise C compiler check
Clean up the compiler target by outsourcing the test to an own variable.
Change the print output and don't write to the build-details file.

This is in preparation for further changes.

Change-Id: I3d6f08ef030744c772b4ec0dc2c9e614fb90461d
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58616
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-11-01 14:25:46 +00:00
Thomas Heijligen
fac2bfe54c pony_spi: fix memory leak
Free data if sp_openserport() fails and pony_spi_init() returns early
with 1.

Change-Id: I11858bd0bdfe8b6d03af616fe4be4fb047b8dcd9
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58583
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2021-11-01 14:03:27 +00:00
Jack Rosenthal
b3df1390dc flashrom_tester: Use elogtool to list firmware eventlog
Mosys is dropping the eventlog command, in favor of the elogtool
command provided in coreboot.  The output is compatible with what
mosys used to output.

Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
Change-Id: I8c4be82fed28b6a19746e6b93fafce23bd8ede5d
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58527
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Ricardo Quesada <ricardoq@google.com>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
2021-10-27 09:12:31 +00:00
Thomas Heijligen
8d8281c3d6 Makefile: remove NEED_LIBUSB1 from FEATURE_CFLAGS
NEED_LIBUSB1 is not used outside of the Makefile. No need to pass it to
the compiler.

Change-Id: Ie7cb3df39daf22cb954186d38ba32812b05d92f9
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58518
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
2021-10-26 12:05:22 +00:00
Thomas Heijligen
9af6d11082 Makefile: meson.build: remove unused CONFIG_I2C_SUPPORT
CONFIG_I2C_SUPPORT has no mention in the source code. No need to pass
it to the compiler.

Change-Id: I2e19335e1b8d39f44dda14edc0a496dda6bc8c9c
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58495
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
2021-10-26 12:05:17 +00:00
Thomas Heijligen
5c538b40c2 Makefile, ich_descriptors_tool/Makefile: unify behavior
ich_descriptors_tool/Makefile: have the same behavior as the main
flashrom Makefile
  - only set gcc explicit on MinGW HOST_OS
  - don't fallback to gcc if CC was not set
  - set CFLAGS and EXEC_SUFFIX for TARGET_OS, not for HOST_OS

Change-Id: I353c3de250167994a4aea1edfef57d839e900d78
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58468
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-10-26 12:05:10 +00:00
Thomas Heijligen
694e2bf218 Makefile: unify the use of filter
Make a filter statement easier to read and fix some cosmetics.

Change-Id: I6cd1e169b435cadb06423836cd9d64cdd2f51a94
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58451
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2021-10-25 09:23:57 +00:00
Anastasia Klimchuk
99330d67b0 tests: Fix fread wrap to return success by default
Successful return value for fread is the number of items read, and
default behaviour for all wraps is to return success.

This worked previously because all existing tests have custom mocks
for fread, so default behaviour hasn't been used. However next patch
in this chain adds new test which needs default fread wrap.

BUG=b:181803212
TEST=ninja test

Change-Id: I17d82d281a87129843f547b87c18f52aca23314d
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58356
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-10-19 08:10:03 +00:00
Anastasia Klimchuk
92989f2496 tests: Add wrap for libusb_init and use it in dediprog test
Missing wrap for libusb_init has been discovered while working
on the test for raiden_debug_spi. Both dediprog (existing test) and
raiden_debug_spi (new test, see later in this chain) are using
libusb_init, so it definitely needs to be wrapped and added to io_mock.

Why tests worked before, without the wrap: my understanding is that
real libusb_init was called for dediprog test? Given that tests
definitely should not call any real libusb functions, wrap is needed.

BUG=b:181803212
TEST=builds and ninja test

Change-Id: I51c9cb96db1afb3298f4d098df96509d3cb3c046
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/57917
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-10-18 12:22:59 +00:00
Anastasia Klimchuk
a7a59cf0bb tests: Extract libusb wraps into separate file
In preparation for adding more tests with lots of libusb wraps,
existing wraps are extracted into separate file.

BUG=b:181803212
TEST=builds and ninja test

Change-Id: I17c1cc0189fcb742a99ad1b0fd615ab95504a74a
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/57916
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
2021-10-18 12:22:47 +00:00
Anastasia Klimchuk
97acc374e4 tests: Move current_io to io_mock.c be visible across tests
tests.c is growing and needs to be split, specifically all
libusb wraps need to be extracted into their own file. See later
in the chain a lot more wraps are added for libusb functions. To
be able to split it, current_io needs to be moved one level up,
to be visible across tests. This allows having multiple files with
wraps, and all the wraps can use current_io.

BUG=b:181803212
TEST=builds and ninja test

Change-Id: I5327b5de430afe13a8cc931c8b4b188dcb8c8cf6
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/57915
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-10-18 12:22:30 +00:00
Anastasia Klimchuk
83b5191399 tests: Move LOG_ME to include/tests.h to be available everywhere
LOG_ME macro is very generic and can be useful anywhere in tests.
Previously was only used in scope of tests.c. With time more tests
are added, and more files, LOG_ME needs to be visible everywhere.

BUG=b:181803212
TEST=builds and ninja test

Change-Id: If7f3d256161bc8b81e996328e445cccab9a82174
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/57914
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-10-18 12:22:23 +00:00
Anastasia Klimchuk
d23613cf66 tests: Add NON_ZERO macro and not_null function instead of MOCK_HANDLE
This patch adds NON_ZERO macro and not_null function into io_mock.h,
so that they can be used anywhere in tests. Common usage for not_null
is to indicate a valid pointer, where it doesn't matter what the
pointer is, only matters it is not null. Common usage of NON_ZERO is
to indicate a valid file descriptor, where it only matters the
descriptor is non-zero integer.

New features replace all usages of previous MOCK_HANDLE.

This patch corrects return value from __wrap_ioctl to be successful
by default. It used to be MOCK_HANDLE, but should be 0. Included in
this patch because this is also a replacement of MOCK_HANDLE.

BUG=b:181803212
TEST=builds and ninja test

Change-Id: I5ad6ee4aa9091447c6c9108c92bf7f6e755fca48
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/57269
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-10-18 12:22:12 +00:00
Thomas Heijligen
f42d2f72cc hwaccess: replace flashrom specific macros by compiler defines
Replace the remaining IS_* macros with the associated compiler defines

Change-Id: Ia0f022d12390722816066d292e1878824adc613c
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58280
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-10-15 14:37:20 +00:00
Thomas Heijligen
1379e54f51 buildsystem: evaluate the USE_IOPL, USE_DEV_IO, USE_IOPERM macros
Determine which macro has to be set for the target system.
Do this in the buildsystem instead of using preprocessor macros.

Change-Id: Ic41ea025e35feb93f07ce7a94c0d15e6e84f38b9
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58278
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2021-10-15 14:36:09 +00:00
Thomas Heijligen
c9d947576b buildsystem: handle the IS_WINDOWS macro
On Windows target systems set the IS_WINDOWS=1 macro by the buildsystem.

Change-Id: I334708f2dec08ec9ca6ad4161fbd7fe22ac023a6
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58277
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-10-15 14:36:00 +00:00
Thomas Heijligen
494180096c platform.h: remove IS_LINUX and IS_MACOSX macros
Replace the remaining uses by the plain macros.
Windows, Linux and MacOS are the only systems with explicit macros.

Only the Windows macro is used in several places. The others can easily
be handled like all other systems.

Change-Id: I23ec8fdcff8202d10ddf5a7520432e5b26b01cd4
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58276
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-10-15 14:35:52 +00:00
Thomas Heijligen
b583647888 buildsystem: Determine the endianness only in the buildsystem
Let the buildsystem (make / meson) handle the endianness determination
and set the __FLASHROM_LITTLE_ENDIAN__ or __FLASHROM_BIG_ENDIAN__ macro
as cflag.

Change-Id: I37093528ae55e712cc30a0267a8ceac332750e7d
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58273
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by:  Felix Singer <felixsinger@posteo.net>
2021-10-15 14:35:38 +00:00
Thomas Heijligen
ba1c5eb125 Makefile: copy determination test for the endian to Makefile.d
Copy the test code for endian detection in an extra directory to split
it from the main flashrom code.

Change-Id: I0c2420fd60d7d6a23c94c9962b06bfd7f3c86ad8
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58270
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2021-10-15 14:35:29 +00:00
Thomas Heijligen
cf542aa1ce Makefile: move determination test for the architecture to Makefile.d
Move the test code for architecture detection in a extra directory to
split it from the main flashrom code.

Change-Id: I29ce73be9c5cbe259a2471f8eea2f8745b68cdfa
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58269
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-10-15 14:35:12 +00:00
Thomas Heijligen
ba275d8bdb Makefile: move determination test for OS to Makefile.d
Move the test code for OS detection in a extra directory to split it
from the main flashrom code.

Change-Id: Id911f17f4100f242e1fde10d23a8459ddf38b369
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58015
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-10-15 14:35:05 +00:00
Thomas Heijligen
8da9a9acdf Makefile: move determination tests for target systems to one place
Change-Id: Ia1b3f0257aaeebb355700b65c51a2ba70b80d5ae
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58248
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-10-15 14:34:55 +00:00
Felix Singer
8c768c2191 serprog: Move content of programmer specific header to C file
Move the programmer specific code into serprog.c and remove its related
header file.

Change-Id: I5c65f43db200129489d487ff948daa08bd0e92fa
Signed-off-by: Felix Singer <felix.singer@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58300
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-10-15 14:31:34 +00:00
Felix Singer
638123045b gfxnvidia: Fix indents
Change-Id: I18f916923d3574dd8c68019e4db3985444dd7bee
Signed-off-by: Felix Singer <felix.singer@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58301
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Thomas Heijligen <src@posteo.de>
2021-10-15 14:31:24 +00:00
Thomas Heijligen
bb0a6447d9 Makefile: summarize systems with the same CPPFLAGS and LDFLAGS
Change-Id: I067430e52eb41bf0af4f08246bbe59117bc09bdb
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58247
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by:  Felix Singer <felixsinger@posteo.net>
2021-10-14 12:44:49 +00:00
Thomas Heijligen
155ce3d9a3 Makefile: use STRIP_ARGS = -s on all systems
Set -s (--strip-all) as STRIP_ARGS explicitly on all systems instead of
only on systems (SunOS / Solaris) where strip-all is not the default
behavior.

Change-Id: I2c80d553fb54d94bc65f07e700c90dd1bae4854e
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58246
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2021-10-14 12:12:28 +00:00
Felix Singer
29418b7479 util: Add Nix shell file
Add a Nix shell file which is able to compile flashrom.

Change-Id: I9757b952f4b034e98c2b4b70fbede52d8efb9d50
Signed-off-by: Felix Singer <felix.singer@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58012
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-10-10 16:02:10 +00:00
Anastasia Klimchuk
a2d09ca893 raiden_debug_spi: Use new API to register shutdown function
This allows programmer to register shutdown function in spi_master
struct, which means there is no need to call register_shutdown in init
function, since this call is now a part of register_spi_master.

As a consequence of using new API, two things are happening here:
1) No resource leakage anymore in case register_shutdown() would fail,
2) Fixed propagation of register_spi_master() return values.

BUG=b:185191942
TEST=test in CB:57918
(Nikolai) tested probe/read/write with a servo micro and puff board

Change-Id: I8927224779f24d1fda088991337e54d7272775a6
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: Nikolai Artemiev <nartemiev@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/57975
Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2021-10-10 10:25:06 +00:00
Anastasia Klimchuk
96b1a15bcc raiden_debug_spi: Move shutdown function above spi_master struct
This patch prepares the programmer to use new API which allows to
register shutdown function in spi_master struct. See also later
patch in this chain, where the programmer is converted to new API.

BUG=b:185191942
TEST=test in CB:57918

Change-Id: I567e24c9d39e24a4a1634ddcbdd05930760afcdc
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/57974
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-10-10 10:24:40 +00:00
Anastasia Klimchuk
f8999921ea raiden_debug_spi: Use spi data in configure_protocol
Spi data for this programmer now contains pointer to spi_master
struct, and can be used in configure_protocol.

This patch is making init code of raiden_debug_spi a bit more
consistent with other programmers, for example it allows to remove
data assignment `spi_config->data = data` from init function. This
assignment was only needed for configure_protocol function, and
now it is not needed anymore.

BUG=b:185191942
TEST=test in CB:57918

Change-Id: I5df0609efcd1fdb274b8cc84536253d5dbae5270
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/57973
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-10-10 10:24:33 +00:00
Anastasia Klimchuk
5a73eb7d1b raiden_debug_spi: Link spi_master struct to spi data
For this programmer, spi_master struct is dynamically allocated
and needs to be freed on shutdown. Adding a pointer to spi data
struct allows to link spi_master from spi data, which in turn allows
to pass spi data into shutdown function. As a result, both
register_spi_master and register_shutdown use the same data, and
this unblocks moving raiden_debug_spi to new API (like all the
other spi masters in commit a69c5196d20d136b1de120f0fa5ea1e06c3776da).

See further patches in this chain.

BUG=b:185191942
TEST=test in CB:57918

Change-Id: I5400802aa6961538df12fcd5339f7e2a5db145a1
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/57972
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-10-10 10:24:14 +00:00
Michael Niewöhner
7b9c74f496 ft2232_spi: reintroduce generic GPIOL control
This reintroduces a reworked version of the GPIOL pin control first
introduced in commit 3207844 (CB:49637), which was reverted in commit
6518cf3 (CB:55692) due to breakage.

This change introduces a new argument `gpiolX` to allow use of the four
GPIOL pins either as generic gpios or as additional CS# signal(s). `X`
specifies the GPIOL pin (0-3) to be set to one of [HLC] with the
following meaning:

 * H - set the pin as output high
 * L - set the pin as output low
 * C - use the pin as additional CS# signal

The third value, `C`, aims to replace the parameter `csgpiol`, that is
now marked as deprecated and can be removed at some point in the future.
`gpiol` and `csgpiol` are mutually exclusive and use of both results in
an error.

Multiple pins may be set by specifying the parameter multiple times.

Documentation was updated/added accordingly.

Test: All pin levels/modes have been verified to behave correctly with a
      logic analyzer.

Change-Id: I3989f0f9596c090de52dca67183b1363dae59d3a
Signed-off-by: Alan Green <avg@google.com>
Signed-off-by: Michael Niewöhner <foss@mniewoehner.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/57810
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-10-04 10:53:03 +00:00
David Hendricks
106f097ef6 ich_descriptors: Add explicit checks for all chipsets
This partially undoes changes made in commit cd9b7b427
(ich_descriptors: Normalize chipset detection) to re-add explicit
matching of each chipset with one or more strap length values.

Since ranges are checked explicitly, the `warn_if` parameter to
warn_peculiar_desc() is no longer necessary and is removed.

Change-Id: Ica49477492876810a6fa212768b1ab9e8c12001f
Signed-off-by: David Hendricks <ddaveh@amazon.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/57793
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-10-01 11:46:22 +00:00
Michael Niewöhner
86867eaa19 flashrom.8: carve out csgpiol into its own section
Documentation for `csgpiol` was put into the generic programmer options
section. Move it to its own section.

Change-Id: Ic7379331d36b3068eacde5a983b4ccb3afc56c51
Signed-off-by: Michael Niewöhner <foss@mniewoehner.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/57893
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
2021-10-01 11:39:23 +00:00
Michael Niewöhner
22ee33c39b ft2232_spi: prevent use of reserved pins on some programmers
On some programmers an output buffer needs to be enabled by pulling a
gpio high/low. This gpio can not be used for `csgpiol`. Prevent this by
printing an error.

Change-Id: Ied450fa5ef358153adefec3beabc63a62c9f60cd
Signed-off-by: Michael Niewöhner <foss@mniewoehner.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/57809
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2021-10-01 11:38:08 +00:00
Simon Buhrow
51a9c38fcc flashchips.c: mark EN25F10 as TEST_OK_PREW
As reported by Wolf Dieter Brandt in his e-mail from 09.Aug.2021.

Change-Id: I0c19f84780e7fa3699fd706f8e105fc5937ba8bf
Signed-off-by: Simon Buhrow <simon.buhrow@posteo.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58031
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
2021-10-01 11:36:21 +00:00
Anastasia Klimchuk
caf6e0dcb2 tests: Revise mock chip definition and usage
This patch is doing few things:

1) Makes chip definitions static global so that they can be
reused between test functions.

2) Promotes existing mock chip from 8KiB to 8MiB and eraseblocks
are expanded accordingly. Old value of 8KiB was very small and it
was confusing. Mock chip looks more realistic now.

3) Uses KiB and MiB macros from flash.h for mock chip definition

4) Renames CHIP_TOTAL_SIZE to MOCK_CHIP_SIZE to avoid confusion
(there is also a W25Q128.V chip in the tests)

5) Makes chip definitions const so that every test can work on a
fresh copy on the stack.

BUG=b:181803212
TEST=builds and ninja test

Change-Id: Ia9b5fc71e30610684e68e9aca9fb1970da8f840a
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/57437
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-10-01 11:35:03 +00:00
Anastasia Klimchuk
1f62b8346e tests: Add tests to read from chip
Two tests cover the code which performs do_read operation.

First one works with fake chip and dummy programmer. Fake chip has all
operations defined, and a buffer to emulate chip memory.

Second one uses the chip which is closer to the real one, because
read/write/unlock/erase operations are real. The tests takes the
advantage of dummyflasher's capability of emulating a W25Q128.V chip.

BUG=b:181803212
TEST=builds and ninja test

Change-Id: Ia57781ebc670c7bd6197e56fe8a20651a425c756
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/57326
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-10-01 11:28:57 +00:00
Anastasia Klimchuk
2d538d87eb tests: Extract setup and teardown for chip tests
Steps to setup and teardown for a chip test are repeated for every
test, so they can be extracted into their own functions.

BUG=b:181803212
TEST=builds and ninja test

Change-Id: If59315646f06344664df08b145866d9ce846d751
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/57436
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-10-01 11:28:41 +00:00
Angel Pons
724a24d702 nicintel_spi.c: Implement set_sck_set_mosi and set_sck_get_miso
Tested on a 8086:1533 (i210 GbE), reads still return the same data.
This cuts the time to read a Winbond W25Q80.V (1 MiB, SPI) from 66
seconds down to 48 seconds, i.e. a 37.5% increase in speed.

Change-Id: I52a0ae5ff331ee2ed41652eb5c2ed7ebe7253d74
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/49267
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-10-01 11:27:15 +00:00
David Hendricks
24495cd46e util/ich_descriptors_tool: Use GNU-style printf in MinGW
This allows MinGW targets to use certain printf formatting
identifiers such as "%v" by adding  -D__USE_MINGW_ANSI_STDIO=1 to
the CFLAGS. This is also done in flashrom's top-level Makefile.

Reported on https://github.com/flashrom/flashrom/issues/149

Change-Id: I644be8b5b607cc77b4be2121c443f0d41d8da687
Signed-off-by: David Hendricks <david.hendricks@gmail.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/43052
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
2021-10-01 11:22:05 +00:00
Thomas Heijligen
98b537befd ch341a: use better english in the debug message
Change-Id: Ib7f15aa36fedc6af990c3ca45e81547cbfde24a1
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58037
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
2021-10-01 11:12:36 +00:00
Angel Pons
1e2a5d8d8d dediprog.c: Split up compound conditional and swap two operations
register_spi_master now becomes the last operation in init function,
which is consistent with other spi masters.

In addition, the patch fixes propagation of register_spi_master return
values, which is also consistent with other spi masters.

TEST=ninja test

Change-Id: Ib7e0179da39279e32a8497466b044b69ec836da8
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/51706
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-10-01 11:11:11 +00:00
Thomas Heijligen
a16f6a5497 internal.c: unify the macro for x86 only code
The #if defined(__i386__) || defined(__x86_64__) guard is commonly used
for x86 only code across flashrom.
Only platform.h and hwaccess.* use the IS_X86 macro.

Change-Id: I94a599431f58666189c8cd601286e9b30c8bf62b
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/57942
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by:  Felix Singer <felixsinger@posteo.net>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2021-09-29 11:31:45 +00:00
Thomas Heijligen
61181a72a4 ch341a_spi: replace active kernel driver detaching by automatic one
Let libusb_claim_interface() handle the kernel driver detaching for us
by allowing automatic kernel driver detachment. Allow this on all
platforms.

Change-Id: If6f19744503055ab8e22c863b31e696808e0407d
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/57889
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
2021-09-29 11:09:44 +00:00