Skip to main content
Nor Sch
Associate III
Oct 11, 2016 10:19 AM UTC
Question

STM32L4 with USB MSD and FatFS, Limitations

Posted on October 11, 2016 at 12:19

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:
  1. The sdmmc-ClockDivider is internally incremented by 2. With a Clock of 48 MHz and the in Theory possibly Divider 0 the 24 MHz should be possible. But In Practice I must use 2 and get a Clock of 12 MHz. Otherwise I get from Read()-Functions permanently SD_RX_OVERRUN, means that I�m to slow with reading incoming Data out of the FIFO. The Demo-Code for the STM32L476-Eval-Board also uses 2 as Divider, but why?
  2. With FatFS the DMA-Write is working fine, with DMA-Read I get again the SD_RX_OVERRUN in every Case after 84 Byte copied from FIFO into my Buffer. The FIFO has 128 Byte and seems to be again faster full than the slow L4 can read out.
  3. With USB MSD I have to use also for the Write the blocking Mode. The DMA-Write is hanging somewhere not getting a Flag (I�m not sure without testing it again, which Flag, but it looked like a suggested IRQ-Handler is not called). So from generated Code no DMA at all is usable here.

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-dma
This topic has been closed for replies.

27 replies

ChrisH
Associate III
Dec 7, 2016 12:09 AM UTC
Posted on December 07, 2016 at 01:09

I'm having exactly the same issues as you mentioned. All from 1 - 3, I haven't found any workaround, I hope its not a HW limitation and possibly some kind of lib bug. Although I doubt it...

ST Technical Moderator
Dec 7, 2016 6:36 PM UTC
Posted on December 07, 2016 at 18:36

Dear Users,

Please, have a look to this

http://www.st.com/content/ccc/resource/technical/document/errata_sheet/65/dd/2c/78/59/b0/4c/68/DM00111498.pdf/files/DM00111498.pdf/jcr:content/translations/en.DM00111498.pdf

 related to the STM32L476xx/STM32L486xx devices, in the section 'SDMMC peripheral limitations' to check if you have the same conditions as described in the errata sheet.

Best Regards

-Imen-

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
Nor Sch
Nor SchAuthor
Associate III
Dec 8, 2016 5:13 PM UTC
Posted on December 08, 2016 at 17:13

These Problems are no Part of the Errata.

Nor Sch
Nor SchAuthor
Associate III
Dec 7, 2016 3:18 PM UTC
Posted on December 07, 2016 at 16:18

Since then I rewrote the complete SD-Driver. I have now a Driver which implements SD and eMMC. The above Problems are still there. But I have it now 100% stable and can use 8-Bit-Bus for eMMC. With this 8-Bit-Bus you can only use 9.6 MHz but at the End it's still a little bit faster than the 4-Bit-SD with 12 MHz.

If you try higher Frequencies, it runs often for a While. But at some Point the SDMMC-HW in the STM32L4 seems to hang. Other Threads are working, but there is no more Traffic on the Cmd-/Data-Lines. Also a Reinit of the SDMMC-HW was not working for me.

For Point 3 there would be a Solution: You only have to rewrite the USB-Driver and the DMA-Implementation. They are Garbage. But they are also so complicated, that normally nobody really wants to rewrite them. If you debug through a Filecopy via USB you will see that there are many many Functions and Layers called out of one Interrupt and there is a lot of Handling in this Interupt-State ... So if you have enough Manpower for your Project: write new Drivers.

ChrisH
Associate III
Dec 7, 2016 4:35 PM UTC
Posted on December 07, 2016 at 16:35

Thank you for quite an extensive reply. For the final product I'm not going to use MSC so rewriting drivers is pointless:) I have weird behaviour with RTOS as interrupt callbacks are not called and when using any sort of DMA functions I timeout. Priorities in NVIC are correct SDMMC1 has higher priority than DMA request, but it is still not called. I probably missed something really simple here. Rewriting DMA Driver might be a need since I want to have long battery life and I want less frequent writes with larger chunks of data. Going here to sleep might be a good idea I guess, hence why I prefer to have working DMA. Btw, DMA Write in MSC worked for me out of the box. Do you think all those problems might be affected by the card that is used or it doesn't matter?

Tesla DeLorean
Guru
Dec 7, 2016 6:46 PM UTC
Posted on December 07, 2016 at 18:46

>>

Do you think all those problems might be affected by the card that is used or it doesn't matter?

