Skip to main content
Associate II
January 24, 2025
Solved

HardFault_Handler() at stm32l0xx_it.c:85 0x80008b4

  • January 24, 2025
  • 4 replies
  • 798 views
MX_GPIO_Init();

MX_SPI2_Init();

MX_USART2_UART_Init();

MX_FATFS_Init();

/* USER CODE BEGIN 2 */

W25Qxxx_Init();

fres = f_mount(&fs,"0:",1);

if(fres == FR_OK)

{

v=9;

fres = f_open(&fp, "info.txt", FA_OPEN_ALWAYS|FA_WRITE);

}

else

{

v=2;

}


trying to use spi flash using fatfs .
but occur hardfault handler when calling fopen . i am not sure whether it is from fopen or not.

This topic has been closed for replies.
Best answer by mƎALLEm

Hello @NOVAL_______BOBY and welcome to the community,

Need to validate your read / write operation to the SPI Flash memory "W25Qxxx" before implementing FatFs on it.

4 replies

mƎALLEm
mƎALLEmBest answer
ST Technical Moderator
January 24, 2025

Hello @NOVAL_______BOBY and welcome to the community,

Need to validate your read / write operation to the SPI Flash memory "W25Qxxx" before implementing FatFs on it.

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
Associate II
January 24, 2025

tried read and write operations worked successfuly but when i try this again 

fres = f_mkfs("0:", FM_FAT, 0, worK, sizeof(worK));

fres = f_mount(&fs,"0:",1);

if(fres == FR_OK) {

v=9;

fres = f_open(&fp, "info.txt", FA_OPEN_ALWAYS|FA_WRITE);

}

else {

v=fres;

}
i got
HardFault_Handler() at stm32l0xx_it.c:85 0x80008b4

Thread #1 [main] 1 [core: 0] (Suspended : Signal : SIGTRAP:Trace/breakpoint trap)
HardFault_Handler() at stm32l0xx_it.c:85 0x80008d8
<signal handler called>() at 0xfffffff9
HAL_SPI_TransmitReceive() at stm32l0xx_hal_spi.c:1,308 0x8003128
HAL_SPI_Receive() at stm32l0xx_hal_spi.c:979 0x8002ca4
W25Qxxx_ReadPage() at w25q32.c:800 0x80010a8
W25Qxxx_ReadSector() at w25q32.c:839 0x8001160
W25Qxxx_diskio_read() at w25q32.c:974 0x8001250
disk_read() at diskio.c:122 0x800406c
move_window() at ff.c:925 0x80045fe
check_fs() at ff.c:2,971 0x80053f8
<...more frames...>

what should be reason any idea??

 

Associate II
January 24, 2025

Duplicate - merged.


tried read and write operations worked successfully but when i try this again 

 

fres = f_mkfs("0:", FM_FAT, 0, worK, sizeof(worK));
fres = f_mount(&fs,"0:",1);
if(fres == FR_OK) {
 v=9;
 fres = f_open(&fp, "info.txt", FA_OPEN_ALWAYS|FA_WRITE);
}
else {
 v=fres;
}

 

i got

HardFault_Handler() at stm32l0xx_it.c:85 0x80008b4

Thread #1 [main] 1 [core: 0] (Suspended : Signal : SIGTRAP:Trace/breakpoint trap)
HardFault_Handler() at stm32l0xx_it.c:85 0x80008d8
() at 0xfffffff9
HAL_SPI_TransmitReceive() at stm32l0xx_hal_spi.c:1,308 0x8003128
HAL_SPI_Receive() at stm32l0xx_hal_spi.c:979 0x8002ca4
W25Qxxx_ReadPage() at w25q32.c:800 0x80010a8
W25Qxxx_ReadSector() at w25q32.c:839 0x8001160
W25Qxxx_diskio_read() at w25q32.c:974 0x8001250
disk_read() at diskio.c:122 0x800406c
move_window() at ff.c:925 0x80045fe
check_fs() at ff.c:2,971 0x80053f8
<...more frames...>

what should be reason any idea??


Post edited to format code - please see this for posting source code, and this for other "formatted" text.

mƎALLEm
ST Technical Moderator
January 24, 2025
To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.