2025-01-08 02:12 PM
Hi
I'm trying to connect an SD card to my Nucleo U5A5ZJ-Q board using SDMMC peripheral and use it with FatFS library. When I use 1GB card and 4 bit mode, everything works fine. By "works fine" I mean that:
1. it passes this FatFS test: http://elm-chan.org/fsw/ff/res/app4.c
2. it is able to create a working text file.
But there are 2 problems:
1. 1 bit SDMMC mode doesn't work. When I'm trying to use it, the FatFS test fails at an SD card write. After clicking around in STM32CubeIDE debugger I found that there is a CRC error in SD callback being set as status, which then leads to a timeout and test fail. This problem isn't critical, because 4 bit mode seems to work, but it worries me a bit.
2. 16GB and 32GB cards don't work. They get a bit further (to reading), but fail in a simmilar way (SD callback -> CRC error -> timeout -> test fail). I haven't been able to test 2-8GB cards yet. This is more of a problem, because it's getting harder and harder to get such small capacity cards.
The whole project is attached below.
Ideas, anyone? Thanks in advance.
Adam
Solved! Go to Solution.
2025-01-21 01:52 AM
Try to connect the sd-adapter with short wires to the board.
On my tests with a H563-nucleo i had disk-err with about 7cm cables ; using same adapter, but cables about 30mm is working fine. (4-bit mode at full speed, 50MHz card clock)
And set pin speed medium and pullups ON on all lines.
2025-01-08 02:31 PM
Hi,
most probably a hardware problem.
1-bit mode is less difficult, so it should work most times...even when 4-bit not working.
So search/read here in forum, what i wrote about sd-card problems and what to do.
...set pin speed medium, pullups on...etc.
+ i have sd-cards on my H743 audio player and no problem, 2GB or 32 GB .
2025-01-08 02:43 PM
Ok, I'm gonna try these things tomorrow. I find it weird that 4 bit mode is working but 1 bit mode is not. It seems that everyone has the opposite situation.
2025-01-10 08:04 AM
I've tested some uSD cards and here are the results:
1. 1 bit SDMMC mode isn't working at all. It's hanging at a first write with CRC error.
2. 4 bit mode does work but only on 1GB and below cards. Anything above 1GB hangs with a CRC error on first read (so after writing).
All pins exept for CLK are with pullups. All pins set to medium.
2025-01-10 08:40 AM - edited 2025-01-10 08:41 AM
So next: how long are your lines cpu/pin -> sd-card/pin ?
and clk /speed setting for sdmmc ?
+
Please dont write or mkfs -never ever- as long , its not working perfect with mount and reading.
Your just lucky, if cards survive these bad access trials.
Only mount and read (existing) files , until this works 100% perfect. Then try a write or create file...
2025-01-20 03:10 PM - edited 2025-01-20 03:13 PM
Sorry for slow reply, I've been quite busy lately.
My CPU -> uSD lines are 20cm + Nucleo track length + uSD adapter track length. I know that these are long, but:
I've used multiple clock speeds, fast and slow, both as SD clock and for SDMMC peripheral. Nothing helped.
When using SPI, everything seems to be working. I used test code from this: https://01001000.xyz/2020-08-09-Tutorial-STM32CubeIDE-SD-card/. I wasn't able to solve SDMMC issues. I would like to use it (4 bits is more than 1) but right now I can't and I've ran out of ideas.
My SPI test hardware setup is the same if not counting connecting cables to different Nucleo pins.
2025-01-21 01:52 AM
Try to connect the sd-adapter with short wires to the board.
On my tests with a H563-nucleo i had disk-err with about 7cm cables ; using same adapter, but cables about 30mm is working fine. (4-bit mode at full speed, 50MHz card clock)
And set pin speed medium and pullups ON on all lines.
2025-01-21 02:16 PM - edited 2025-01-21 02:58 PM
All SDMMC pins medium and pullup, 4 bit mode. With 4cm SDMMC cables the uSD card is working at 40MHz. Thank you very much for the suggestion! Was noise causing it to not work with most of the cards?
But there's still one problem. Why 1 bit mode returns FatFS error 13 (FR_NO_FILESYSTEM)?
2025-01-22 12:16 AM
Good!
>Why 1 bit mode returns FatFS error
Well, card always starting in 1-bit mode, so if 4-bit is working, 1-bit works anyway. (basically.)
So look, what in your 1-bit-mode-setting is different or what happens at start...
+
check just by mount with parameter 1 , mount now. (0 = delayed mount, no info about working or not here.)
>Was noise causing it to not work with most of the cards?
Maybe also...but biggest problem with the (nowadays) very fast pin drivers (in card and in cpu) is: there might be ringing and reflections, more and bigger with every cm of wire. So the receiver can "see" only some ringing instead of a clear hi or lo level at xx MHz signals.
2025-01-22 10:35 AM