aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Makefile: move functions and macros to own fileThomas Heijligen2021-09-282-197/+215
| | | | | | | | | | | | | Move all define statements in its own file to tidy up the main Makefile. Change-Id: I451f2eeab2773982e02b2f2fdc9e8abe1cc87630 Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de> Reviewed-on: https://review.coreboot.org/c/flashrom/+/57935 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Felix Singer <felixsinger@posteo.net>
* custom_baud: move Linux specific code into own fileThomas Heijligen2021-09-284-47/+69
| | | | | | | | | | | Handle system specific code in an own file like i2c_helper_linux.c. The build system decides when to build it. Change-Id: I0744e769dcc6000483e7256105903a87e927ee77 Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de> Reviewed-on: https://review.coreboot.org/c/flashrom/+/57990 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
* os.h: remove unneeded includeThomas Heijligen2021-09-271-2/+0
| | | | | | | | | | | No symbol from platform.h is used in os.h Change-Id: Ia8f463ab8f9f064fe79f5ee0840b851ae497a080 Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de> Reviewed-on: https://review.coreboot.org/c/flashrom/+/57936 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Felix Singer <felixsinger@posteo.net> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
* ft2232_spi: clarify the comment about gpio configurationMichael Niewöhner2021-09-261-2/+5
| | | | | | | | | | | | | The comment explaining gpio levels might be easily misunderstood when the reader misses the word `output`. Add an explicit description of handling of the GPIOL* pins to avoid that and make things even more clear. Change-Id: Iaceec889a65ead8cdde917f61b2a9695d440f781 Signed-off-by: Michael Niewöhner <foss@mniewoehner.de> Reviewed-on: https://review.coreboot.org/c/flashrom/+/57808 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
* flashrom.8: add missing entry for `--flash-contents`Michael Niewöhner2021-09-261-0/+7
| | | | | | | | Change-Id: I64a8200a86329bd26a2069c5dc39430de9f8ba09 Signed-off-by: Michael Niewöhner <foss@mniewoehner.de> Reviewed-on: https://review.coreboot.org/c/flashrom/+/57807 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
* flashrom.8: replace `svn changelog` with `git history`Michael Niewöhner2021-09-261-1/+1
| | | | | | | | | Change-Id: If8659dd603cbabdb8e20d89f818072986373e24f Signed-off-by: Michael Niewöhner <foss@mniewoehner.de> Reviewed-on: https://review.coreboot.org/c/flashrom/+/57811 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
* remove compile guardsThomas Heijligen2021-09-2618-83/+0
| | | | | | | | | | | | | The build system handles the decision when to build a file. Extra compile guards for the source files are not necessary. Change-Id: I76a76e05c7a7dd27637325ab1e9d8946fd5f9076 Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de> Reviewed-on: https://review.coreboot.org/c/flashrom/+/57797 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: Nico Huber <nico.h@gmx.de>
* mec1308: remove MEC1308 EC programmerVictor Ding2021-09-229-602/+2
| | | | | | | | | | | | | | | | | Best efforts were made to upstream older Chromebook support for good intentions for folks interested. However, we no longer have the hardware available to test and maintain the code as the hardware is now end of life. Therefore the code state has sadly fallen into a unknown state. BUG=none BRANCH=none TEST=builds and ninja test passes Signed-off-by: Victor Ding <victording@google.com> Change-Id: I535b6380846734c999474519e9e60a73eb6a2ec4 Reviewed-on: https://review.coreboot.org/c/flashrom/+/56476 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
* ene_lpc: remove ENE LPC programmerVictor Ding2021-09-229-681/+3
| | | | | | | | | | | | | | | | | Best efforts were made to upstream older Chromebook support for good intentions for folks interested. However, we no longer have the hardware available to test and maintain the code as the hardware is now end of life. Therefore the code state has sadly fallen into a unknown state. BUG=none BRANCH=none TEST=builds and ninja test passes Signed-off-by: Victor Ding <victording@google.com> Change-Id: I3f40db22c42c04ce029c4defd837e05ebb550c9b Reviewed-on: https://review.coreboot.org/c/flashrom/+/56475 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
* dediprog.c: Drop dediprog_ prefix for spi data struct membersAnastasia Klimchuk2021-09-131-60/+54
| | | | | | | | | | | | | | The name of the struct type already contains dp_ prefix, so prefix doesn't need to be repeated in members name. BUG=b:185191942 TEST=builds and ninja test Change-Id: I688d50926b78a6c3f1c5a8ba4ef88a0d5b495bd0 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56415 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
* dediprog.c: Refactor singleton states into reentrant patternAnastasia Klimchuk2021-09-131-112/+150
| | | | | | | | | | | | | | | | | | Move global singleton states into a struct and store within the spi_master data field for the life-time of the driver. This is one of the steps on the way to move spi_master data memory management behind the initialisation API, for more context see other patches under the same topic "register_master_api". BUG=b:185191942 TEST=builds and ninja test Change-Id: I72085e750af97b94dfa94f2ebf2a134e41a2ec8d Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56414 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
* chipset_enable.c: Mark Z97 as DEPSophie van Soest2021-09-131-1/+1
| | | | | | | | | | | Tested on GIGABYTE GA-Z97-HD3. Signed-off-by: Sophie van Soest <sophie@entropie.rocks> Change-Id: I73bdd9afefae8e7c013d400e17a15e56d84322f4 Reviewed-on: https://review.coreboot.org/c/flashrom/+/56060 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Michael Niewöhner <foss@mniewoehner.de>
* ich_descriptors_tool: Add missing Comet Point in usageMichał Żygowski2021-09-121-0/+1
| | | | | | | | Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com> Change-Id: Ia1e3e231944513521d5db064340a0247f1884290 Reviewed-on: https://review.coreboot.org/c/flashrom/+/55993 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
* ni845x_spi: add missing const specifier to the spi_transmit functionMiklós Márton2021-09-061-1/+1
| | | | | | | | | | Change-Id: I2c14361283b2da3725d9ba2cae0e1007e6be3d66 Signed-off-by: Miklós Márton <martonmiklosqdev@gmail.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/57003 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* Add support for Intel Emmitsburg PCHJonathan Zhang2021-09-012-0/+3
| | | | | | | | | | | | | | | | | | | | This patch does the following: - Add PCIe ID for Intel Emmitsburg PCH - Based on ICH descriptor content, choose CHIPSET_C620_SERIES_LEWISBURG if ISL/PSL is 80. TESTED=tried on a server with Intel Emmitsburg PCH, flash update was successful. This server, however, does not have flash chip installed, it instead has em100 emulator connected. Change-Id: I2a1bb7467e693d1583aa885fa0e277075edd4a3e Signed-off-by: Jonathan Zhang <jonzhang@fb.com> Signed-off-by: David Hendricks <ddaveh@amazon.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/54965 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Christian Walter <christian.walter@9elements.com> Reviewed-by: Johnny Lin <Johnny_Lin@wiwynn.com> Reviewed-by: Tim Chu <Tim.Chu@quantatw.com>
* tests: Mock file i/o for linux_mtd and linux_spi testsAnastasia Klimchuk2021-08-305-4/+180
| | | | | | | | | | | | | | | | | | | | | | | | This patch adds an init-shutdown test for linux_mtd. Since linux_mtd is using file i/o operations, those are added to the framework and mocked. Another driver linux_spi which is also using file i/o, got an upgrade in this patch, and it is now reading max buffer size from sysfs (using mocked file i/o). A good side-effect is that linux_mtd is the first test for opaque masters, which is great to have in preparation for a change like CB:56103 but for opaque masters. BUG=b:181803212 TEST=builds and ninja test Change-Id: I73f0d6ff2ad5074add7a721ed3416230d3647e3f Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56413 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>
* par_master: Fix propagation of register_par_master() return valuesAnastasia Klimchuk2021-08-3010-28/+10
| | | | | | | | | | | | | | | This patch checks return value of register_par_master() so that in case of an error this error is not ignored anymore. BUG=b:185191942 TEST=builds and ninja test Change-Id: I377afae41708c7433a56615e2f096bce9c5349f1 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/57192 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Nico Huber <nico.h@gmx.de>
* par_master: Use new API to register shutdown functionAnastasia Klimchuk2021-08-302-15/+4
| | | | | | | | | | | | | | | | | | This allows par masters to register shutdown function in par_master struct, which means there is no need to call register_shutdown in init function, since this call is now a part of register_par_master. As a consequence of using new API, this patch also fixes propagation of register_par_master() return values. BUG=b:185191942 TEST=builds and ninja test Change-Id: Ief7be907f53878b4b6567b52889735e5fff64ead Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/57156 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
* par_master: Move shutdown function above par_master structAnastasia Klimchuk2021-08-302-18/+18
| | | | | | | | | | | | | | | | | | This patch prepares par masters to use new API which allows to register shutdown function in par_master struct. See also later patch in this chain, where par masters are converted to new API. BUG=b:185191942 TEST=builds and ninja test Comparing flashrom binary before and after the patch, make clean && make CONFIG_EVERYTHING=yes VERSION=none binary is the same Change-Id: I87e9ce0ad9b39b39645dc24cb0d75d1e7a6d9047 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/57155 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* par_master: Add shutdown function in par_master structAnastasia Klimchuk2021-08-302-0/+8
| | | | | | | | | | | | | | | | | | With this, register_par_master can take care of register_shutdown as well, and every par master only needs to call register_par_master instead of calling both register_par_master and register_shutdown. Next patches in the chain convert par masters to use new API. BUG=b:185191942 TEST=builds and ninja test Change-Id: I0fee15d548cdd16678e551eeb351e659812ddf76 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/57154 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* ni845x_spi: handle PROGRAMFILES(X86) env var properlyMiklós Márton2021-08-271-2/+11
| | | | | | | | | | | | | | | | | The PROGRAMFILES(X86) envvar contains brackets which could not be interpreted by the Makefile's interpreter. A sed based tweak have been added to extract the variable value from the env command output. The prefixed include and linker path with this (now correctly extracted) prefix only added to the compilation flags if it differ from the PROGRAMFILES variable. Change-Id: I397619a5038567d649a417ce6b9d8ac9e1c8c67b Signed-off-by: Miklós Márton <martonmiklosqdev@gmail.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56636 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Nico Huber <nico.h@gmx.de>
* spi_master: Use new API to register shutdown functionAnastasia Klimchuk2021-08-2521-112/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows spi masters 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. Basic testing: when I comment out free(data) in linux_spi_shutdown, test fails with error ../linux_spi.c:235: note: block 0x55a4db276510 allocated here ERROR: linux_spi_init_and_shutdown_test_success leaked 1 block(s) Means, shutdown function is invoked. BUG=b:185191942 TEST= 1) builds and ninja test including CB:56911 2) On ARMv7 device flashrom -p linux_spi -V -> using linux_spi, chip found 3) On x86_64 AMD device flashrom -p internal -V -> this is actually using sb600spi, chip found Change-Id: Ib60300f9ddb295a255d5ef3f8da0e07064207140 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56103 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* opaque_master: Use new API to register shutdown functionAnastasia Klimchuk2021-08-252-15/+5
| | | | | | | | | | | | | | | | | | | | | | | This allows opaque masters to register shutdown function in opaque_master struct, which means there is no need to call register_shutdown in init function, since this call is now a part of register_opaque_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_opaque_master() return values. BUG=b:185191942 TEST=1) builds and ninja test including CB:56413 2) on ARMv7 device flashrom -p linux_mtd -V -> using linux_mtd, chip found Change-Id: Id8471a117556edcbf9694752fabe05cf4501ce70 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56825 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* flashchips: Add MX25L12833FTao Xia2021-08-242-3/+3
| | | | | | | | | | | | Just add the name to the existing entry, as usual it is supposed to be compatible. Signed-off-by: Tao Xia <xiatao5@huaqin.corp-partner.google.com> Change-Id: I14ab7e04f5209d2bcf34b0d2de9da2c01bf32d00 Reviewed-on: https://review.coreboot.org/c/flashrom/+/56546 Reviewed-by: Weimin Wu <wuweimin@huaqin.corp-partner.google.com> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* flashchips.c: Add 'GD25LQ128E' to match C and D variantsEdward O'Callaghan2021-08-241-1/+1
| | | | | | | | | | | | | | | | | As defined by gigadevice. C, D and E are all meant to be the same. BUG=b:185957191 BRANCH=none TEST=builds Change-Id: I3bef9386a185a0e8c54c125af5509b63540995aa Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/55742 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nikolai Artemiev <nartemiev@google.com> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
* tests: Add tests to erase a chipAnastasia Klimchuk2021-08-194-0/+237
| | | | | | | | | | | | | | | | | | | | Two tests cover the code which performs do_erase 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: I6f74bfe4e02244d24d6c837cc3d551251e7b4898 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56501 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* tests: Use real spi_send_command for all tests except spi25.cAnastasia Klimchuk2021-08-191-13/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | At the moment one test (spi25.c) uses wrap of spi_send_command, and all other existing tests don't care about this function (don't call it at all). However in the next patch a new test in introduced, which needs a real spi_send_command. Following the approach "don't mock unless it is strictly necessary", all tests that don't care go into real function bucket. A declaration for __real_spi_send_command is needed for visibility, this way wrap function can redirect to real function for all other tests except spi25.c. Additionally, wrap function moves below mock_chip, so that mock_chip is visible inside wrap. BUG=b:181803212 TEST=builds and ninja test Change-Id: I22945cce3d0f36adaa8032167a3ef4e54eccb611 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56753 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* tests: add init_shutdown test for realtek_mst_i2c_spiPeter Marheine2021-08-195-0/+100
| | | | | | | | | | | | | | | | This can catch regressions like the earlier one in this programmer that caused initialization to always fail. Requires support for mocking POSIX file I/O functions because the programmer does ioctls on the opened file. TEST=ninja test Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: I5a5c617d1ec35d2a3bbe622e5add82a65eb396f0 Reviewed-on: https://review.coreboot.org/c/flashrom/+/56911 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* opaque_master: Move shutdown function above opaque_master structAnastasia Klimchuk2021-08-172-25/+25
| | | | | | | | | | | | | | | | | | This patch prepares opaque masters to use new API which allows to register shutdown function in opaque_master struct. See also later patch in this chain, where opaque masters are converted to new API. BUG=b:185191942 TEST=builds and ninja test Comparing flashrom binary before and after the patch, make clean && make CONFIG_EVERYTHING=yes VERSION=none binary is the same Change-Id: I5000cfceeba859a76177a17c1cb7d1c1e9fc03fe Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56824 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* opaque_master: Add shutdown function in opaque_master structAnastasia Klimchuk2021-08-172-0/+8
| | | | | | | | | | | | | | | | | | With this, register_opaque_master can take care of register_shutdown as well, and every opaque master only needs to call register_opaque_master instead of calling both register_opaque_master and register_shutdown. Next patches in the chain convert opaque masters to use new API. BUG=b:185191942 TEST=builds and ninja test from CB:56413 Change-Id: I34183e6bafc787eec54ee4a26b73a40803f3ce99 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56823 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* linux_mtd: Free param right after its last usageAnastasia Klimchuk2021-08-171-4/+6
| | | | | | | | | | | | | | | | | Param is only used in the first half of init function, and it is local, so there is no need to keep it until the end. This makes handling error paths in the second half of init function shorter, because those paths can just return 1 instead of going to a label. BUG=b:185191942 TEST=builds and ninja test from CB:56413 Change-Id: I126a8d06297ef4d42bc93a73f7067ccc1352d1e9 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56822 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
* nicintel_eeprom: Check UNPROG_DEVICE in 82580 shutdownAnastasia Klimchuk2021-08-171-14/+24
| | | | | | | | | | | | | | | | | | | | | | | | | Previously shutdown function was registered conditionally for 82580, only if the device was not UNPROG_DEVICE. This patch moves the check for UNPROG_DEVICE into shutdown function itself, so that shutdown function can be always registered for 82580. This also fixes a memory leak in nicintel_ee_shutdown_82580. No changes for i210 device init/shutdown, only for 82580. And very importantly this unlocks API change which plans to move register_shutdown inside register_opaque_master, similar to what's done in CB:56103 BUG=b:185191942 TEST=builds Change-Id: I5c729a3a63d0106e65525a6a77b2f9104c96847f Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56821 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* nicintel_eeprom: Delete extra parentheses from if conditionAnastasia Klimchuk2021-08-171-1/+1
| | | | | | | | | | | | BUG=185191942 TEST=builds Change-Id: I068bd227668a79f14e38e703a5a49db18d5de8c7 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56820 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* spi_master: Move shutdown function above spi_master structAnastasia Klimchuk2021-08-1714-188/+184
| | | | | | | | | | | | | | | | | | | This patch prepares spi masters to use new API which allows to register shutdown function in spi_master struct. See also later patch in this chain, where spi masters are converted to new API. BUG=b:185191942 TEST=builds and ninja test Comparing flashrom binary before and after the patch, make clean && make CONFIG_EVERYTHING=yes VERSION=none binary is the same Change-Id: I50716686552b4ddcc6089d5afadb19ef59d9f9b4 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56101 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
* spi_master: Add shutdown function in spi_master structAnastasia Klimchuk2021-08-172-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | With this, register_spi_master can take care of register_shutdown as well, and every spi master only needs to call register_spi_master instead of calling both register_spi_master and register_shutdown. Testing: In dummyflasher, comment out free(data) in shutdown. Test fails with error: ../dummyflasher.c:949: note: block 0x55e0727a6e40 allocated here ERROR: dummy_init_and_shutdown_test_success leaked 1 block(s) Means, shutdown function is invoked for drivers with "old" API (so, transitioning from old to new API is not breaking anything). Next patches in the chain converts spi masters to use new API. BUG=b:185191942 TEST=builds and ninja test Change-Id: I2dc80dceca2f8204bcd0dad1f51753d7e79f1af5 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/55932 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
* realtek_mst_i2c_spi: don't always fail initPeter Marheine2021-08-101-1/+1
| | | | | | | | | | | | | | | | | | In some earlier refactoring the init function for this programmer was broken such that it never succeeds, since the return value was never set to a value other than a generic failure. Fix it to return success unless there is a problem. TEST=flashrom -p realtek_mst_i2c_spi:bus=n --flash-size now works when n is a bus that has a connected MST. Change-Id: I0596014fc9b76b4d11de230f9f5c414c1321dff1 Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56799 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* tests: Add init-shutdown test for nicrealtekAnastasia Klimchuk2021-08-095-0/+34
| | | | | | | | | | | | | | | | | | This patch adds a test and mocks for two pci functions that nicreltek is using. Main reason for this is to have at least one test for par master (currently there are none), in preparation for a change like CB:56103 but for par masters. BUG=b:181803212 TEST=ninja test Change-Id: Iaed14fe1d83c8eb45ec185ebd3f1c97cb81941f4 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56470 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* programmer_table: Remove space between address operator and variableAnastasia Klimchuk2021-08-091-2/+2
| | | | | | | | | | | | | | | BUG=none TEST=builds Change-Id: Iba29b1bc3d77b8c17c51fc0552c129e6965fa308 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56469 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Thomas Heijligen <src@posteo.de> Reviewed-by: Paul Menzel <paulepanter@mailbox.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
* ft2232_spi: Add FTDI search by description.Harry Johnson2021-07-291-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | This adds to the search-by-serial functionality with search-by-description (product string). This is useful when e.g. one has multiple FTDIs in a system and wants the serial numbers to reflect the system-level serial number, and the description to reflect the subcomponent names. Tested manually by running with both serial and description searches, on a machine with multiple FTDIs plugged in. Ensured that when two devices with the same vid/pid/serial number are plugged in, description can be used to differentiate. Verifed no-description, no-serial, one FTDI plugged in base case works. Original version of this code used the original single "arg" char*, but on further thought, this wasn't worth the readability and functionality losses. The new version with arg2 gets rid of several lines of code, the gotos, and adds the ability to filter by both description and serial simultaneously. Change-Id: Ib4be23247995710900175f5f16e38db577ef08fa Signed-off-by: Harry Johnson <johnsonh@waymo.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56164 Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* spi_master: Add default write_aai function to masters that have noneAnastasia Klimchuk2021-07-232-0/+2
| | | | | | | | | | | | | | | | | | | | | write_aai is required to register a spi master, if it is not set in spi_master struct then register_spi_master returns ERROR_FLASHROM_BUG. Masters in this patch did not have it set in the struct, and register_spi_master always returned an error for them. However return value of register_spi_master was ignored, so this was hard to notice. Next patch in the chain checks return value of register_spi_master. BUG=b:185191942 TEST=builds and ninja test Change-Id: I712e74e11244e1f0ab8d8e245fcd5207ce211219 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56102 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
* tests: Add unit tests for layout sanity checksAnastasia Klimchuk2021-07-223-0/+111
| | | | | | | | | | | | | | | Three more tests in this patch where layout does / does not pass sanity checks. BUG=b:193584590 TEST=ninja test Change-Id: Ia21585d60443b2741f3868d7887476090e35f79b Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56440 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
* tests: Trim excessive new lines from layout test outputAnastasia Klimchuk2021-07-221-18/+18
| | | | | | | | | | | | | | | | | | This patch is making layout test output more compact, spanning less vertical lines while logging the same information. No changes made to the test functionality. BUG=b:193584590 TEST=ninja test Change-Id: I36a39505f8db508672cde5a848684a3a22f5ccc4 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56439 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
* Replace freenode referencesAngel Pons2021-07-213-31/+16
| | | | | | | | | | | | 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>
* print_wiki.c: Update mailing list referenceAngel Pons2021-07-211-1/+1
| | | | | | | | | Change-Id: I5c67b5b3be2f306132d8565539bbf10477222026 Signed-off-by: Angel Pons <th3fanbus@gmail.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56030 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>
* tests: Add layout tests for overlapping regionsAnastasia Klimchuk2021-07-194-0/+116
| | | | | | | | | | | | | | | | | | There are no tests for layout, it would be great to add some. Also partially inspired by commit 06a89d713951a2e08ef8fb698a7688357baa83d1 and commit c9039fc27916c03e21ba91365d01e6bc49503053 BUG=b:193584590 TEST=ninja test Change-Id: I7aa8dc0c9bc5a22fe5deea757eea1a151b969cea Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56324 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
* tests: Wrap strdup to help cmocka recognise memory allocationAnastasia Klimchuk2021-07-193-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | This is a known issue in cmocka (see https://github.com/clibs/cmocka/issues/17) where cmocka does not recognise memory allocation happening inside strdup, and then later throws an error when the memory is freed. If the issue is fixed at some point, this workaround can be removed. Given that cmocka already overrides malloc, calloc, realloc, free, adding strdup there seems fine. Existing tests now can (and have to) free the memory they allocated by strdup, and this is in the same patch. BUG=b:193584590 TEST=ninja test Change-Id: I56aef6b342752d80995c36ab075b12198fc101d9 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56323 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
* dediprog: Init-shutdown test for dediprogAnastasia Klimchuk2021-07-195-3/+111
| | | | | | | | | | | | | | | | | This patch adds mocks for libusb functions. To avoid dependency on libusb.h, libusb symbols for context and device handle are redefined. Real libusb functions are never called in tests anyway, cmocka wraps work with this without complaints. BUG=b:181803212 TEST=builds and ninja test Change-Id: I38508dfb6d7c24d42522f22fcae0c5e410c5f7ea Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/55934 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>
* flashrom.c: Reorder read_by_layout() to avoid forward declEdward O'Callaghan2021-07-161-27/+26
| | | | | | | | | | | | | | 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>
* flashrom.c: Reorder check_block_eraser() to avoid forward declEdward O'Callaghan2021-07-161-27/+25
| | | | | | | | | | | | | | 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>
* flashrom.c: Make extract_param() static localEdward O'Callaghan2021-07-162-2/+1
| | | | | | | | | | | | | | | 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>