cancel
Showing results for 
Search instead for 
Did you mean: 

stm32F10x MSC with SPI Flash (W25Q256) problem

thonsha
Associate

Hello,

I am trying make a USB device MSC.

It works fine with SD card, but I want both SD card and flash.( I set max_lun to 1.)

I have wrote the SPI_Flash_Write and  SPI_Flash_Read that can be called by MAL_Write and MAL_Read.

It seems work fine cause I can format the flash disk on my computer and put files into the disk.

However, everytime I turn off my board and turn on it, it ask me to format the disk again and again.

I have searched many solutions. Someone said that I should use FATFS f_mkfs to format first.

I tried but not worked , is that true or any other problem I missed ? 

 

Regards,

thonsha

 

2 REPLIES 2
FBL
ST Employee

Hi @thonsha 

Would you provide some code snippets for these functions " SPI_Flash_Write and  SPI_Flash_Read that can be called by MAL_Write and MAL_Read" .

I suggest you as a first step to isolate the problem and start with an example FATFS with micro SD card. Then we can move and use it as MSC Device.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.


>>It seems work fine cause I can format the flash disk on my computer and put files into the disk.

Seems a bit subjective, given it's not actually retaining content. The caching on the host will hide a lot of ills.

Perhaps use 4KB sectors on the FLASH, and test the read returns the same data that was written. Have a big enough sector buffer, and MAX_SS is adequate.

You should only need to format the content once, either from the Host or via f_mkfs()

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