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

3877 Commits

Author SHA1 Message Date
Arnaud Ferraris
34b1a6aa57 linux_mtd: fix build with clang >= 19
Starting with version 19, clang issues a warning when using `strlen()`
for initializing a static array's size. This causes the build to fail as
the project also sets `-Werror`.

This is fixed by using `sizeof()` instead, which is guaranteed to be
evaluated at compilation time and therefore not triggering the
problematic warning.

Change-Id: If470a65702e9ae08e4303123a0014e53a1fee56e
Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84856
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Maximilian Brune <maximilian.brune@9elements.com>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-11-01 23:38:55 +00:00
persmule
9ff3d4cf75 erasure_layout: Add an option to sacrifice unchanged blocks for speed
The patch adds command line option to handle the following situation:

There is a region which is requested to be erased (or written, because
the write operation uses erase too). Some of the areas inside this
region don't need to be erased, because the bytes already have expected
value. Such areas can be skipped.

The logic selects eraseblocks that can cover the areas which need to be
erased. Suppose there is a region which is partially covered by
eraseblocks of size S (partially because remaining areas don't need to
be erased). Now suppose we can cover the whole region with eraseblock
of larger size, S+1, and erase it all at once. This will run faster:
erase opcode will only be sent once instead of many smaller opcodes.
However, this will run erase over some areas of the chip memory that
didn't need to be erased. Which means, the chip, as a hardware, will
wear faster.

New command line option sets the maximum % memory that is allowed for
redundant erase. Default is 0, S+1 size block only selected if all the
area needs to be erased in full. 50 means that if more than a half of
the area needs to be erased, a S+1 size block can be selected to cover
all area with one block.

The tradeoff is the speed of programming operation VS the longevity of
the chip. Default is longevity.

Change-Id: I154e8a713f626c37dbbe118db700055b96d24803
Co-developed-by: persmule <persmule@hardenedlinux.org
Co-developed-by: Anastasia Klimchuk <aklm@flashrom.org>
Signed-off-by: persmule <persmule@hardenedlinux.org>
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84721
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
2024-11-01 08:04:48 +00:00
Victor
32e5aca1a9 flashchips: add GD25F128F
GD25F128F: 3V 128Mbit, high performance

Tested on ch347 with erase, write, read, and protection
Corrected the OTP statement.

Change-Id: I14c0905f50e92492287d50f8377790b997c4acfe
Signed-off-by: Victor <vlim@gigadevice.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84827
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-10-31 09:43:19 +00:00
Anastasia Klimchuk
19ce5c98ef doc: Add chip models support into recent development
Change-Id: I9b96902a02b83d35f0a0f221bd1678b7edf99dad
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84870
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
2024-10-30 23:54:26 +00:00
Anastasia Klimchuk
e60702d846 erasure_layout: Fix unreachable error message
Change-Id: I11d2d1359f74475cb20a1c91bddb380b4952a704
Spotted-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84725
Reviewed-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-10-27 06:14:13 +00:00
Anastasia Klimchuk
75dc0655b9 Complete and fix progress feature implementation for all operations
Original progress reporting implemented in CB:49643 and it has some
issues, for example:

    size_t start_address = start;
    size_t end_address = len - start;

End address is anything but length minus start address.

    update_progress(flash,
                    FLASHROM_PROGRESS_READ,
                    /*current*/ start - start_address + to_read,
                    /*total*/ end_address);

Total should just be length if that's how current value is computed.

---

libflashrom needs to know total size ahead of time.
That's init_progress() and changed update_progress().

It also needs to store the last current value to be able to update it.
That's stage_progress in flashrom_flashctx.

Measuring accurately amount of data which will be read/erased/written
isn't easy because things can be skipped as optimizations. The next
patch in the chain aims to address this, there are TODO/FIXME
comments there.

---

CLI shares terminal with the rest of the code and has to maintain more
state to handle that reasonably well.