Cards can change the system dynamics, within ST's code base historically these can cause race issues. ie mostly sequence/ordering becoming more critical when the card responds near instantaneously.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
ChrisH
Associate III
Dec 9, 2016 7:41 PM UTC
Posted on December 09, 2016 at 20:41

Now with bare minimum setup using RTOS + FATFs with SDIO driver, I can read in DMA but can't write since in Read DMA interrupts are normally fired and everything works while in write they won't work. On the other hand with USB MSC it is opposite, write DMA works, read DMA doesn't.

robertwood9170
Associate
Dec 13, 2016 11:06 PM UTC
Posted on December 14, 2016 at 00:06

I have also seen similar (but not exactly the same) issues.

Background: we are developing an STM32l486 LoRa EndPoint for sensors; after many iterations, the hardware appears solid, and re drivers, the SD card is the last driver to be developed. It also has been by far the hardest; it took a very long time to get any life. Here's were we are at:

1) Our SDMMCCLK is 48MHz from the PLL (our crystal is 12MHz, our system clock is 72MHz). From the HAL library:

SDMMC_CK = SDMMCCLK / (ClockDiv + 2). We could not get anything working with ClockDiv equal to 0, 1, or 2. With ClockDiv equal to 3, we got very intermittent success. With ClockDiv equal to 4 and larger, we got some success, but still significant errors. For the smaller ClockDiv's the errors were RCV_OVERRUN's and TR_UNDERRUN's.

2) We were not successful using BSP_SD_ReadBlocks_DMA() or BSP_SD_WriteBlocks() in sd_diskio.c; we were able to read and write many times using low 

ClockDiv's and non DMA block reads and writes. We have not yet tracked down exactly what is failing when using DMA block reads and writes, we hope to get to this sometime. It appears others have been more successful than us wrt using DMA.

3) Whenever we tried running f_mkfs((TCHAR const*)SDPath, 0, 0), the SD card got corrupted; we have given up on this for now as we can easily make fat32 initialized cards using fdisk to partition and either mkfs or mkdosfs. We have not tracked down where 

f_mkfs goes wrong and probably won't as we don't see the necessity to use an STM32 to format the SD card.

4) After getting the example from STM32Cube_FW_L4_V1.5/Projects/STM32L476G_EVAL/Applications/FatFs/FatFs_uSD/ to work most of the time using a large ClockDiv (so that 

SDMMC_CK is 8MHz or slower)

and with f_mkfs commented out, we put the example code in a loop to open a file, write, close the file, re-open, read, and re-close as is done in the example. It ran often but almost never made 100 loops; the failures seem to be always occurring at the opens and closes of the write portion. If we retry the open or close directly using gdb after breaking, it often returns FR_OK, so the problem appears sporadic.

5) The cube generated code has errors: for example:

PeriphClkInit.PLLSAI1.PLLSAI1Source = RCC_PLLSOURCE_HSE;

and

PeriphClkInit.PLLSAI1.PLLSAI1M = 1; in SystemClock_Config() of main.c of the example. Errors like this do not inspire confidence in the quality of the Cube code.

Structure PLLSAI1 does not have 

PLLSAI1Source and 

PLLSAI1M components, only the main PLL has them. Also, combining the code generated from Cube with the code from the examples is very error prone and convoluted.

6) Summary: we are mostly working, but far from production ready after significant efforts. The 

STM32L476G_EVAL is the only Cube/HAL example that seems to have a chance of working. Documentation for getting microSD cards working with the STM32L4XX's is not there. It would be nice if there was a cohesive example using HAL and Cube code, but refactored into something sensible that could be used as a starting point. Also, at this time, we think the hardware may be buggy, but it is too complicated to tell. Will update later when we get more insight. Hoping this helps others and it would sure be nice to get some help from ST here.

ChrisH
Associate III
Dec 14, 2016 1:21 AM UTC
Posted on December 14, 2016 at 01:21

At the moment I got Read and Write DMA working fine and pooling is not an option at least in my case as I had various over/under run errors when using FreeRTOS (most likely you need to perform read writes under taskEnterCritical/taskExitCritical). The key is to correctly set up DMA you can't use separate channels for Read and Write. Therefore only add SDMMC1 request without TX nor RX at the end (when using CubeMX) or simply cofigure it just one DMA channel for both rx and tx. Lastly, you need to set up interrupts so that SDMMC1 interrupt has higher priority than DMA interrupt.

robertwood9170
Associate
Dec 14, 2016 2:45 AM UTC
Posted on December 14, 2016 at 02:45

Thanks Chris, I'll give your suggestions a try. I believe the code that

comes from the Cube example uses channel 4 only, but if it does seem to

