Skip to content

Commit f0204ef

Browse files
authored
flashrom: 1.3 -> 1.5.1 (#382143)
2 parents 810d309 + 2d4e8c8 commit f0204ef

File tree

2 files changed

+137
-19
lines changed

2 files changed

+137
-19
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
From 38b2cb092e866dede6b6ffddd135ff54a9bda69e Mon Sep 17 00:00:00 2001
2+
From: Angel Pons <[email protected]>
3+
Date: Wed, 2 Nov 2022 22:45:52 +0100
4+
Subject: [PATCH] sb600spi.c: Drop "Promontory" support
5+
6+
The "Promontory" code is riddled with issues, some of them can result in
7+
soft bricks. Moreover, Promontory doesn't have a SPI controller.
8+
9+
Drop support for "Promontory" in flashrom for now: it's holding back the
10+
entire project and it's unlikely that it'll be fixed in a timely manner.
11+
12+
Change-Id: I1457946dce68321b496d9ffa40a0c5ab46455f72
13+
Signed-off-by: Angel Pons <[email protected]>
14+
Reviewed-on: https://review.coreboot.org/c/flashrom/+/68824
15+
Tested-by: build bot (Jenkins) <[email protected]>
16+
Reviewed-by: Felix Singer <[email protected]>
17+
Reviewed-by: Swift Geek (Sebastian Grzywna) <[email protected]>
18+
Reviewed-by: Edward O'Callaghan <[email protected]>
19+
(cherry picked from commit 664c58f32af45b2acf7520c05bb40ef2c2f0891e)
20+
---
21+
sb600spi.c | 31 ++-----------------------------
22+
1 file changed, 2 insertions(+), 29 deletions(-)
23+
24+
diff --git a/sb600spi.c b/sb600spi.c
25+
index cec7e0a5..e84bb8d6 100644
26+
--- a/sb600spi.c
27+
+++ b/sb600spi.c
28+
@@ -48,7 +48,6 @@ enum amd_chipset {
29+
CHIPSET_HUDSON234,
30+
CHIPSET_BOLTON,
31+
CHIPSET_YANGTZE,
32+
- CHIPSET_PROMONTORY,
33+
};
34+
35+
#define FIFO_SIZE_OLD 8
36+
@@ -135,7 +134,8 @@ static enum amd_chipset determine_generation(struct pci_dev *dev)
37+
*/
38+
} else if (rev == 0x4b || rev == 0x51 || rev == 0x59 || rev == 0x61 || rev == 0x71) {
39+
msg_pdbg("Promontory (rev 0x%02x) detected.\n", rev);
40+
- return CHIPSET_PROMONTORY;
41+
+ msg_perr("AMD \"Promontory\" chipsets are currently not supported (https://ticket.coreboot.org/issues/370)");
42+
+ return CHIPSET_AMD_UNKNOWN;
43+
} else {
44+
msg_pwarn("FCH device found but SMBus revision 0x%02x does not match known values.\n"
45+
"Please report this to [email protected] and include this log and\n"
46+
@@ -572,18 +572,6 @@ static int handle_imc(const struct programmer_cfg *cfg, struct pci_dev *dev, enu
47+
return amd_imc_shutdown(dev);
48+
}
49+
50+
-static int promontory_read_memmapped(struct flashctx *flash, uint8_t *buf,
51+
- unsigned int start, unsigned int len)
52+
-{
53+
- struct sb600spi_data * data = (struct sb600spi_data *)flash->mst->spi.data;
54+
- if (!data->flash) {
55+
- map_flash(flash);
56+
- data->flash = flash; /* keep a copy of flashctx for unmap() on tear-down. */
57+
- }
58+
- mmio_readn((void *)(flash->virtual_memory + start), buf, len);
59+
- return 0;
60+
-}
61+
-
62+
static int sb600spi_shutdown(void *data)
63+
{
64+
struct sb600spi_data *sb600_data = data;
65+
@@ -617,17 +605,6 @@ static const struct spi_master spi_master_yangtze = {
66+
.shutdown = sb600spi_shutdown,
67+
};
68+
69+
-static const struct spi_master spi_master_promontory = {
70+
- .max_data_read = MAX_DATA_READ_UNLIMITED,
71+
- .max_data_write = FIFO_SIZE_YANGTZE - 3,
72+
- .command = spi100_spi_send_command,
73+
- .map_flash_region = physmap,
74+
- .unmap_flash_region = physunmap,
75+
- .read = promontory_read_memmapped,
76+
- .write_256 = default_spi_write_256,
77+
- .shutdown = sb600spi_shutdown,
78+
-};
79+
-
80+
int sb600_probe_spi(const struct programmer_cfg *cfg, struct pci_dev *dev)
81+
{
82+
struct pci_dev *smbus_dev;
83+
@@ -731,8 +708,6 @@ int sb600_probe_spi(const struct programmer_cfg *cfg, struct pci_dev *dev)
84+
case CHIPSET_SB89XX:
85+
case CHIPSET_HUDSON234:
86+
case CHIPSET_YANGTZE:
87+
- case CHIPSET_PROMONTORY:
88+
- msg_pdbg(", SpiBusy=%"PRIi32"", (tmp >> 31) & 0x1);
89+
default: break;
90+
}
91+
msg_pdbg("\n");
92+
@@ -808,8 +783,6 @@ int sb600_probe_spi(const struct programmer_cfg *cfg, struct pci_dev *dev)
93+
register_spi_master(&spi_master_sb600, data);
94+
else if (amd_gen == CHIPSET_YANGTZE)
95+
register_spi_master(&spi_master_yangtze, data);
96+
- else
97+
- register_spi_master(&spi_master_promontory, data);
98+
99+
return 0;
100+
}
101+
--
102+
2.45.2
103+
Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,50 @@
11
{
22
fetchurl,
33
stdenv,
4-
installShellFiles,
4+
bash-completion,
5+
cmocka,
56
lib,
67
libftdi1,
78
libjaylink,
89
libusb1,
10+
openssl,
11+
meson,
12+
ninja,
913
pciutils,
1014
pkg-config,
15+
sphinx,
1116
jlinkSupport ? false,
1217
}:
1318

14-
stdenv.mkDerivation rec {
19+
stdenv.mkDerivation (finalAttrs: {
1520
pname = "flashrom";
16-
version = "1.3.0";
21+
version = "1.5.1";
1722

1823
src = fetchurl {
19-
url = "https://download.flashrom.org/releases/flashrom-v${version}.tar.bz2";
20-
hash = "sha256-oFMjRFPM0BLnnzRDvcxhYlz5e3/Xy0zdi/v/vosUliM=";
24+
url = "https://download.flashrom.org/releases/flashrom-v${finalAttrs.version}.tar.xz";
25+
hash = "sha256-H5NLB27UnqziA2Vewkn8eGGmuOh/5K73MuR7bkhbYpM=";
2126
};
2227

28+
patches = [
29+
# Release notes for 1.4.0 state that Promontory chipsets are unsupported, and that attempting to read flash on those systems may crash the system.
30+
# The patch that removes this (broken) support only made it into the 1.3.0 release, seemingly by mistake, and the relevant code has been essentially untouched since.
31+
# We cherry-pick the upstream patch from 1.3.0, though amended to reference the relevant bug in the error message, rather than requesting the user email upstream.
32+
# https://ticket.coreboot.org/issues/370
33+
# https://review.coreboot.org/c/flashrom/+/68824
34+
./0001-sb600spi.c-Drop-Promontory-support.patch
35+
];
36+
2337
nativeBuildInputs = [
38+
meson
39+
ninja
2440
pkg-config
25-
installShellFiles
41+
sphinx
42+
bash-completion
2643
];
2744
buildInputs =
2845
[
46+
openssl
47+
cmocka
2948
libftdi1
3049
libusb1
3150
]
@@ -37,20 +56,16 @@ stdenv.mkDerivation rec {
3756
--replace 'GROUP="plugdev"' 'TAG+="uaccess", TAG+="udev-acl"'
3857
'';
3958

40-
makeFlags =
41-
[
42-
"PREFIX=$(out)"
43-
"libinstall"
44-
]
45-
++ lib.optional jlinkSupport "CONFIG_JLINK_SPI=yes"
46-
++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) [
47-
"CONFIG_INTERNAL_X86=no"
48-
"CONFIG_INTERNAL_DMI=no"
49-
"CONFIG_RAYER_SPI=no"
50-
];
59+
mesonFlags = [
60+
(lib.mesonOption "programmer" "auto")
61+
(lib.mesonEnable "man-pages" true)
62+
(lib.mesonEnable "tests" (!stdenv.buildPlatform.isDarwin))
63+
];
64+
65+
doCheck = !stdenv.hostPlatform.isDarwin;
5166

5267
postInstall = ''
53-
install -Dm644 util/flashrom_udev.rules $out/lib/udev/rules.d/flashrom.rules
68+
install -Dm644 $NIX_BUILD_TOP/$sourceRoot/util/flashrom_udev.rules $out/lib/udev/rules.d/flashrom.rules
5469
'';
5570

5671
NIX_CFLAGS_COMPILE = lib.optionalString (
@@ -65,4 +80,4 @@ stdenv.mkDerivation rec {
6580
platforms = platforms.all;
6681
mainProgram = "flashrom";
6782
};
68-
}
83+
})

0 commit comments

Comments
 (0)