Similar to CB:64668, an effort is made to keep the progress on a
single line. Non-progress output is kept track of to know when
moving to a new line cannot be avoided.

---

A script to test the CLI:

\#!/bin/bash
t=${1:-rewW}
shift

if [[ $t =~ r ]]; then
    echo ">>> READ"
    ./flashrom -p dummy:emulate=W25Q128FV,freq=64mhz -r dump.rom --progress "$@"
    echo
fi

if [[ $t =~ e ]]; then
    echo ">>> ERASE"
    ./flashrom -p dummy:emulate=W25Q128FV,freq=64mhz -E --progress "$@"
    echo
fi

if [[ $t =~ w ]]; then
    echo ">>> WRITE (without erase)"
    dd if=/dev/zero of=zero.rom bs=1M count=16 2> /dev/null
    ./flashrom -p dummy:emulate=W25Q128FV,freq=64mhz -w zero.rom --progress "$@"
    echo
fi

if [[ $t =~ W ]]; then
    echo ">>> WRITE (with erase)"
    dd if=/dev/zero of=zero.rom bs=1M count=16 2> /dev/null
    dd if=/dev/random of=random.rom bs=1M count=16 2> /dev/null
    ./flashrom -p dummy:emulate=W25Q128FV,freq=64mhz,image=random.rom -w zero.rom --progress "$@"
    echo
fi

Co-developed-by: Anastasia Klimchuk <aklm@flashrom.org>
Co-developed-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Change-Id: If1e40fc97f443c4f0c0501cef11cff1f3f84c051
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84102
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-10-27 06:13:11 +00:00
Nikolai Artemiev
83ba5e93c1 writeprotect: Fix inaccurate return code
If hardware protection is requested but not supported by the flash
chip, return an error code indicating that the protection mode is
unsupported, rather than indicating that all WP features are unsupported.

TEST=ninja test

Change-Id: I29e9069c7781fbb238f30aa9a9285b692b0c7200
Signed-off-by: Nikolai Artemiev <nartemiev@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84826
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-10-26 06:27:13 +00:00
Anastasia Klimchuk
339a7dcd37 VERSION: Change name pattern to match tag name from now on
This patch updated the VERSION file itself, and the document on
release process.

Change-Id: I2bd2e57e42c29ea5a9d8bc334b86c6fa5c4b46a4
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84811
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
2024-10-25 01:20:30 +00:00
Anastasia Klimchuk
25819a432d erase/write: Deselect all smaller blocks when large block is selected
Previously the logic which selected large block did deselect of
smaller blocks, but only one level below. So some even smaller blocks
could still remain selected, and this would result in duplicate erase.

This patch deselects all smaller blocks of all levels below, down to
the smallest size. If the area is covered by one large block, no
other smaller blocks inside are needed.

Change-Id: Icfc18d5c090b1dcb92ab157e2c139be71af59300
Spotted-by: persmule <persmule@hardenedlinux.org>
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Co-authored-by: persmule <persmule@hardenedlinux.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84686
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-10-24 01:47:55 +00:00
Anastasia Klimchuk
dc88d5d618 tests: Add assert for eraseblocks order of invocations for write op
Change-Id: I558fded2b9f876e33ca92dea324d90ef73f6a2be
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84783
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
2024-10-24 01:46:35 +00:00
Ssunk
252499003c flashchips: Add Support for XMC XM25LU64C
Add initial support for the SPI flash chip XM25LU64C
Datasheet link: https://www.xmcwh.com/uploads/954/XM25LU64C%20_%20Ver1.4.pdf

XM25QU64C/XM25LU64C Tested with ch341a programmer: probe, read, write, erase

Change-Id: I8d1af7fbfb4c45db09ed5ac82c683d273c8151c7
Signed-off-by: Kan Sun <ssunkkan@gmail.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84775
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-10-24 01:31:03 +00:00
Victor Lim
1ba039ce96 flashchips: add GD25F256F
GD25F256F: 3V 256Mbit, high performance

Tested on ch347 with erase, write, read, and protection