include RX and TX, for example:

state = ((SD_DMAConfigRx(&uSdHandle) == SD_OK) ? MSD_OK : MSD_ERROR);

and

state = ((SD_DMAConfigTx(&uSdHandle) == SD_OK) ? MSD_OK : MSD_ERROR);

but when you look at the code for the two Config functions, they seem

pretty well the same, and both use channel 4.

hdma_tx.Instance = DMA2_Channel4

In both Config functions, the priority for DMA channel 4 is set at 6,

HAL_NVIC_SetPriority(DMA2_Channel4_IRQn, 6, 0);

HAL_NVIC_EnableIRQ(DMA2_Channel4_IRQn);

whereas the SDMMC1 priority is set at 5

/* NVIC configuration for SDMMC1 interrupts */

HAL_NVIC_SetPriority(SDMMC1_IRQn, 5, 0);

HAL_NVIC_EnableIRQ(SDMMC1_IRQn);

which makes the SDMMC1 higher priority as it has a lower number.

In summary, I think I am already doing what you suggest, but I must be

doing something wrong elsewhere. Thanks again.

-Ken

robertwood9170
Associate
Dec 14, 2016 11:57 PM UTC
Posted on December 15, 2016 at 00:57

Update: I finally appear to have the eval example of STM32Cube_FW_L4_V1.5.0/Projects/STM32L476G_EVAL/Applications/FatFs/FatFs_uSD/ working with DMA. What I have now is a combination of code from the above example and code generated by Cube. I didn't record everything but I can mention a few of things I did (I did lots and lots of trial and error  and I am very far from the beginning). Firstly, the example and the code produced by Cube have many conflicts especially wrt init functions. I have tried to put files that have been customized into my home source directory similar to Cube, but I have not been perfect here (which may cause problems later). The main driver from the example that has been really modified is STM32Cube_FW_L4_V1.5.0/Drivers/BSP/STM32L476G_EVAL/stm32l476g_eval_sd.c; I copied this to my home src directory and renamed it stm32l476_sd.c. Also, we are actually using the 64 pin 486, not the 476, but the only differences appear to be a hardware AES is included in the 486. Almost all our code was originally developed with a previous iteration based on the 476. The equivalent file produced by Cube is in the home Src directory and is called 

bsp_driver_sd.c and is very different. Since the example fatfs were written to work with 

stm32l476g_eval_sd.c, I used it as my basis. This may have been a mistake. However, I do most of my inits in 

stm32l4xx_hal_msp.c in my home src directory similar to the Cube code. The Cube code does most of its configs in main.c.; I moved these to stm32l4xx_hal_hw.c again in home/src. I also put my interrupt handler redirection into home/src/stm32l4xx_it.c again similar to Cube. Now for some details (I will only use my file names).

1) In BSP_SD_ReadBlocks_DMA() in 

stm32l476_sd.c, I no longer set uSdHandle.hdmatx = NULL or call SD_DMAConfigRx(&uSdHandle). The changing of hdma_rx.Init.Direction, for example is done in the HAL library file 

stm32l4xx_hal_sd.c in HAL_SD_ReadBlocks_DMA() at line 896; also the DMA callbacks are also set in the function (i.e. hsd->hdmarx->XferCpltCallback  = SD_DMA_RxCplt at line 892). The 

SD_DMAConfigRx() function completely re configures everytime 

BSP_SD_ReadBlocks_DMA() is called. This seems wasteful. Similar comments for

SD_DMAConfigTx(), 

The configuration for the interrupts is now being done in my HAL_SD_MspInit() function in my home/src/

stm32l4xx_hal_msp.c similar to how Cube sets things up.The lines look like:

__HAL_LINKDMA(hsd,hdmarx,hdma_sdmmc1);

__HAL_LINKDMA(hsd,hdmatx,hdma_sdmmc1);

SD_on();

HAL_Delay(1);

/* Peripheral interrupt init */

HAL_NVIC_SetPriority(SDMMC1_IRQn, 5, 0);

HAL_NVIC_EnableIRQ(SDMMC1_IRQn);

/* USER CODE BEGIN SDMMC1_MspInit 1 */

/* NVIC configuration for DMA transfer complete interrupt */

HAL_NVIC_SetPriority(DMA2_Channel4_IRQn, 6, 0);

HAL_NVIC_EnableIRQ(DMA2_Channel4_IRQn);

The function 

