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

3940 Commits

Author SHA1 Message Date
Hsuan Ting Chen
a79ec2425e flashchips: Split and add write-protect support for MX25L12833F
MX25L12833F datasheet: https://www.macronix.com/Lists/Datasheet/Attachments/8934/MX25L12833F,%203V,%20128Mb,%20v1.0.pdf
Status register: page 30 table 7 (BP0~BP3, SRWD)
Configuration register: page 31 table 8 (TB)
Security register: page 57 table 12 (WPSEL)

MX25L12835F datasheet:
https://www.macronix.com/Lists/Datasheet/Attachments/8653/MX25L12835F,%203V,%20128Mb,%20v1.6.pdf
Status register: page 31(BP0~BP3, SRWD)
Configuration register: page 32 table 7 (TB)
Security register: page 61 table 9 (WPSEL)

MX25L12845E datasheet: (no CONFIG)
https://www.mxic.com.tw/Lists/Datasheet/Attachments/8693/MX25L12845E,%203V,%20128Mb,%20v1.9.pdf
Status register: page 17 (BP0~BP3, SRWD)
Security register: page 29 (WPSEL)

MX25L12865E datasheet: (no CONFIG)
https://media.digikey.com/pdf/Data%20Sheets/Macronix/MX25L6465E,_MX25L12865E.pdf
Status register: page 19 (BP0~BP3, SRWD)
Security register: page 31 (WPSEL)

MX25L12873F datasheet: (no hardware WP)
https://www.mxic.com.tw/Lists/Datasheet/Attachments/8652/MX25L12873F,%203V,%20128Mb,%20v1.2.pdf
Status register: page 31(BP0~BP3, SRWD)
Configuration register: page 32 table 7 (TB)
Security register: page 60 table 9 (WPSEL)

Splits the MX25L12833F/MX25L12835F/MX25L12845E/MX25L12865E/MX25L12873F
group into three subgroups:
* MX25L12833F: This chip have the configuration register and WP tested
* MX25L12835F/MX25L12873F: These chips have the configuration register.
* MX25L12845E/MX25L12865E: These chips don't have the configuration
  register.

Tests the write protect functionality on the MX25L12833F chip only.

BUG=b:332486637
TEST=Test flashrom --wp-disable with MX25L12833FZNI-10 on ChromeOS

Change-Id: I379c833eea3ed3487504126f45c6df672a772ddc
Signed-off-by: Hsuan Ting Chen <roccochen@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/81792
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-04-22 07:28:08 +00:00
DanielZhang
be95e0be1f flashchips: Add write protect function support for MX25R1635F
The MX25R1635F has been tested by ch341a programmer : read, write,
erase and wp.

We have tested --wp-enable, --wp-disable, --wp-list and --wp-range
commands for write-protect feature.

MX25R1635F datasheet is available at the following URL:
https://www.macronix.com/Lists/Datasheet/Attachments/8702/MX25R1635F,%20Wide%20Range,%2016Mb,%20v1.6.pdf

Change-Id: I6e2b417ab177039618069d8e35132ddbfb814f03
Signed-off-by: DanielZhang <danielzhang@mxic.com.cn>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/81840
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-04-22 05:13:29 +00:00
DanielZhang
6f47cc1737 flashchips: Add support for MXIC MX25R8035F
The MX25R8035F has been tested by ch341a programmer : read, write,
erase and wp.

We have tested --wp-enable, --wp-disable, --wp-list and --wp-range
commands for write-protect feature.

MX25R8035F datasheet is available at the following URL:
https://www.macronix.com/Lists/Datasheet/Attachments/8749/MX25R8035F,%20Wide%20Range,%208Mb,%20v1.6.pdf

Change-Id: Iec244ffc29278c1f8c3ae47d17af2c4fe5fbe498
Signed-off-by: DanielZhang <danielzhang@mxic.com.cn>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/81837
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-04-22 05:12:40 +00:00
roccochen@chromium.com
85f14efe06 ich: Add names for region 5, 9, 10, 11, 12, 15
Add Region 9 for Intel Meteor Lake; update missing regions.

* Include Region 9 as officially required for Intel Meteor Lake platform.
* Incorporate missing region names from https://github.com/coreboot/coreboot/blob/main/util/ifdtool/ifdtool.c for completeness.

Region 5: Device Expansion (DE or DevExp)
Region 9: Device Expansion 2 (DE2 or DevExp2)
Region 10: Innovation Engine (IE)
Region 11: 10 GbE 0
Region 12: 10 GbE 1
Region 15: PTT

BUG=b:319773700
TEST=Run `flashrom -VV` on MTL and see all the regions are printed out

