Memory mapping to USB Mass Storage Device (device)

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have a custom PCB with the ATSAME70Q21A microcontroller.

After reading the quick start guide to the USB Mass Storage module, I am uncertain with respect to how the Mass Storage driver maps memory to USB.

If I have external SRAM at a particular address, how do I specify the address where to start the mapping?

 

http://asf.atmel.com/docs/latest...

 

According to the documentation, there is an "automatic link" between the memory and the USB mass storage device.  What does this mean, and how do I specify the starting address?  The documentation seems to be very vague, but this particular function seems to be involved:

 

void task(void) {
   udi_msc_process_trans();
   } 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Don't know the CPU. Don't know how ASF handles this.

 

But in general when a USB devices enumerates as an MSD to an OS like Windows or Linux what they are going to want to do is treat it as a SCSI storage device. So using the USB comms channel the OS will be sending your device SCSI command to first ask it things like what capacity it is and then later request to read/write sector N in 512 byte chunks.

 

If you wanted to "fake" this in RAM (you sure? it is volatile!) then you could break up a larger buffer into 512 byte chunks and send/write each when you get requests to read/write sector N. For the OS to treat it as a "drive" the first sectors passed back are going to need to make it "look" like some well known filing system such as FAT12/FAT16/FAT32 (the "simple" ones!).

 

After the host has asked capacity it will almost certainly then request a read of sector 0. The contents you pass back will need to look like either a Master Boot Record (aka "partition table") or a boot sector/BPB (FAT specific) first sector.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks, clawson.

 

The external SRAM mapping is required since the SRAM is attached to an FPGA and the FPGA places data into SRAM.  The SRAM is then going to be read over USB.

 

The ASF should be able to do some sort of memory mapping.  I am just not certain how the memory mapping is being set up.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi nkinar

I have a problem like yours.I opened usb mass storage device example on Atmel Studio 7 with arduino due board(sam3x8e).OS recognized board as mass storage.I created new text file and save it then i powered off board.when i reconnect ,OS want format.Cause example used virtual memory(RAM,volatile).I want use internal flash.But i didn't find start address.Where is data?  Did you find any solution about this issue?

Thank you  

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm interested as well in using the internal flash fas a MSC. Does anyone have an example code?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

rosenrot wrote:
I'm interested as well in using the internal flash fas a MSC. Does anyone have an example code?
You might want to say what micro it is you are talking about.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry, it is for the SAMD21.

 

I'm interested in making it a MSC using the internal flash or an external serial flash like the one coming with the xplained pro evaluation board.

 

I found examples for it for using a sd card, however I only need small storage and would like to save some costs.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just to warn you then that while this is a forum for ASF/Start it has, curiously, been placed within the AVR set of forums so we don't see too many ARM readers here. You might actually be better off posting this in something like the "Cortex M" forum perhaps?

 

Moderator.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oh, I see. I thought since the topic was similar and the SAMD21 also uses ASF that I would be at the right place. Thanks for letting me know.