You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nuttx.apache.org by Simon Filgis <si...@ingenieurbuero-filgis.de> on 2022/02/08 10:52:16 UTC

SPI with DMA on SAME70

Dear all,

I'm using ST7789.c in combination with lvgl-lib.

The bottleneck to the display is the SPI communication. But even if I
increase the SPI frequency to 24MHz, it does not get faster. This is
because of constant delay between the bytes.

I guessed that this can be improved using DMA. But that does not seem to
work out of the box. In the SPI TX callback the result of the DMA transfer
is -4. The transfer is not executed.

Can anybody give me a hint on what to do?

Best regards,

Simon

--
Hard- and Softwaredevelopment Consultant
Ingenieurbüro-Filgis
USt-IdNr.: DE305343278

Re: SPI with DMA on SAME70

Posted by Simon Filgis <si...@ingenieurbuero-filgis.de>.
Hello Michael,

Thank you for your answer. That is true, SPI driver's initial flag setup is
0.

The flags are evaluated dynamically and very meaningful
within spi_exchange() and set via

  sam_dmaconfig(spics->rxdma, rxflags);
  sam_dmaconfig(spics->txdma, txflags);

I will try with setup initial flags to try.

Any hint to debug is appreciated :)


Simon


--
Hard- and Softwaredevelopment Consultant
Ingenieurbüro-Filgis
USt-IdNr.: DE305343278


On Tue, Feb 8, 2022 at 12:17 PM Michal Lenc <mi...@seznam.cz> wrote:

> Hello Simon,
>
>
>
> I did take a look into SPI driver for SAME70 a few months ago. The one
> thing
> that was a little bit weird to me was the lack of DMA flags passed to sam_
> dmachannel() function (somewhere here https://github.com/apache/incubator-
> nuttx/blob/master/arch/arm/src/samv7/sam_spi.c#L2043
> <https://github.com/apache/incubator-nuttx/blob/master/arch/arm/src/samv7/sam_spi.c#L2043>)
> compared to the flags
> I needed to select for ADC DMA support to function correctly (https://
>
> github.com/apache/incubator-nuttx/blob/master/arch/arm/src/samv7/sam_afec.c#
> L1125
> <http://github.com/apache/incubator-nuttx/blob/master/arch/arm/src/samv7/sam_afec.c#L1125>).
> I didn't invest more time into it as we had other priorities back
> then and I think we sticked with SPI without DMA. But it could be one of
> the
> problems.
>
>
>
>
> You can also take a look into sam_afec.c file, the DMA is working fine
> there. Hope this helps.
>
> Best regards,
> Michal Lenc
>
> ---------- Původní e-mail ----------
> Od: Simon Filgis <si...@ingenieurbuero-filgis.de>
> Komu: dev@nuttx.apache.org
> Datum: 8. 2. 2022 11:52:38
> Předmět: SPI with DMA on SAME70
> "Dear all,
>
> I'm using ST7789.c in combination with lvgl-lib.
>
> The bottleneck to the display is the SPI communication. But even if I
> increase the SPI frequency to 24MHz, it does not get faster. This is
> because of constant delay between the bytes.
>
> I guessed that this can be improved using DMA. But that does not seem to
> work out of the box. In the SPI TX callback the result of the DMA transfer
> is -4. The transfer is not executed.
>
> Can anybody give me a hint on what to do?
>
> Best regards,
>
> Simon
>
> --
> Hard- and Softwaredevelopment Consultant
> Ingenieurbüro-Filgis
> USt-IdNr.: DE305343278
> "

Re: SPI with DMA on SAME70

Posted by Michal Lenc <mi...@seznam.cz>.
Hello Simon,



I did take a look into SPI driver for SAME70 a few months ago. The one thing
that was a little bit weird to me was the lack of DMA flags passed to sam_
dmachannel() function (somewhere here https://github.com/apache/incubator-
nuttx/blob/master/arch/arm/src/samv7/sam_spi.c#L2043) compared to the flags 
I needed to select for ADC DMA support to function correctly (https://
github.com/apache/incubator-nuttx/blob/master/arch/arm/src/samv7/sam_afec.c#
L1125). I didn't invest more time into it as we had other priorities back 
then and I think we sticked with SPI without DMA. But it could be one of the
problems.




You can also take a look into sam_afec.c file, the DMA is working fine 
there. Hope this helps.

Best regards,
Michal Lenc

---------- Původní e-mail ----------
Od: Simon Filgis <si...@ingenieurbuero-filgis.de>
Komu: dev@nuttx.apache.org
Datum: 8. 2. 2022 11:52:38
Předmět: SPI with DMA on SAME70 
"Dear all, 

I'm using ST7789.c in combination with lvgl-lib. 

The bottleneck to the display is the SPI communication. But even if I 
increase the SPI frequency to 24MHz, it does not get faster. This is 
because of constant delay between the bytes. 

I guessed that this can be improved using DMA. But that does not seem to 
work out of the box. In the SPI TX callback the result of the DMA transfer 
is -4. The transfer is not executed. 

Can anybody give me a hint on what to do? 

Best regards, 

Simon 

-- 
Hard- and Softwaredevelopment Consultant 
Ingenieurbüro-Filgis 
USt-IdNr.: DE305343278 
"

Re: SPI with DMA on SAME70

Posted by Simon Filgis <si...@ingenieurbuero-filgis.de>.
Hi Michael,

I'm doing the work to offload CPU from display activity. It would be very
nice if SD-Card and UART could also profit on samv7 :)

I tested DMA with SPI and it works (althought I can write only to one half
> of the display but that might be some my problems in configuration if all
> your tests were fine)


I have the same experience with the display. Only half is written. But the
blocksize seems to be complete. Therefore I assume that half of the line is
correct data. The other half of the line is wrong data. How many pixels
does your display line have? Mine has 240.

Regards,

Simon

--
Hard- and Softwaredevelopment Consultant
Ingenieurbüro-Filgis
USt-IdNr.: DE305343278


On Sun, Feb 20, 2022 at 10:17 PM Michal Lenc <mi...@seznam.cz> wrote:

> Hello Simon,
>
>
>
> I had noticed your DMA fix PR (https://github.com/apache/incubator-nuttx/
> pull/5513 <https://github.com/apache/incubator-nuttx/pull/5513>) so I
> tested it with HSMCI SD card interface. There are still some
> problems when I undef HSCMI_NOTXDMA at
> https://github.com/apache/incubator-
> nuttx/blob/master/arch/arm/src/samv7/sam_hsmci.c#L122
> <https://github.com/apache/incubator-nuttx/blob/master/arch/arm/src/samv7/sam_hsmci.c#L122>.
> The card unmounts
> itself as soon as I try to write to it with 'echo' command. I think this
> might be quite a different problem that can be sam_hsmci.c related as some
> other TX DMAs are working.
>
>
>
>
> I tested DMA with SPI and it works (althought I can write only to one half
> of the display but that might be some my problems in configuration if all
> your tests were fine) as well as DMA with USB device. I will take a look
> into HSCMI with DMA in the future, currently more critical problem for our
> implementation at Elektroline.cz company is DMA support for U(S)ART. That
> will also be a nice way to find if there are some further DMA TX bugs.
>
> Best regards,
> Michal Lenc
>
> ---------- Původní e-mail ----------
> Od: Simon Filgis <si...@ingenieurbuero-filgis.de>
> Komu: dev@nuttx.apache.org
> Datum: 14. 2. 2022 16:33:32
> Předmět: Re: SPI with DMA on SAME70
> "Dear all,
>
> I started to follow up this topic.
>
> Found that one in sam_hsmci.c:
>
> /* There is some unresolved issue with the SAMV7 DMA. TX DMA is currently
> * disabled.
> */
>
>
> #undef HSCMI_NORXDMA /* Define to disable RX DMA */
> *#define HSCMI_NOTXDMA 1 /* Define to disable TX DMA */*
>
>
> That fits my (and Michael Lenc's) experience that DMA peripheral to memory
> works. Memory to the peripheral seems broken though.
>
> I will therefore debug *sam_xdmax.c*. Even if I find some odd comments on
> DMA timeouts in sam_spi.c.
>
> If anybody has a better idea, or remembers details ;), please give
> feedback.
>
>
> BR,
>
> Simon
>
> --
> Hard- and Softwaredevelopment Consultant
> Ingenieurbüro-Filgis
> USt-IdNr.: DE305343278
>
>
> On Tue, Feb 8, 2022 at 11:52 AM Simon Filgis <
> simon@ingenieurbuero-filgis.de
> >
> wrote:
>
> > Dear all,
> >
> > I'm using ST7789.c in combination with lvgl-lib.
> >
> > The bottleneck to the display is the SPI communication. But even if I
> > increase the SPI frequency to 24MHz, it does not get faster. This is
> > because of constant delay between the bytes.
> >
> > I guessed that this can be improved using DMA. But that does not seem to
> > work out of the box. In the SPI TX callback the result of the DMA
> transfer
>
> > is -4. The transfer is not executed.
> >
> > Can anybody give me a hint on what to do?
> >
> > Best regards,
> >
> > Simon
> >
> > --
> > Hard- and Softwaredevelopment Consultant
> > Ingenieurbüro-Filgis
> > USt-IdNr.: DE305343278
> >
> "

Re: SPI with DMA on SAME70

Posted by Michal Lenc <mi...@seznam.cz>.
Hello Simon,



I had noticed your DMA fix PR (https://github.com/apache/incubator-nuttx/
pull/5513) so I tested it with HSMCI SD card interface. There are still some
problems when I undef HSCMI_NOTXDMA at https://github.com/apache/incubator-
nuttx/blob/master/arch/arm/src/samv7/sam_hsmci.c#L122. The card unmounts 
itself as soon as I try to write to it with 'echo' command. I think this 
might be quite a different problem that can be sam_hsmci.c related as some 
other TX DMAs are working.




I tested DMA with SPI and it works (althought I can write only to one half 
of the display but that might be some my problems in configuration if all 
your tests were fine) as well as DMA with USB device. I will take a look 
into HSCMI with DMA in the future, currently more critical problem for our 
implementation at Elektroline.cz company is DMA support for U(S)ART. That 
will also be a nice way to find if there are some further DMA TX bugs.

Best regards,
Michal Lenc

---------- Původní e-mail ----------
Od: Simon Filgis <si...@ingenieurbuero-filgis.de>
Komu: dev@nuttx.apache.org
Datum: 14. 2. 2022 16:33:32
Předmět: Re: SPI with DMA on SAME70 
"Dear all, 

I started to follow up this topic. 

Found that one in sam_hsmci.c: 

/* There is some unresolved issue with the SAMV7 DMA. TX DMA is currently 
* disabled. 
*/ 


#undef HSCMI_NORXDMA /* Define to disable RX DMA */ 
*#define HSCMI_NOTXDMA 1 /* Define to disable TX DMA */* 


That fits my (and Michael Lenc's) experience that DMA peripheral to memory 
works. Memory to the peripheral seems broken though. 

I will therefore debug *sam_xdmax.c*. Even if I find some odd comments on 
DMA timeouts in sam_spi.c. 

If anybody has a better idea, or remembers details ;), please give feedback.


BR, 

Simon 

-- 
Hard- and Softwaredevelopment Consultant 
Ingenieurbüro-Filgis 
USt-IdNr.: DE305343278 


On Tue, Feb 8, 2022 at 11:52 AM Simon Filgis <simon@ingenieurbuero-filgis.de
> 
wrote: 

> Dear all, 
> 
> I'm using ST7789.c in combination with lvgl-lib. 
> 
> The bottleneck to the display is the SPI communication. But even if I 
> increase the SPI frequency to 24MHz, it does not get faster. This is 
> because of constant delay between the bytes. 
> 
> I guessed that this can be improved using DMA. But that does not seem to 
> work out of the box. In the SPI TX callback the result of the DMA transfer

> is -4. The transfer is not executed. 
> 
> Can anybody give me a hint on what to do? 
> 
> Best regards, 
> 
> Simon 
> 
> -- 
> Hard- and Softwaredevelopment Consultant 
> Ingenieurbüro-Filgis 
> USt-IdNr.: DE305343278 
> 
"

Re: SPI with DMA on SAME70

Posted by Simon Filgis <si...@ingenieurbuero-filgis.de>.
Dear all,

I started to follow up this topic.

Found that one in sam_hsmci.c:

/* There is some unresolved issue with the SAMV7 DMA.  TX DMA is currently
 * disabled.
 */


#undef  HSCMI_NORXDMA              /* Define to disable RX DMA */
*#define HSCMI_NOTXDMA            1 /* Define to disable TX DMA */*


That fits my (and Michael Lenc's) experience that DMA peripheral to memory
works. Memory to the peripheral seems broken though.

I will therefore debug *sam_xdmax.c*. Even if I find some odd comments on
DMA timeouts in sam_spi.c.

If anybody has a better idea, or remembers details ;), please give feedback.

BR,

Simon

--
Hard- and Softwaredevelopment Consultant
Ingenieurbüro-Filgis
USt-IdNr.: DE305343278


On Tue, Feb 8, 2022 at 11:52 AM Simon Filgis <si...@ingenieurbuero-filgis.de>
wrote:

> Dear all,
>
> I'm using ST7789.c in combination with lvgl-lib.
>
> The bottleneck to the display is the SPI communication. But even if I
> increase the SPI frequency to 24MHz, it does not get faster. This is
> because of constant delay between the bytes.
>
> I guessed that this can be improved using DMA. But that does not seem to
> work out of the box. In the SPI TX callback the result of the DMA transfer
> is -4. The transfer is not executed.
>
> Can anybody give me a hint on what to do?
>
> Best regards,
>
> Simon
>
> --
> Hard- and Softwaredevelopment Consultant
> Ingenieurbüro-Filgis
> USt-IdNr.: DE305343278
>