Change-Id: I3b164ce4ae84bfd523fcd8be416c5d13183ed632
Signed-off-by: Hsuan Ting Chen <roccochen@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/81356
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-04-21 08:19:33 +00:00
Maximilian Brune
e5ed0c6340 util/list_yet_unsupported_chips.h: Fix path
Change-Id: Iecb6cf3d1f214102a243a3ffa8d0c9301263af0a
Signed-off-by: Maximilian Brune <maximilian.brune@9elements.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/81855
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-04-15 20:53:49 +00:00
Anastasia Klimchuk
c06abc9014 doc: Make OS specific instructions as headers so they are linkable
When html page is generated, all headers are generated as links on
the page. It is useful to have OS specific instructions as a link
to share with people.

Change-Id: I78645131b1f0acbedcf11964a204a24c45b62cff
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/81780
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi
2024-04-12 09:27:12 +00:00
Anton Samsonov
7bc347e16d Makefile: Fix cleanup for Sphinx versions prior to 4.x
Fixup for change I9cd280551a1ba4d17edb2e857d56f80431b61e1b.

Change-Id: I123aec7cf2f016ba905c220cfc84a217523f9932
Signed-off-by: Anton Samsonov <devel@zxlab.ru>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/81802
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-04-12 05:25:50 +00:00
Anastasia Klimchuk
124b6eaf6b meson: Update CI script to enforce building man pages and docs
`test_build.sh` is used by Jenkins, therefore it should build
everything. Docker container for Jenkins is expected to have all
the dependencies installed, and if some of them are missing, script
should fail.

Recently we had a situation when docker image was missing sphinx
and flashrom Jenkins was silently skipping building man-pages and
documentation. This patch prevents this happening again, because
building man pages and docs will be enforced.

Change-Id: Ib89abddad27d1168cf0a621cf4bdb9f541266165
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/81665
Reviewed-by: Martin L Roth <gaumless@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anton Samsonov <avscomputing@gmail.com>
2024-04-10 03:01:06 +00:00
Funkeleinhorn
2a5d2920d8 serprog: Add SPI Mode and CS Mode commands
This commit adds two new commands to the serprog protocol which allow
more fine grained control over the SPI bus. This enables more
applications over serprog like e.g. flashing AVR microcontrollers.
This can be tried with my forks of pico-serprog:

https://github.com/funkeleinhorn/pico-serprog/tree/spimode

and avrdude:

https://github.com/funkeleinhorn/avrgirl/tree/serprog-programmer

I announced this change in flashrom and flashprog IRC channels and got
overall positive feedback in the flashprog channel. The same changes
will be sent to flashprog to prevent diverging specs.

Change-Id: Idb5a9a3710fede322def5191d68b7fba0e135292
Signed-off-by: Funkeleinhorn <git@funkeleinhorn.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/81428
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-04-02 02:51:19 +00:00
Hsuan Ting Chen
041644a6af classic_cli_manpage.rst: Update doc for custom_rst of raiden_debug_spi
Update technical details for custom_rst of raiden_debug_spi to help
users better understand their configuration options.

BUG=b:161745002
BRANCH=none
TEST=`meson compile -C testdir` and
     view ./testdir/doc/html/classic_cli_manpage.html

Change-Id: Ie2b084a3ed9bf40f91bfa81dbc95ec69d99d5ad0
Signed-off-by: Hsuan Ting Chen <roccochen@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/81114
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-03-30 12:46:15 +00:00
DanielZhang
1bcedfa598 flashchips: Add support for MXIC MX25L12850F
The MX25L12850F has been tested by ch341a programmer : read, write,
erase and wp.

We have tested --wp-enable, --wp-disable, --wp-list and --wp-range
commands for write-protect feature.

MX25L12850F datasheet is available at the following URL:
https://www.macronix.com/Lists/Datasheet/Attachments/8632/MX25L12850F,%203V,%20128Mb,%20v1.0.pdf

Change-Id: I71ac70d273904f94d015401f9d8df587084efad0
Signed-off-by: DanielZhang <danielzhang@mxic.com.cn>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/81350
Reviewed-by: Alexander Goncharov <chat@joursoir.net>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-03-30 07:57:37 +00:00
Anastasia Klimchuk
435309ea28 doc/dev_guide: Add section about Jenkins build, and scan-build
Change-Id: I416b632c55d1ceb925456ac8c8947dfbcef2e888
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/81261
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
2024-03-27 23:14:37 +00:00
Anton Samsonov
b65f347377 flashchips: Add Zetta Device ZD25LQ128
Datasheet: http://www.zettadevice.com/uploads/files/163410630201e3483211247ac1.pdf

Tested probe, read, erase, write, verify on ZD25LQ128AWIG chips
using Linux SPI and DediProg SF100 programmers.

