We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi Everyone...........
I m working on a project in that I need USB mass storage implementation for external NAND flash.
I m using LPC2378 uC and I have an example code of USB MSC for LPC2300 that is implemented for internal flash memory of controller. This code is working well on my controller kit.
I do not have much knowledge of MSC. Now I want to use this code for external raw NAND flash.
Could I use this code for my application????
If yes, tehn what and where will I have to modify in the code???
If no, then kindly give me any other solution.........
Thanks in Advance,
Raj
Starting with this example, you can make the device you want. But it isn't so easy.
Learn the stuff you have to modify. I've written about the outline of MSC (Mass-Storage Class) implementation on this post. http://www.keil.com/forum/docs/thread16271.asp 3-Mar-2010 10:52 GMT Tsuneo Chinzei
There are two stages to make it up. 1) Redirect SCSI commands to NAND FLASH access.
Read Capacity(10) - return the last LBA (depending on the capacity of the media - NAND FLASH) Read(10), Write(10) - redirect block (sector) access to the NAND FLASH If you support other optional SCSI commands, you have to modify them all.
2) Wearout management of the NAND FLASH
On file system like FAT, FAT and directory sectors on the media are often changed. To average the erase cycle among sectors, you have to rotate the target sector. Usually, this procedure is implemented using a sector access table, which redirect from logical sector to physical one.
Tsuneo
Hi Tsuneo..
Thax for reply....
I agree that I have to implement 2 stages ie Redirect SCSI commands and Wearout management.
But before implementing these stages, I just want to use this code to read constant data upto 256MB. I want that whenever I connect my device to PC It should show Removeable Disk Drive with capacity of 256MB and consist of one file <File.Txt> having data upto 256MB.
For this I have changed code accordindy: For constant data I took a DataBuffer[512] array which consist of constant 512 bytes. < /* Mass Storage Memory Layout */ #define MSC_MemorySize 1024*256000 #define MSC_BlockSize 512 #define MSC_BlockCount (MSC_MemorySize /MSC_BlockSize) > < BYTE Memory[2048/*MSC_MemorySize*/]; /* MSC Memory in RAM */ >
But I m not know where should I put my DataBuffer[512] array in this code. Could I do this without interfacing NAND flash???? and where will I have to modify in this code???
Kindly do revert with solution..
Thax, Raj
> I just want to use this code to read constant data upto 256MB.
For a read-only drive, you don't need to implement wearout management. But I still recommend you to support SCSI Write(10) and erase sector. And a jumper on the board which enables this write command.
With this configuration, you can make up file system on the drive using OS utility. Also the file is written directly from OS. When finished, plug off the jumper to make it read-only. Otherwise, you have to prepare the file system records and file contents as a HEX data, to burn it over a programmer to the FLASH.
> where will I have to modify in this code???
In addition to above change of #define's on your post,
Memory[] array is a RAM media, which holds entire "disk" space. U8 Memory[MSC_MemorySize]; - mscuser.c
You don't need it any more, because it is replaced by NAND FLASH. At the top of main(), this array is initialized by ROM array DiskImage[] That is, this initialization routine and DiskImage[] are also to be deleted.
int main (void) { U32 n; for (n = 0; n < MSC_ImageSize; n++) { /* Copy Initial Disk Image */ Memory[n] = DiskImage[n]; /* from Flash to RAM */ }
Rewrite these routines so that it accesses to your DataBuffer[] or NAND FLASH MSC_MemoryRead(), MSC_MemoryWrite(), MSC_MemoryVerify() - mscuser.c