2023-10-08 01:24 PM - edited 2023-10-09 12:50 AM
i tried to build a simple audio player , data from SD-card to USB audio host.
audio host is a big mystery , only (in STM world) one (!) example now, with Azure rtos + USBx .
(CubeIDE 1.13.1 , H563zit-nucleo board )
ok, seem to work now, but SD-card reading with Filex not working - what a surprise.
tried to debug, but i cannot find the problem...debug shows access to read low level sectors work,
but after ...> 100 sectors reading, first "logical" sector access, then hard fault. always.
but i cannot find out, whats wrong here.
last sector read seem ok, can see data (FAT32 etc.) , but next read to "first logical sector" gives hard fault...
Solved! Go to Solution.
2023-12-07 01:50 AM - edited 2023-12-23 02:47 AM
Update: now with short wires (about 25mm lenght) to sd-card-holder also 4-bit mode working with all cards i tested;
Speed is 100Mbit ( 4 x 25Mbit ) with "good" cards: Transcend, Kingston canvas select plus 32GB.
Speed is 200Mbit ( 4 x 50Mbit ) with SanDisk extreme 32GB; about 22MB/s .
Just the port pin setting i have different from "what STM Cube forces you" :
GPIO_PULLUP; + GPIO_SPEED_FREQ_MEDIUM;
Without pullups its not working, so i think STM should change this setting in Cube.
2023-12-07 05:39 PM
IDK, I got my SD card working with the first try, however, I had hard faults trying to write a file on a USB stick formatted with ExFAT. It turned out ExFAT needs 128K memory pool. After changing this both SD and USB work fine. BTW, how is FILEX related to the SD GPIO settings? I thought those are separate things. AFAIK FILEX is only responsible for translating bit streams into sectors and files. So you have typically some functions (like in HAL) that detect and initialize the SD, and when they pass your transport layer is probably all good. However, there is a slight possibility that all transport layer checks would pass, but the data received is bad, so when FILEX tries to do something with it it fails miserably. My guess it's either not FILEX, or, maybe try to increase its memory pool to like 128k and see what happens ;)
BTW, hard fault after reading some sectors is pretty typical for insufficient memory for FILEX.
2023-12-07 09:53 PM
> speed is 200Mbit ( 4 x 50Mbit ) with SanDisk extreme 32GB; about 22MB/s
Interesting!
A little OT:
I used µSD cards once, in 2012, with another ARM, and FatFS, also audio, battery powered.
The most interesting take-away from that project (besides my first 32bit experience) was difference between SD cards, concerning power consumption and speed.
SanDisk (and Samsung) was the winner, highest speed, even combined with lowest power consumption.
Run-time on battery difference was between 6 hours and 10 hours (SanDisk).
2023-12-26 12:46 PM - edited 2023-12-26 01:06 PM
Also little OT:
When looking (on my audio player) continuous data block reads, 16kB, there are "magic" differences between cards:
- the Kingston canvas select : this type should be top, read at >80MB/s
-- using 32GB version shows 0,7..1,2 ms time to read 16KB
-- using 64GB version shows 1...40 ms time to read 16KB
Maybe i got a bad, bad example (have only one of this cards) here, but i tested with speed test on linux and see:
so it can read at 90MB, but sometimes --- bad dropouts.
Compare a SanDisk extreme , 32GB :
THIS card reads at 96MB/s -- always.
I think, this is a very important difference, showing a little the "internal" quality of the flash area.
Also the write performance is very different: the Kingston card writing at 50 or 5 (!) MB, alternately (!) ,
the SanDisk at 80 or 70 MB .... rate the drama yourself.
btw. i have no friends at San ... or get money from them. Just testing some cards, i have. :)
2025-02-09 02:30 AM
i am using AZRTOS FIleX and try to interface a typical sandisk 16GB, by 4 bit width, 48MHz clock.
Wires from nucleo f767zi to card holder is about 22cm.
In the past I was using FATFS that partially work, as sometimes file is blank after creation.
Now I come back to this matter as I need to use ethernet so I migrate to AZRTOS, but cannot find any useful example that I could understand in this 2 weeks.
Do you mind to share some core snippets for FileX to interface with SD card?
it can just a simple card-mounting and write a string to a text file will do. I can expand from there.
2025-02-09 03:13 AM
>Wires from nucleo f767zi to card holder is about 22cm.
= 220mm . no way, to get it working.
->now with short wires (about 25mm lenght) to sd-card-holder also 4-bit mode working with all cards i tested;
2025-02-09 07:21 AM
25mm? that is very short dupont wire... i will try make that length.
by the way, is the code for AZRTOS SDMMC interface need to stay in FileX>App>app_filex.c?
my main RTOS task is in netxduo.c though, does it work calling FX SDCard related functions from app_filex.c?
I havent found any simple fileX-SDcard example though, if you could share a template or a few words or URL.
====
a separate question:
My old FATFS-SDcard 1bit, that used to work now no longer working, it can create .txt but write blank into the card. the text file is blank after the code run without error.
do you know how to fix it?
2025-02-09 07:58 AM
i need to thank you for the answer which I saw your answer in other thread, which reminded me the correct setup to use in FATFS
in combination, now I had the wire to be 10cm that works for FATFS, 1B.
1. Pull up all the Data pin
2. speed set to medium
3. MX clock divider 12, so 24MHz sysclk is cut to <2MHz
4. SDMMC global interrupt = enabled
===
now i had to tweak to see where is the bottom line of this parameters, and at the same time hope you could point a way for me to how to migrate to AZRTOS FileX style...