2017-05-27 10:16 AM
Hi everyone,
Recently i've been looking for information about NAND flash interfacing with STM32 devices. Few App notes after, and some watched tutorias, I actually cannot understand how can i interface with a NAND memory in order to use it as a SD card (controller is supposed to be the STM32 device).
In brief, does anyone knows how to store data into a NAND flash and use FATFs module with USB OTG libs to read it using a computer?. This is to say, employing a STM32 MCU + NAND memory as a USB Stick but saving incoming information from an UART device to NAND memory in order to read it later with a computer.
Thanks for all!
Best regars!
2017-05-27 12:07 PM
For the PC to be able to read you'd need to implement a USB MSC device.
You need to become familiar with how to read, write and erase blocks onto the NAND device, manage things like wear leveling (ie avoid the constant reused of the same spots).
For both FATFS and MSC you have to get your head around deblocking the smaller 512 byte units into the much larger blocks and erase blocks of the NAND device. You can only write to erased blocks, so you have to juggle the existing content of the larger blocks insert the new content. You'd likely want to cache content, and have a lazy-writer, so that you do one erase/commit rather than grind continuously over the sectors within the same block.
I believe this requires some long/hard thinking about the problem, not watching videos.
For a simple data logger the use of a microSD card is far less of a circus.
2017-05-27 06:20 PM
Thanks for your reply Clive One!
Implementing a USB MSC device is very easy due to Cube MX allows to generate the driver and links it with generic functions in order to provide interface between memory unit and USB driver, but the main problem is as you said: being able of understand how a NAND memory works...
Actually i'd implemented a microSD data logger and it works fine... but i'm looking for some 'professional' and soldable into PCB version of it. I thought about use eMMC cards, which theorically may act as SD ones, but i cant ensure the correct welding process for the component into the PCB, so i prefer to use non-bga components.Another option is to use a tSD, but there is very few information about these devices, so it may be discarded...
The last one is NAND memory... but i did not imagined that it could get so hard to implement, cause i read that there is some kind of peripheral (FSMC) which control the memory and i only had to worry about high level application.
Guess that there are NAND drivers which allow to interface with them as a SD card, but i prefer to save PCB area...
Any help will be usefull!
Thanks!2017-05-27 08:06 PM
The SD card uses NAND internally, but uses a micro-controller to hide all the complexity.
The NAND is connected off the external bus of the STM32, that places it within the address space of the processor, but you must access it as a block device, and manage the read, write, erase, along with generating/checking the error-correction data, and applying correction when appropriate.