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. :)