Replacing sd card with external SPI NAND for file system

zliudr
Posts: 360
Joined: Thu Oct 03, 2019 5:15 am

Replacing sd card with external SPI NAND for file system

Postby zliudr » Wed Feb 03, 2021 5:14 pm

I'm using a microSD card for my file system which is fine as a prototype but has problems in production. I can't source sd cards with consistent performance or quality and I don't like the slots with contact issues due to vibration and not able to conformal coat it.

Since the WROVER's SPI flash can have an SPIFFS, can I create an SPIFFS on an external NAND SPI flash? Could anyone suggest a part number for say 128MB to 1GB size flashes? I've read a number of spec sheets and realize that this one for instance has a different command sets than SD commands. I wonder if this is the right SPI flash for ESP32.

https://www.digikey.com/en/products/det ... GR/9484745

Here is a list of commands I found to be common among these SPI NAND flashes. I don't know the details of SD card commands but was able to tell that these are NOT SD card commands. These NAND SPI flashes all claim their commands are compatible with NOR SPI flashes, which I think is what WROVER is using for program storage. I've tested the speed of the SPIFFS on WROVER and the speed is a lot slower than the microSD card I'm running with an SPI interface. I wonder if it's just the WROVER's SPI flash being NOR is slow to write to plus avoid CPU loading instructions. I hope with an SPI NAND flash external to WROVER it would match that of sd card on SPI. I read about NAND vs NOR, which is fast sequential read/write but slow random read/write for NAND vs fast random read vs slow write. It explains my test speeds that writes to the SPIFFS.

Image

My other option is to source SPI NAND flash with SD controllers so they act exactly like sd cards. It's a preferred option since the speed is higher but I can't find any vendors outside of China and samples are expensive to ship to me. If someone has a part number that can be sourced from within USA, that would be greatly appreciated. My current options are both overseas and these sales people are not the most understanding people.

http://www.xtxtech.com/products_detail/3/ProId-10/

http://www.longsto.com/product/list-39.html

zliudr
Posts: 360
Joined: Thu Oct 03, 2019 5:15 am

Re: Replacing sd card with external SPI NAND for file system

Postby zliudr » Thu Feb 04, 2021 2:38 am

I came across this part of the ESP-IDF doc saying not able to use mmap in the first note:

https://docs.espressif.com/projects/esp ... flash.html

Does this mmap mean memory mapping apis that creates cache for data and instructions described here?

https://docs.espressif.com/projects/esp ... apping-api

The note also mentions only able to use SPI1. Is this the SPI that SD library is using?

ESP_Sprite
Posts: 9746
Joined: Thu Nov 26, 2015 4:08 am

Re: Replacing sd card with external SPI NAND for file system

Postby ESP_Sprite » Thu Feb 04, 2021 3:20 am

Mmap is that you map a bit of flash directly into address space. You effectively get a pointer to it without having to copy (part of) the file into RAM. You can only do that on the primary flash. For external flash, you'll have to use calls like esp_partition_read() to read the data into RAM.

zliudr
Posts: 360
Joined: Thu Oct 03, 2019 5:15 am

Re: Replacing sd card with external SPI NAND for file system

Postby zliudr » Thu Feb 04, 2021 3:59 am

Thanks! I've been reading on the ESP-IDF doc. It seems that I can use maybe SPI2 or HSPI to access external SPI NAND Flash ICs. I only saw one example of SPI flash access, and it calls a convenience function esp_vfs_spiffs_register(). I wonder if there is any example that uses external SPI NAND flash ICs so I can learn how to.

Also, here is a quote:
Due to limitations of the cache, access to external flash is limited to esp_flash_* APIs through SPI1 only.
https://docs.espressif.com/projects/esp ... flash.html

So if I want to hook up another SPI Nand Flash, I end up sharing SPI bus with the SPI Flash inside the wrover module, with all its precautions I have to observe?

https://docs.espressif.com/projects/esp ... n-spi1-bus

So there's no way I can use the SPI SD card's SPI2 (HSPI, correct?) to drive an SPI NAND flash?

Who is online

Users browsing this forum: No registered users and 117 guests