Change-Id: Ibbbbb8a55adbcbc2ee1785782c4eb3771d50c167
Signed-off-by: Victor Lim <vlim@gigadevice.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84090
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-10-21 05:55:13 +00:00
Victor Lim
521c85cc7b flashchips: add GD25F64F
GD25F64F: 3V 64Mbit, high performance

Tested on ch347 with erase, write, read, and protection

Change-Id: I07005f1589b76c8a61a1a744b16dc6b0c9020e11
Signed-off-by: Victor Lim <vlim@gigadevice.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84705
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-10-16 07:32:55 +00:00
persmule
348dbeb05f erasure_layout: Erase larger block only when all sub-block need erase
A larger (not the smallest) erase block used to get erased when half
of sub-blocks it contains need erase, which has at least 2 issues:

1. The rest half of sub-blocks that do not need erase are also erased,
   introducing some erase overheads.

2. More severely, since this logic only selects a block and delects
   its sub-blocks when half of sub-blocks need erase, but this logic
   does not deselect "nested sub-blocks (sub-blocks of sub-block)" not
   reach the limit under this block, the logic may cause duplicated
   erase. For example, if a erase block (often the largest one
   corresponding to the whole chip) has half of its sub-blocks and
   some incontiguous nested sub-blocks needing erase, these double
   sub-blocks will end up being erased twice, introducing even more
   erase overheads than whole-chip erase.

The older behavior of flashrom before adding erasure_layout.c, when no
communicational error occurs, will neither erase blocks that do not
need erase, nor cause duplicated erase. Higher efficiency should be
achieved without introducing extra erase overheads, by allowing
combining contiguous small erase blocks only when they can
coincidently form a larger erase block.

Change-Id: I9e10749186e395da67ec80e296119f33c3f83122
Signed-off-by: persmule <persmule@hardenedlinux.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84614
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-10-13 23:15:15 +00:00
Anastasia Klimchuk
ad6d288b45 doc/contact: Add note to IRC section and calm down the formatting
Change-Id: Ic808508b5da431d6c0b88a9b2847c34c7b02cfe0
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84679
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-10-09 23:55:57 +00:00
persmule
26a1eb514c ichspi: Probe opcode in POSSIBLE_OPCODES[] as well
ich_spi_send_command() and ich_spi_send_multicommand() will overwrite
the "Sector erase" opcode with the opcode for command via
reprogram_opcode_on_the_fly(), but not restore it, causing the "Sector
erase" opcode may get lost after sending commands, leaving only "Bulk
erase" opcode which erase the whole chip available.

In the mean time, ich_spi_probe_opcode() used not to report opcodes in
POSSIBLE_OPCODES[] but not in curopcodes->opcode[] as supported.

Now, if the opcode being probed is not in curopcodes->opcode[] but in
POSSIBLE_OPCODES[], it will be reported as supported, and programmed
later by ich_spi_send_(multi)command().

Fix:https://ticket.coreboot.org/issues/556

Change-Id: I3fc831fc072e2af9265835cb2f71bf8c222c6a64
Signed-off-by: persmule <persmule@hardenedlinux.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84253
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
2024-10-09 05:34:32 +00:00
persmule
f80caddca0 ichspi: Merge spi_master implementations for Intel ich
There seems no problem to use ich_spi_probe_opcode() for
spi_master::probe_opcode() on ich7, so we may merge former
spi_master_ich7 and spi_master_ich9 into spi_master_ich, for both
init_ich7_spi() and init_ich_default().

Change-Id: I6a65c97e910622a55da7cef8a10de3af6a99c9e8
Signed-off-by: persmule <persmule@hardenedlinux.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84593
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
2024-10-09 05:33:54 +00:00
persmule
0332d5e3ad ichspi: const-correct POSSIBLE_OPCODES[]
POSSIBLE_OPCODES[] is never modified, so mark it as read-only.

