Need example for fat sd card access over MCI module

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

I am searching for an example for fat file access based on USB device MSC example -EVK1104.

I want to create a file on sd card and append data using MCI hardware and possible dma access.

On usb connection the device goes in mass storage mode and the pc can read data on sd card.

I need information about additional modules used in this project and how to configure fat system to access sd card over mci.

Best regards
Michael

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

I think the USB host MSC example for EVK1104 just does this.
avr32\services\usb\_asf_v1\class\mass_storage\examples\conf

-sma

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

yes the host usb example is the base for my system.
but i don't know how to create and write files on sd card using avr32uc3a3 controller.

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

I found the application note AVR114 about the atmel file system!
First step is done mounting device works.
I can't open any file!

Last Edited: Fri. Jan 6, 2012 - 11:41 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
		// Reset all navigators.
        nav_reset();
        // Select the desired drive.
        nav_drive_set(3);
        // Try to mount it.
        if (!nav_partition_mount())
        {

			if ( nav_setcwd((FS_STRING) "logfile.txt", 1, 1) ) 
			{ 
				if ( file_open(FOPEN_MODE_W) ) 
				{ 
					file_write_buf(acMsgbuff, sizeof(acMsgbuff));			
				}
				file_close();
			 }		
			 nav_reset();
			 uiTaskwritten = 1;
		}	
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is there no simple file open example avaliable?
The configuration of hw interface for fat access is done in conf_access ?
I select drive 3 as lun 3 (SD controller)?
My usb mass_storage slave runs so hw configuration is correct for this part of software.

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

I attempted this, and failed. I do think that Atmel's FAT driver works, but I couldn't figure out how to make it work. Instead, I went back to FatFS (http://elm-chan.org/fsw/ff/00ind...) which works great.

A word of warning, if you do try using FatFS, take note that it does not technically support DMA transfers. I wound up creating some of my own functions, that used FatFS to find sectors on the disk, but then my own read functions that used DMA (using ASF MCI drivers). It's sloppy, but it works.

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

My first success with the file system!
After testing 3 framework versions it runs under V2.9!
The nav_drive_set function don't uses lun no. they use a drive index so first drive needs to be index 0! The second pitfall is the filesystem is case sensitive!

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

mbruch wrote:
I found the application note AVR114 about the atmel file system!
First step is done mounting device works.
I can't open any file!

Thanks, pal! Your year old post probably just saved me hours and hours of cursing in frustration! Why they have buried this document like that is beyond me. To me it seems Atmel has some serious issues with their documentation and with exposing it properly. Of course now I remember stumbling upon this PDF some time ago (when I had no need for it).

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

mbruch wrote:
My first success with the file system!
After testing 3 framework versions it runs under V2.9!
The nav_drive_set function don't uses lun no. they use a drive index so first drive needs to be index 0! The second pitfall is the filesystem is case sensitive!

Well, actually, you can use LUN names/IDs but chances are they've added this option later as this post is year old now. Anyway, I'm using LUN_ID_SD_MMC_SPI_MEM as an argument for nav_drive_set() and it gets properly evaluated to 0 in my case. It's actually quite clever, how they done it (all in preprocessor), if you analyze definitions in conf_access.h and ctrl_access.h carefully.