USB msd not sticking

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

USB msd not sticking

268 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by beto on Mon Jun 06 21:12:17 MST 2011
re:  usb msd example on a LPC1343.

When I drag a bin file to the drive does it go to ram or flash. My bin file does not seem stick after a reboot, the txt file reappears.  :mad:
0 Kudos
4 Replies

259 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Mon Jun 13 23:50:36 MST 2011
Thank you Gbm,

you just hit Beto with a stick into a corner of which he apparently does not return anymore.
Thanks! This is the best way to make sure that there will be not too many newby questions on this forum. Very professional attitude

I just read Beto's question and I think it is pretty clear:


Quote:

[B][COLOR=Red]usb msd example[/COLOR][/B] on a LPC1343.

When I drag a bin file to the drive does it go to ram or flash.

Which sample project? Dear Gbm, please read the first sentence: [B]USB MSD example[/B] for the lpc1343. In my version of the example projects this is called usbmsd.
Or, to almost quote your (Gbm's) own words: The questions are generally written for the people who want to read and understand English. If this isn't your goal, or you do not want to help out a new LPCXpresso programmer you don't need to reply at all. (Yes, I can be professional too :D)

But now all flaming aside and back to the question ...

There is indeed not too much information given with the example projects, you have to read through the source code to discover what this does.
The USB source code is split over a number of logically names C files. Logical ... if you know how the USB code is written and what it does.

The files named usb...c contain the core USB stack, files with msc...c add the mass storage class and the other two files (DiskImg.c and memory.c) contain the user code.

DiskImg contains just the file system with the .txt file, the user program can be found in memory.c.
If you read through that file you will find the following:
int main (void) {
  uint32_t n;

  for (n = 0; n < MSC_ImageSize; n++) {     /* Copy Initial Disk Image */
    Memory[n] = DiskImage[n];               /*   from Flash to RAM     */
  }
That should answer your question: the initial disk image is copied from flash to RAM.
Looking further in mscuser.c you will find the following function:

void MSC_MemoryWrite (void) {
  uint32_t n;

  if ((Offset + BulkLen) > MSC_MemorySize) {
    BulkLen = MSC_MemorySize - Offset;
    BulkStage = MSC_BS_CSW;
    MSC_SetStallEP(MSC_EP_OUT);
  }

[COLOR=Red][B]  for (n = 0; n < BulkLen; n++) {
    Memory[Offset + n] = BulkBuf[n];
  }
[/B][/COLOR]
  Offset += BulkLen;
  Length -= BulkLen;

  CSW.dDataResidue -= BulkLen;

  if ((Length == 0) || (BulkStage == MSC_BS_CSW)) {
    CSW.bStatus = CSW_CMD_PASSED;
    MSC_SetCSW();
  }
}
And all at the top of that file you will find the definition for Memory[] which is an array of uint8_t in RAM.

Regards,

Rob
0 Kudos

259 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gbm on Tue Jun 07 11:01:05 MST 2011
First, you didn't write anything about WHICH sample project you are trying to use. Second, there should be a C source file implementing block device interface for MSD - check the name of the file - maybe it contains the information you are looking for. If not - have a look inside.
0 Kudos

259 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by beto on Tue Jun 07 09:13:01 MST 2011
So...are you telling me that everybody who uses the usb code understands the details of it....and everyone that uses the free rtos understands that also....you must be quite the expert....

Anyone know where I can ask questions on LPCexpresso sample code:mad:
0 Kudos

259 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gbm on Mon Jun 06 21:58:59 MST 2011
The examples are generally written for the people who want to read and understand the sample code. If this isn't your goal, you don't need to touch them at all.
0 Kudos