Change-Id: I217f8a9e50b9e2e9f2731adec89a46780874c754
Signed-off-by: persmule <persmule@hardenedlinux.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84595
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
2024-10-09 05:33:27 +00:00
Anastasia Klimchuk
f5d1bed6d4 ichspi: Change the opcode position for reprogramming on the fly 2->4
The function for reprogramming on the fly was using the default
configuration O_ST_M25P as a base and the position 2 as the position
to reprogram. Position 2 corresponds to JEDEC_SE which is often useful
for chip erase (when less than whole chip needs to be erased).

This patch changes the default position to reprogram to 4, which
corresponds to JEDEC_REMS. It is used less often, but if it needs to
be used, it will be discovered missing and reprogrammed back.

For erase opcodes, there is usually several of them available. So if
one is missing, erase still can be performed with the remaining ones.
However, this hides the fact that one of available erase opcodes is
missing (it won't be reprogrammed back), and also it gives non-optimal
erase layout.

Context: https://ticket.coreboot.org/issues/556

Change-Id: I6bc855daedf0af2e8de191f23a3512de3ebc3fef
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84567
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
2024-10-09 05:33:11 +00:00
Peter Marheine
6c26e9efed build: never install cmocka
meson's default behavior is to install subprojects, so because we use a
wrap to get cmocka if needed and the cmocka wrap sets install=true
unless cross-compiling, cmocka headers and libraries will be installed
by `meson install`. This isn't useful (because cmocka is used only for
tests which don't get installed), and can cause install errors in some
configurations.

meson can be told to never install subprojects with `meson install
--skip-subprojects` which solves this, but is inconvenient because that
option must be specified on the command line and there is little hope of
meson's default behavior changing [1].

To fix this, I've replaced `patch_url` for the wrap with an included
`patch_directory` instead, which was created by unpacking the original
archive pointed to by `patch_url` and setting `install : false` in
src/meson.build.

A more concise option to make the same change would be to make the
change to the `install` option in a new patch specified via `diff_files`
(which works because patches from `diff_files` are applied after
applying the `patch_*` archive), but `diff_files` is not supported by
Meson before version 0.63.0 which would require increasing flashrom's
minimum meson version from the current 0.56.0. This seems too new, since
meson 0.56 was released in October 2020 while meson 0.63 was released in
July 2022.

[1]: https://github.com/mesonbuild/meson/issues/10561#issuecomment-1444059473

BUG=https://ticket.coreboot.org/issues/561

Change-Id: I15f549175e2d5d52979814d7f7530da868871ce8
Signed-off-by: Peter Marheine <pmarheine@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84557
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-10-01 04:51:21 +00:00
Anastasia Klimchuk
84bfe0e04e tests: Add header stdlib.h to allow scan-build to do analysis
Without the header being explicitly included, scan-build run on CI
was returning errors for these files, such as:

include the header <stdlib.h> or explicitly provide a declaration
for 'calloc'

The functions in question were calloc, free, etc.

Change-Id: I4b79c5f86c074c456533296c309293e4064abe3f
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84455
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-09-25 01:46:27 +00:00
Anastasia Klimchuk
c7680c0236 doc: Convert doc for ft2232_spi
From page:
https://wiki.flashrom.org/FT2232SPI_Programmer

The sections about openbiosprog-spi, RushSPI, Amontec have broken
links and are not added to this patch. If we find out where these
project live now (if they still are active), would be good to add
the info later.

Change-Id: Id30b6c92838d7ca6e26a4cc3e0aeeb3f3ce07668
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/83866
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-09-25 01:45:29 +00:00
Anastasia Klimchuk
b0e8bc4a3b doc: Add manpage item for nicintel_spi
The existing page on old wiki is very small and fits into
a manpage item:

https://wiki.flashrom.org/NICIntel

Change-Id: I139065611c68c0fa0a675fe49a6f8bc20e9057f7
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/83751
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2024-09-25 01:44:29 +00:00
Anastasia Klimchuk
88d31fc1b4 dummyflasher: Enable higher frequency emulation, add docs and tests
The patch adds a section on a manpage to explain the freq
parameter in dummyflasher, and tests for various valid and invalid
values of freq parameter.

Co-developed-by: Anastasia Klimchuk <aklm@flashrom.org>
Co-developed-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Change-Id: Iaca5d95f8f977bf0c2283c6458d8977e6ce70251
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84423
Reviewed-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-09-25 01:39:33 +00:00
Anastasia Klimchuk
aa1189039e en29lv640b.c: Fix the comment about chunksize
Co-developed-by: Anastasia Klimchuk <aklm@flashrom.org>
Co-developed-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Change-Id: I104611d42b301662e2c833498aca99c879685846
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84422
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2024-09-23 09:57:14 +00:00
Anastasia Klimchuk
87f2d6791d dediprog: Fix comment about usb transfer size
Co-developed-by: Anastasia Klimchuk <aklm@flashrom.org>
Co-developed-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Change-Id: I1ad7f89b0a6c91907440e3897ac262bd82f846d5
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84421
Reviewed-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-09-23 09:54:21 +00:00
Anastasia Klimchuk
b6b0eba310 Fix FEATURE_NO_ERASE chips and add test for them
New check was added to `check_block_eraser` in
commit 0f389aea9e630c3b21547a5dd8dbe572a8502853 but it was not
handling FEATURE_NO_ERASE chips.

This patch fixes processing such chips and adds test to run
write and verify with dummyflasher for FEATURE_NO_ERASE chips.

Ticket: https://ticket.coreboot.org/issues/553

Change-Id: I582fe00da0715e9b5e92fcc9d15d5a90a2615117
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84203
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
2024-09-16 01:13:21 +00:00
Grant Pannell
d71e88ecfb erasure_layout: Fix init_eraseblock segmentation fault
Fix a segmentation fault that is caused by accessing an invalid
"subedata" pointer on the last iteration of the init_eraseblock loop.
Instead, short circuit the loop condition to check the sub block index
first, and do not access the invalid pointer if it is the last sub
block.

Issue was encountered in:
- OS: OpenBSD 7.5 amd64
- Compiler: clang 16.0.6
- Chip: Macronix MX25U6435E/F

BUG=https://ticket.coreboot.org/issues/555

Change-Id: I61bf0d93aa9f0b2b420b146be16fcd5124f0dc5d
Signed-off-by: Grant Pannell <grant@digitaldj.net>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84234
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: DigitalDJ
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-09-10 06:41:11 +00:00
Michał Żygowski
11d5c1750f ichspi: Add RaptorPoint PCH support
Based on public Intel 700 Series PCH datasheet, DOC 743835 rev 004.

The IDs of IoT chipset SKUs (ending with E) can only be found in "12th
Gen Intel® Core™ Processors Family (Formerly Known as Alder Lake -S)
for IoT Platforms External Design Specification (EDS) Addendum" DOC
634528 rev 2.7 (NDA).

TEST=Probe flash on Z790 chipset. Run the ich_descriptors_tool and
check the output is correct as expected.

Change-Id: I13ac52d5400c0e2260e12d605077fc2182c379ef
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/83854
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2024-09-08 08:13:30 +00:00
Anastasia Klimchuk
14f121e39e Ensure verify operation completed in full if chip memory modified
The patch adds new functionality to the test: tracking the areas of
chip memory that were modified (i.e. by erase or write operation),
and then checking those areas were completely covered by verify
operation.

The test operates over the mock chip memory of 16 bytes, so it is
possible to track each byte which was modified, and assert that is
has been verified afterwards.

Adding the test found a bug which is fixed in this commit:

Post-cleanup after processing unaligned region for the case when end
region needs to be extended to align with erase block. Writing was
done correctly, but post-processing of newcontents could cause
one-off offset at the end of the region, which would make
verification appear false-negative (see test cases #16-19).

Change-Id: I3c5d55a0deb20f23f4072caac8c0dce04cc98fd4
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84078
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
2024-09-08 07:48:12 +00:00
Peter Marheine
2c573640f3 reduce DELAY_MINIMUM_SLEEP_US to 100 by default
This makes flashrom sleep more eagerly rather than busy-waiting,
observing that most delays in flashrom are either less than 100
microseconds (barely enough time to get any work done, even on a fast
machine) or much more than 1 millisecond (very wasteful to busy-loop).
Since we believe most systems offer good timer resolution that should
provide sleep latency on the order of 100 microseconds, this is a
reasonable default.

For DOS, the default is set to 50ms because the best available timing
source on DOS only ticks at about 20 Hz.

Signed-off-by: Peter Marheine <pmarheine@chromium.org>
Change-Id: I0f431d240c670446218b14811ef62a34e4c83da2
Reviewed-on: https://review.coreboot.org/c/flashrom/+/81608
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-09-02 23:52:30 +00:00
Victor Lim
b2a35e1bd4 flashchips: add GD25B512MF and GD25R512MF
GD25B512MF: 3V 512Mbit, QE = 1
GD25R512MF: GD25B512MF feature + RPMC
These two part share the same datasheet on the flash side.
https://www.gigadevice.com.cn/Public/Uploads/uploadfile/files/20240412/DS-00975-GD25B512MF-Rev1.1.pdf

Tested both models on ch347 with erase, write, read, and protection.

Change-Id: I9821efb34fb4abb806ad52acec46aad186888c07
Signed-off-by: Victor Lim <vlim@gigadevice.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/84083
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-09-01 08:52:33 +00:00
ZhiYuanNJ
00e02a6184 ch347_spi: Add spi clock frequency selection
CH347 SPI interface supports up to 60M.
For example, to set a 30M spi rate, use -p ch347_spi:spispeed=30M.

Change-Id: If2be48929db540a6598ac0b60b37e64597156db7
Signed-off-by: ZhiYuanNJ Liu <871238103@qq.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/82776
Reviewed-by: Nicholas Chin <nic.c3.14@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-08-29 22:43:09 +00:00
Victor Lim
6ccfef8ccd flashchips: add GD25B256E and GD25R256E
removed FEATURE_WRSR_EXT2 from the model after datasheet review.
replace
printlock	= SPI_PRETTYPRINT_STATUS_REGISTER_BP3_SRWD,
.unlock		= SPI_DISABLE_BLOCKPROTECT,

with

.printlock	= SPI_PRETTYPRINT_STATUS_REGISTER_BP4_SRWD,
.unlock		= SPI_DISABLE_BLOCKPROTECT_BP4_SRWD,

GD25B256E: 3V 256Mbit, Quad enabled.
GD25R256E: GD25B256E features + RPMC, so they share the same datasheet on flash side
https://www.gigadevice.com.cn/Public/Uploads/uploadfile/files/20230627/DS-00658-GD25B256E-Rev1.1.pdf

Tested both models on ch347 with erase, write, read and protection.

Change-Id: Ie733e0c2e35fa4797f5198f2c8334469b65f402c
Signed-off-by: Victor Lim <vlim@gigadevice.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/83998
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-08-27 04:48:28 +00:00
Samantaz Fox
23051106fa flashchips: Update test status for Fudan FM25Q08 and FM25Q128
Both of these chips were tested in-circuit with an SOIC-8 clamp and two
different BusPirate boards: the BPv3.6 from Adafruit (sku 237) and the
BPv3.6a from Sparkfun (sku TOL-12942), on a Fedora 38 host, using
flashrom 9a570318 (changes rebased since then).

Change-Id: Ib3c94f03a132a912bb4bb9d36e8783f4468587c4
Signed-off-by: Samantaz Fox <coding@samantaz.fr>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/83970
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-08-26 03:02:03 +00:00
Samantaz Fox
4e61edbace flashchips: Add definitions for Fudan FM25Q04, FM25Q64 and FM25Q128
These chips have the exact same characteristics as their 8/16/32 counterparts,
except for the different flash size.

Relevant datasheets (I've also included the FM25Q32 as a reference):
* https://www.fmsh.com/nvm/FM25Q04_ds_eng.pdf
* https://www.fmsh.com/nvm/FM25Q32_ds_eng.pdf
* https://www.fmsh.com/nvm/FM25Q64_ds_eng.pdf
* https://www.fmsh.com/nvm/FM25Q128_ds_eng.pdf

Testing status will be updated in a subsequent commit.

Change-Id: I88fcc2bbb9706c8adb3722da6aa0e1d2d04c3fde
Signed-off-by: Samantaz Fox <coding@samantaz.fr>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/83969
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-08-26 02:59:31 +00:00
Miklos Marton
e0ed3b20df stlinkv3_spi: Mark STLinkV3-Mini not working
The STLinkV3 Mini does not support the bridge API,
it return LIBUSB_IO_ERROR when querying
the bridge version. The official ST updater does
not lists the bridge version in the info screen.
Due to it's construction (additional connector on the
bottom) it is likely that ST disabled the bridge functions
on the castellated pads.

Change-Id: Ic1ea4ca7acedca5d374cff8fcef450c18e55a9e8
Signed-off-by: Miklos Marton <martonmiklosqdev@gmail.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/83921
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-08-23 10:05:07 +00:00
Victor Lim
b938411eff flashchips: add GD25B128E and GD25R128E
GD25B128E: 3V 128Mbit shipped with QE = 1
https://www.gigadevice.com.cn/Public/Uploads/uploadfile/files/20220714/DS-00594-GD25B128E-Rev1.0.pdf

GD25R128E: GD25Q128E with RPMC feature.
GD25Q128E and GD25R128E share the same datasheet on the flash side.
https://www.gigadevice.com.cn/Public/Uploads/uploadfile/files/20240729/DS-00480-GD25Q128E-Rev1.3.pdf

Tested on ch347 both models with read write erase and protection.

Change-Id: I14e3c44ebbcc65640042a7719401615b5aa66cc2
Signed-off-by: Victor Lim <vlim@gigadevice.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/83967
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-08-23 07:43:54 +00:00
Kane Chen
1197f0832d chipset_enable.c: Use PCI_ACCESS_ECAM to access pci register
In the latest pciutils(v3.13.0), it supports accessing pci registers
by ecam. This patch uses libpci version check to decide whether
flashrom calls libpci and use 0xcf8/0xcfc or ecam to access pci
registers.

BUG=b:359813524
TEST=with libpci >= 3.13.0, flashrom is working with ECAM access

Change-Id: I4549f87c8b01da0a1d3d8ce0b3b75c1f5fa2cbab
Signed-off-by: Kane Chen <kane.chen@intel.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/83896
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Hsuan-ting Chen <roccochen@google.com>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
2024-08-22 23:36:35 +00:00
Anastasia Klimchuk
33dda3387c doc: Remove leftover reference to building_with_make
Change-Id: If6d3580972ea7d42503004b922b90829025bd62d
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/83942
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
2024-08-22 01:22:55 +00:00
Anastasia Klimchuk
87134f538d tree: Remove print_wiki.c
Old wiki website is retired and so is print_wiki.c

Change-Id: I9990add27f7fdddc23ddd1f33306566ce7548417
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/83941
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
2024-08-22 01:22:27 +00:00
Victor Lim
97922fba17 flashchips: add GD25LF512MF model
GD25LF512MF: 1.8V 512Mbit high performance, quad IO enabled.

Tested on ch347 with erase, write, read, and protection

Change-Id: I3d202f5afcc9c33a4040f8186dc6fef1878ba79a
Signed-off-by: Victor Lim <vlim@gigadevice.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/83912
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-08-20 13:12:16 +00:00
Victor Lim
8685230caa flashchips: adding GD25LB512MF/GD25LR512MF
GD25LB512MF: 1.8V 512Mbit shipped with Quad enabled.
https://www.gigadevice.com.cn/Public/Uploads/uploadfile/files/20231213/DS-01012-GD25LB512MF-Rev1.0.pdf

GD25LR512MF: all GD25LB512MF features + RPMC feature
The datasheet is identical with GD25LB512MF for the NOR flash side.

Tested both models on ch347 with erase, read, write, and protection.

Change-Id: I6a0061a43af5966c93c95645b51a640c00f3d829
Signed-off-by: Victor Lim <vlim@gigadevice.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/83899
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-08-17 08:06:19 +00:00
Bora Guvendik
e4cb19a489 flashchips: add support for MX77U51250F chip
Add initial support for Macronix MX77U51250F.

BUG=none
BRANCH=none
TEST= Tested read, write and probe on google/fatcat with internal
programmer.

Change-Id: I2c2e94f01dc63f60cf636bc6afe1f033e2a6f83c
Signed-off-by: Bora Guvendik <bora.guvendik@intel.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/82626
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: DZ <danielzhang@mxic.com.cn>
2024-08-17 08:05:54 +00:00
Victor
126de26b44 flashchips: add GD25LB512ME
Added GD25LB512ME to Flashchips.C
added Sames as GD25LB512ME to GIGADEVICE_GD25LR512ME to flashchips.h

GD25LB512ME is 1.8V 512Mbit, Quad enabled when shipped.
https://www.gigadevice.com.cn/Public/Uploads/uploadfile/files/20230627/DS-00580-GD25LB512ME-Rev1.5.pdf

Tested on ch347 with erase, program, read, and protection.

Change-Id: I04103814f901478098c1a989f4239792b64073ec
Signed-off-by: Victor Lim <vlim@gigadevice.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/83795
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-08-15 12:51:44 +00:00
Anastasia Klimchuk
9c3aed0269 flashrom.c: Rename {erase|write}_by_layout_new as the only one
We used to have two code paths for erase and write, so we had
{erase|write}_by_layout in two variants: *_new and *_legacy.
Now that legacy is removed, *_new can be renamed without *_new
suffix.

Change-Id: Ib21bf29e1993c4fc0516e76fde2ad283eedb50d2
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/83852
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aarya <aarya.chaumal@gmail.com>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
2024-08-15 02:27:52 +00:00
Anastasia Klimchuk
5ddd3b55fc flashrom.c: Delete legacy erase and write logic
Current code path for erase and write has been enabled in the tree
since May 2023, which is more than 1 year ago (15 months ago),
and legacy path has been disabled since the same time.

Current logic has been officially released in v1.4.0 in July 2024.

Change-Id: I08fd686fecf6a5313eea2d66b368661c664f4800
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/83846
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aarya <aarya.chaumal@gmail.com>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
2024-08-15 02:27:03 +00:00
Anastasia Klimchuk
213fdb0f9f doc: Add doc describing release process
Change-Id: Id6aacf5ef3879a5e236759e7a4a6af3cf7cc0a00
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/83762
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-08-12 12:16:14 +00:00
Peter Marheine
133b112d09 Remove the Makefile
As was described in the version 1.4 release notes, this deletes the
Makefile and supporting elements leaving Meson as the only supported
buildsystem.

Signed-off-by: Peter Marheine <pmarheine@chromium.org>
Change-Id: Ib3cf22cf636ef9b70527b734ffa34aead2a74edd
Reviewed-on: https://review.coreboot.org/c/flashrom/+/83673
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-08-12 00:09:12 +00:00
Victor
03090fec0a flashchips: add GD25LF256F
added GD25LF256F on flashchips.c
added GIGADEVICE_GD25LF256F=0x6319 on flashchip.h

GD25LF256F is a higher performance 1.8V 256Mbit SPI flash

I have tested on CH347 with erase, program, read, protection.

Change-Id: I21a71606476e823faa38a7920aa2b10e25d68d26
Signed-off-by: Victor <vlim@gigadevice.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/83717
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-08-09 12:59:12 +00:00