2016-10-11 03:19 AM
First: I do not use USB MSD and FatFS at same Time, but they work on the same SD-Card. This SD-Card is connected via SDIO with 4 Bit Databus. I use a STM32L476 but I think the Problems should be identical for all STM32L4-MCUs.
In the last Weeks I worked among others a lot on USB MSD and FatFS and got a bunch of Trouble with this. I updated FatFS (R0.12b) and FreeRTOS (v9.0.0). To get it run, I also used some Code from the Examples of the STM32L476-Eval-Board. Additionally I refactored a lot of CubeMx-generated Files including HAL-Drivers. The Result was cleaner, shorter and better readable Code without lot of duplicate Stuff, but I couldn't find any (not-documented) Errors or Reasons for obscure Limitations. Here are the Limitations I found:Can anyone give some Hints to these Problems or can anyone confirm these Limitations? Any Suggestion is welcome!
By the Way here are the Speed-Limits I got with deactivating other Threads. The Internal Tests are done with a 1MB-File. For the USB MSD I used a Windows 7 and copied Files greater 40 MB. Internal FatFS Read 3908 kB/s Internal FatFS Write 678,6 kB/s USB MSD Read 702 kB/s USB MSD Write 657 kB/s I think I�m on the Limit with these Values for the slow STM32L4 with 12 MHz SDIO-Clock and only USB FS with 12 Mbit/s. But I�m sure, that I will need the DMA later to get a little bit more Power for the other Threads � Also I think, that the Implementation of SD-HAL-Drivers and FatFS is not really cooperative for RTOS. After the Start of Read / Write even with DMA you will poll on some Flags. Has anyone a Hint for a fine working Solution which has multithreading better integrated? #stm32l4-usb-msd-fatfs-dma2017-01-02 04:29 AM
Hello
Bryenton.Al
,Back to case 1, you have to refer to the
where it is specified that:SDIO_CK/fPCLK2 frequency ratio Maximum value is4/3
which should be aligned with your deduction. In all cases as specified in the RM0351,PCLK2 and SDMMC_CK clock frequencies must respect the following condition:
Frequency(PCLK2) > ( ( 3xWidth) �?� 32) × Frequency(SDMMC_CK)
About case 3, we need to understand more why do you suggest to add
10mSec
delay ? Could you please provide us more details?Best Regards
-Imen-
2017-01-02 06:40 PM
Hi Imen,
Thanks for the responses to each of my points!
On 1, I had not seen this 4/3 SDIO_CK/fPCLK2 ratio, I had only noticed the second 3*width / 32 one. I had been using 4 bit SDIO, should have mentioned that, and was finding that the 3*4/32 i.e.the 3/8 ratio I mentioned above did not hold, but the 6/8 i.e. 3/4 one you pointed out certainly does. If you compare these 2 I believe there are many cases where the 3/8 rule is satisfied, but the 4/3 rule needs to be applied to make things work. Wish I knew about that one a lot earlier.
On 2, great, I had been using rel 1.4 and 1.5 so another reason to migrate to 1.6.
On 4, great.
On 3, I will try to redo some tests to give more specifics, but recollection is that at lower speeds (i.e. Pclk2< 8M) if I didn't put in over a 5msec delay that it would regularly fail the Cmd 0/8 sequence. 10msec seemed to resolve this issue.
A general question Imen, but is there a place that I can submit specific bug reports? as mentioning them in forums like this probably isn't the most effective way.
Thanks,
Al
2017-01-03 04:03 AM
Hi
Bryenton.Al
,You can add'bug' tag to this discussion. This help you andusersto filter by tags and find specificbug as quickly as possible.
All comments and suggestions are welcome to improve our solutions.
Best Regards
Imen
2017-03-06 10:32 AM
I cannot answer the specifics in you post, buy I finally have a nice working implementation of FatFS on an SD card using DMA and also FreeRTOS. Here are some of the important lessons I learned. My system is based on the STM32F4 discovery board.
2017-08-15 08:34 AM
Hello frends!
I tried produce very simple project for uSD card communication by CubeMx.
The project was generated in the POLLING Mode SD communication and write and read functions working properly.
I tried to change POLLING to DMA write read mode. Now it is impossible to open file , because I received error.
The cause of error is : Impossible to find FAT on the SD card.
I compared this project to base sample from
STM32Cube_FW_L4_V1.5.0/Projects/STM32L476G_EVAL/Applications/FatFs/FatFs_uSD/.
It is mostly the same. The CubeMx produce this code slightly optimized.
I return to sample from
STM32Cube_FW_L4_V1.5.0/Projects/STM32L476G_EVAL/Applications/FatFs/FatFs_uSD/.
I produced a lot of changes in this code and tried to work in the DMA mode. I produced TX and RX true different DMA.
Now I have DMA_read working quite well. It is mean that I can read 2G file by chanks of 8kBytes without great problems. The DMA_write process working till writings block has less 1024 bytes long. If more then write error occure quickly. As usial it is CRC error.
I need DMA write and read communication, because my main application can't wait for POLLING mode.
So, Can anybody send me working project with write and read by DMA using.
I can send to anybody my partially working project for analyze also.
For answers my EMail is
mailto:boretskyv@gmail.com
.Thank you very much.
2017-08-15 10:59 AM
Hi
boretsky.vladimi.002
,This blog:
https://community.st.com/0D50X00009bMM7JSAW
may bring you some help.-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2017-08-16 02:57 AM
Hi,
The explanation why it doesn't work with DMA is provided by
dresler.tomas
inhttps://community.st.com/0D50X00009XkYIISA3
.-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2017-08-16 03:20 AM
Hello AMEL N!
Thank you for yours response.
I tried improve my project according to SDIODMAFatFS.pdf document.
I received the same results. If I use BSP_SD_WriteBlocks
and BSP_SD_ReadBlocks functions(It's mean that read and write producing in
the polling mode) all working properly.
If I change BSP_SD_WriteBlocks to BSP_SD_WriteBlocks_DMA and
BSP_SD_ReadBlocks to BSP_SD_ReadBlocks_DMA it is impossible even open file
. The returned error is RES_NOFILESYSTEM. It's mean that we have problem
with read from SD card in DMA mode. I doubt that it was checked oreviously.
Does anybody tested any processor from STM32L4 family for write and read SD
card in the DMA mode?
BORETSKY VLADIMIR
Mobile: 972(0)503-002216
EMail: boretskyv@gmail.com
2017-08-15 19:02 GMT+03:00 Amel N <st-microelectronics@jiveon.com>:
STMicroelectronics Community
<https://community.st.com/?et=watches.email.thread>
Re: STM32L4 with USB MSD and FatFS, Limitations
reply from Amel N
<https://community.st.com/people/st.mcu?et=watches.email.thread> in *STM32
MCUs Forum* - View the full discussion
<https://community.st.com/message/165739-re-stm32l4-with-usb-msd-and-fatfs-limitations?commentID=165739&et=watches.email.thread ♯ comment-165739>