From 83fff6f4fc2c60db03146ef4216ffc0c6e7f9a97 Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Tue, 8 Jun 2021 18:25:56 +0200 Subject: [PATCH] ecpprog: Improve reset procedure 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 --- ecpprog/ecpprog.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ecpprog/ecpprog.c b/ecpprog/ecpprog.c index 09826a8..2ac29e3 100644 --- a/ecpprog/ecpprog.c +++ b/ecpprog/ecpprog.c @@ -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(){ -- 2.30.2