Renamed ZETTADEVICE_ macros to ZETTA_ to accomodate longer suffixes.

Change-Id: I5cb20158e81ab109f16958285b8787858efb4831
Signed-off-by: Anton Samsonov <devel@zxlab.ru>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/81392
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-03-26 05:34:52 +00:00
Anastasia Klimchuk
70e1a41ead cli_common: Add link to the documentation how to mark chip tested
Perhaps some of the users will be able to follow the instructions
and send a patch to mark chip as tested. The option to send report
to the mailing list remains available as before.

Change-Id: I36105725058f2fecb82408c369b70b3324502ece
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/81266
Reviewed-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
2024-03-21 12:16:49 +00:00
Anastasia Klimchuk
9cc6be205d serprog: Fix scan-build warning of resource leak
Warning found by the latest scan-build run:

*** CID 1534883:    (RESOURCE_LEAK)
/serprog.c: 853 in serprog_init()
847                                     "by programmer!\n", cs_num8);
848				goto init_err_cleanup_exit;
849                     }
850             }
851             bt = serprog_buses_supported;
852             if (sp_docommand(S_CMD_S_BUSTYPE, 1, &bt, 0, NULL))
>>>CID 1534883:    (RESOURCE_LEAK)
>>>Variable "cs" going out of scope leaks the storage it points to.
853                     goto init_err_cleanup_exit;
854     }

Follow up on
commit e8c350f55e596aae3ab2bbc210b68389e2301a6c

Change-Id: Id9cf211de3c482f702adebfcfa274a183c83a33f
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/81032
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Alexander Goncharov <chat@joursoir.net>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2024-03-21 10:59:40 +00:00
Brian Norris
54b053e6b2 udelay: Lower the sleep vs delay threshold
By default, we busy-loop (a.k.a., "delay") for most delay values, and
only allow sleeping for large delays. But busy-looping is expensive, as
it wastes CPU cycles.

In a simple program that runs a bunch of samples of [1] over 1000
samples, I find that for 0.1 s (100000 us):

 64x2 AMD CPU (CONFIG_HZ=250 / CONFIG_NO_HZ_FULL=y):
   min diff: 60 us
   max diff: 831 us
   mean diff: 135 us

 4+2 Mediatek MT8183 CPU (CONFIG_HZ=1000 / CONFIG_NO_HZ_IDLE=y /
                          sysctl kernel.timer_highres=1):
   min diff: 70 us
   max diff: 1556 us
   mean diff: 146 us

 4+2 Mediatek MT8183 CPU (CONFIG_HZ=1000 / CONFIG_NO_HZ_IDLE=y /
                          sysctl kernel.timer_highres=0):
   min diff: 94 us
   max diff: 7222 us
   mean diff: 1201 us

i.e., maximum 1.5% error, typically ~0.1% error with high resolution
timers. Max 7% error, typical 1% error with low resolution timers. The
error is always in the positive direction (i.e., sleep longer than the
requested delay, not shorter than the request).

This seems reasonable.

[1] Stripped / pseudocode:

  clock_gettime(CLOCK_MONOTONIC, before);
  nanosleep({ .tv_nsec = usecs * 1000 }, NULL);
  clock_gettime(CLOCK_MONOTONIC, after);
  diff = abs((after - before) / 1000 - usecs));

Change-Id: Ifd4821c66c5564f7c975c08769a6742f645e9be0
Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/80808
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-03-14 10:24:22 +00:00
Brian Norris
3c5eb532ad cli_classic: Defer flashrom_init calibration until after options parsing
flashrom_init() may run through an expensive delay calibration phase,
depending on the system timer behavior (e.g., if high resolution timers
are disabled). This is wholly unnecessary if we're only going to dump
usage output or similar.

Defer the calibration until we've finished our CLI overhead.

BUG=b:325539928
TEST=`flashrom --help` with `sysctl kernel.timer_highres` == 0

Change-Id: I57949ab511df04c6922008fa8cb12467154e2c5e
Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/80772
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Hsuan-ting Chen <roccochen@google.com>
Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-03-14 10:16:08 +00:00
Brian Norris
0802655531 linux_mtd: Provide no-op delay implementation
Flashrom has several magic programmer_delay() calls scattered throughout
its codebase (see cli_classic.s/main() and
flashrom.c/flashrom_image_write(), at least). These delays are
superfluous for the linux_mtd programmer, because it's an opaque
programmer in which all protocol details are handled by the kernel
driver.

Stub out the delay function, so we don't waste up to 1.1 seconds of
needless delay time, depending on the operation and CLI vs libflashrom
usage.

