ecpprog: Improve reset procedure
authorSylvain Munaut <tnt@246tNt.com>
Tue, 8 Jun 2021 16:25:56 +0000 (18:25 +0200)
committerGregory Davill <greg.davill@gmail.com>
Wed, 9 Jun 2021 00:37:17 +0000 (10:07 +0930)
Doesn't work 100% of the time, for 100% of the flashes but for windbond
ones, it at least goes from 0% success if it was in QPI to 100% if
I try twice in a row.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
ecpprog/ecpprog.c

index 09826a8ca3f1acae6bcfe6bdba09f097142d0a08..2ac29e3503fff24fbd44d59144086bf7045b5a66 100644 (file)
@@ -196,7 +196,18 @@ static void flash_read_id()
 static void flash_reset()
 {
        uint8_t data[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
-       xfer_spi(data, 8);
+
+       // This disables CRM is if it was enabled
+       jtag_go_to_state(STATE_SHIFT_DR);
+       jtag_tap_shift(data, data, 64, true);
+
+       // This disables QPI if it was enabled
+       jtag_go_to_state(STATE_SHIFT_DR);
+       jtag_tap_shift(data, data, 2, true);
+
+       // This issues a flash reset command
+       jtag_go_to_state(STATE_SHIFT_DR);
+       jtag_tap_shift(data, data, 8, true);
 }
 
 static uint8_t read_status_1(){