From 63fa4fda85f14aa53f9cbb0efad5961d08bb7137 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fin=20Maa=C3=9F?= Date: Thu, 24 Oct 2024 15:10:37 +0200 Subject: [PATCH 1/2] bios: litespi: clear rx queue after write MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit clear rx queue at the end of spiflash_master_write(). Signed-off-by: Fin Maaß --- litex/soc/software/liblitespi/spiflash.c | 3 +++ litex/soc/software/liblitespi/spiram.c | 3 +++ 2 files changed, 6 insertions(+) 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); } From d7bf75a75c95e6a1742959aff0981d66a685ee71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fin=20Maa=C3=9F?= Date: Thu, 24 Oct 2024 15:12:12 +0200 Subject: [PATCH 2/2] bios: litespi: add newline to debug output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit add newline to debug output Signed-off-by: Fin Maaß --- litex/soc/software/liblitespi/spiflash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/litex/soc/software/liblitespi/spiflash.c b/litex/soc/software/liblitespi/spiflash.c index f62138389..fd9f2b954 100644 --- a/litex/soc/software/liblitespi/spiflash.c +++ b/litex/soc/software/liblitespi/spiflash.c @@ -156,7 +156,7 @@ static uint32_t spiflash_read_id_register(void) transfer_cmd(w_buf, buf, 4); #ifdef SPIFLASH_DEBUG - printf("[ID: %02x %02x %02x %02x]", buf[0], buf[1], buf[2], buf[3]); + printf("[ID: %02x %02x %02x %02x]\n", buf[0], buf[1], buf[2], buf[3]); #endif /* FIXME normally the status should be in buf[1], @@ -173,7 +173,7 @@ static uint32_t spiflash_read_status_register(void) transfer_cmd(w_buf, buf, 4); #ifdef SPIFLASH_DEBUG - printf("[SR: %02x %02x %02x %02x]", buf[0], buf[1], buf[2], buf[3]); + printf("[SR: %02x %02x %02x %02x]\n", buf[0], buf[1], buf[2], buf[3]); #endif /* FIXME normally the status should be in buf[1],