dediprog: Use more general 4BA write mode for newer protocols
We used to send the specific WRITE_MODE_4B_ADDR_256B_PAGE_PGM_0x12
command combined with the 0x12 JEDEC SPI opcode. This doesn't work
on newer programmers anymore, and it turns out that `dpcmd' pairs
it only in special cases with an SF100.
`dpcmd' suggests that for SF600 and newer, the more generic write
mode (WRITE_MODE_4B_ADDR_256B_PAGE_PGM) works with the 0x12 opcode
too. So using that for protocal version 3 seems safe.
Tested with "SF600PG2. V:01.01.012 HW:01.00".
Change-Id: I8a4a94b574c1bf846173fff89ee9ef65c02d2d33
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/108
Tested-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
diff --git a/dediprog.c b/dediprog.c
index 82364e8..c7b4ae8 100644
--- a/dediprog.c
+++ b/dediprog.c
@@ -393,7 +393,10 @@
data_packet[4] = JEDEC_READ_4BA_FAST;
} else if (dedi_spi_cmd == WRITE_MODE_PAGE_PGM
&& (flash->chip->feature_bits & FEATURE_4BA_WRITE)) {
- data_packet[3] = WRITE_MODE_4B_ADDR_256B_PAGE_PGM_0x12;
+ if (protocol(dp_data) >= PROTOCOL_V3)
+ data_packet[3] = WRITE_MODE_4B_ADDR_256B_PAGE_PGM;
+ else
+ data_packet[3] = WRITE_MODE_4B_ADDR_256B_PAGE_PGM_0x12;
data_packet[4] = JEDEC_BYTE_PROGRAM_4BA;
}