2025-01-23 7:42 AM - edited 2025-01-23 7:44 AM
Hi Everyone,
I am using SPI NOR Flash (AT25SF128) with STM32F429 microcontoller. The requirement of my system are as follows: I write data to the SPI Flash using only HAL_SPI_**** statements. I want to read the data written to this flash using a USB (By creating a MSC class of USB). The USB interface is required only for data reading.
I have seen similar examples with SD card (SPI or SDIO). However, these examples cannot be applied to the SPI NOR Flash mainly due to following problems that I see. 1> The windows only see a USB when it sees a proper FAT partition, which I don't know how to configure it by using stm32 only. SD Cards can be formatted separately before plugging in with the microcontroller. 2> The FATFS middle present in the CUBEIDE doesnot have an option for a SPI NOR flash.
If anyone knows about this implementation, please guide me to the relevant post / page / link.
Note: Please refer to example with SPI NOR Flash and not the SD Card
2025-08-22 9:52 AM
Hello @ali_metu
Sorry for my late reply. I guess our colleague @Haithem Rahmani can help you achieve this using USBX stack!
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.
2025-08-22 10:05 AM
For FATFS you'd need to tune the DISKIO layer read/write functions to access your NOR FLASH, you'd also likely want to use 4KB Sectors instead of 512-Byte ones, as this is the minimum erase block size.
This will take more memory for the buffers, and for f_mkfs() to work.
TBH I think an MSC can report as having 4KB sectors (get capacity/mode page), and then Windows should be able for format the "media", and again here you'd need to implement READ and WRITE LBA block(s) where the write would do the erase and then write pages (256-bytes).
https://community.st.com/t5/stm32-mcus-products/usb-device-msc-with-external-flash/td-p/674099
2025-08-22 1:45 PM
Consider USB MTP class (also known as MCP).