summaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-bsp
diff options
context:
space:
mode:
authorArmin Kuster <akuster808@gmail.com>2017-10-26 14:25:04 -0700
committerArmin Kuster <akuster808@gmail.com>2018-03-01 16:10:37 -0800
commit503a572e1420c650ea0279e3e7db1cb401239196 (patch)
treedfde674270446c06f8791a0b69e9cb4f66d89102 /meta-oe/recipes-bsp
parent50759d254a16165f070807fb992815319b97dddd (diff)
downloadmeta-openembedded-503a572e1420c650ea0279e3e7db1cb401239196.tar.gz
flashrom: move to recipes-bsp
Signed-off-by: Armin Kuster <akuster808@gmail.com>
Diffstat (limited to 'meta-oe/recipes-bsp')
-rw-r--r--meta-oe/recipes-bsp/flashrom/flashrom/0001-Remove-undefined-behavior.patch82
-rw-r--r--meta-oe/recipes-bsp/flashrom/flashrom/0001-spi-Define-_XOPEN_SOURCE-to-enable-ffs-libc-API.patch28
-rw-r--r--meta-oe/recipes-bsp/flashrom/flashrom/sst26.patch198
-rw-r--r--meta-oe/recipes-bsp/flashrom/flashrom_0.9.9.bb20
4 files changed, 328 insertions, 0 deletions
diff --git a/meta-oe/recipes-bsp/flashrom/flashrom/0001-Remove-undefined-behavior.patch b/meta-oe/recipes-bsp/flashrom/flashrom/0001-Remove-undefined-behavior.patch
new file mode 100644
index 000000000..51397dc55
--- /dev/null
+++ b/meta-oe/recipes-bsp/flashrom/flashrom/0001-Remove-undefined-behavior.patch
@@ -0,0 +1,82 @@
1From d2a03b3e43043b596a79803bcb93f70e513bbb50 Mon Sep 17 00:00:00 2001
2From: Patrick Georgi <pgeorgi@google.com>
3Date: Mon, 13 Mar 2017 13:48:03 +0100
4Subject: [PATCH] Remove undefined behavior
5
6Per clang-3.9, the compiler fails on #define ...defined(...) statements
7as they're undefined behavior (apparently with different behavior
8between gcc/clang and msvc, too).
9
10See clang's cfe repo commit r258128 for details.
11
12Change-Id: I82b6235e11b425fae45eebbe06b08f81c5bdbb98
13Signed-off-by: Patrick Georgi <pgeorgi@google.com>
14Reviewed-on: https://review.coreboot.org/18792
15Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
16Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
17---
18 hwaccess.c | 18 +++++++++++++++---
19 platform.h | 18 +++++++++++++++---
20 2 files changed, 30 insertions(+), 6 deletions(-)
21
22diff --git a/hwaccess.c b/hwaccess.c
23index aede7e3..2bf6f42 100644
24--- a/hwaccess.c
25+++ b/hwaccess.c
26@@ -37,9 +37,21 @@
27 #error "Unknown operating system"
28 #endif
29
30-#define USE_IOPL (IS_LINUX || IS_MACOSX || defined(__NetBSD__) || defined(__OpenBSD__))
31-#define USE_DEV_IO (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__))
32-#define USE_IOPERM (defined(__gnu_hurd__))
33+#if IS_LINUX || IS_MACOSX || defined(__NetBSD__) || defined(__OpenBSD__)
34+#define USE_IOPL 1
35+#else
36+#define USE_IOPL 0
37+#endif
38+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
39+#define USE_DEV_IO 1
40+#else
41+#define USE_DEV_IO 0
42+#endif
43+#if defined(__gnu_hurd__)
44+#define USE_IOPERM 1
45+#else
46+#define USE_IOPERM 0
47+#endif
48
49 #if USE_IOPERM
50 #include <sys/io.h>
51diff --git a/platform.h b/platform.h
52index c5a52ef..b2fdcd0 100644
53--- a/platform.h
54+++ b/platform.h
55@@ -25,9 +25,21 @@
56 #define __PLATFORM_H__ 1
57
58 // Helper defines for operating systems
59-#define IS_LINUX (defined(__gnu_linux__) || defined(__linux__))
60-#define IS_MACOSX (defined(__APPLE__) && defined(__MACH__)) /* yes, both. */
61-#define IS_WINDOWS (defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(__WINDOWS__))
62+#if defined(__gnu_linux__) || defined(__linux__)
63+#define IS_LINUX 1
64+#else
65+#define IS_LINUX 0
66+#endif
67+#if defined(__APPLE__) && defined(__MACH__) /* yes, both. */
68+#define IS_MACOSX 1
69+#else
70+#define IS_MACOSX 0
71+#endif
72+#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(__WINDOWS__)
73+#define IS_WINDOWS 1
74+#else
75+#define IS_WINDOWS 0
76+#endif
77
78 // Likewise for target architectures
79 #if defined (__i386__) || defined (__x86_64__) || defined(__amd64__)
80--
812.13.3
82
diff --git a/meta-oe/recipes-bsp/flashrom/flashrom/0001-spi-Define-_XOPEN_SOURCE-to-enable-ffs-libc-API.patch b/meta-oe/recipes-bsp/flashrom/flashrom/0001-spi-Define-_XOPEN_SOURCE-to-enable-ffs-libc-API.patch
new file mode 100644
index 000000000..4170fefd2
--- /dev/null
+++ b/meta-oe/recipes-bsp/flashrom/flashrom/0001-spi-Define-_XOPEN_SOURCE-to-enable-ffs-libc-API.patch
@@ -0,0 +1,28 @@
1From 7c65a465a3ddeb7afb9a7c49d010ae7e5d5b1ad1 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 18 Jul 2017 20:25:49 -0700
4Subject: [PATCH] spi: Define _XOPEN_SOURCE to enable ffs() libc API
5
6musl exposes this issue
7
8Signed-off-by: Khem Raj <raj.khem@gmail.com>
9---
10 spi.c | 2 +-
11 1 file changed, 1 insertion(+), 1 deletion(-)
12
13diff --git a/spi.c b/spi.c
14index 894f73f..aeb6518 100644
15--- a/spi.c
16+++ b/spi.c
17@@ -21,7 +21,7 @@
18 /*
19 * Contains the generic SPI framework
20 */
21-
22+#define _XOPEN_SOURCE
23 #include <strings.h>
24 #include <string.h>
25 #include "flash.h"
26--
272.13.3
28
diff --git a/meta-oe/recipes-bsp/flashrom/flashrom/sst26.patch b/meta-oe/recipes-bsp/flashrom/flashrom/sst26.patch
new file mode 100644
index 000000000..46a01529f
--- /dev/null
+++ b/meta-oe/recipes-bsp/flashrom/flashrom/sst26.patch
@@ -0,0 +1,198 @@
1--- flashrom-0.9.9.orig/chipdrivers.h
2+++ flashrom-0.9.9/chipdrivers.h
3@@ -103,6 +103,7 @@
4 int spi_prettyprint_status_register_sst25(struct flashctx *flash);
5 int spi_prettyprint_status_register_sst25vf016(struct flashctx *flash);
6 int spi_prettyprint_status_register_sst25vf040b(struct flashctx *flash);
7+int spi_disable_blockprotect_sst26_global_unprotect(struct flashctx *flash);
8
9 /* sfdp.c */
10 int probe_spi_sfdp(struct flashctx *flash);
11--- flashrom-0.9.9.orig/flashchips.c
12+++ flashrom-0.9.9/flashchips.c
13@@ -12564,6 +12564,120 @@
14
15 {
16 .vendor = "SST",
17+ .name = "SST26VF016B(A)",
18+ .bustype = BUS_SPI,
19+ .manufacture_id = SST_ID,
20+ .model_id = SST_SST26VF016B,
21+ .total_size = 2048,
22+ .page_size = 256,
23+ .feature_bits = FEATURE_WRSR_WREN | FEATURE_OTP,
24+ .tested = TEST_OK_PREW,
25+ .probe = probe_spi_rdid,
26+ .probe_timing = TIMING_ZERO,
27+ .block_erasers =
28+ {
29+ {
30+ .eraseblocks = { {4 * 1024, 512} },
31+ .block_erase = spi_block_erase_20,
32+ }, {
33+ .eraseblocks = {
34+ {8 * 1024, 4},
35+ {32 * 1024, 1},
36+ {64 * 1024, 30},
37+ {32 * 1024, 1},
38+ {8 * 1024, 4},
39+ },
40+ .block_erase = spi_block_erase_d8,
41+ }, {
42+ .eraseblocks = { {2 * 1024 * 1024, 1} },
43+ .block_erase = spi_block_erase_c7,
44+ },
45+ },
46+ .printlock = spi_prettyprint_status_register_plain, /* TODO: improve */
47+ .unlock = spi_disable_blockprotect_sst26_global_unprotect,
48+ .write = spi_chip_write_256, /* Multi I/O supported */
49+ .read = spi_chip_read, /* Fast read (0x0B) and multi I/O supported */
50+ .voltage = {2700, 3600},
51+ },
52+ {
53+ .vendor = "SST",
54+ .name = "SST26VF032B(A)",
55+ .bustype = BUS_SPI,
56+ .manufacture_id = SST_ID,
57+ .model_id = SST_SST26VF032B,
58+ .total_size = 4096,
59+ .page_size = 256,
60+ .feature_bits = FEATURE_WRSR_WREN | FEATURE_OTP,
61+ .tested = TEST_UNTESTED,
62+ .probe = probe_spi_rdid,
63+ .probe_timing = TIMING_ZERO,
64+ .block_erasers =
65+ {
66+ {
67+ .eraseblocks = { {4 * 1024, 1024} },
68+ .block_erase = spi_block_erase_20,
69+ }, {
70+ .eraseblocks = {
71+ {8 * 1024, 4},
72+ {32 * 1024, 1},
73+ {64 * 1024, 62},
74+ {32 * 1024, 1},
75+ {8 * 1024, 4},
76+ },
77+ .block_erase = spi_block_erase_d8,
78+ }, {
79+ .eraseblocks = { {4 * 1024 * 1024, 1} },
80+ .block_erase = spi_block_erase_c7,
81+ },
82+ },
83+ .printlock = spi_prettyprint_status_register_plain, /* TODO: improve */
84+ .unlock = spi_disable_blockprotect_sst26_global_unprotect,
85+ .write = spi_chip_write_256, /* Multi I/O supported */
86+ .read = spi_chip_read, /* Fast read (0x0B) and multi I/O supported */
87+ .voltage = {2700, 3600},
88+ },
89+
90+
91+ {
92+ .vendor = "SST",
93+ .name = "SST26VF064B(A)",
94+ .bustype = BUS_SPI,
95+ .manufacture_id = SST_ID,
96+ .model_id = SST_SST26VF064B,
97+ .total_size = 8192,
98+ .page_size = 256,
99+ .feature_bits = FEATURE_WRSR_WREN | FEATURE_OTP,
100+ .tested = TEST_OK_PREW,
101+ .probe = probe_spi_rdid,
102+ .probe_timing = TIMING_ZERO,
103+ .block_erasers =
104+ {
105+ {
106+ .eraseblocks = { {4 * 1024, 2048} },
107+ .block_erase = spi_block_erase_20,
108+ }, {
109+ .eraseblocks = {
110+ {8 * 1024, 4},
111+ {32 * 1024, 1},
112+ {64 * 1024, 126},
113+ {32 * 1024, 1},
114+ {8 * 1024, 4},
115+ },
116+ .block_erase = spi_block_erase_d8,
117+ }, {
118+ .eraseblocks = { {8 * 1024 * 1024, 1} },
119+ .block_erase = spi_block_erase_c7,
120+ },
121+ },
122+ .printlock = spi_prettyprint_status_register_plain, /* TODO: improve */
123+ .unlock = spi_disable_blockprotect_sst26_global_unprotect,
124+ .write = spi_chip_write_256, /* Multi I/O supported */
125+ .read = spi_chip_read, /* Fast read (0x0B) and multi I/O supported */
126+ .voltage = {2700, 3600},
127+ },
128+
129+ {
130+ .vendor = "SST",
131 .name = "SST25WF512",
132 .bustype = BUS_SPI,
133 .manufacture_id = SST_ID,
134--- flashrom-0.9.9.orig/flashchips.h
135+++ flashrom-0.9.9/flashchips.h
136@@ -697,6 +697,8 @@
137 #define SST_SST25VF064C 0x254B
138 #define SST_SST26VF016 0x2601
139 #define SST_SST26VF032 0x2602
140+#define SST_SST26VF016B 0x2641
141+#define SST_SST26VF032B 0x2642
142 #define SST_SST26VF064B 0x2643
143 #define SST_SST27SF512 0xA4
144 #define SST_SST27SF010 0xA5
145--- flashrom-0.9.9.orig/linux_spi.c
146+++ flashrom-0.9.9/linux_spi.c
147@@ -141,6 +141,16 @@
148 return 0;
149 }
150
151+static void print_hex(const char *msg, const void *buf, size_t len)
152+{
153+ size_t i;
154+ msg_pspew("%s:\n", msg);
155+ for (i = 0; i < len; i++) {
156+ msg_pspew(" %02x", ((uint8_t *)buf)[i]);
157+ }
158+ msg_pspew("\n");
159+}
160+
161 static int linux_spi_send_command(struct flashctx *flash, unsigned int writecnt,
162 unsigned int readcnt,
163 const unsigned char *txbuf,
164@@ -172,10 +182,12 @@
165 else
166 iocontrol_code = SPI_IOC_MESSAGE(2);
167
168+ print_hex("Write", txbuf, writecnt);
169 if (ioctl(fd, iocontrol_code, msg) == -1) {
170 msg_cerr("%s: ioctl: %s\n", __func__, strerror(errno));
171 return -1;
172 }
173+ if (readcnt) print_hex("Got", rxbuf, readcnt);
174 return 0;
175 }
176
177--- flashrom-0.9.9.orig/spi25_statusreg.c
178+++ flashrom-0.9.9/spi25_statusreg.c
179@@ -196,6 +196,19 @@
180 return spi_disable_blockprotect_generic(flash, 0x3C, 0, 0, 0xFF);
181 }
182
183+int spi_disable_blockprotect_sst26_global_unprotect(struct flashctx *flash)
184+{
185+ int result = spi_write_enable(flash);
186+ if (result)
187+ return result;
188+
189+ static const unsigned char cmd[] = { 0x98 }; /* ULBPR */
190+ result = spi_send_command(flash, sizeof(cmd), 0, cmd, NULL);
191+ if (result)
192+ msg_cerr("ULBPR failed\n");
193+ return result;
194+}
195+
196 /* A common block protection disable that tries to unset the status register bits masked by 0x0C (BP0-1) and
197 * protected/locked by bit #7. Useful when bits 4-5 may be non-0). */
198 int spi_disable_blockprotect_bp1_srwd(struct flashctx *flash)
diff --git a/meta-oe/recipes-bsp/flashrom/flashrom_0.9.9.bb b/meta-oe/recipes-bsp/flashrom/flashrom_0.9.9.bb
new file mode 100644
index 000000000..4cdd8ad23
--- /dev/null
+++ b/meta-oe/recipes-bsp/flashrom/flashrom_0.9.9.bb
@@ -0,0 +1,20 @@
1DESCRIPTION = "flashrom is a utility for identifying, reading, writing, verifying and erasing flash chips"
2LICENSE = "GPLv2"
3HOMEPAGE = "http://flashrom.org"
4
5LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe"
6DEPENDS = "pciutils libusb libusb-compat"
7
8SRC_URI = "http://download.flashrom.org/releases/flashrom-${PV}.tar.bz2 \
9 file://0001-spi-Define-_XOPEN_SOURCE-to-enable-ffs-libc-API.patch \
10 file://sst26.patch \
11 file://0001-Remove-undefined-behavior.patch \
12 "
13SRC_URI[md5sum] = "aab9c98925d9cfb5ffb28b67a6112530"
14SRC_URI[sha256sum] = "cb3156b0f63eb192024b76c0814135930297aac41f80761a5d293de769783c45"
15
16inherit pkgconfig
17
18do_install() {
19 oe_runmake PREFIX=${prefix} DESTDIR=${D} install
20}