This is the 10^173 time you post something without any code, do you really expect any help this way?
Whenever you get a hardfault, check where it was generated, the debugging panel shows the last few calls, and usually the variables hold their values at the moment of the crash.
So just don't sit there, " Meh, I got a Hardfault", it's probably caused by a null pointer because something failed to init properly.
In any case, you should be able to see the exact line where it crashed.
I've tried HAL SDMMC in the past, worked well.
Maybe you're skipping some checks, like the return statuses, you can't simply do this:
void init()
{
HAL_SD_Init();
Do_Something();
}
Instead, always check the returning value was 0 (HAL_OK).
Making you own error handler which is simple, and a little macro will make it even easier.
#define test(func) if(func) handle_err(__FILE__, __LINE__)
void handle_err(char *file, int line)
{
printf("Error in %s:%d\n", file, line);
while(1);
}
void init()
{
test( HAL_SD_Init() );
Do_Something();
}
Simple example:
https://onlinegdb.com/-zODV20KQAlso remember to always check the stack usage and adjust it in MX.
HAL code using USB / Storage / Filesystems (also *printf) functions use heap allocation, so try increasing it to something large like 8KB-16KB.
After this, initialize everything, call all HAL and std functions (Including printf, etc) to make sure all the buffers were allocated, then check the heap usage with
mallinfo().
The value you need is
uordblks (Allocated heap in bytes), adjust the reserved heap accordingly with some little extra, you don't want to waste memory either.