From bedf052341235668cce21b930025aa38278b216b Mon Sep 17 00:00:00 2001 From: Charlie Birks Date: Sat, 11 Jun 2022 20:47:43 +0100 Subject: [PATCH] stm32: work around QSPI failing to read the last 32 bytes Locking up everything including debugging... --- 32blit-stm32/Src/quadspi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/32blit-stm32/Src/quadspi.c b/32blit-stm32/Src/quadspi.c index b7db3568a..cb0d179ba 100644 --- a/32blit-stm32/Src/quadspi.c +++ b/32blit-stm32/Src/quadspi.c @@ -33,7 +33,10 @@ void MX_QUADSPI_Init(void) hqspi.Init.ClockPrescaler = 2; hqspi.Init.FifoThreshold = 1; hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_NONE; - hqspi.Init.FlashSize = QSPI_FLASH_SIZE; + + // Use a flash size 2x what we should to avoid "Memory-mapped read of last memory byte fails" + // (due to prefetch, it's actually the last 32 bytes) + hqspi.Init.FlashSize = QSPI_FLASH_SIZE + 1; hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_1_CYCLE; hqspi.Init.ClockMode = QSPI_CLOCK_MODE_3; hqspi.Init.FlashID = QSPI_FLASH_ID_2;