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
QSPI erratum "fix" not applicable to stm32L496 Topic is solved
Re: QSPI erratum "fix" not applicable to stm32L496
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
}
/*===========================================================================*/
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
}
/*===========================================================================*/
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: QSPI erratum "fix" not applicable to stm32L496
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
}
/*===========================================================================*/
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
}
/*===========================================================================*/
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: QSPI erratum "fix" not applicable to stm32L496
Hi,
Fixed bug as #1153.
Now the code in 20.x and 19.x is equal to the trunk.
Giovanni
Fixed bug as #1153.
Now the code in 20.x and 19.x is equal to the trunk.
Giovanni
Re: QSPI erratum "fix" not applicable to stm32L496
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?
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?
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: QSPI erratum "fix" not applicable to stm32L496
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
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
Re: QSPI erratum "fix" not applicable to stm32L496
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.
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: QSPI erratum "fix" not applicable to stm32L496
Reopening, apparently there is a significant difference between DMAv1 and DMAv2, v2 disables channels on completion, v1 doesn't.
Giovanni
Giovanni
Who is online
Users browsing this forum: No registered users and 57 guests