BUG=b:325539928
TEST=`elogtool add 0xa7` on a linux_mtd system (such as a Mediatek
       Chromebook):
     Time improvement - reduces from ~1.5s wall clock to about 0.4s
     CPU usage: -90%, as most of the CPU cycles (before this change) are
       spent in needless magic-delay busy loops

Change-Id: I3ac69d3fd7cfc689c5b32c130d044516ed846c29
Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/80771
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-03-14 10:14:51 +00:00
Anastasia Klimchuk
537050351a doc: Update arbitration team to be flashrom specific
Same approach as it was before: founder and current project lead.

Change-Id: I1043b9499ab22da5ec981592d7b4311f027c4b5f
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/81106
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-03-10 20:48:29 +00:00
Brian Norris
7be490758e fmap: Update major/minor version check
It's not valid to separately check the major and minor versions. The
proper minor check would be something like:

  if (fmap->ver_major == FMAP_VER_MAJOR &&
      fmap->ver_minor > FMAP_VER_MINOR)
    ERROR();

But this code was alleged (at introduction in [1]) to have come from
cbfstool, and cbfstool doesn't bother with a minor version check. This
check is only for finding the FMAP while searching the flash; it isn't
actually here for integrity and compatibility purpose.

Drop the MINOR version check; align with cbfstool on the MAJOR version
check; and match the cbfstool comments for is_valid_fmap(), to emphasize
the lack of precision.

[1] Commit c82900b66142 ("Add support to get layout from fmap (e.g.
    coreboot rom)")

BRANCH=none
BUG=b:288327526
TEST=libflashrom + ChromiumOS flashmap

Change-Id: I984835579d3b257a2462906f1f5091b179891bd0
Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/79060
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-03-08 12:30:13 +00:00
Anastasia Klimchuk
f2a750475a doc: Add doc how to support flashrom project
Change-Id: I59a4f5978bc8ffa8ca3a3dc3f15c770ef5fcedce
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/80729
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi <patrick@coreboot.org>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
2024-03-05 11:24:04 +00:00
Anastasia Klimchuk
d15e86d7b0 doc: Add links to Gerrit groups in team page
Change-Id: I493db8c7b2610076136d439e172e3f2cee971346
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/80765
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi <patrick@coreboot.org>
2024-03-01 08:55:53 +00:00
Riku Viitanen
f5ca2dbf7f serprog: clean up documentation
* serprog.h doesn't exist, so refer to .c source instead
* in the doc, no other command has S_CMD_ prefix either

Change-Id: Ic83e7fd80840f2db0b006935a964721da0388068
Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/80499
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-03-01 07:01:50 +00:00
Riku Viitanen
e8c350f55e serprog: Add support for multiple SPI chip selects
Tested with an EliteBook 8560w, Pi Pico, and my serprog firmware:
https://codeberg.org/Riku_V/pico-serprog/

As seen on Flashprog: https://review.sourcearcade.org/c/flashprog/+/51

Change-Id: If8052bc6f5c314dcc493bc083bb8270723efaae7
Signed-off-by: Riku Viitanen <riku.viitanen@protonmail.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/80498
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-03-01 07:01:23 +00:00
Anton Samsonov
6d128a4fff Makefile: Fix version string for non-Git builds
Match the version string for `make` builds to that of `meson` builds
from both Git- and non-Git (release or current snapshot) source trees.

Change-Id: I8694e618878823a9e96b1f2bcfa63f6c71d3c2ed
Signed-off-by: Anton Samsonov <devel@zxlab.ru>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/79152
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2024-02-25 10:49:17 +00:00
Anastasia Klimchuk
49fbdc7dd6 doc: Clarify that adding docs follows dev process and add into howtos
Also add link to "How to add new doc" into a collection of
Contributors howtos.

The doc stays in root of docs, and also in the main left-side
menu on the website, so that it is very easy to discover. Everyone
who has even the slightest motivation to update the docs, should
be able to find instructions easily.

Change-Id: I882de0614ab76b8e83b0fafa67296526fecd8a16
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/80631
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2024-02-23 01:44:26 +00:00
Anton Samsonov
8b074c8b7c Makefile,meson.build: Add support for Sphinx versions prior to 4.x
As of version 3.x, `sphinx-build` outputs man pages to "8" directory
instead of "man8" expected by Makefile and doc/meson.build. See:
    https://github.com/sphinx-doc/sphinx/issues/7996
    https://github.com/sphinx-doc/sphinx/issues/9217

Current solution is to rename "8" to "man8" after documentation build.
That enables successful build and installation, as well as dependency
tracking at build-system level, but not on `sphinx-build` own level
upon which `meson` build blindly relies.

