8 years, 4 months ago.

Using SDFileSystem with Micron Flash Memory

Hi,

since i am new to microcontroller programming maybe i have not yet full understanding of the concepts. So if i am using something wrong please explain shortly the right steps.

I tried to use SDFileSystem lib with Micron Flash Memory M25P16 and i am getting

No disk, or could not put SD card in to SPI idle state
Didn't get a response from the disk
Set 512-byte block timed out

Does anybody have succesfully used SDFileSystem or any other FAT based file system library with memories other than sd cards? Is this something normal? If not how can i save informations in such memory devices?

Thanks

2 Answers

8 years, 4 months ago.

Hello Anteo. Personally have not used the SPI flash device with mbed yet but you are working with the SPI interface.

Respectively, the SPI interface consists of the MOSI, MISO, SCLK and CS (chip select) lines to operate.

Have these been connected correctly for your target board ?

Which target board are you using ?

What is your wiring to the target board ?

Which mbed code are you testing that failed to work ?

Perhaps consider to test one of the many other posted code solutions for SPI flash filesystems ?

For example:

https://developer.mbed.org/users/k4zuki/code/USBSPIFileSystem/

If you wish to simply R/W values non-volatile memory (ie. your SPI Micron M25P16) then you can use simpler R/W routines dealing with the SPI interface. The SPI memories come in many variances including the standard and common SPI opcodes but many are available now with QUAD SPI mode which permit 4 bit values to be toggled into or out of the flash memory on a single clock cycle. This in addition to very high speeds allow you to explore assorted options. The solution will vary with your requirements and target board.

Reply:

Anteo - the code being used appears to be strictly supporting only the SD Card devices and is using higher level commands to communicate with the storage medium. Respectively you can confirm this detail by reviewing the data sheet for the Micro M25P16 SPI flash memory. The commands are very different between these devices. It will be best to use the SD Card medium for your project if you wish to use this library.

On the other hand, if you only wish to R/W storage values then the SPI flash memory will make sense. That is the area we have some experience with but used a FPGA like device (XMOS) for this case review. XMOS is many times faster than the MBED solution but MBED is much easier to implement. Due to the high volumes of scale the use of SD Cards is very practical. You can find SD card sockets from assorted sources. If you wish to source in bulk at much lower cost than Digikey, Mouser, etc. then consider to contact Shenzhen Atom in Shenzhen, China. You will have to buy in bulk but will be at a fraction of the cost you will pay from standard distribution channels. Be sure to check the specs of the SD card socket to be sure it meets your needs and matches your PCB footprint.

So in summary, while the SD Card features the use of the SPI interface this doe not imply that you can use SPI flash memory ICs with this library from MBED. ARM appears to be advertising a library that can support SD Cards or even SPI Flash memory with a filesystem but most likely a commercial (paid) solution.

See here for the commands used for SD Cards:

http://elm-chan.org/docs/mmc/mmc_e.html

If you are willing to try alternative solutions:

http://interactive.freertos.org/entries/20218177-FatFS-Demo-FAT-File-System-on-External-NOR-FLASH-STM32-

  • not MBED related

Accepted Answer

Hi Sanjiv,

thanks for your reply.

I used this lib https://developer.mbed.org/users/neilt6/code/SDFileSystem/ and this code

SDFileSystem sd(PA_7, PA_6, PA_5, PB_6, "sd");

to initialize it.

I am using a custom Board which is almost same as the Nucleo F103RB (i have same microcontroller) and until now everything that i am programming based on mbed works. I have also connected a sd card on other pins and it works perfectly with the lib i mentioned. I can write into it and read from the sd card. Only the M25P16 flash is not working.

I have to mention that the sd card came preformatted with FAT. Is this important? I do not know if the M25P16 memory is preformatted. Should it be formatted to work? If yes how can i check and format the memory if needed?

posted by anteo c 17 Jan 2016
8 years, 4 months ago.

The SDFileSystem library is as the name might indicate, intended for SD cards, not for flash ICs. You can search if there are libraries for your device, and if they support a filesystem. Basic filesystem support is quite easy to add, but it can depend on the flash: Many have larger sectors to erase than 512B, the default for a FATFileSystem.