From 8e9202121719a8a4a3cda13c060562293909f932 Mon Sep 17 00:00:00 2001 From: Daniel DeGrasse Date: Mon, 12 Feb 2024 23:12:38 -0600 Subject: [PATCH] stop ICE40 FPGA before initializing SPI flash Since commit bdd0dca (release v1.5.0), ice_fpga_stop() has been called after the ice_flash_init function, which wakes flash from sleep. In order to avoid contention on the SPI bus during the flash wake command, stop the ICE40 FPGA prior to sending SPI flash wake command. Signed-off-by: Daniel DeGrasse --- src/ice_usb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ice_usb.c b/src/ice_usb.c index ea171f26..aae484c1 100644 --- a/src/ice_usb.c +++ b/src/ice_usb.c @@ -343,6 +343,9 @@ void dfu_init(uint8_t alt) ice_cram_open(); break; case DFU_ALT_FLASH: + // Make sure the RP2040 have full access to the SPI bus + ice_fpga_stop(); + ice_flash_init(); // Ensure reboot in case user doesn't pass -R to dfu-util @@ -355,9 +358,6 @@ void dfu_init(uint8_t alt) // Disable all interrupts except USB and DMA (needed for flash program) irq_set_mask_enabled(~((1 << USBCTRL_IRQ) | (1 << DMA_IRQ_1)), false); - - // Make sure the RP2040 have full access to the SPI bus - ice_fpga_stop(); break; } }