FatFS with Cube HAL address problem
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-06-27 8:40 AM
Posted on June 27, 2016 at 17:40
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 0x9313530
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-06-27 11:01 AM
Posted on June 27, 2016 at 20:01
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.Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-06-28 9:05 AM
Posted on June 28, 2016 at 18:05
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).
