STM32F4 SPI DMA buffer size issue

2020-11-24 Thread Oleg Evseev
Hi all,

STM32f405rg custom board - MTD on SPI1 and SD card on SPI2.

MTD on SPI1 works without DMA and with if defined CONFIG_STM32_SPI1_DMA=y

but if also
CONFIG_STM32_SPI1_DMA_BUFFER=1024
is set, partitions get created, there are mtdblockX in /dev, geometry can
be read correctly, but reading or writing hangs up.
As I see in map g_spi1_rxbuf, g_spi1_txbuf are in SRAM, not in CCM.

Same with SD card. If defined CONFIG_STM32_SPI2_DMA_BUFFER=1024 there is
still /dev/mmcsd device, it gets mounted, but ls /fs/microsd shows no SD
content.

CONFIG_STM32_SPI_DMATHRESHOLD=8

What can be a problem? Thanks in advance for help!

---
With regards, Oleg.


RE: STM32F4 SPI DMA buffer size issue

2020-11-24 Thread David Sidrane
Oleg,

Have you scoped the interface?

For gins and giggles try reducing the SPI clock drive strength. Step it down
and retest.

David

-Original Message-
From: Oleg Evseev [mailto:ev.m...@gmail.com]
Sent: Tuesday, November 24, 2020 4:57 AM
To: dev@nuttx.apache.org
Subject: STM32F4 SPI DMA buffer size issue

Hi all,

STM32f405rg custom board - MTD on SPI1 and SD card on SPI2.

MTD on SPI1 works without DMA and with if defined CONFIG_STM32_SPI1_DMA=y

but if also
CONFIG_STM32_SPI1_DMA_BUFFER=1024
is set, partitions get created, there are mtdblockX in /dev, geometry can
be read correctly, but reading or writing hangs up.
As I see in map g_spi1_rxbuf, g_spi1_txbuf are in SRAM, not in CCM.

Same with SD card. If defined CONFIG_STM32_SPI2_DMA_BUFFER=1024 there is
still /dev/mmcsd device, it gets mounted, but ls /fs/microsd shows no SD
content.

CONFIG_STM32_SPI_DMATHRESHOLD=8

What can be a problem? Thanks in advance for help!

---
With regards, Oleg.


GD32VF103

2020-11-24 Thread Matias N.
Hi,
when I bought some stuff from Seeedstudio last time, I added a Longan Nano to 
the purchase since it was really cheap and wanted to give it a try. I played 
around with it for a few days and managed to get some basic support for NuttX, 
but it seems either the core has some issues during debug or the tooling is not 
up to par yet. For starters it appears that you cannot reset the chip via debug 
connection so there's some hack needed for that to work. But I'm having even 
worse issues with openocd while debugging (memory reads react differently 
depending of if I single-step or just use breakpoints). Hopefully this is a bug 
in the (forked) openocd I used and not some chip errata.

By any chance anyone tried to work with this chip? 
It is not particularly interesting to me (it is mostly a clone of STM32F103), 
but I figured it could be good to support it if it ends up being used in 
products, such as the Pine64 Pinecil soldering iron.

Best,
Matias

Re: STM32F4 SPI DMA buffer size issue

2020-11-24 Thread Oleg Evseev
> Have you scoped the interface?

You mean a bus by analyzer? No, I don't have such ability for now.

For SD card I tried to reduce the SPI frequency from 24MHz to 10MHz, but it
didn't help when DMA is enabled. In fact it get failed to find a valid boot
record, while fat_hwread of sector zero is returned without errors.

The other strange thing I found out, is that when *DMA is not used*, SD
can't be used after mounting on boot. If I go through breakpoints in stm32
spi_setfrequency for example it get mounted ok and ls shows SD content.
It's hard to understand what is going on because it seems that debug
influence on the result. While debugging I saw the case when SD get mounted
but than on mkdir of log folder reading mmcsd_geometry get failed in
mmcsd_getcsd or mkdir success, but log dir is the only one thing on SD
while it is not empty.