Change-Id: I9cd280551a1ba4d17edb2e857d56f80431b61e1b
Signed-off-by: Anton Samsonov <devel@zxlab.ru>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/77778
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
2024-02-21 11:07:24 +00:00
Anastasia Klimchuk
56bb56d8e3 doc: Add doc how to add unit tests
Change-Id: I73f6add194a531c4f88b822d92c31ec67c23d2dc
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/80340
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-02-11 08:01:48 +00:00
Davide Gerhard
f08acc669b flashchips: Add Macronix MX25R1635F
16Mbit (2MiB) [x1/x2/x4] Wide Voltage Range (VCC 1.65V-3.6V). It is
similar to the already-supported MX25R3235F, but the total size is
halved.

Tested probe, read, erase, write and verify with buspirate.

Datasheet: https://www.mxic.com.tw/Lists/Datasheet/Attachments/8702/MX25R1635F,%20Wide%20Range,%2016Mb,%20v1.6.pdf

Change-Id: Idce301ed90d6742b56e928068d201e5c3a2e5aee
Signed-off-by: Davide Gerhard <rainbow@irh.it>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/69678
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-02-07 06:16:49 +00:00
roccochen@chromium.com
04deed8c8f flashrom_tester: Fix partial_lock_test on libflashrom
partial_lock_test (Lock_top_quad, Lock_bottom_quad, Lock_bottom_half,
and Lock_top_half) tries to:
1. Disable HWWP
2. Lock partial
3. Enable HWWP
4. Try to write the locked partial and expect a failure
...

The 4th step only works on flashrom binary since the binary will set
FLASHROM_FLAG_VERIFY_AFTER_WRITE=1 by default and it will error out
while verifying.

But libflashrom does not set any flag beforehand, so it has
FLASHROM_FLAG_VERIFY_AFTER_WRITE=0 and thus it will think the write
command works normally and raise no error. This causes the issue that
flashrom_tester with libflashrom has been failed until today.

To solve this issue, there are two solutions:
1. Take care of the default flags in libflashrom
2. Always pass --noverify to flashrom binary and verify it afterwards.

To make both methods more consistent, I fix it with approach 1.

BUG=b:304439294
BRANCH=none
TEST=flashrom_tester internal --libflashrom Lock_top_quad

Change-Id: I7a8ac0c0984fef3cd9e73ed8d8097ddf429e54b2
Signed-off-by: roccochen@chromium.com <roccochen@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/79304
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-02-03 07:43:35 +00:00
Anastasia Klimchuk
c52f949b62 doc: Add docs how to add and update test status of flashchips
For reference, link to doc about adding new chip
on the old website:
https://wiki.flashrom.org/Development_Guidelines#Adding/reviewing_a_new_flash_chip

Docs on how to update test status of flashchips never existed before.

Change-Id: I8dde689f2a0430ae10d3fa68bee727c5a9d70aec
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/80205
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
2024-02-03 07:06:49 +00:00
Anastasia Klimchuk
a21be9153a flashchips: Mark FM25Q16 as probe/read tested
As reported on the mailing list:
https://mail.coreboot.org/hyperkitty/list/flashrom@flashrom.org/thread/I6H7DXADVD4ICAW3QURUFWHXW5NNAT3E/

Change-Id: I8e55cd6eeb693bf33e580d662da08e50fb46809d
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/79975
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-01-18 07:17:21 +00:00
Anastasia Klimchuk
2bf299f1bf tests: Add test cases for erasing/writing unaligned layout regions
The test cases from #16 onwards cover the case when layout region is
not aligned with eraseblock region, and therefore either layout start
boundary or end boundary needs to be extended to align with
eraseblock.

Ticket: https://ticket.coreboot.org/issues/494
Change-Id: I726a30b0e47a966e8093ddc19abf4a65fb1d70ce
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/78985
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2024-01-15 02:01:54 +00:00
Anastasia Klimchuk
48b9ece5ad erasure_layout: Fix unaligned region end offset by 1
In the case when layout region is not aligned with eraseblock,
end region boundary is extended to match the eraseblock. There is
a special handling of this extended area (between original end of
region and extended one). Fix the offset of this extended area by +1
so that it covers the extended area and not the original region.

Before the patch, the last byte of the original region was failed to
write since it was treated as if an extended area, while it was the
last byte of the normal layout region.

Ticket: https://ticket.coreboot.org/issues/494
Change-Id: I7f78a0090065cd2a952cba1a5d28179483ba4c55
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/78984
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
2024-01-15 02:01:31 +00:00
Tyler Wang
bb8e6f904b flashchips: Add write-protect support for GD25LQ255E
datasheet: https://www.gigadevice.com.cn/Public/Uploads/uploadfile/files/20221129/DS-00562-GD25LQ255E-Rev1.1.pdf

