Page 1 of 1

QSPI erratum "fix" not applicable to stm32L496

Posted: Sat Apr 03, 2021 8:51 pm
by faisal
The fix here: viewtopic.php?f=35&t=5602 , is not applicable to L496. The errata sheets are different with regards to QSPI for L476/486 and L496 .

I tested with and without the errata patch applied, and using the version that 'addresses' the errata doesn't work on L496. It results in the wspi read function hanging waiting to be resumed from the ISR.

We need to selectively include the errata "fix" depending on specific model.

https://www.st.com/resource/en/errata_s ... ronics.pdf

https://www.st.com/resource/en/errata_s ... ronics.pdf

Re: QSPI erratum "fix" not applicable to stm32L496

Posted: Sun Apr 04, 2021 1:16 am
by faisal
I checked all the errata for the L4 series (https://www.st.com/en/microcontrollers- ... umentation). There are 12 errata published for the different devices in the series. Below is the applicable patch targeting those devices that have the "Extra data written in the FIFO at the end of a read transfer" bug.

diff --git a/ChibiOS_20.x.x/os/hal/ports/STM32/LLD/QUADSPIv1/hal_wspi_lld.c b/ChibiOS_20.x.x/os/hal/ports/STM32/LLD/QUADSPIv1/hal_wspi_lld.c
index 678339a02..8ef9ba7d1 100644
--- a/ChibiOS_20.x.x/os/hal/ports/STM32/LLD/QUADSPIv1/hal_wspi_lld.c
+++ b/ChibiOS_20.x.x/os/hal/ports/STM32/LLD/QUADSPIv1/hal_wspi_lld.c
@@ -95,6 +95,7 @@ static void wspi_lld_serve_interrupt(WSPIDriver *wspip) {
while (dmaStreamGetTransactionSize(wspip->dma) > 0U)
;

+#if defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L486xx)^M
/* Handling of errata: Extra data written in the FIFO at the end of a
read transfer.*/
if (wspip->state == WSPI_RECEIVE) {
@@ -102,6 +103,7 @@ static void wspi_lld_serve_interrupt(WSPIDriver *wspip) {
(void) wspip->qspi->DR;
}
}
+#endif^M
}

/*===========================================================================*/

Re: QSPI erratum "fix" not applicable to stm32L496

Posted: Sun Apr 04, 2021 2:30 am
by Giovanni
Hi,

Thanks for finding, will fix ASAP.

Giovanni

Re: QSPI erratum "fix" not applicable to stm32L496

Posted: Sun Apr 04, 2021 4:49 am
by faisal
The actual diff on my end is below. I was missing the dmaStreamClearInterrupt(wspip->dma) - which was added in the last month as a bug fix. However, that didn't fix the problem. I kept that, but removed the errata handling and added back the dmaStreamDisable from the previous revision. That seems to work.

diff --git a/ChibiOS_20.x.x/os/hal/ports/STM32/LLD/QUADSPIv1/hal_wspi_lld.c b/ChibiOS_20.x.x/os/hal/ports/STM32/LLD/QUADSPIv1/hal_wspi_lld.c
index 678339a02..18dc6c970 100644
--- a/ChibiOS_20.x.x/os/hal/ports/STM32/LLD/QUADSPIv1/hal_wspi_lld.c
+++ b/ChibiOS_20.x.x/os/hal/ports/STM32/LLD/QUADSPIv1/hal_wspi_lld.c
@@ -95,6 +95,11 @@ static void wspi_lld_serve_interrupt(WSPIDriver *wspip) {
while (dmaStreamGetTransactionSize(wspip->dma) > 0U)
;
+ /* Clearing DMA interrupts here because the DMA ISR is not called on
+ transfer complete.*/
+ dmaStreamClearInterrupt(wspip->dma);
+
+#if defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L486xx)
/* Handling of errata: Extra data written in the FIFO at the end of a
read transfer.*/
if (wspip->state == WSPI_RECEIVE) {
@@ -102,6 +107,9 @@ static void wspi_lld_serve_interrupt(WSPIDriver *wspip) {
(void) wspip->qspi->DR;
}
}
+#else
+ dmaStreamDisable(wspip->dma);
+#endif
}

/*===========================================================================*/