diff --git a/litex/soc/software/liblitespi/spiflash.c b/litex/soc/software/liblitespi/spiflash.c index a8f8bf866..f62138389 100644 --- a/litex/soc/software/liblitespi/spiflash.c +++ b/litex/soc/software/liblitespi/spiflash.c @@ -111,6 +111,9 @@ static void spiflash_master_write(uint32_t val, size_t len, size_t width, uint32 spiflash_core_master_rxtx_write(val); while (!spiflash_rx_ready()); + /* Clear RX queue. */ + spiflash_core_master_rxtx_read(); + /* Clear CS. */ spiflash_core_master_cs_write(0); } diff --git a/litex/soc/software/liblitespi/spiram.c b/litex/soc/software/liblitespi/spiram.c index b5890f210..7e49ab2a8 100644 --- a/litex/soc/software/liblitespi/spiram.c +++ b/litex/soc/software/liblitespi/spiram.c @@ -97,6 +97,9 @@ static void spiram_master_write(uint32_t val, size_t len, size_t width, uint32_t spiram_core_master_rxtx_write(val); while (!spiram_rx_ready()); + /* Clear RX queue. */ + spiflash_core_master_rxtx_read(); + /* Clear CS. */ spiram_core_master_cs_write(0); }