2016-06-27 08:40 AM
I'm using STM32F446RE to implement FatFS with Cube, using eval_sd.h file from F446RE_EVAL. I'm performing periodically writes in files and sometimes the code works, other it gives me a Hard fault at ff.c: validate, when accessing fil->fs:
staticFRESULT validate ( /* FR_OK(0): The object is valid, !=0: Invalid */ void* obj /* Pointer to the object FIL/DIR to check validity */){ FIL *fil = (FIL*)obj; /* Assuming offset of .fs and .id in the FIL/DIR structure is identical */ if (!fil || !fil->fs || !fil->fs->fs_type || fil->fs->id != fil->id || (disk_status(fil->fs->drv) & STA_NOINIT)) return FR_INVALID_OBJECT; ENTER_FF(fil->fs); /* Lock file system */ return FR_OK;}The problem is fil->is have address 0x9313330, so it seems that it was never addressed. Anyone having this problem? My custom HardFault Handler prints:In Hard Fault HandlerSCB->HFSR = 0x40000000Forced Hard FaultSCB->CFSR = 0x00008200PRECISERR at 0x93135302016-06-27 11:01 AM
Hi,
Could you disclose the code that you use when open file and writing?Make sure that the ''FIL'' structure is pointing to valid memory before you use it with fatFS f_ functions. FatFS will not do that for you if I recall correctly.2016-06-28 09:05 AM
Forget about it, one of my ''if'' didn't have the right condition so it kept filling a char array in the bss past it's limit, thus changing the memory after that (including the FIL structure with that pointer).