BUG=b:311336475
TEST=Verified on karis

w/o this patch:
$ flashrom_tester --flashrom_binary ./flashrom internal Lock_top_quad
  --> Failed

w/ this patch:
$ flashrom_tester --flashrom_binary ./flashrom internal Lock_top_quad
  --> Pass

This lock_top_quad test did(copied from partial_lock_test()):
* Disable hardware WP so we can modify the protected range.
* Then enable software WP so the range is enforced and enable
  hardware WP so that flashrom does not disable software WP during the
  operation.
* Check that we cannot write to the protected region.
* Check that we can write to the non protected region.

Change-Id: I1425e931433c00caceaabc6037a79099d6d5eac5
Signed-off-by: Tyler Wang <tyler.wang@quanta.corp-partner.google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/79460
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
Reviewed-by: Hsuan-ting Chen <roccochen@google.com>
2024-01-05 03:55:57 +00:00
Tyler Wang
6f3339fda6 flashchips: Add GD25LQ255E
datasheet: https://www.gigadevice.com.cn/Public/Uploads/uploadfile/files/20221129/DS-00562-GD25LQ255E-Rev1.1.pdf

BUG=b:311336475
TEST=(1) flashrom -p internal -r /tmp/bios.bin, get "SUCCESS" result
     (2) flashrom -p internal -w /tmp/bios.bin, get "SUCCESS" result
     (3) flashrom -i RW_MRC_CACHE -E, get "SUCCESS" result

Change-Id: I0d780255ed6772f4aa406584acf071a7ddd6da47
Signed-off-by: Tyler Wang <tyler.wang@quanta.corp-partner.google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/79088
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Hsuan-ting Chen <roccochen@google.com>
Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
2024-01-05 03:54:45 +00:00
roccochen@chromium.com
5106287e22 flashrom_tester: Drop technical debt
Drop `-p host` ChromeOS miss-feature and use `-p internal` instead.

BUG=b:296978620
BRANCH=none
TEST=run flashrom-tester with newer flashrom

Change-Id: I1ea174c1760fee3e41a2ef0e9779badf0c51298d
Signed-off-by: roccochen@chromium.com <roccochen@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/79303
Reviewed-by: Evan Benn <evanbenn@gmail.com>
Reviewed-by: David Wu <david_wu@quanta.corp-partner.google.com>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Nick Vaccaro <nvaccaro@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Bob Moragues <moragues@google.com>
2023-12-21 22:38:32 +00:00
Carly Zlabek
8ac3574fc6 erasure_layout: Remove redundant verifications from erase_write
Previously, in the worst-case scenario of erasing region content then
writing new data, three rounds of verification were performed inside of
the `erase_write` function through calls to:

  1. `check_erased_range` when erasing with respect to region boundaries
  2. `check_erased_range` for the entire erase block after the loop
     containing verification 1 completed
  3. `verify_range` when all erases/writes were complete

Verification 2 duplicated verification 1 and was orphaned by commit
fa8808595a, which dropped its paired erasefn call but missed this
related step.

Verification 3 duplicated verification which occurs in
`flashrom_image_write` based on `flashctx flags`.

Now, these 2 redundant verifications are removed to improve the
performance of `erase_write`.

This change was tested using the linux_spi programmer to erase and write
to an MT25QL512 chip.

Change-Id: I638835facd9311979c4991cc4ca41a4b9e174bd5
Signed-off-by: Carly Zlabek <carlyzlabek@gmail.com>
Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/79354
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2023-12-18 00:22:31 +00:00
Scott Chao
e188cc383e flashrom_tester: Align WP output format with upstream
After WP output format changed, the flashrom_tester will always read
software write protect is disabled.

BUG=b:300300436
TEST=Verify on flashrom_tester

Change-Id: I755891e0d8b5857650febe08c2094733cf1f4c79
Signed-off-by: Scott Chao <scott_chao@wistron.corp-partner.google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/77887
Reviewed-by: Hsuan-ting Chen <roccochen@google.com>
Tested-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
2023-12-13 21:40:22 +00:00
David Reguera Garcia
0dbf2ded28 buspirate_spi: add support for hiz output with pullups=off
When working with low-voltage chips, the internal 10k pull-ups
of the Bus Pirate might be too high. In such cases, it's necessary
to create an external pull-up using lower-value resistors. For this,
you can use the 'hiz' parameter.  This way, the Bus Pirate will
operate as an open drain with 'pullups=off'

So, why not just use the 'pullups=on' option for this scenario? I'm
trying to prevent a very typical human error in the training sessions
I conduct.