SD_on() just turns on the PFET to power up the SD card. Notice that there is now a global for the dma handler function (i.e. 

hdma_sdmmc1). In the example driver, static locals were used for the dma handlers and this caused all kinds of problems. For example, HAL_SD_CheckReadOperation() was failing because hsd->DmaTransferCplt was not being set in HAL_SD_IRQHandler() because the dma handler was incorrect. Note: this is all in the HAL library file 

stm32l4xx_hal_sd.c.

The current set up is very convoluted and really needs to be refactored in a major way. For example, if you can follow this:

f_open() calls find_volume() (in ff.c) which calls disk_initialize() (in dsikio.c) which calls SD_initialize() (in sd_diskio.c) which calls BSP_SD_Init() (in stm32l476.c) which calls HAL_SD_Init() (in stm32l4xx_hal_sd.c) which calls HAL_SD_MspInit() (in my stm32l4xx_hal_msp.c file) which configures the SD once again! Sigh! Also, setting the dma handlers in the sd handler is done in a lot of different places and is hard to track down. The above example is the only reasonable example I found for sdio for the STM32L476 and once again it is not consistent the code generated by the Cube.

In the end, I was able to run the example 1000 times with each time opening the file, writing the file, closing the file, re-opening the file, reading the file, and confirming it was the same as that written. I am not running f_mkfs(). Each time, an LED toggles on my board; I can see there are times it stops for a noticeable fraction of a second, but no errors occur. With my 72MHz system frequency and uSdHandle.Init.ClockDiv set to 4, each complete iteration takes 42ms.

Finally, finally, this took a number of weeks of long days including weekends; I wouldn't suggest taking it on unless you are willing to invest the time; I'm sure there are easier and more efficient ways of accomplishing the same, but I couldn't find them with the sparse documentation available. I would suggest ST consider investing some resources to clean this up. Anyways, I think I am done for now and ready to move on.

ChrisH
Associate III
Dec 15, 2016 2:22 AM UTC
Posted on December 15, 2016 at 02:22

I'm glad it worked for you in the end although you took kinda round way, btw in cube generation settings there is an option to generate a separate pair of h/c files for each peripheral so it makes your code much cleaner personally I always use it. Secondly code generated by Cube is more or less ok, but you have to remember where to put your code because Cube like to overwrite code which is in 'wrong' place. What you wrote regarding eval project is totally right and makes sense. Btw since you use LORA I assume you work heavily on optimizing your power consumption, what are your average current when using SD Card? I heard it can actually drain quite a lot...

robertwood9170
Associate
Dec 15, 2016 8:17 PM UTC
Posted on December 15, 2016 at 21:17

Update 2: f_mkfs() is now working as well; indeed, it appears everything in fatfs (that I have tried is working). This is for ClockDiv = 3 (SD-CLK = 9.6MHz) or larger, for ClockDIv = 2 (SD-CLK=12MHz) it doesn't work at all. I'm currently mostly using ClockDiv = 4 (SD-CLK=8MHz). Now here's the interesting thing: for a test bench which is mostly writes, the frequency of SD-CLK make very little difference. For example, in a test bench that links, mounts, opens a file, write 100 lines of 47 characters each, closes, opens, and reads the complete contents once (it actually does a bit more, but I don't believe it is significant):

FD-CLK = 8MHz: 88ms/iteration (I do 100 iterations).

FD-CLK = 6MHz: 91ms/iteration

FD-CLK = 1MHz: 144ms/iteration.

The times vary a bit between tests (maybe 5%). I found this very surprising. Changing the test so that in each iteration, during the read part, the file was opened, completely read 100 times be using f_lseak to reset to the beginning of the file before each read, and then this process was repeated 100 times, produced a larger effect due to FD-CLK, but not even close to being proportional. For example, for the modified test with 100 reads (of 4700 bytes in each read) in each of the iterations:

FD-CLK=8MHz: 29ms/iteration

FD-CLK = 1MHz: 118ms/iteration

Currently, I have no idea why these times are not closer to being proportional to the FD-CLK period.

Chris, you are correct, with LoRa power is absolutely critical. We have not yet done power measurements. I believe it will be very dependent on whether it is a read or write (I believe writes require quite a bit more power) and maybe on the type of SD card. We are working on End Points, and almost all current End Points do not have SD cards. Our current plans are to store most samples in RAM and then every so often store the RAM contents on the SD card. In this way, we can mostly leave the SD card off to minimise memory. The other reason we need the SD card is it will allow us to do firm-ware updates which we think are absolutely necessary, especially in commercial applications. Using LoRa to download firmware updates is very difficult if not almost impossible. When I get some power measurements, I will post.

bryenton
Visitor II
Dec 30, 2016 6:49 PM UTC
Posted on December 30, 2016 at 19:49

