dediprog: Fix and enable 4BA modes for SF600Plus-G2
This was already enabled for the SF600 with protocol v3, however
never implemented. The read path is now covered by the configu-
rable read command discovered during multi-i/o development. For
writes we have to override the command if no native 4BA write is
available and we are in 4BA mode.
Tested with "SF600PG2. V:01.01.012 HW:01.00" and a W25Q256JV..Q
treated as a W25Q256FV (i.e. no native-4BA erase/write opcodes).
Change-Id: I7cc537a96d470461ce35e4c4e97435c4ecb0c4ca
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/169
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
diff --git a/dediprog.c b/dediprog.c
index da398e9..625728e 100644
--- a/dediprog.c
+++ b/dediprog.c
@@ -532,10 +532,17 @@
if (dediprog_set_io_mode(dp, SINGLE_IO_1_1_1))
return -1;
- if (dp_spi_cmd == WRITE_MODE_PAGE_PGM
- && (flash->chip->feature_bits & FEATURE_4BA_WRITE)) {
- cmd_buf[3] = WRITE_MODE_4B_ADDR_256B_PAGE_PGM;
- cmd_buf[4] = JEDEC_BYTE_PROGRAM_4BA;
+ if (dp_spi_cmd == WRITE_MODE_PAGE_PGM) {
+ if (flash->chip->feature_bits & FEATURE_4BA_WRITE) {
+ cmd_buf[3] = WRITE_MODE_4B_ADDR_256B_PAGE_PGM;
+ cmd_buf[4] = JEDEC_BYTE_PROGRAM_4BA;
+ } else if (flash->in_4ba_mode) {
+ cmd_buf[3] = WRITE_MODE_4B_ADDR_256B_PAGE_PGM;
+ cmd_buf[4] = JEDEC_BYTE_PROGRAM;
+ } else if (flashprog_flash_getsize(flash) > 16*MiB) {
+ msg_cerr("Can't handle 4-byte address with dediprog.\n");
+ return -1;
+ }
}
/* 16 LSBs and 16 HSBs of page size */
/* FIXME: This assumes page size of 256. */
@@ -1522,7 +1529,7 @@
spi_master_dediprog.features &= ~SPI_MASTER_DUAL_IO;
if ((dp_data->devicetype == DEV_SF100 && protocol(dp_data) == PROTOCOL_V1) ||
- (dp_data->devicetype == DEV_SF600 && protocol(dp_data) == PROTOCOL_V3))
+ (dp_data->devicetype >= DEV_SF600 && protocol(dp_data) == PROTOCOL_V3))
spi_master_dediprog.features &= ~SPI_MASTER_NO_4BA_MODES;
if (protocol(dp_data) >= PROTOCOL_V2)