cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4 SDMMC standalone mode (no RTOS): Works polled, not with DMA

willcfj
Senior

Hi, pretty sure this is a newbie type question. I'm using the SDMMC interface on an STM32L476. Right now it is just wired to a Nucleo board so I can do some benchmarking before committing it to a layout. I'm using STM32CubeMX and following the example in section 3.3 of UM1721 (Fatfs on CubeMX). After learning the hard way pullup resistors *are* necessary (some other posts said not), I am able to talk to a card, but only if I use polled mode ("Use DMA Template" set to disable in STM32CubeMX Fatfs settings). When enabled, the code hangs in the sd_diskio_dma.c SD_Read() routine right after the BSP_SD_ReadBlocks_DMA() call.

The note for "Use DMA Template" says to ensure that DMAs are properly configured but no more info. In the SDMMC configuration I've tried tried selecting SDMMC1 and then both SDMMC1_TX_SDMMC1_RX. I always get the stall. I am sure there i something basic I'm missing, but been at it for a couple days now and deciding to ask. Since this seems a very basic "follow the app note", rationalizing it might be useful for others too.

I've only recently migrated from the basic StcPeriph libraries to STMCube, starting with the LL routines, this is my attempt using HAL.

will

42 REPLIES 42

The level conversion on the SparkFun board isn't helpful on STM32 designs. These things from WaveShare, have pull-ups and work better

Supports Full-Size and Micro form factors

https://www.waveshare.com/sd-storage-board.htm

Micro only

https://www.waveshare.com/micro-sd-storage-board.htm

The ViewTool versions also work well

http://viewtool.com/index.php/en/36-2016-09-26-03-58-56/111-ficus-sd

There are some other cheap and nasty things on eBay, etc

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I don't use CubeMX, it is a time saving tool that wastes time in my universe.

I'm using the HAL examples as a basis for the things, and have Polled and DMA variants working on assorted STM32 platforms, non-RTOS. I can also support eMMC (4-128GB modules tested), and have validated functionality out to 200-400GB cards. Got a lot of time and resources invested, so code only being shared with clients.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

With my current state of the design, I cannot get the eMMC working beyond 8 Mhz clock (still using only 1 data wire for now).

0690X000006CGhVQAW.jpg

Clive:

OK, understand your situation, thanks.

will

Lucasz:

Sky-wiring is tricky. To me it is only good for some basic verification work and not much beyond that before going to a board. Even at slow speeds, if the transitions are high speed you can still get ringing. My wires are quite a bit shorter and looking at the signals with my scope show that they are far from clean.

Being able to get 17Mbps with this far-from-ideal setup just gives me confidence that once I go to a PCB with a ground plane and both series and pullup resistors to get clean signals, bandwidth can only go up. My test was with 24MHz divided by 4 (6MHz) too, but was able to get 4-bit mode working. If you have a scope, might be worth checking D1-D3 to see if maybe something is obviously not-pretty.

will

will

Hi Will,
You are right, my cables are really bad. But at this point, i need it to work at any speed and with any data signals. Also, I was able to use 4 data bits thanks to Clive's help on a Nucleo board. Just could not bring the rest 3 signals to my current PCB because the pins are already in use by other peripherals. I am also looking forward to the next pcb revision, with series resistors and 4 data lines.
T J
Lead

they are very thick wires, do you have any wirewrap wire ?

too hard to retro fit... which eMMC chip are you using ?

I can whip up a daughter board for you...

Attaching the test app for SD card on NUCLEO-L476RG, outputs diagnostic and menu on VCP at 115200 8N1

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

This was Lukasz's eMMC dongle for the NUCLEO-144 boards, also readable using a full size SD Card socket, which is what I was using today on the NUCLEO-64

0690X000006CGidQAG.jpg

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
willcfj
Senior

Just to let folk know: I'm still working on the root issue. I have confirmed that the stall is because there is no DMA happening at all, not because the DMA finished and the end isn't somehow being flagged. I also need a DMA-driven DAC for this project. Since I am pretty sure the "something basic" I'm missing has to do with DMAs, I'm going to fiddle withe the simpler peripheral (the DAC over SDMMC) to see what is wrong. Hopefully any lesson learned from the DAC DMA setup wil be applicable to the SDMMC DMA setup.

will