In this case (without DMA) reducing SPI frequency from 24MHz to 20MHz seems
to fix the problem (but maybe it depends on delays and may appear again
once there will be more commands on boot for instance, I don't know).

Quite a strange behaviour for now.

вт, 24 нояб. 2020 г. в 17:12, David Sidrane :

> Oleg,
>
> Have you scoped the interface?
>
> For gins and giggles try reducing the SPI clock drive strength. Step it
> down
> and retest.
>
> David
>
> -Original Message-
> From: Oleg Evseev [mailto:ev.m...@gmail.com]
> Sent: Tuesday, November 24, 2020 4:57 AM
> To: dev@nuttx.apache.org
> Subject: STM32F4 SPI DMA buffer size issue
>
> Hi all,
>
> STM32f405rg custom board - MTD on SPI1 and SD card on SPI2.
>
> MTD on SPI1 works without DMA and with if defined CONFIG_STM32_SPI1_DMA=y
>
> but if also
> CONFIG_STM32_SPI1_DMA_BUFFER=1024
> is set, partitions get created, there are mtdblockX in /dev, geometry can
> be read correctly, but reading or writing hangs up.
> As I see in map g_spi1_rxbuf, g_spi1_txbuf are in SRAM, not in CCM.
>
> Same with SD card. If defined CONFIG_STM32_SPI2_DMA_BUFFER=1024 there is
> still /dev/mmcsd device, it gets mounted, but ls /fs/microsd shows no SD
> content.
>
> CONFIG_STM32_SPI_DMATHRESHOLD=8
>
> What can be a problem? Thanks in advance for help!
>
> ---
> With regards, Oleg.
>


RE: STM32F4 SPI DMA buffer size issue

2020-11-24 Thread David Sidrane
Hi Oleg,

See inline [DBS]

David
-Original Message-
From: Oleg Evseev [mailto:ev.m...@gmail.com]
Sent: Tuesday, November 24, 2020 9:46 AM
To: dev@nuttx.apache.org
Subject: Re: STM32F4 SPI DMA buffer size issue

> Have you scoped the interface?

You mean a bus by analyzer? No, I don't have such ability for now.

[DBS]  Use an oscilloscope, but with a high speed FET probe. You may see
incredible overshoot, when DMA is on.


For SD card I tried to reduce the SPI frequency from 24MHz to 10MHz, but it
didn't help when DMA is enabled. In fact it get failed to find a valid boot
record, while fat_hwread of sector zero is returned without errors.


[DBS] By drive strength I mean the slew rate control not frequency

See
https://github.com/PX4/PX4-Autopilot/blob/master/boards/px4/fmu-v6x/nuttx-config/include/board.h#L411-L431
For an eample.

The other strange thing I found out, is that when *DMA is not used*, SD
can't be used after mounting on boot. If I go through breakpoints in stm32
spi_setfrequency for example it get mounted ok and ls shows SD content.
It's hard to understand what is going on because it seems that debug
influence on the result. While debugging I saw the case when SD get mounted
but than on mkdir of log folder reading mmcsd_geometry get failed in
mmcsd_getcsd or mkdir success, but log dir is the only one thing on SD
while it is not empty.

In this case (without DMA) reducing SPI frequency from 24MHz to 20MHz seems
to fix the problem (but maybe it depends on delays and may appear again
once there will be more commands on boot for instance, I don't know).

Quite a strange behaviour for now.

вт, 24 нояб. 2020 г. в 17:12, David Sidrane :

> Oleg,
>
> Have you scoped the interface?
>
> For gins and giggles try reducing the SPI clock drive strength. Step it
> down
> and retest.
>
> David
>
> -Original Message-
> From: Oleg Evseev [mailto:ev.m...@gmail.com]
> Sent: Tuesday, November 24, 2020 4:57 AM
> To: dev@nuttx.apache.org
> Subject: STM32F4 SPI DMA buffer size issue
>
> Hi all,
>
> STM32f405rg custom board - MTD on SPI1 and SD card on SPI2.
>
> MTD on SPI1 works without DMA and with if defined CONFIG_STM32_SPI1_DMA=y
>
> but if also
> CONFIG_STM32_SPI1_DMA_BUFFER=1024
> is set, partitions get created, there are mtdblockX in /dev, geometry can
> be read correctly, but reading or writing hangs up.
> As I see in map g_spi1_rxbuf, g_spi1_txbuf are in SRAM, not in CCM.
>
> Same with SD card. If defined CONFIG_STM32_SPI2_DMA_BUFFER=1024 there is
> still /dev/mmcsd device, it gets mounted, but ls /fs/microsd shows no SD
> content.
>
> CONFIG_STM32_SPI_DMATHRESHOLD=8
>
> What can be a problem? Thanks in advance for help!
>
> ---
> With regards, Oleg.
>