For example, in the previous session, a user might have left the VPU
(vextern) connected to 5V, and now they need to access a 1.8V chip.
If 'pullups=on' is used, the following will happen:
5V (VPU) --> CD4060 --> 2K (internal Bus Pirate) --> MOSI target chip.
By having the option to set a 'hiz=on', this can be avoided. Since the
pull-ups will remain deactivated while the Bus Pirate will function in
an open-drain mode

Return init error for invalid values of pullups, hiz, psus. Previously,
invalid values of the params pullups, hiz, psus were handled as "off"
(i.e. disabled). This created a potential human error when users were
running flashrom with e.g. pullups=1 and expected pullups to be on,
while the value 1 was handled as invalid and off.

Change-Id: I6d9909b23782ef3fcb1428fd127dae0d6b211855
Signed-off-by: David Reguera Garcia <dreg@rootkit.es>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/79299
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2023-12-10 21:47:27 +00:00
Hsuan Ting Chen
360d965ce7 MAINTAINERS: Add Hsuan Ting Chen for flashrom_tester
BUG=none
BRANCH=none
TEST=~/coreboot/util/scripts/get_maintainer.pl -f
     util/flashrom_tester/build.rs

Change-Id: I71139401b5f2c7c1b4e76ba67ff774e030a343aa
Signed-off-by: Hsuan Ting Chen <roccochen@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/79319
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2023-12-08 22:36:20 +00:00
Anastasia Klimchuk
9a570318bb docs: Add guideline about Gerrit display names
If none of "Full name" or "Display name" is set for a Gerrit account,
code reviews emails are sent from "Name of user not set" instead of
a user name. It is worth clarifying explicitly in the docs.

Change-Id: I69b6f5c1c56a2798dd156582cb5fa246b2396ab3
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/79250
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Reviewed-by: Stanislav Ponomarev <me@stasponomarev.com>
2023-11-30 01:44:35 +00:00
Fabrice Fontaine
fb456a6306 Makefile: CONFIG_INTERNAL depends on raw mem access
CONFIG_INTERNAL depends on raw mem access resulting in the following
build failure on sh4 since version 1.3.0:

/home/thomas/autobuild/instance-3/output-1/per-package/flashrom/host/bin/../lib/gcc/sh4a-buildroot-linux-gnu/12.3.0/../../../../sh4a-buildroot-linux-gnu/bin/ld: libflashrom.a(internal.o): in function `internal_chip_readn':
internal.c:(.text+0x8): undefined reference to `mmio_readn'

Fixes the build raised by buildroot autobuilders with the following
options:
- CONFIG_FT2232_SPI=no
- CONFIG_USBBLASTER_SPI=no
- CONFIG_ENABLE_LIBUSB1_PROGRAMMERS=yes
- CONFIG_ENABLE_LIBPCI_PROGRAMMERS=yes

Here is the target information:
C compiler found: sh4a-buildroot-linux-gnu-gcc.br_real (Buildroot 2022.08-rc1-5515-gf1a47904b63) 12.3.0
Target arch: sh
Target OS: Linux
Target endian: little

Full build log:
- http://autobuild.buildroot.org/results/f74a9d315fb519f284428234713f43fcf4e35fd0

Change-Id: I7610f5f7cc5b114ffa90d5752155acc8b6b7c9f7
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/78930
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Alexander Goncharov <chat@joursoir.net>
2023-11-30 01:27:05 +00:00
Anton Samsonov
8efe4fb708 Remove dependency on C23 __has_include()
Use build system to check header presence:
* getopt.h (from include/cli_classic.h)
* pciutils/pci.h (from include/platform/pci.h)

Tested with <getopt.h> and <pci/pci.h> using GNU Make 4.1, 4.2.1, 4.4.1
and Meson 0.56.0, 1.2.1 against GCC 13.2.1 and GCC 5.5-, 7.3-compatible
(EDG 4.14-, 5.1-based) on openSuSE Tumbleweed and a custom LFS distro.

Change-Id: Ic544963ffd29626ae0a21bdddb1c78850cc43ec6
Signed-off-by: Anton Samsonov <devel@zxlab.ru>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/77089
Reviewed-by: Alexander Goncharov <chat@joursoir.net>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2023-11-28 23:26:01 +00:00
Stanislav Ponomarev
bda8361453 serial: Fix sp_flush_incoming for serprog TCP connections
During the development of an esp32 serprog-compatible SPI programmer,
and implementation of the TCP over Wi-Fi for serprog,
I discovered that sp_flush_incoming() silently fails
if the underlying sp_fd descriptor is a TCP socket.

This patch adds a check for this case - tcflush returns ENOTTY,
meaning tcflush is not supported for not terminal objects,
in this case a fallback serialport_read_nonblock loop is used.

TESTED=esp32-serprog, TCP-over-WiFi mode, ~90% connection attempts fail to synchronize without patch; no synchronization issues with patch applied.

