USBMSD with Nand Flash K9F2G08U0M + Fat file system

28 Aug 2012

Hi all

I want to do USBMSD with Nand Flash K9F2G08U0M + Fat file system(It's really complicated for me)

Does anyone give me some intruction for my project?

Is there any library or program associating with my project?

Thanks much

28 Aug 2012

Hi,

USBMSD calls functions which have to be defined by a user to access the storage chip (in your case the nand flash). So the first thing to do is to provide the following functions:

virtual int disk_read(char * data, int block): function to read a block
virtual int disk_write(const char * data, int block): function to write a block
virtual int disk_initialize(): function to initialize the memory
virtual int disk_sectors(): return the number of blocks
virtual int disk_size(): return the memory size
virtual int disk_status(): return the status of the storage chip (0: OK, 1: not initialized, 2: no medium in the drive, 4: write protection)

Once these functions implemented, you should be able to use USBMSD + Nand flash. But exactly the same functions has to be defined to have FatFileSystem running. So you can imagine having a NandK9F2G08U0M C++ class which implements all the previous functions and inherits from USBMSD and FatFileSystem to achieve what you want.

You can find the implementation of these functions for an sd card here.

To summarize, the first thing to do is to provide all the necessary functions to access your storage chip.

Sam

28 Aug 2012

Thanks Sam

In this moment I accessed my storage chip(K9F2G08U0M) but just writing byte, reading byte or erase block nomarlly and simply from my storage chip. So that, I have to write my function again complying all function you refer to. I understood it. Thanks you

ttnghiabk

04 Sep 2012

Hi,

There're something wrong with my Flash(K9F2G08U0M)

I must erase my Flash before writing data to it and I can not erase my flash each sector or page, I just erase it each block but one block of my nand flash occupies (128K + 4K) bytes, and one block(or sector) in FATFS occupies 512bytes /media/uploads/ttnghiabk/k9f2g08u0m.png

so that, I have a big trouble when I write the disk_write function, I can not erase 128K and just change 512 byte of it, it takes me so much time

I misinterpreted something, didn't I?

Can you recommand me some advice to overcome my problem?