Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 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) |