Skip to main content
AScha.3
Super User
October 8, 2023
Solved

SD-card not working with Azure/Filex - anybody got it working ?

  • October 8, 2023
  • 6 replies
  • 10074 views

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

AScha3_0-1696796640862.png

 

Best answer by AScha.3

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. 

6 replies

AScha.3
AScha.3Author
Super User
October 9, 2023

and: sd-card mount most times working (with 2GB card , FAT16 ; not good with 8GB FAT32 :(

AScha3_0-1696833534967.png

so hardware access (4 bit mode, 50Mbit max) seems ok.

"If you feel a post has answered your question, please click ""Accept as Solution""."
AScha.3
AScha.3Author
Super User
October 9, 2023

so- nobody using Filex (on SD-card) ???

"If you feel a post has answered your question, please click ""Accept as Solution""."
Haithem Rahmani
ST Employee
October 10, 2023

Hi @AScha.3 ,

from the screenshot, you seem to have enabled the fault tolerance in FileX  is that the case?
is there any reason to enable it?

regards
Haithem.

AScha.3
AScha.3Author
Super User
October 10, 2023

Hi @Haithem Rahmani  , 

this was my last idea, what could help this MS**bleep** to get it working.

But first, thx to look+write here , i already was thinking, STM no more has much interest in any problems of customers or users...

But anyway, i kicked out this MS excrement. not working at all...imagine : the company , that was "creator" of fatfs, makes program (or STM spoils it ? ) that cannot work with fatfs systems... tragedy. or almost comedy level. 

Now , after debugging 5 days this nonsense, i just copied in Mr. Changs fatfs ( Generic FAT Filesystem module R0.15 , not the 6 year old version, that STM still has in Cube) and it worked instantly . So i will try to use this.

But still i would like to know, is this Filex running with success anywhere ?

response on forum shows --- not much. (nothing...) so nobody using/trying it at all ?

STM should think about their bad idea, to rule out fatfs from Cube , only Azure/Filex is to be selected now.

If going on on this road, my way will be another in future.

 

"If you feel a post has answered your question, please click ""Accept as Solution""."
AScha.3
AScha.3Author
Super User
October 19, 2023

so really nobody using Azure/Filex ?

"If you feel a post has answered your question, please click ""Accept as Solution""."
AScha.3
AScha.3Author
Super User
December 3, 2023

after working some time with (actual version of ) FatFS , i got similar problems with some sd-cards.

so maybe the hardware/interface is the reason -- and give Azure/Filex another chance...

after some hours of reading/learning , i got Filex now reading directories with files , as it should .

the "examples" from STM helping not much, because i found only one (!!!) example : open/write a small string to a file,

close, open and read it. only in root/main directory. and this in many copies on some boards/cpus , but this is just one super primitive example , helping nothing for searching a file through directories and subdirs etc.

https://github.com/STMicroelectronics/STM32CubeH5/blob/main/Projects/STM32H573I-DK/Applications/FileX/Fx_uSD_File_Edit/FileX/App/app_filex.c#L145

 

With little help from MS i got it ... https://learn.microsoft.com/en-us/azure/rtos/filex/chapter4#fx_directory_first_full_entry_find

but still only 1-bit sdmmc is reading all cards , 4-bit only working with one card (in my tests , so far).

"If you feel a post has answered your question, please click ""Accept as Solution""."
AScha.3
AScha.3AuthorBest answer
Super User
December 7, 2023

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. 

"If you feel a post has answered your question, please click ""Accept as Solution""."
HTD
Senior II
December 8, 2023

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.

LCE
Principal II
December 8, 2023

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

AScha.3
AScha.3Author
Super User
December 26, 2023

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:

AScha3_0-1703623261419.png

so it can read at 90MB, but sometimes --- bad dropouts.

Compare a SanDisk extreme , 32GB :

AScha3_1-1703623391806.png

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

"If you feel a post has answered your question, please click ""Accept as Solution""."
Associate
February 9, 2025

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.

AScha.3
AScha.3Author
Super User
February 9, 2025

>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;

"If you feel a post has answered your question, please click ""Accept as Solution""."
Associate
February 9, 2025

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?