Signed-off-by: Stanislav Ponomarev <me@stasponomarev.com>

Change-Id: I9724a2fcd4a41dede2c15f83877efa6c3b0b7fae
Reviewed-on: https://review.coreboot.org/c/flashrom/+/79112
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2023-11-27 09:09:35 +00:00
Hsuan Ting Chen
abd9a1e9e8 flashchips: Split GD25Q127C/GD25Q128C and add GD25Q128E
Q127C and Q128C are not the same. Q127C doesn't support QPI but Q128C
does. So we need to split the existing GD25Q127C/GD25Q128C into two
separated entries. We also introduce the new flashchip Q128E and merge
it into Q127C.

Datasheets:
Q128E: https://www.gigadevice.com.cn/Public/Uploads/uploadfile/files/20220714/DS-00480-GD25Q128E-Rev1.2.pdf
Q127C: https://www.gigadevice.com.cn/Public/Uploads/uploadfile/files/20220714/DS-00220-GD25Q127C-Rev2.3.pdf
Q128C: https://www.endrich.com/sixcms/media.php/2/GD25Q128C-Rev2.pdf

Q128E and Q127C/Q128C have compatible main functions, their differences
are:
* Q128E uses 55 nm process, while Q127C/Q128C use 65nm
* Q128E/Q127C does not support QPI
* Q128E/Q127C have OTP: 3072B, while Q128C are 1536B
* Q128E's fast read clock frequency is 133MHz, while Q127C/Q128C are
  104MHZ

So we decided to merge Q128E into Q127C.

We also tested that Q128E could pass flashrom_tester while probing it as
127C/128C, so the main functionalities are compatible.

Change the chip name from GD25Q127C/GD25Q128C to two entries
GD25Q127C/GD25Q128E and GD25Q128C to make it more accurate.

Chip revision history:
- The 'GD25Q127C/GD25Q128C' definition was added in
  `commit e0c7abf219b81ad049d09a4671ebc9196153d308` as 'GD25Q128C' and
  later renamed to 'GD25Q127C/GD25Q128C'

BUG=b:304863141, b:293545382
BRANCH=none
TEST=flashrom_tester with flashrom binary could pass with Q128E,
     which contains probe, read, write, erase, and write protect

Signed-off-by: Hsuan Ting Chen <roccochen@google.com>
Change-Id: I3300671b1cf74b3ea0469b9c5a833489ab4914f5
Reviewed-on: https://review.coreboot.org/c/flashrom/+/78348
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2023-11-19 23:23:46 +00:00
Alexander Goncharov
41cb46672e flashchips: change print lock status funcs for Winbond chips
Decode status register bits for user friendly output.

Signed-off-by: Alexander Goncharov <chat@joursoir.net>
Change-Id: I5066863b514825aee0dffe496492514ac99b6e49
Reviewed-on: https://review.coreboot.org/c/flashrom/+/75877
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
2023-11-18 20:52:33 +00:00
Alexander Goncharov
8a7f8ade46 spi25_statusreg: rename amic_a25l032 print to a generic name
Other chips (at least Winbond) will benefit from this change.

Also, drop the FIXME comment, as it can be misleading. The
"pretty print" functions should only display values from the
Status Register, so using an inappropriate function might only
confuse user.

Signed-off-by: Alexander Goncharov <chat@joursoir.net>
Change-Id: I7169a2312698343e1065cdca91a3985e00cb3804
Reviewed-on: https://review.coreboot.org/c/flashrom/+/78874
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
2023-11-18 20:52:05 +00:00
Anastasia Klimchuk
ffa2159923 tests: Unit tests for erase function selection algo
The test checks that algorithm for erase functions selection
works and there are no regressions.

Specifically, test contains an array of test cases. Each case
initialises a given initial state of the memory for the mock chip,
and layout regions on the chip, and then performs erase and write
operations.
At the end of operation, test asserts the following:
- the state of mock chip memory is as expected, i.e. properly erased
  or written
- erase blocks are invoked in expected order and expected number
  of them
- chip operation (erase or write) returned 0.

Change-Id: I8f3fdefb76e71f6f8dc295d9dead5f38642aace7
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/67535
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
2023-11-12 22:18:46 +00:00
Anastasia Klimchuk
9c130dbfcc erasure_layout: Add region boundaries to printed info message
Change-Id: I511a79754cff15e7dba26f5313d7015830780f60
Signed-off-by: Anastasia Klimchuk <aklm@flashrom.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/78492
Reviewed-by: Alexander Goncharov <chat@joursoir.net>
Reviewed-by: Aarya <aarya.chaumal@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2023-11-12 22:18:04 +00:00