From: Sylvain Munaut Date: Tue, 8 Jun 2021 16:25:56 +0000 (+0200) Subject: ecpprog: Improve reset procedure X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=83fff6f4fc2c60db03146ef4216ffc0c6e7f9a97;p=ecpprog.git 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 --- 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(){