cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 FATFS with SPI FLASH

NOVAL_______BOBY
Associate

I am trying to interface a SPI flash from Winbond (W25Q64JV) with FATFS.

I have no previous experience with FATFS.

I initialize FATFS in CubeMX with the option "used-defined" and modified the MAXIMUM and MINIMUM Sector Size to 4096, as it is the smallest possible erase sector dimension.

I Got a Sample github code. This is It.
https://github.com/maxiufeng258/SPI_Flash_Uart_Led_Polling_V1.0.

i got w25Qxxx file from this github file which contain spi command to interact with w25q64.
Now i know i should edit User_diskio or diskio,c as mentioned in the gitcode.

i done it and got hardfault error at HAL_SPI_Transmit() function.
i know that so many done and success it before . 
but i dont get a clear picture of how it done. anyone guide ASAP 

3 REPLIES 3
Saket_Om
ST Employee

Hello @NOVAL_______BOBY 

Could you please share more details about the issue?

Does the SPI start writing and then go to a hard fault after transmitting a given number of bytes?

Does the execution go to a hard fault since the first bytes?

You mentioned in the post below that you succeeded in making the writing process work but failed in the reading process.

FatFS write successful but read not working on w2... - STMicroelectronics Community

If your question is answered, please close this topic by clicking "Accept as Solution".

Thanks
Omar

before first byte transfer it goes to hard fault error. 
when i try to do first time , i write sucessfully. but after try to open it show no such file and if i try to list all files, shows no such root directory.

>>before first byte transfer it goes to hard fault error. 

Debug the Hard Fault cause, usually pretty fundamental. Look at the faulting code, look at the registers when it faults. Likely you're using a bad pointer, pointing to the wrong memory, or exceeding that memories limits. Potentially the stack might be too small.

Ideally have a Hard Fault Handler that outputs actionable data.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..