Edward O'Callaghan has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/71742 )
Change subject: flashrom.c: Rewrite prepare_chip_access() 4BA enablement
......................................................................
flashrom.c: Rewrite prepare_chip_access() 4BA enablement
Factor out the 4BA enablement logic into its own function and
break down predicates into a series of easy to follow base-cases
complete with comments.
TEST=`$ sudo ./flashrom -p internal -r /tmp/bios`.
on a Found chipset "Intel Tiger Lake U Premium".
Change-Id: I10a426331cb2a3485e3dd786fa771e20870cbd84
Signed-off-by: Edward O'Callaghan <quasisec(a)google.com>
---
M flashrom.c
1 file changed, 57 insertions(+), 24 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/42/71742/1
diff --git a/flashrom.c b/flashrom.c
index 822594b..f7499c3 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -1905,6 +1905,45 @@
return 0;
}
+static int enable_4ba_if_required(struct flashctx *const flash)
+{
+ /* Check if chip too small to need 4BA. */
+ if (flash->chip->total_size <= 16 * 1024) {
+ return 0;
+ }
+
+ /* Check if SPI bus with 4BA enabled has a SPI master missing 4BA mode. */
+ if (!spi_master_no_4ba_modes(flash)) {
+ return 0;
+ }
+
+ /* Check if SPI bus with 4BA has a SPI master that supports a 4BA mode. */
+ if (!spi_master_4ba(flash)) {
+ msg_cerr("Programmer doesn't support this chip. Aborting.\n");
+ return 1;
+ }
+
+ /* Check chip supports native 4BA instructions and if not bail out. */
+ if ((flash->chip->feature_bits & FEATURE_4BA_NATIVE) != FEATURE_4BA_NATIVE) {
+ msg_cerr("Chip does not support 4BA Native instructions. Aborting.\n");
+ return 1;
+ }
+
+ /* Check if chip is on a chipbus that supports 4BA addressing mode. */
+ if (!spi_chip_4ba(flash)) {
+ return 0;
+ }
+
+ /* Enable/disable 4-byte addressing mode. */
+ int ret = spi_master_4ba(flash) ? spi_enter_4ba(flash): spi_exit_4ba(flash);
+ if (ret) {
+ msg_cerr("Failed to set correct 4BA mode! Aborting.\n");
+ return 1;
+ }
+
+ return 0;
+}
+
int prepare_flash_access(struct flashctx *const flash,
const bool read_it, const bool write_it,
const bool erase_it, const bool verify_it)
@@ -1933,30 +1972,7 @@
flash->address_high_byte = -1;
flash->in_4ba_mode = false;
- /* Be careful about 4BA chips and broken masters */
- if (flash->chip->total_size > 16 * 1024 && spi_master_no_4ba_modes(flash)) {
- /* If we can't use native instructions, bail out */
- if ((flash->chip->feature_bits & FEATURE_4BA_NATIVE) != FEATURE_4BA_NATIVE
- || !spi_master_4ba(flash)) {
- msg_cerr("Programmer doesn't support this chip. Aborting.\n");
- return 1;
- }
- }
-
- /* Enable/disable 4-byte addressing mode if flash chip supports it */
- if (spi_chip_4ba(flash)) {
- int ret;
- if (spi_master_4ba(flash))
- ret = spi_enter_4ba(flash);
- else
- ret = spi_exit_4ba(flash);
- if (ret) {
- msg_cerr("Failed to set correct 4BA mode! Aborting.\n");
- return 1;
- }
- }
-
- return 0;
+ return enable_4ba_if_required(flash);
}
void finalize_flash_access(struct flashctx *const flash)
--
To view, visit https://review.coreboot.org/c/flashrom/+/71742
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I10a426331cb2a3485e3dd786fa771e20870cbd84
Gerrit-Change-Number: 71742
Gerrit-PatchSet: 1
Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-MessageType: newchange
Attention is currently required from: Sam McNally, Felix Singer, Angel Pons.
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/71269 )
Change subject: programmer.h: Guard against sending spi commands on non-spi mst
......................................................................
Patch Set 2:
(1 comment)
File flashrom.c:
https://review.coreboot.org/c/flashrom/+/71269/comment/3751906d_36a73bbc
PS1, Line 1937: spi_master_no_4ba_modes
> Could we skip this entire section on 4ba for non-SPI masters?
I feel like the code needs a bit of work.. Can we just fix the immediate issue first (>16MB flashing is broken on ichspi).
--
To view, visit https://review.coreboot.org/c/flashrom/+/71269
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I7cce4f9c032d33c01bf616e27a50b9727a40fe1b
Gerrit-Change-Number: 71269
Gerrit-PatchSet: 2
Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Reviewer: Jonathon Hall <jonathon.hall(a)puri.sm>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Nikolai Artemiev <nartemiev(a)google.com>
Gerrit-CC: Sam McNally <sammc(a)google.com>
Gerrit-CC: Subrata Banik <subratabanik(a)google.com>
Gerrit-Attention: Sam McNally <sammc(a)google.com>
Gerrit-Attention: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Comment-Date: Sat, 07 Jan 2023 09:16:14 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Sam McNally <sammc(a)google.com>
Comment-In-Reply-To: Edward O'Callaghan <quasisec(a)chromium.org>
Comment-In-Reply-To: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-MessageType: comment
Attention is currently required from: Felix Singer, Vasily Galkin, Thomas Heijligen, roman.stingler(a)gmail.com.
Hello Felix Singer, build bot (Jenkins), Thomas Heijligen, roman.stingler(a)gmail.com,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/58179
to look at the new patch set (#5).
Change subject: flashchips.c: Add support for IS25WQ040
......................................................................
flashchips.c: Add support for IS25WQ040
Based on https://github.com/flashrom/flashrom/pull/204
squashed with fixes of IS25WQ040 size: it is 4Mbits, not 4MBytes, see
https://www.issi.com/WW/pdf/25WQ020-040.pdf
Tested read, write and erase with ft2232_spi-based "Tigard" programmer.
Change-Id: I072c6b94d7931637d1c2721c3316205f2d57320e
Signed-off-by: Roman Stingler <roman.stingler(a)gmail.com>
Signed-off-by: Vasily Galkin <galkin-vv(a)ya.ru>
---
M flashchips.c
M include/flashchips.h
2 files changed, 60 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/79/58179/5
--
To view, visit https://review.coreboot.org/c/flashrom/+/58179
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I072c6b94d7931637d1c2721c3316205f2d57320e
Gerrit-Change-Number: 58179
Gerrit-PatchSet: 5
Gerrit-Owner: Vasily Galkin
Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Reviewer: roman.stingler(a)gmail.com
Gerrit-CC: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-Attention: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Attention: Vasily Galkin
Gerrit-Attention: Thomas Heijligen <src(a)posteo.de>
Gerrit-Attention: roman.stingler(a)gmail.com
Gerrit-MessageType: newpatchset
Attention is currently required from: Felix Singer, Thomas Heijligen, roman.stingler(a)gmail.com.
Hello Felix Singer, build bot (Jenkins), Thomas Heijligen, roman.stingler(a)gmail.com,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/58179
to look at the new patch set (#4).
Change subject: flashchips.c: Add support for IS25WQ040
......................................................................
flashchips.c: Add support for IS25WQ040
Based on https://github.com/flashrom/flashrom/pull/204
squashed with fixes of IS25WQ040 size: it is 4Mbits, not 4MBytes, see
https://www.issi.com/WW/pdf/25WQ020-040.pdf
Tested read, write and erase with ft2232_spi-based "Tigard" programmer.
Change-Id: I072c6b94d7931637d1c2721c3316205f2d57320e
Signed-off-by: Roman Stingler <roman.stingler(a)gmail.com>
Signed-off-by: Vasily Galkin <galkin-vv(a)ya.ru>
---
M flashchips.c
M include/flashchips.h
2 files changed, 60 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/79/58179/4
--
To view, visit https://review.coreboot.org/c/flashrom/+/58179
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I072c6b94d7931637d1c2721c3316205f2d57320e
Gerrit-Change-Number: 58179
Gerrit-PatchSet: 4
Gerrit-Owner: Vasily Galkin
Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Reviewer: roman.stingler(a)gmail.com
Gerrit-CC: Paul Menzel <paulepanter(a)mailbox.org>
Gerrit-Attention: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Attention: Thomas Heijligen <src(a)posteo.de>
Gerrit-Attention: roman.stingler(a)gmail.com
Gerrit-MessageType: newpatchset
Attention is currently required from: Edward O'Callaghan, Angel Pons.
Sam McNally has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/71576 )
Change subject: chipset_enable.c: Add TL UP3 and UP4/Y id's
......................................................................
Patch Set 1:
(1 comment)
File chipset_enable.c:
https://review.coreboot.org/c/flashrom/+/71576/comment/637d65cb_688eb081
PS1, Line 2083: {0x8086, 0xa083, B_S, DEP, "Intel", "Tiger Lake U Premium 3", enable_flash_pch500},
> Let's keep it, but mark it as untested (change `DEP` to `NT`).
Sure; going off the coreboot #define, I think this should be "Tiger Lake Base UP4" or "Tiger Lake U Base", depending on the naming scheme used for the others..
--
To view, visit https://review.coreboot.org/c/flashrom/+/71576
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I77120612f7a770ae1319f4cd82913fa465f355f5
Gerrit-Change-Number: 71576
Gerrit-PatchSet: 1
Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Elyes Haouas <ehaouas(a)noos.fr>
Gerrit-Reviewer: Sam McNally <sammc(a)google.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Comment-Date: Fri, 06 Jan 2023 10:50:51 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Sam McNally <sammc(a)google.com>
Comment-In-Reply-To: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-MessageType: comment
Attention is currently required from: Felix Singer, Edward O'Callaghan, Angel Pons.
Sam McNally has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/71269 )
Change subject: programmer.h: Guard against sending spi commands on non-spi mst
......................................................................
Patch Set 2:
(1 comment)
File flashrom.c:
https://review.coreboot.org/c/flashrom/+/71269/comment/d2310077_4c7d1571
PS1, Line 1937: spi_master_no_4ba_modes
> sort of but not really. This is a chip bustype check not a master bustype check. […]
Could we skip this entire section on 4ba for non-SPI masters?
--
To view, visit https://review.coreboot.org/c/flashrom/+/71269
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I7cce4f9c032d33c01bf616e27a50b9727a40fe1b
Gerrit-Change-Number: 71269
Gerrit-PatchSet: 2
Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Reviewer: Jonathon Hall <jonathon.hall(a)puri.sm>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Nikolai Artemiev <nartemiev(a)google.com>
Gerrit-CC: Sam McNally <sammc(a)google.com>
Gerrit-CC: Subrata Banik <subratabanik(a)google.com>
Gerrit-Attention: Felix Singer <felixsinger(a)posteo.net>
Gerrit-Attention: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Comment-Date: Fri, 06 Jan 2023 10:48:16 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Edward O'Callaghan <quasisec(a)chromium.org>
Comment-In-Reply-To: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-MessageType: comment
Attention is currently required from: Sam McNally, Anastasia Klimchuk.
Hello Sam McNally, build bot (Jenkins), Anastasia Klimchuk,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/71659
to look at the new patch set (#2).
Change subject: tests/: Add subregion alignment unit-test
......................................................................
tests/: Add subregion alignment unit-test
A written region that is sized below that of the erasure granularity
can result in a incorrectly read region that does not include prior
content within the region before the write op. This was dealt with
in ChromeOS downstream by expanding out the read to match the erase
granularity however does not seem to impact upstream. Add a unit-test
to avoid regression as this is important behaviour to cover.
Change-Id: Id3ce5cd1936f0f348d34a6c77cee15e27a5c353f
Signed-off-by: Edward O'Callaghan <quasisec(a)google.com>
---
M tests/chip.c
M tests/tests.c
M tests/tests.h
3 files changed, 120 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/59/71659/2
--
To view, visit https://review.coreboot.org/c/flashrom/+/71659
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Id3ce5cd1936f0f348d34a6c77cee15e27a5c353f
Gerrit-Change-Number: 71659
Gerrit-PatchSet: 2
Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Sam McNally <sammc(a)google.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Sam McNally <sammc(a)google.com>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-MessageType: newpatchset