Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

Issue While Porting FAT32 Driver on Virtex -4

Posted by Anurag on May 11, 2012
Dear Sir

I am getting issue While POrting FAT32 Driver using SDCard on Virtex-4 Code.is compile.At a run time i getting issue of File Write to SDCard.I am using Follwing code

Error:- Its shows NoValied FAT32 File System on SDCard..So please guide for fixed this issue

:-E- SendCmd18,0 (1)
Open File to write Failure...error = 13
-Open File fil.fs = 0
-Open File fil.id = 0
-Open File fil.dsect = 0
-Open File fil.clust = 0
-Open File fil.fsize = 0

Write a text data to the Card.
write file Failure...error = 9

Close the file writeen.
Open File to write...


void prvTaskD (void* pvParameters)
{

SPI_Int();

(void) pvParameters; // Just to stop compiler warnings.

for (;;) {
static FRESULT rc; /* Result code */
static FATFS fatfs; /* File system object */
static FIL fil; /* File object */
static DIR dir; /* Directory object */
static FILINFO fno; /* File information object */
int i ;
char key ;

static UINT bw, br, numread;
static BYTE buff[64];
BYTE Message[] = "HELLO from www.letrungthang.blogspot.com" ; // message's content
TCHAR *FilePath = "MESSAGE.TXT" ; // file path

f_mount(0, &fatfs); /* Register volume work area (never fails) */

// File testing
printf("Open File to write...\n\r");

if( rc != FR_OK ) {
// printf("-E- f_mount pb: 0x%X (%s)\n\r", rc);
return 0;
}

// Test if the disk is formated
rc = f_opendir (&dir,STR_ROOT_DIRECTORY);
if(rc == FR_OK ){

// erase sdcard to re-format it ?
printf("-I- The disk is already formated.\n\r");

// Display the file tree
printf("-I- Display files contained on the SDcard :\n\r");
// FF_ScanDir(STR_ROOT_DIRECTORY);

printf("-I- Do you want to erase the sdcard to re-format disk ? (y/n)!\n\r");

key = 'y';
if( (key == 'y') || (key == 'Y'))
{
for(i=0;i<100;i++) {
// MEDSdcard_EraseBlock(&medias[ID_DRV], i);
}
printf("-I- Erase the first 100 blocks complete !\n\r");
rc = FR_NO_FILESYSTEM;
}
}


//------------------------------------
//------------------------------------
rc = f_open(&fil, FilePath, FA_WRITE | FA_OPEN_ALWAYS); /* Create a file on the drive 0 */
if(rc) rc = f_open(&fil, FilePath, FA_WRITE | FA_OPEN_ALWAYS);// try again once

if (!rc) {
printf("Open File to write successful...\n\r");
}else {
printf("Open File to write Failure...error = %u\n\r",rc);
}
printf("-Open File fil.fs = %d\n\r",fil.fs);
printf("-Open File fil.id = %d\n\r",fil.id);
printf("-Open File fil.dsect = %d\n\r",fil.dsect);
printf("-Open File fil.clust = %d\n\r",fil.clust);
printf("-Open File fil.fsize = %d\n\r",fil.fsize);

printf("\nWrite a text data to the Card.\n\r");

rc = f_write(&fil, Message, sizeof(Message)-1, &bw); // write file

if (!rc) {
printf("write success. %u bytes written.\n\r", bw);
}else {
printf("write file Failure...error = %u\n\r",rc);
}


printf("\nClose the file writeen.\n\r");
rc = f_close(&fil); // close file

if (!rc) {
printf("File writeen closed success.\n\r");
}else {
printf("File close writeen was failure...error = %u\n\r",rc);
}

//------------------------------------
//------------------------------------
printf("\n\rOpen File to read...\n\r");
rc = f_open(&fil, FilePath, FA_READ | FA_OPEN_EXISTING); /* Create a file on the drive 0 */
if(rc) rc = f_open(&fil, FilePath, FA_READ | FA_OPEN_EXISTING);// try again once

printf("-Open File fil.fs = %d\n\r",fil.fs);
printf("-Open File fil.id = %d\n\r",fil.id);
printf("-Open File fil.dsect = %d\n\r",fil.dsect);
printf("-Open File fil.clust = %d\n\r",fil.clust);
printf("-Open File fil.fsize = %d\n\r",fil.fsize);

if (!rc) {
printf("Open File to read successful...\n\r");
}else {
printf("Open File to read Failure...error = %u\n\r",rc);
}

printf("\nRead the file content from the Card:\n\r");
for (;;) {
rc = f_read(&fil, buff, sizeof(buff), &br); /* Read a chunk of file */
if (rc || !br) break; /* Error or end of file */

// for (int i = 0; i < br; i++) /* Type the data */
// putchar(buff);

numread += br ;
}

if (!rc) {
printf("\n\r%u bytes read.\n\r", numread);
}else {
printf("read file Failure...error = %u\n\r",rc);
}

printf("\nClose the file.\n\r");
rc = f_close(&fil); // close file

if (!rc) {
printf("File closed.\n\r");
}else {
printf("File close Failure...error = %u\n\r",rc);
}
//--------------------------------------
//------------------------------------
// Directory testing
printf("\nOpen root directory.\n\r");
rc = f_opendir(&dir, "");

if (!rc) {
printf("Open Dir OK.\n\r");
}else {
printf("Open Dir Failure...error = %u\n\r",rc);
}

printf("\nDirectory listing...\n\r");
for (;;) {
rc = f_readdir(&dir, &fno); /* Read a directory item */
if (rc || !fno.fname[0]) break; /* Error or end of dir */

if (fno.fattrib & AM_DIR)
printf(" [dir] %s\n\r", fno.fname); // is Directory
else
printf("%8lu %s\n\r", fno.fsize, fno.fname); // is file
}

if (!rc) {
printf("Listing Dir complete.\n\r");
}else {
printf("Listing Dir Failure...error = %u\n\r",rc);
}

printf("\nTest completed.\n\r");
f_mount(0, NULL);/* Unregister work area prior to discard it */

// vTaskDelay(1000);

}
}

RE: Issue While Porting FAT32 Driver on Virtex -4

Posted by Richard on May 11, 2012
Absolutely no idea. This is not FreeRTOS code, a system I have never used, and has nothing to do with FreeRTOS as far as I can see. Sorry, but I can't help. Where did you get the file system from? I would recommend asking your questions there.

Regards.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists