HardFault on f_write() from FatFS
Hi to all,
I'm facing with an hard fault when call f_write() or f_read() from FatFs library (R0.12c).
I'm able to mount SD card, create a file in write mode, write to it using f_puts().
As suggested, I use the HardFault_Handler:
void HardFault_Handler(void)
{
/* USER CODE BEGIN HardFault_IRQn 0 */
static volatile int _Continue;
_Continue = 0;
while(_Continue == 0);
return;
/* USER CODE END HardFault_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_HardFault_IRQn 0 */
/* USER CODE END W1_HardFault_IRQn 0 */
}
}Once inside, I change the value of _Countinue to 1, and follow the execution with "Step into".
I found that the HardFault is caused by function validate() inside f_write().
I can't find the cause.
I use a STM32F103RCT, the project id generated in CubeMX. I try different Heap and Stack (0x800, 0x800) but the problem still remain.
So I have two questions:
1) How can I choose the best Heap/stack size and what is the greater value that I can configure ?
2) There is a way to identify the cause of HardFault ? I know what instruction generate it, but I don't know why.
Thanks to all.
