mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2026-05-05 04:16:46 +02:00
main/flashrom: fix ffs definition, add support for sst26 spi flash
This commit is contained in:
parent
a7c946f2fb
commit
acc627e27d
@ -2,7 +2,7 @@
|
||||
# Maintainer: Nathan Angelacos <nangel@alpinelinux.org>
|
||||
pkgname=flashrom
|
||||
pkgver=0.9.9
|
||||
pkgrel=1
|
||||
pkgrel=2
|
||||
pkgdesc="A utility for identifying, reading, writing, verifying and erasing flash chips"
|
||||
url="http://www.flashrom.org/Flashrom"
|
||||
arch="all"
|
||||
@ -11,24 +11,23 @@ depends=dmidecode
|
||||
makedepends="pciutils-dev libusb-compat-dev linux-headers"
|
||||
subpackages="$pkgname-doc"
|
||||
install="$pkgname.post-install"
|
||||
source="http://download.flashrom.org/releases/flashrom-$pkgver.tar.bz2"
|
||||
source="http://download.flashrom.org/releases/flashrom-$pkgver.tar.bz2
|
||||
sst26.patch
|
||||
musl-ffs.patch
|
||||
"
|
||||
|
||||
_builddir="$srcdir"/$pkgname-$pkgver
|
||||
|
||||
prepare() {
|
||||
cd "$_builddir"
|
||||
}
|
||||
builddir="$srcdir"/$pkgname-$pkgver
|
||||
|
||||
build() {
|
||||
cd "$_builddir"
|
||||
make PREFIX=/usr/ WARNERROR=no || return 1
|
||||
cd "$builddir"
|
||||
make PREFIX=/usr/
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "$_builddir"
|
||||
cd "$builddir"
|
||||
make PREFIX="$pkgdir/usr/" install
|
||||
}
|
||||
|
||||
md5sums="aab9c98925d9cfb5ffb28b67a6112530 flashrom-0.9.9.tar.bz2"
|
||||
sha256sums="cb3156b0f63eb192024b76c0814135930297aac41f80761a5d293de769783c45 flashrom-0.9.9.tar.bz2"
|
||||
sha512sums="155445ce7acab97f91596aad704aa2211da1c3f71fb463fc65c621dfea41e44b5de7db801c5b5cfc37450e8a8cfed5b202553715d999710422c830a0c38ae153 flashrom-0.9.9.tar.bz2"
|
||||
sha512sums="155445ce7acab97f91596aad704aa2211da1c3f71fb463fc65c621dfea41e44b5de7db801c5b5cfc37450e8a8cfed5b202553715d999710422c830a0c38ae153 flashrom-0.9.9.tar.bz2
|
||||
545dfadf8d0c53c9b0116af29eb4454b09ec74b2e906258aa7fcedb472957941a405273fae8ccd1e2f2ec5a848780a8191fcde80e2714573c76b3cd35ab279fa sst26.patch
|
||||
371131e37ee0f2ce31b5dd264707b91817a2f0a3654943e6b3430df862d4bb64f27117c1c94276cb447f5b45f1771b9997f9c96423d68c6dd4565c1e1f442a5e musl-ffs.patch"
|
||||
|
||||
10
main/flashrom/musl-ffs.patch
Normal file
10
main/flashrom/musl-ffs.patch
Normal file
@ -0,0 +1,10 @@
|
||||
--- flashrom-0.9.9/spi.c.orig 2017-07-16 14:56:35.786503889 +0300
|
||||
+++ flashrom-0.9.9/spi.c 2017-07-16 14:58:31.698126720 +0300
|
||||
@@ -22,6 +22,7 @@
|
||||
* Contains the generic SPI framework
|
||||
*/
|
||||
|
||||
+#define _BSD_SOURCE
|
||||
#include <strings.h>
|
||||
#include <string.h>
|
||||
#include "flash.h"
|
||||
198
main/flashrom/sst26.patch
Normal file
198
main/flashrom/sst26.patch
Normal file
@ -0,0 +1,198 @@
|
||||
--- flashrom-0.9.9.orig/chipdrivers.h
|
||||
+++ flashrom-0.9.9/chipdrivers.h
|
||||
@@ -103,6 +103,7 @@
|
||||
int spi_prettyprint_status_register_sst25(struct flashctx *flash);
|
||||
int spi_prettyprint_status_register_sst25vf016(struct flashctx *flash);
|
||||
int spi_prettyprint_status_register_sst25vf040b(struct flashctx *flash);
|
||||
+int spi_disable_blockprotect_sst26_global_unprotect(struct flashctx *flash);
|
||||
|
||||
/* sfdp.c */
|
||||
int probe_spi_sfdp(struct flashctx *flash);
|
||||
--- flashrom-0.9.9.orig/flashchips.c
|
||||
+++ flashrom-0.9.9/flashchips.c
|
||||
@@ -12564,6 +12564,120 @@
|
||||
|
||||
{
|
||||
.vendor = "SST",
|
||||
+ .name = "SST26VF016B(A)",
|
||||
+ .bustype = BUS_SPI,
|
||||
+ .manufacture_id = SST_ID,
|
||||
+ .model_id = SST_SST26VF016B,
|
||||
+ .total_size = 2048,
|
||||
+ .page_size = 256,
|
||||
+ .feature_bits = FEATURE_WRSR_WREN | FEATURE_OTP,
|
||||
+ .tested = TEST_OK_PREW,
|
||||
+ .probe = probe_spi_rdid,
|
||||
+ .probe_timing = TIMING_ZERO,
|
||||
+ .block_erasers =
|
||||
+ {
|
||||
+ {
|
||||
+ .eraseblocks = { {4 * 1024, 512} },
|
||||
+ .block_erase = spi_block_erase_20,
|
||||
+ }, {
|
||||
+ .eraseblocks = {
|
||||
+ {8 * 1024, 4},
|
||||
+ {32 * 1024, 1},
|
||||
+ {64 * 1024, 30},
|
||||
+ {32 * 1024, 1},
|
||||
+ {8 * 1024, 4},
|
||||
+ },
|
||||
+ .block_erase = spi_block_erase_d8,
|
||||
+ }, {
|
||||
+ .eraseblocks = { {2 * 1024 * 1024, 1} },
|
||||
+ .block_erase = spi_block_erase_c7,
|
||||
+ },
|
||||
+ },
|
||||
+ .printlock = spi_prettyprint_status_register_plain, /* TODO: improve */
|
||||
+ .unlock = spi_disable_blockprotect_sst26_global_unprotect,
|
||||
+ .write = spi_chip_write_256, /* Multi I/O supported */
|
||||
+ .read = spi_chip_read, /* Fast read (0x0B) and multi I/O supported */
|
||||
+ .voltage = {2700, 3600},
|
||||
+ },
|
||||
+ {
|
||||
+ .vendor = "SST",
|
||||
+ .name = "SST26VF032B(A)",
|
||||
+ .bustype = BUS_SPI,
|
||||
+ .manufacture_id = SST_ID,
|
||||
+ .model_id = SST_SST26VF032B,
|
||||
+ .total_size = 4096,
|
||||
+ .page_size = 256,
|
||||
+ .feature_bits = FEATURE_WRSR_WREN | FEATURE_OTP,
|
||||
+ .tested = TEST_UNTESTED,
|
||||
+ .probe = probe_spi_rdid,
|
||||
+ .probe_timing = TIMING_ZERO,
|
||||
+ .block_erasers =
|
||||
+ {
|
||||
+ {
|
||||
+ .eraseblocks = { {4 * 1024, 1024} },
|
||||
+ .block_erase = spi_block_erase_20,
|
||||
+ }, {
|
||||
+ .eraseblocks = {
|
||||
+ {8 * 1024, 4},
|
||||
+ {32 * 1024, 1},
|
||||
+ {64 * 1024, 62},
|
||||
+ {32 * 1024, 1},
|
||||
+ {8 * 1024, 4},
|
||||
+ },
|
||||
+ .block_erase = spi_block_erase_d8,
|
||||
+ }, {
|
||||
+ .eraseblocks = { {4 * 1024 * 1024, 1} },
|
||||
+ .block_erase = spi_block_erase_c7,
|
||||
+ },
|
||||
+ },
|
||||
+ .printlock = spi_prettyprint_status_register_plain, /* TODO: improve */
|
||||
+ .unlock = spi_disable_blockprotect_sst26_global_unprotect,
|
||||
+ .write = spi_chip_write_256, /* Multi I/O supported */
|
||||
+ .read = spi_chip_read, /* Fast read (0x0B) and multi I/O supported */
|
||||
+ .voltage = {2700, 3600},
|
||||
+ },
|
||||
+
|
||||
+
|
||||
+ {
|
||||
+ .vendor = "SST",
|
||||
+ .name = "SST26VF064B(A)",
|
||||
+ .bustype = BUS_SPI,
|
||||
+ .manufacture_id = SST_ID,
|
||||
+ .model_id = SST_SST26VF064B,
|
||||
+ .total_size = 8192,
|
||||
+ .page_size = 256,
|
||||
+ .feature_bits = FEATURE_WRSR_WREN | FEATURE_OTP,
|
||||
+ .tested = TEST_OK_PREW,
|
||||
+ .probe = probe_spi_rdid,
|
||||
+ .probe_timing = TIMING_ZERO,
|
||||
+ .block_erasers =
|
||||
+ {
|
||||
+ {
|
||||
+ .eraseblocks = { {4 * 1024, 2048} },
|
||||
+ .block_erase = spi_block_erase_20,
|
||||
+ }, {
|
||||
+ .eraseblocks = {
|
||||
+ {8 * 1024, 4},
|
||||
+ {32 * 1024, 1},
|
||||
+ {64 * 1024, 126},
|
||||
+ {32 * 1024, 1},
|
||||
+ {8 * 1024, 4},
|
||||
+ },
|
||||
+ .block_erase = spi_block_erase_d8,
|
||||
+ }, {
|
||||
+ .eraseblocks = { {8 * 1024 * 1024, 1} },
|
||||
+ .block_erase = spi_block_erase_c7,
|
||||
+ },
|
||||
+ },
|
||||
+ .printlock = spi_prettyprint_status_register_plain, /* TODO: improve */
|
||||
+ .unlock = spi_disable_blockprotect_sst26_global_unprotect,
|
||||
+ .write = spi_chip_write_256, /* Multi I/O supported */
|
||||
+ .read = spi_chip_read, /* Fast read (0x0B) and multi I/O supported */
|
||||
+ .voltage = {2700, 3600},
|
||||
+ },
|
||||
+
|
||||
+ {
|
||||
+ .vendor = "SST",
|
||||
.name = "SST25WF512",
|
||||
.bustype = BUS_SPI,
|
||||
.manufacture_id = SST_ID,
|
||||
--- flashrom-0.9.9.orig/flashchips.h
|
||||
+++ flashrom-0.9.9/flashchips.h
|
||||
@@ -697,6 +697,8 @@
|
||||
#define SST_SST25VF064C 0x254B
|
||||
#define SST_SST26VF016 0x2601
|
||||
#define SST_SST26VF032 0x2602
|
||||
+#define SST_SST26VF016B 0x2641
|
||||
+#define SST_SST26VF032B 0x2642
|
||||
#define SST_SST26VF064B 0x2643
|
||||
#define SST_SST27SF512 0xA4
|
||||
#define SST_SST27SF010 0xA5
|
||||
--- flashrom-0.9.9.orig/linux_spi.c
|
||||
+++ flashrom-0.9.9/linux_spi.c
|
||||
@@ -141,6 +141,16 @@
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static void print_hex(const char *msg, const void *buf, size_t len)
|
||||
+{
|
||||
+ size_t i;
|
||||
+ msg_pspew("%s:\n", msg);
|
||||
+ for (i = 0; i < len; i++) {
|
||||
+ msg_pspew(" %02x", ((uint8_t *)buf)[i]);
|
||||
+ }
|
||||
+ msg_pspew("\n");
|
||||
+}
|
||||
+
|
||||
static int linux_spi_send_command(struct flashctx *flash, unsigned int writecnt,
|
||||
unsigned int readcnt,
|
||||
const unsigned char *txbuf,
|
||||
@@ -172,10 +182,12 @@
|
||||
else
|
||||
iocontrol_code = SPI_IOC_MESSAGE(2);
|
||||
|
||||
+ print_hex("Write", txbuf, writecnt);
|
||||
if (ioctl(fd, iocontrol_code, msg) == -1) {
|
||||
msg_cerr("%s: ioctl: %s\n", __func__, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
+ if (readcnt) print_hex("Got", rxbuf, readcnt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
--- flashrom-0.9.9.orig/spi25_statusreg.c
|
||||
+++ flashrom-0.9.9/spi25_statusreg.c
|
||||
@@ -196,6 +196,19 @@
|
||||
return spi_disable_blockprotect_generic(flash, 0x3C, 0, 0, 0xFF);
|
||||
}
|
||||
|
||||
+int spi_disable_blockprotect_sst26_global_unprotect(struct flashctx *flash)
|
||||
+{
|
||||
+ int result = spi_write_enable(flash);
|
||||
+ if (result)
|
||||
+ return result;
|
||||
+
|
||||
+ static const unsigned char cmd[] = { 0x98 }; /* ULBPR */
|
||||
+ result = spi_send_command(flash, sizeof(cmd), 0, cmd, NULL);
|
||||
+ if (result)
|
||||
+ msg_cerr("ULBPR failed\n");
|
||||
+ return result;
|
||||
+}
|
||||
+
|
||||
/* A common block protection disable that tries to unset the status register bits masked by 0x0C (BP0-1) and
|
||||
* protected/locked by bit #7. Useful when bits 4-5 may be non-0). */
|
||||
int spi_disable_blockprotect_bp1_srwd(struct flashctx *flash)
|
||||
Loading…
x
Reference in New Issue
Block a user