Hi,

I spent ALOT of time getting these working as well. The SD drivers have many bugs/timing issues in them.

For MSD and FatFS the most important issues to address are:

1) PCLK2 to SDMMC_CK must be such that PCLK2 is > 6/8*SDMMC_CK. This means that you can't just use the SDMMC_TRANSFER_CLK_DIV define, but need to adjust it to ensure .ClockDiv is set properly. Please note that the RM states 3/8 relationship but in testing from .5-80MHz SYS/PCLK frequencies seems that 6/8 ratio is needed. Whenever a new SD card or eMMC is used, this needs to be tested since might need to slow down SDMMC_CK a bit more or possibly speed it up if testing proves OK. To be safe, when ratio close to 6/8 I add 1 to ClockDiv to ensure SDMMC ratio is fast enough, and that gives reliable results, albeit slightly lower throughput.

2) ensure these are corrected as follows:

#define SDMMC_DCTRL_DBLOCKSIZE_2             (0x4U << SDMMC_DCTRL_DBLOCKSIZE_Pos) /*!< 0x00000040 */ // ie. 3U -> 4U

#define SDMMC_DCTRL_DBLOCKSIZE_3             (0x8U << SDMMC_DCTRL_DBLOCKSIZE_Pos) /*!< 0x00000080 */ // ie. 4U -> 8U

3) add a 10mSec delay after  __HAL_SD_SDMMC_ENABLE(hsd); and before CMD0/CMD8 sequence in SD_PowerON

4) fix bugs in uin64_t parameter to allow >4G devices in calls to BSP_SD_ReadBlocks, BSP_SD_ReadBlocks_DMA, BSP_SD_WriteBlocks, BSP_SD_WriteBlocks_DMA function calls, i.e.

    (uint64_t)(sector * BLOCK_SIZE), => should be  (uint64_t)sector * BLOCK_SIZE,

To get eMMC working there are many additional resolutions and functions that are needed since ST drivers don't fully support it.

Hopefully these will be of use and save you some/a lot of time.

Al

ChrisH
Associate III
Dec 31, 2016 3:56 PM UTC
Posted on December 31, 2016 at 15:56

Regarding first one I've never run clock lower than 80MHz so far so I didnt encounter those issues - good to know anyway as I'm planning to lower frequency when dealing with less demanding tasks.

2 is fixed.

with 3 I didn't actually have any issues becuase of this and lastly indeed there is this bug in sd_diskio

G A
Visitor II
Mar 6, 2017 6:32 PM UTC
Posted on March 06, 2017 at 19:32

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.

  1. For FatFS there is a module called 'Compatibility checker for low level disk I/O module' on the FatFS web site. It is very hard to find. Before you try anything with files make sure this module runs. This tests all the drivers to make sure FatFS will work. Note: unless you re-write the HAL modules the last test, 4GB barrier, will fail. This is to support files over 4GB. Depending on you application that may be OK. (SD cards bigger than 4GB are OK as long as individual files are under 4GB). 

    http://elm-chan.org/fsw/ff/res/app4.c

  2. When using DMA you need to be careful about word alignment. FatFS does a good job of caching and coalescing writes but frequently it will pass a non word aligned pointer to the HAL write function. It took me a long time to track this issue. Currently I trap misaligned writes in the HAL write function and copy to an aligned buffer. With more time I would like to explore how to reconfigure HAL DMA to handle half word or byte transfers. This issue is detected by the test code above.
  3. Make sure the SDIO global interrupt has higher (lower numerical, Ej. 5) priority than the DMA Stream interrupt (Ej priority 6 for TX and 7 for RX)
vladimir boretsky
Associate
Aug 15, 2017 3:34 PM UTC
Posted on August 15, 2017 at 17:34

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.

Amel NASRI
ST Technical Moderator
Aug 15, 2017 5:59 PM UTC
Posted on August 15, 2017 at 17:59

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 "Best Answer" on the reply which solved your issue or answered your question.
vladimir boretsky
Associate
Aug 16, 2017 10:20 AM UTC
Posted on August 16, 2017 at 10:20

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>

Amel NASRI
ST Technical Moderator
Aug 16, 2017 9:57 AM UTC
Posted on August 16, 2017 at 11:57

Hi,

The explanation why it doesn't work with DMA is provided by

dresler.tomas

‌ in

https://community.st.com/0D50X00009XkYIISA3

.

-Amel

To give better visibility on the answered topics, please click on "Best Answer" on the reply which solved your issue or answered your question.