Signed-off-by: Sean Nelson audiohacked@gmail.com --- pm49fl00x.c | 69 ----------------------------------------------------------- 1 files changed, 0 insertions(+), 69 deletions(-)
diff --git a/pm49fl00x.c b/pm49fl00x.c index 5e5eec8..fd93ef6 100644 --- a/pm49fl00x.c +++ b/pm49fl00x.c @@ -38,82 +38,13 @@ void write_lockbits_49fl00x(chipaddr bios, int size, }
int unlock_49fl00x(struct flashchip *flash) { write_lockbits_49fl00x(flash->virtual_registers, flash->total_size * 1024, 0, flash->page_size); return 0; }
int lock_49fl00x(struct flashchip *flash) { write_lockbits_49fl00x(flash->virtual_registers, flash->total_size * 1024, 1, flash->page_size); return 0; } - -int erase_49fl00x(struct flashchip *flash) -{ - int i; - int total_size = flash->total_size * 1024; - int page_size = flash->page_size; - - /* unprotected */ - write_lockbits_49fl00x(flash->virtual_registers, - total_size, 0, page_size); - - /* - * erase_chip_jedec() will not work... Datasheet says - * "Chip erase is available in A/A Mux Mode only". - */ - printf("Erasing page: "); - for (i = 0; i < total_size / page_size; i++) { - /* erase the page */ - if (erase_block_jedec(flash, i * page_size, page_size)) { - fprintf(stderr, "ERASE FAILED!\n"); - return -1; - } - printf("%04d at address: 0x%08x", i, i * page_size); - printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"); - fflush(stdout); - } - printf("\n"); - - /* protected */ - write_lockbits_49fl00x(flash->virtual_registers, - total_size, 1, page_size); - - return 0; -} - -int write_49fl00x(struct flashchip *flash, uint8_t *buf) -{ - int i; - int total_size = flash->total_size * 1024; - int page_size = flash->page_size; - chipaddr bios = flash->virtual_memory; - - /* unprotected */ - write_lockbits_49fl00x(flash->virtual_registers, total_size, 0, - page_size); - - printf("Programming page: "); - for (i = 0; i < total_size / page_size; i++) { - /* erase the page before programming */ - if (erase_block_jedec(flash, i * page_size, page_size)) { - fprintf(stderr, "ERASE FAILED!\n"); - return -1; - } - - /* write to the sector */ - printf("%04d at address: 0x%08x", i, i * page_size); - write_sector_jedec_common(flash, buf + i * page_size, - bios + i * page_size, page_size, 0xffff); - printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"); - fflush(stdout); - } - printf("\n"); - - /* protected */ - write_lockbits_49fl00x(flash->virtual_registers, total_size, 1, - page_size); - - return 0; -}
Signed-off-by: Sean Nelson audiohacked@gmail.com --- chipdrivers.h | 3 -- w39v040c.c | 69 --------------------------------------------------------- 2 files changed, 0 insertions(+), 72 deletions(-)
diff --git a/chipdrivers.h b/chipdrivers.h index 6b9f9d6..e04b6c0 100644 --- a/chipdrivers.h +++ b/chipdrivers.h @@ -109,29 +109,26 @@ int erase_sector_49lfxxxc(struct flashchip *flash, unsigned int address, unsigne int erase_block_49lfxxxc(struct flashchip *flash, unsigned int address, unsigned int sector_size); int erase_chip_49lfxxxc(struct flashchip *flash, unsigned int addr, unsigned int blocksize); int write_49lfxxxc(struct flashchip *flash, uint8_t *buf); int unlock_49lfxxxc(struct flashchip *flash);
/* sst_fwhub.c */ int erase_sst_fwhub(struct flashchip *flash); int erase_sst_fwhub_block(struct flashchip *flash, unsigned int offset, unsigned int page_size); int erase_sst_fwhub_sector(struct flashchip *flash, unsigned int offset, unsigned int page_size); int write_sst_fwhub(struct flashchip *flash, uint8_t *buf); int printlock_sst_fwhub(struct flashchip *flash);
/* w39v040c.c */ -int probe_w39v040c(struct flashchip *flash); -int erase_w39v040c(struct flashchip *flash); -int write_w39v040c(struct flashchip *flash, uint8_t *buf); int printlock_w39v040c(struct flashchip *flash);
/* w39V080fa.c */ int probe_winbond_fwhub(struct flashchip *flash); int erase_winbond_fwhub(struct flashchip *flash); int write_winbond_fwhub(struct flashchip *flash, uint8_t *buf); int unlock_winbond_fwhub(struct flashchip *flash);
/* w29ee011.c */ int probe_w29ee011(struct flashchip *flash);
/* stm50flw0x0x.c */ int probe_stm50flw0x0x(struct flashchip *flash); diff --git a/w39v040c.c b/w39v040c.c index 20e53fa..74cd1e2 100644 --- a/w39v040c.c +++ b/w39v040c.c @@ -11,107 +11,38 @@ * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
#include "flash.h" #include "chipdrivers.h"
-int probe_w39v040c(struct flashchip *flash) -{ - chipaddr bios = flash->virtual_memory; - int result = probe_jedec(flash); - uint8_t lock; - - if (!result) - return result; - - chip_writeb(0xAA, bios + 0x5555); - programmer_delay(10); - chip_writeb(0x55, bios + 0x2AAA); - programmer_delay(10); - chip_writeb(0x90, bios + 0x5555); - programmer_delay(10); - - lock = chip_readb(bios + 0xfff2); - - chip_writeb(0xAA, bios + 0x5555); - programmer_delay(10); - chip_writeb(0x55, bios + 0x2AAA); - programmer_delay(10); - chip_writeb(0xF0, bios + 0x5555); - programmer_delay(40); - - printf("%s: Boot block #TBL is %slocked, rest of chip #WP is %slocked.\n", - __func__, lock & 0x4 ? "" : "un", lock & 0x8 ? "" : "un"); - return 1; -} - int printlock_w39v040c(struct flashchip *flash) { chipaddr bios = flash->virtual_memory; uint8_t lock;
chip_writeb(0xAA, bios + 0x5555); programmer_delay(10); chip_writeb(0x55, bios + 0x2AAA); programmer_delay(10); chip_writeb(0x90, bios + 0x5555); programmer_delay(10);
lock = chip_readb(bios + 0xfff2);
chip_writeb(0xAA, bios + 0x5555); programmer_delay(10); chip_writeb(0x55, bios + 0x2AAA); programmer_delay(10); chip_writeb(0xF0, bios + 0x5555); programmer_delay(40);
printf("%s: Boot block #TBL is %slocked, rest of chip #WP is %slocked.\n", __func__, lock & 0x4 ? "" : "un", lock & 0x8 ? "" : "un"); return 0; } - -int erase_w39v040c(struct flashchip *flash) -{ - int i; - unsigned int total_size = flash->total_size * 1024; - - for (i = 0; i < total_size; i += flash->page_size) { - if (erase_sector_jedec(flash, i, flash->page_size)) { - fprintf(stderr, "ERASE FAILED!\n"); - return -1; - } - } - - return 0; -} - -int write_w39v040c(struct flashchip *flash, uint8_t *buf) -{ - int i; - int total_size = flash->total_size * 1024; - int page_size = flash->page_size; - chipaddr bios = flash->virtual_memory; - - if (erase_flash(flash)) { - fprintf(stderr, "ERASE FAILED!\n"); - return -1; - } - - printf("Programming page: "); - for (i = 0; i < total_size / page_size; i++) { - printf("%04d at address: 0x%08x", i, i * page_size); - write_sector_jedec_common(flash, buf + i * page_size, - bios + i * page_size, page_size, 0xffff); - printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"); - } - printf("\n"); - - return 0; -}
Signed-off-by: Sean Nelson audiohacked@gmail.com --- chipdrivers.h | 3 -- w39v080fa.c | 66 --------------------------------------------------------- 2 files changed, 0 insertions(+), 69 deletions(-)
diff --git a/chipdrivers.h b/chipdrivers.h index e04b6c0..64c8845 100644 --- a/chipdrivers.h +++ b/chipdrivers.h @@ -112,29 +112,26 @@ int write_49lfxxxc(struct flashchip *flash, uint8_t *buf); int unlock_49lfxxxc(struct flashchip *flash);
/* sst_fwhub.c */ int erase_sst_fwhub(struct flashchip *flash); int erase_sst_fwhub_block(struct flashchip *flash, unsigned int offset, unsigned int page_size); int erase_sst_fwhub_sector(struct flashchip *flash, unsigned int offset, unsigned int page_size); int write_sst_fwhub(struct flashchip *flash, uint8_t *buf); int printlock_sst_fwhub(struct flashchip *flash);
/* w39v040c.c */ int printlock_w39v040c(struct flashchip *flash);
/* w39V080fa.c */ -int probe_winbond_fwhub(struct flashchip *flash); -int erase_winbond_fwhub(struct flashchip *flash); -int write_winbond_fwhub(struct flashchip *flash, uint8_t *buf); int unlock_winbond_fwhub(struct flashchip *flash);
/* w29ee011.c */ int probe_w29ee011(struct flashchip *flash);
/* stm50flw0x0x.c */ int probe_stm50flw0x0x(struct flashchip *flash); int erase_stm50flw0x0x(struct flashchip *flash); int erase_block_stm50flw0x0x(struct flashchip *flash, unsigned int block, unsigned int blocksize); int erase_sector_stm50flw0x0x(struct flashchip *flash, unsigned int block, unsigned int blocksize); int erase_chip_stm50flw0x0x(struct flashchip *flash, unsigned int addr, unsigned int blocklen); int write_stm50flw0x0x(struct flashchip *flash, uint8_t *buf);
diff --git a/w39v080fa.c b/w39v080fa.c index 0163766..047f86b 100644 --- a/w39v080fa.c +++ b/w39v080fa.c @@ -101,79 +101,13 @@ int unlock_winbond_fwhub(struct flashchip *flash) else printf_debug("No hardware block locking (good!)\n");
if (locking & ((1 << 2) | (1 << 3))) return -1;
/* Unlock the complete chip */ for (i = 0; i < total_size; i += flash->page_size) if (unlock_block_winbond_fwhub(flash, i)) return -1;
return 0; } - -static int erase_sector_winbond_fwhub(struct flashchip *flash, - unsigned int sector) -{ - chipaddr bios = flash->virtual_memory; - /* Remember: too much sleep can waste your day. */ - - printf("0x%08x\b\b\b\b\b\b\b\b\b\b", sector); - - /* Sector Erase */ - chip_writeb(0xAA, bios + 0x5555); - chip_writeb(0x55, bios + 0x2AAA); - chip_writeb(0x80, bios + 0x5555); - - chip_writeb(0xAA, bios + 0x5555); - chip_writeb(0x55, bios + 0x2AAA); - chip_writeb(0x30, bios + sector); - - /* wait for Toggle bit ready */ - toggle_ready_jedec(bios); - - if (check_erased_range(flash, sector, flash->page_size)) { - fprintf(stderr, "ERASE FAILED!\n"); - return -1; - } - return 0; -} - -int erase_winbond_fwhub(struct flashchip *flash) -{ - int i, total_size = flash->total_size * 1024; - - unlock_winbond_fwhub(flash); - - printf("Erasing: "); - - for (i = 0; i < total_size; i += flash->page_size) { - if (erase_sector_winbond_fwhub(flash, i)) { - fprintf(stderr, "ERASE FAILED!\n"); - return -1; - } - } - - printf("\n"); - - return 0; -} - -int write_winbond_fwhub(struct flashchip *flash, uint8_t *buf) -{ - int i; - int total_size = flash->total_size * 1024; - chipaddr bios = flash->virtual_memory; - - if (erase_winbond_fwhub(flash)) - return -1; - - printf("Programming: "); - for (i = 0; i < total_size; i += flash->page_size) { - printf("0x%08x\b\b\b\b\b\b\b\b\b\b", i); - write_sector_jedec_common(flash, buf + i, bios + i, flash->page_size, 0xffff); - } - printf("\n"); - - return 0; -}
Signed-off-by: Sean Nelson audiohacked@gmail.com --- chipdrivers.h | 5 +-- flashchips.c | 32 ++++++++++++------- sst_fwhub.c | 96 ++------------------------------------------------------- 3 files changed, 24 insertions(+), 109 deletions(-)
diff --git a/chipdrivers.h b/chipdrivers.h index 64c8845..e51f5df 100644 --- a/chipdrivers.h +++ b/chipdrivers.h @@ -102,31 +102,28 @@ int erase_chip_28sf040(struct flashchip *flash, unsigned int addr, unsigned int int erase_sector_28sf040(struct flashchip *flash, unsigned int address, unsigned int sector_size); int write_28sf040(struct flashchip *flash, uint8_t *buf);
/* sst49lfxxxc.c */ int probe_49lfxxxc(struct flashchip *flash); int erase_49lfxxxc(struct flashchip *flash); int erase_sector_49lfxxxc(struct flashchip *flash, unsigned int address, unsigned int sector_size); int erase_block_49lfxxxc(struct flashchip *flash, unsigned int address, unsigned int sector_size); int erase_chip_49lfxxxc(struct flashchip *flash, unsigned int addr, unsigned int blocksize); int write_49lfxxxc(struct flashchip *flash, uint8_t *buf); int unlock_49lfxxxc(struct flashchip *flash);
/* sst_fwhub.c */ -int erase_sst_fwhub(struct flashchip *flash); -int erase_sst_fwhub_block(struct flashchip *flash, unsigned int offset, unsigned int page_size); -int erase_sst_fwhub_sector(struct flashchip *flash, unsigned int offset, unsigned int page_size); -int write_sst_fwhub(struct flashchip *flash, uint8_t *buf); int printlock_sst_fwhub(struct flashchip *flash); +int unlock_sst_fwhub(struct flashchip *flash);
/* w39v040c.c */ int printlock_w39v040c(struct flashchip *flash);
/* w39V080fa.c */ int unlock_winbond_fwhub(struct flashchip *flash);
/* w29ee011.c */ int probe_w29ee011(struct flashchip *flash);
/* stm50flw0x0x.c */ int probe_stm50flw0x0x(struct flashchip *flash); int erase_stm50flw0x0x(struct flashchip *flash); diff --git a/flashchips.c b/flashchips.c index 727d69d..bc9b295 100644 --- a/flashchips.c +++ b/flashchips.c @@ -4074,100 +4074,106 @@ struct flashchip flashchips[] = { .bustype = CHIP_BUSTYPE_FWH, /* A/A Mux */ .manufacture_id = SST_ID, .model_id = SST_49LF002A, .total_size = 256, .page_size = 16 * 1024, .feature_bits = FEATURE_REGISTERMAP | FEATURE_EITHER_RESET, .tested = TEST_OK_PRW, .probe = probe_jedec, .probe_timing = 1, /* 150 ns */ .block_erasers = { { .eraseblocks = { {4 * 1024, 64} }, - .block_erase = erase_sst_fwhub_sector, + .block_erase = erase_sector_jedec, }, { .eraseblocks = { {16 * 1024, 16} }, - .block_erase = erase_sst_fwhub_block, + .block_erase = erase_block_jedec, }, { .eraseblocks = { {256 * 1024, 1} }, .block_erase = NULL, /* AA 55 80 AA 55 10, only in A/A mux mode */ } }, .printlock = printlock_sst_fwhub, - .write = write_sst_fwhub, + .printlock = printlock_sst_fwhub, + .unlock = unlock_sst_fwhub, + .write = write_jedec_1, .read = read_memmapped, },
{ .vendor = "SST", .name = "SST49LF003A/B", .bustype = CHIP_BUSTYPE_FWH, /* A/A Mux */ .manufacture_id = SST_ID, .model_id = SST_49LF003A, .total_size = 384, .page_size = 64 * 1024, .feature_bits = FEATURE_REGISTERMAP | FEATURE_EITHER_RESET, .tested = TEST_OK_PR, .probe = probe_jedec, .probe_timing = 1, /* 150 ns */ .block_erasers = { { .eraseblocks = { {4 * 1024, 96} }, - .block_erase = erase_sst_fwhub_sector, + .block_erase = erase_sector_jedec, }, { .eraseblocks = { {64 * 1024, 6} }, - .block_erase = erase_sst_fwhub_block, + .block_erase = erase_block_jedec, }, { .eraseblocks = { {384 * 1024, 1} }, .block_erase = NULL, /* AA 55 80 AA 55 10, only in A/A mux mode */ } }, .printlock = printlock_sst_fwhub, - .write = write_sst_fwhub, + .printlock = printlock_sst_fwhub, + .unlock = unlock_sst_fwhub, + .write = write_jedec_1, .read = read_memmapped, },
{ /* Contrary to the data sheet, TBL# on the SST49LF004B affects the top 128kB (instead of 64kB) * and is only honored for 64k block erase, but not 4k sector erase. */ .vendor = "SST", .name = "SST49LF004A/B", .bustype = CHIP_BUSTYPE_FWH, /* A/A Mux */ .manufacture_id = SST_ID, .model_id = SST_49LF004A, .total_size = 512, .page_size = 64 * 1024, .feature_bits = FEATURE_REGISTERMAP | FEATURE_EITHER_RESET, .tested = TEST_OK_PREW, .probe = probe_jedec, .probe_timing = 1, /* 150 ns */ .block_erasers = { { .eraseblocks = { {4 * 1024, 128} }, - .block_erase = erase_sector_jedec, /* missing unlock */ + .block_erase = erase_sector_jedec, }, { .eraseblocks = { {64 * 1024, 8} }, - .block_erase = erase_sst_fwhub_block, /* same as erase_block_jedec, but with unlock */ + .block_erase = erase_block_jedec, }, { .eraseblocks = { {512 * 1024, 1} }, .block_erase = NULL, /* AA 55 80 AA 55 10, only in A/A mux mode */ }, }, .printlock = printlock_sst_fwhub, - .write = write_sst_fwhub, + .printlock = printlock_sst_fwhub, + .unlock = unlock_sst_fwhub, + .write = write_jedec_1, .read = read_memmapped, },
{ .vendor = "SST", .name = "SST49LF004C", .bustype = CHIP_BUSTYPE_FWH, .manufacture_id = SST_ID, .model_id = SST_49LF004C, .total_size = 512, .page_size = 4 * 1024, .feature_bits = FEATURE_REGISTERMAP, .tested = TEST_UNTESTED, @@ -4198,37 +4204,39 @@ struct flashchip flashchips[] = { .bustype = CHIP_BUSTYPE_FWH, /* A/A Mux */ .manufacture_id = SST_ID, .model_id = SST_49LF008A, .total_size = 1024, .page_size = 64 * 1024, .feature_bits = FEATURE_REGISTERMAP | FEATURE_EITHER_RESET, .tested = TEST_OK_PRW, .probe = probe_jedec, .probe_timing = 1, /* 150 ns */ .block_erasers = { { .eraseblocks = { {4 * 1024, 256} }, - .block_erase = erase_sst_fwhub_sector, + .block_erase = erase_sector_jedec, }, { .eraseblocks = { {64 * 1024, 16} }, - .block_erase = erase_sst_fwhub_block, + .block_erase = erase_block_jedec, }, { .eraseblocks = { {1024 * 1024, 1} }, .block_erase = NULL, /* AA 55 80 AA 55 10, only in A/A mux mode */ } }, .printlock = printlock_sst_fwhub, - .write = write_sst_fwhub, + .printlock = printlock_sst_fwhub, + .unlock = unlock_sst_fwhub, + .write = write_jedec_1, .read = read_memmapped, },
{ .vendor = "SST", .name = "SST49LF008C", .bustype = CHIP_BUSTYPE_FWH, .manufacture_id = SST_ID, .model_id = SST_49LF008C, .total_size = 1024, .page_size = 4 * 1024, .feature_bits = FEATURE_REGISTERMAP, .tested = TEST_UNTESTED, diff --git a/sst_fwhub.c b/sst_fwhub.c index a325278..721a808 100644 --- a/sst_fwhub.c +++ b/sst_fwhub.c @@ -17,38 +17,26 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
/* Adapted from the Intel FW hub stuff for 82802ax parts. */
#include <stdlib.h> #include <string.h> #include "flash.h" #include "chipdrivers.h"
-// I need that Berkeley bit-map printer -void print_sst_fwhub_status(uint8_t status) -{ - printf("%s", status & 0x80 ? "Ready:" : "Busy:"); - printf("%s", status & 0x40 ? "BE SUSPEND:" : "BE RUN/FINISH:"); - printf("%s", status & 0x20 ? "BE ERROR:" : "BE OK:"); - printf("%s", status & 0x10 ? "PROG ERR:" : "PROG OK:"); - printf("%s", status & 0x8 ? "VP ERR:" : "VPP OK:"); - printf("%s", status & 0x4 ? "PROG SUSPEND:" : "PROG RUN/FINISH:"); - printf("%s", status & 0x2 ? "WP|TBL#|WP#,ABORT:" : "UNLOCK:"); -} - int check_sst_fwhub_block_lock(struct flashchip *flash, int offset) { chipaddr registers = flash->virtual_registers; uint8_t blockstatus;
blockstatus = chip_readb(registers + offset + 2); printf_debug("Lock status for 0x%06x (size 0x%06x) is %02x, ", offset, flash->page_size, blockstatus); switch (blockstatus & 0x3) { case 0x0: printf_debug("full access\n"); break; case 0x1: @@ -83,101 +71,23 @@ int clear_sst_fwhub_block_lock(struct flashchip *flash, int offset) return blockstatus; }
int printlock_sst_fwhub(struct flashchip *flash) { int i;
for (i = 0; i < flash->total_size * 1024; i += flash->page_size) check_sst_fwhub_block_lock(flash, i);
return 0; }
-int erase_sst_fwhub_block(struct flashchip *flash, unsigned int offset, unsigned int page_size) -{ - uint8_t blockstatus = clear_sst_fwhub_block_lock(flash, offset); - - if (blockstatus) { - printf("Block lock clearing failed, not erasing block " - "at 0x%06x\n", offset); - return 1; - } - - if (erase_block_jedec(flash, offset, page_size)) { - fprintf(stderr, "ERASE FAILED!\n"); - return -1; - } - toggle_ready_jedec(flash->virtual_memory); - - return 0; -} - -int erase_sst_fwhub_sector(struct flashchip *flash, unsigned int offset, unsigned int page_size) -{ - uint8_t blockstatus = clear_sst_fwhub_block_lock(flash, offset); - - if (blockstatus) { - printf("Sector lock clearing failed, not erasing sector " - "at 0x%06x\n", offset); - return 1; - } - - if (erase_sector_jedec(flash, offset, page_size)) { - fprintf(stderr, "ERASE FAILED!\n"); - return -1; - } - toggle_ready_jedec(flash->virtual_memory); - - return 0; -} - -int erase_sst_fwhub(struct flashchip *flash) +int unlock_sst_fwhub(struct flashchip *flash) { int i; - unsigned int total_size = flash->total_size * 1024;
- for (i = 0; i < total_size; i += flash->page_size) { - if (erase_sst_fwhub_block(flash, i, flash->page_size)) { - fprintf(stderr, "ERASE FAILED!\n"); - return -1; - } - } + for (i = 0; i < flash->total_size * 1024; i += flash->page_size) + clear_sst_fwhub_block_lock(flash, i);
return 0; }
-int write_sst_fwhub(struct flashchip *flash, uint8_t *buf) -{ - int i, rc; - int total_size = flash->total_size * 1024; - int page_size = flash->page_size; - chipaddr bios = flash->virtual_memory; - uint8_t *readbuf = malloc(page_size); - - printf("Programming page: "); - for (i = 0; i < total_size / page_size; i++) { - printf("%04d at address: 0x%08x", i, i * page_size); - - /* Auto Skip Blocks, which already contain the desired data: - * Faster, because we only write, what has changed - * More secure, because blocks, which are excluded - * (with the exclude or layout feature) - * are not erased and rewritten; data is retained also - * in sudden power off situations - */ - flash->read(flash, readbuf, i * page_size, page_size); - if (memcmp((void *)(buf + i * page_size), - (void *)(readbuf), page_size)) { - rc = erase_sst_fwhub_block(flash, i * page_size, - page_size); - if (rc) - return 1; - write_sector_jedec_common(flash, buf + i * page_size, - bios + i * page_size, page_size, 0xffff); - } - printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"); - } - printf("\n"); - - return 0; -}
Signed-off-by: Sean Nelson audiohacked@gmail.com --- sharplhf00l04.c | 31 +++---------------------------- 1 files changed, 3 insertions(+), 28 deletions(-)
diff --git a/sharplhf00l04.c b/sharplhf00l04.c index d5ab38c..659f129 100644 --- a/sharplhf00l04.c +++ b/sharplhf00l04.c @@ -12,97 +12,72 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
#include <stdlib.h> #include "flash.h" #include "chipdrivers.h"
-// I need that Berkeley bit-map printer -void print_lhf00l04_status(uint8_t status) -{ - printf("%s", status & 0x80 ? "Ready:" : "Busy:"); - printf("%s", status & 0x40 ? "BE SUSPEND:" : "BE RUN/FINISH:"); - printf("%s", status & 0x20 ? "BE ERROR:" : "BE OK:"); - printf("%s", status & 0x10 ? "PROG ERR:" : "PROG OK:"); - printf("%s", status & 0x8 ? "VP ERR:" : "VPP OK:"); - printf("%s", status & 0x4 ? "PROG SUSPEND:" : "PROG RUN/FINISH:"); - printf("%s", status & 0x2 ? "WP|TBL#|WP#,ABORT:" : "UNLOCK:"); -} - /* FIXME: The datasheet is unclear whether we should use toggle_ready_jedec * or wait_82802ab. */
int erase_lhf00l04_block(struct flashchip *flash, unsigned int blockaddr, unsigned int blocklen) { chipaddr bios = flash->virtual_memory + blockaddr; chipaddr wrprotect = flash->virtual_registers + blockaddr + 2; uint8_t status;
// clear status register chip_writeb(0x50, bios); printf("Erase at 0x%lx\n", bios); status = wait_82802ab(flash->virtual_memory); - print_lhf00l04_status(status); + print_82802ab_status(status); // clear write protect printf("write protect is at 0x%lx\n", (wrprotect)); printf("write protect is 0x%x\n", chip_readb(wrprotect)); chip_writeb(0, wrprotect); printf("write protect is 0x%x\n", chip_readb(wrprotect));
// now start it chip_writeb(0x20, bios); chip_writeb(0xd0, bios); programmer_delay(10); // now let's see what the register is status = wait_82802ab(flash->virtual_memory); - print_lhf00l04_status(status); + print_82802ab_status(status); printf("DONE BLOCK 0x%x\n", blockaddr);
if (check_erased_range(flash, blockaddr, blocklen)) { fprintf(stderr, "ERASE FAILED!\n"); return -1; } return 0; }
-void write_page_lhf00l04(chipaddr bios, uint8_t *src, - chipaddr dst, int page_size) -{ - int i; - - for (i = 0; i < page_size; i++) { - /* transfer data from source to destination */ - chip_writeb(0x40, dst); - chip_writeb(*src++, dst++); - wait_82802ab(bios); - } -} - int write_lhf00l04(struct flashchip *flash, uint8_t *buf) { int i; int total_size = flash->total_size * 1024; int page_size = flash->page_size; chipaddr bios = flash->virtual_memory;
if (erase_flash(flash)) { fprintf(stderr, "ERASE FAILED!\n"); return -1; } printf("Programming page: "); for (i = 0; i < total_size / page_size; i++) { printf("%04d at address: 0x%08x", i, i * page_size); - write_page_lhf00l04(bios, buf + i * page_size, + write_page_82802ab(bios, buf + i * page_size, bios + i * page_size, page_size); printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"); } printf("\n");
return 0; }
Signed-off-by: Sean Nelson audiohacked@gmail.com --- sst28sf040.c | 24 ------------------------ 1 files changed, 0 insertions(+), 24 deletions(-)
diff --git a/sst28sf040.c b/sst28sf040.c index bbb9d56..0c90526 100644 --- a/sst28sf040.c +++ b/sst28sf040.c @@ -82,50 +82,26 @@ int write_sector_28sf040(chipaddr bios, uint8_t *src, chipaddr dst, continue; } /*issue AUTO PROGRAM command */ chip_writeb(AUTO_PGRM, dst); chip_writeb(*src++, dst++);
/* wait for Toggle bit ready */ toggle_ready_jedec(bios); }
return 0; }
-int probe_28sf040(struct flashchip *flash) -{ - chipaddr bios = flash->virtual_memory; - uint8_t id1, id2; - - chip_writeb(RESET, bios); - programmer_delay(10); - - chip_writeb(READ_ID, bios); - programmer_delay(10); - id1 = chip_readb(bios); - programmer_delay(10); - id2 = chip_readb(bios + 0x01); - - chip_writeb(RESET, bios); - programmer_delay(10); - - printf_debug("%s: id1 0x%02x, id2 0x%02x\n", __func__, id1, id2); - if (id1 == flash->manufacture_id && id2 == flash->model_id) - return 1; - - return 0; -} - int erase_28sf040(struct flashchip *flash) { chipaddr bios = flash->virtual_memory;
unprotect_28sf040(bios); chip_writeb(CHIP_ERASE, bios); chip_writeb(CHIP_ERASE, bios); protect_28sf040(bios);
programmer_delay(10); toggle_ready_jedec(bios);
if (check_erased_range(flash, 0, flash->total_size * 1024)) {
Signed-off-by: Sean Nelson audiohacked@gmail.com --- chipdrivers.h | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/chipdrivers.h b/chipdrivers.h index e51f5df..d8678a2 100644 --- a/chipdrivers.h +++ b/chipdrivers.h @@ -81,33 +81,30 @@ int erase_m29f400bt(struct flashchip *flash); int block_erase_m29f400bt(struct flashchip *flash, unsigned int start, unsigned int len); int block_erase_chip_m29f400bt(struct flashchip *flash, unsigned int start, unsigned int len); int write_m29f400bt(struct flashchip *flash, uint8_t *buf); int write_coreboot_m29f400bt(struct flashchip *flash, uint8_t *buf); void protect_m29f400bt(chipaddr bios); void write_page_m29f400bt(chipaddr bios, uint8_t *src, chipaddr dst, int page_size);
/* pm49fl00x.c */ int unlock_49fl00x(struct flashchip *flash); int lock_49fl00x(struct flashchip *flash);
/* sharplhf00l04.c */ -int probe_lhf00l04(struct flashchip *flash); int erase_lhf00l04_block(struct flashchip *flash, unsigned int blockaddr, unsigned int blocklen); int write_lhf00l04(struct flashchip *flash, uint8_t *buf); -void protect_lhf00l04(chipaddr bios);
/* sst28sf040.c */ -int probe_28sf040(struct flashchip *flash); int erase_chip_28sf040(struct flashchip *flash, unsigned int addr, unsigned int blocklen); int erase_sector_28sf040(struct flashchip *flash, unsigned int address, unsigned int sector_size); int write_28sf040(struct flashchip *flash, uint8_t *buf);
/* sst49lfxxxc.c */ int probe_49lfxxxc(struct flashchip *flash); int erase_49lfxxxc(struct flashchip *flash); int erase_sector_49lfxxxc(struct flashchip *flash, unsigned int address, unsigned int sector_size); int erase_block_49lfxxxc(struct flashchip *flash, unsigned int address, unsigned int sector_size); int erase_chip_49lfxxxc(struct flashchip *flash, unsigned int addr, unsigned int blocksize); int write_49lfxxxc(struct flashchip *flash, uint8_t *buf); int unlock_49lfxxxc(struct flashchip *flash);
Signed-off-by: Sean Nelson audiohacked@gmail.com --- chipdrivers.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/chipdrivers.h b/chipdrivers.h index d8678a2..ca82c2d 100644 --- a/chipdrivers.h +++ b/chipdrivers.h @@ -49,26 +49,28 @@ uint8_t spi_read_status_register(void); int spi_disable_blockprotect(void); int spi_byte_program(int addr, uint8_t databyte); int spi_nbyte_program(int addr, uint8_t *bytes, int len); int spi_nbyte_read(int addr, uint8_t *bytes, int len); int spi_read_chunked(struct flashchip *flash, uint8_t *buf, int start, int len, int chunksize); int spi_aai_write(struct flashchip *flash, uint8_t *buf);
/* 82802ab.c */ uint8_t wait_82802ab(chipaddr bios); int probe_82802ab(struct flashchip *flash); int erase_82802ab(struct flashchip *flash); int erase_82802ab_block(struct flashchip *flash, unsigned int page, unsigned int pagesize); int write_82802ab(struct flashchip *flash, uint8_t *buf); +void print_82802ab_status(uint8_t status); +void write_page_82802ab(chipaddr bios, uint8_t *src, chipaddr dst, int page_size);
/* jedec.c */ uint8_t oddparity(uint8_t val); void toggle_ready_jedec(chipaddr dst); void data_polling_jedec(chipaddr dst, uint8_t data); int write_byte_program_jedec(chipaddr bios, uint8_t *src, chipaddr dst); int probe_jedec(struct flashchip *flash); int erase_chip_jedec(struct flashchip *flash); int write_jedec(struct flashchip *flash, uint8_t *buf); int write_jedec_1(struct flashchip *flash, uint8_t *buf); int erase_sector_jedec(struct flashchip *flash, unsigned int page, unsigned int pagesize); int erase_block_jedec(struct flashchip *flash, unsigned int page, unsigned int blocksize);
On 16.03.2010 00:45, Sean Nelson wrote:
Signed-off-by: Sean Nelson audiohacked@gmail.com
chipdrivers.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
This patch needs to be folded into patch 5 of this series to get a bisectable tree.
Regards, Carl-Daniel
On 3/15/10 5:34 PM, Carl-Daniel Hailfinger wrote:
On 16.03.2010 00:45, Sean Nelson wrote:
Signed-off-by: Sean Nelsonaudiohacked@gmail.com
chipdrivers.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
This patch needs to be folded into patch 5 of this series to get a bisectable tree.
Regards, Carl-Daniel
Commited as part of r941.
On 16.03.2010 00:45, Sean Nelson wrote:
Signed-off-by: Sean Nelson audiohacked@gmail.com
chipdrivers.h | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
This patch needs to be folded into patch 5 and 6 of this series to get clean bisectable and revertable patches.
Regards, Carl-Daniel
On 3/15/10 5:33 PM, Carl-Daniel Hailfinger wrote:
On 16.03.2010 00:45, Sean Nelson wrote:
Signed-off-by: Sean Nelsonaudiohacked@gmail.com
chipdrivers.h | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
This patch needs to be folded into patch 5 and 6 of this series to get clean bisectable and revertable patches.
Regards, Carl-Daniel
Committed as part of r942.
On 16.03.2010 00:45, Sean Nelson wrote:
Signed-off-by: Sean Nelson audiohacked@gmail.com
sst28sf040.c | 24 ------------------------ 1 files changed, 0 insertions(+), 24 deletions(-)
If you commit this together with the matching hunk of chipdrivers.h (Patch 7/8), it is
Acked-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Regards, Carl-Daniel
On 3/15/10 5:26 PM, Carl-Daniel Hailfinger wrote:
On 16.03.2010 00:45, Sean Nelson wrote:
Signed-off-by: Sean Nelsonaudiohacked@gmail.com
sst28sf040.c | 24 ------------------------ 1 files changed, 0 insertions(+), 24 deletions(-)
If you commit this together with the matching hunk of chipdrivers.h (Patch 7/8), it is
Acked-by: Carl-Daniel Hailfingerc-d.hailfinger.devel.2006@gmx.net
Regards, Carl-Daniel
Thanks, committed in r942. Along with patch 7.
On 16.03.2010 00:45, Sean Nelson wrote:
Signed-off-by: Sean Nelson audiohacked@gmail.com
sharplhf00l04.c | 31 +++---------------------------- 1 files changed, 3 insertions(+), 28 deletions(-)
If you fold patch 8 of this series into this patch, this is Acked-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Regards, Carl-Daniel
On 3/15/10 5:40 PM, Carl-Daniel Hailfinger wrote:
On 16.03.2010 00:45, Sean Nelson wrote:
Signed-off-by: Sean Nelsonaudiohacked@gmail.com
sharplhf00l04.c | 31 +++---------------------------- 1 files changed, 3 insertions(+), 28 deletions(-)
If you fold patch 8 of this series into this patch, this is Acked-by: Carl-Daniel Hailfingerc-d.hailfinger.devel.2006@gmx.net
Regards, Carl-Daniel
Commited in r941. Along with patch 8.
On 16.03.2010 00:45, Sean Nelson wrote:
Signed-off-by: Sean Nelson audiohacked@gmail.com
I have edited the patch below quite a bit to show where I see a problem.
chipdrivers.h | 5 +-- flashchips.c | 32 ++++++++++++------- sst_fwhub.c | 96 ++------------------------------------------------------- 3 files changed, 24 insertions(+), 109 deletions(-)
diff --git a/sst_fwhub.c b/sst_fwhub.c index a325278..721a808 100644 --- a/sst_fwhub.c +++ b/sst_fwhub.c @@ -83,101 +71,23 @@
int printlock_sst_fwhub(struct flashchip *flash) { int i;
for (i = 0; i < flash->total_size * 1024; i += flash->page_size) check_sst_fwhub_block_lock(flash, i);
return 0; }
-int erase_sst_fwhub_sector(struct flashchip *flash, unsigned int offset, unsigned int page_size) -{
- uint8_t blockstatus = clear_sst_fwhub_block_lock(flash, offset);
- if (blockstatus) {
printf("Sector lock clearing failed, not erasing sector "
"at 0x%06x\n", offset);
return 1;
- }
[...]
- return 0;
-}
+int unlock_sst_fwhub(struct flashchip *flash) { int i;
for (i = 0; i < flash->total_size * 1024; i += flash->page_size)
clear_sst_fwhub_block_lock(flash, i);
return 0;
}
Note that the old code checks the return code of clear_sst_fwhub_block_lock(), but the new code ignores the return code completely. At the very least, I'd expect the code to complain loudly. Ideal would be to try to unlock all even if unlock fails for one or more. Basically, complain for each failed unlock, but continue and return 0 only if all unlocks were sucessful. With that addressed and a successful compile test, the patch is Acked-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Regards, Carl-Daniel
On 3/15/10 6:25 PM, Carl-Daniel Hailfinger wrote:
On 16.03.2010 00:45, Sean Nelson wrote:
Signed-off-by: Sean Nelsonaudiohacked@gmail.com
I have edited the patch below quite a bit to show where I see a problem.
chipdrivers.h | 5 +-- flashchips.c | 32 ++++++++++++------- sst_fwhub.c | 96 ++------------------------------------------------------- 3 files changed, 24 insertions(+), 109 deletions(-)
diff --git a/sst_fwhub.c b/sst_fwhub.c index a325278..721a808 100644 --- a/sst_fwhub.c +++ b/sst_fwhub.c @@ -83,101 +71,23 @@
int printlock_sst_fwhub(struct flashchip *flash) { int i;
for (i = 0; i< flash->total_size * 1024; i += flash->page_size) check_sst_fwhub_block_lock(flash, i);
return 0; }
-int erase_sst_fwhub_sector(struct flashchip *flash, unsigned int offset, unsigned int page_size) -{
- uint8_t blockstatus = clear_sst_fwhub_block_lock(flash, offset);
- if (blockstatus) {
printf("Sector lock clearing failed, not erasing sector "
"at 0x%06x\n", offset);
return 1;
- }
[...]
- return 0;
-}
+int unlock_sst_fwhub(struct flashchip *flash) { int i;
for (i = 0; i< flash->total_size * 1024; i += flash->page_size)
clear_sst_fwhub_block_lock(flash, i);
return 0; }
Note that the old code checks the return code of clear_sst_fwhub_block_lock(), but the new code ignores the return code completely. At the very least, I'd expect the code to complain loudly. Ideal would be to try to unlock all even if unlock fails for one or more. Basically, complain for each failed unlock, but continue and return 0 only if all unlocks were sucessful. With that addressed and a successful compile test, the patch is Acked-by: Carl-Daniel Hailfingerc-d.hailfinger.devel.2006@gmx.net
Regards, Carl-Daniel
Fixed as follows: if (clear()) { print "Scream Murder"; return_code++; }
return return_code;
Thanks. Committed in r943. Patch attached for history account.
On 16.03.2010 00:45, Sean Nelson wrote:
Signed-off-by: Sean Nelson audiohacked@gmail.com
Acked-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Regards, Carl-Daniel
On 3/15/10 5:24 PM, Carl-Daniel Hailfinger wrote:
Acked-by: Carl-Daniel Hailfingerc-d.hailfinger.devel.2006@gmx.net
Thanks, Committed in r940.
On 16.03.2010 00:45, Sean Nelson wrote:
Signed-off-by: Sean Nelson audiohacked@gmail.com
Acked-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Regards, Carl-Daniel
On 3/15/10 5:21 PM, Carl-Daniel Hailfinger wrote:
On 16.03.2010 00:45, Sean Nelson wrote:
Signed-off-by: Sean Nelsonaudiohacked@gmail.com
Acked-by: Carl-Daniel Hailfingerc-d.hailfinger.devel.2006@gmx.net
Regards, Carl-Daniel
Commited in r939.
On 16.03.2010 00:45, Sean Nelson wrote:
Signed-off-by: Sean Nelson audiohacked@gmail.com
Acked-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Regards, Carl-Daniel
On 3/15/10 5:28 PM, Carl-Daniel Hailfinger wrote:
On 16.03.2010 00:45, Sean Nelson wrote:
Signed-off-by: Sean Nelsonaudiohacked@gmail.com
Acked-by: Carl-Daniel Hailfingerc-d.hailfinger.devel.2006@gmx.net
Regards, Carl-Daniel
Thanks, Commited in r938.