QSPI erratum "fix" not applicable to stm32L496 Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
faisal
Posts: 374
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 44 times
Been thanked: 60 times

QSPI erratum "fix" not applicable to stm32L496  Topic is solved

Postby faisal » Sat Apr 03, 2021 8:51 pm

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

faisal
Posts: 374
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 44 times
Been thanked: 60 times

Re: QSPI erratum "fix" not applicable to stm32L496

Postby faisal » Sun Apr 04, 2021 1:16 am

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
}

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

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: QSPI erratum "fix" not applicable to stm32L496

Postby Giovanni » Sun Apr 04, 2021 2:30 am

Hi,

Thanks for finding, will fix ASAP.

Giovanni

faisal
Posts: 374
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 44 times
Been thanked: 60 times

Re: QSPI erratum "fix" not applicable to stm32L496

Postby faisal » Sun Apr 04, 2021 4:49 am

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
}

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

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: QSPI erratum "fix" not applicable to stm32L496

Postby Giovanni » Sat Apr 24, 2021 6:14 am

Hi,

Fixed bug as #1153.

Now the code in 20.x and 19.x is equal to the trunk.

Giovanni

faisal
Posts: 374
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 44 times
Been thanked: 60 times

Re: QSPI erratum "fix" not applicable to stm32L496

Postby faisal » Sat Sep 25, 2021 5:55 am

os/hal/ports/STM32/LLD/QUADSPIv1/hal_wspi_lld.c

Bugfix #1116 removed this and replaced it with errata handling code: dmaStreamDisable(wspip->dma)
Then Bugfix

Then in bugfix #1153 the errata handling code was wrapped in a preprocessor #if block to select the code only for certain processor types.
Does that mean dmaStreamDisable(wspip->dma) should be there as an #else?

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: QSPI erratum "fix" not applicable to stm32L496

Postby Giovanni » Sat Sep 25, 2021 6:15 am

Hi,

The DMA stream disables itself on transfer complete, if we put a disable() in there then there is the risk to disable the DMA channel before its internal buffers are fully committed to memory.

Are you experiencing any specific issue with the current code?

Giovanni

faisal
Posts: 374
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 44 times
Been thanked: 60 times

Re: QSPI erratum "fix" not applicable to stm32L496

Postby faisal » Sat Sep 25, 2021 8:03 pm

Giovanni wrote:Hi,

The DMA stream disables itself on transfer complete, if we put a disable() in there then there is the risk to disable the DMA channel before its internal buffers are fully committed to memory.

Are you experiencing any specific issue with the current code?

Giovanni


I haven't tested the latest code - my repo has the patch I submitted above (posting.php?mode=quote&f=35&p=40502#pr39694). I'll pull your version, test, and report back.

Thanks.

faisal
Posts: 374
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 44 times
Been thanked: 60 times

Re: QSPI erratum "fix" not applicable to stm32L496

Postby faisal » Fri Nov 05, 2021 10:28 pm

I just checked this. Without the dmaStreamDisable at the end, I can't read from my QSPI flash chip. It seems to be required.

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: QSPI erratum "fix" not applicable to stm32L496

Postby Giovanni » Sat Nov 06, 2021 5:59 am

Reopening, apparently there is a significant difference between DMAv1 and DMAv2, v2 disables channels on completion, v1 doesn't.

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 20 guests