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;
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…nr”);
if( rc != FR_OK ) {
// printf(”-E- f_mount pb: 0x%X (%s)nr”, 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.nr”);
// Display the file tree
printf(”-I- Display files contained on the SDcard :nr”);
// FF_ScanDir(STR_ROOT_DIRECTORY);
printf(”-I- Do you want to erase the sdcard to re-format disk ? (y/n)!nr”);
key = ‘y’;
if( (key == ‘y’) || (key == ‘Y’))
{
for(i=0;i<100;i++) {
// MEDSdcard_EraseBlock(&medias, i);
}
printf(”-I- Erase the first 100 blocks complete !nr”);
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…nr”);
}else {
printf(”Open File to write Failure…error = %unr”,rc);
}
printf(”-Open File fil.fs = %dnr”,fil.fs);
printf(”-Open File fil.id = %dnr”,fil.id);
printf(”-Open File fil.dsect = %dnr”,fil.dsect);
printf(”-Open File fil.clust = %dnr”,fil.clust);
printf(”-Open File fil.fsize = %dnr”,fil.fsize);
printf(”nWrite a text data to the Card.nr”);
rc = f_write(&fil, Message, sizeof(Message)-1, &bw); // write file
if (!rc) {
printf(”write success. %u bytes written.nr”, bw);
}else {
printf(”write file Failure…error = %unr”,rc);
}
printf(”nClose the file writeen.nr”);
rc = f_close(&fil); // close file
if (!rc) {
printf(”File writeen closed success.nr”);
}else {
printf(”File close writeen was failure…error = %unr”,rc);
}
//————————
//————————
printf(”nrOpen File to read…nr”);
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 = %dnr”,fil.fs);
printf(”-Open File fil.id = %dnr”,fil.id);
printf(”-Open File fil.dsect = %dnr”,fil.dsect);
printf(”-Open File fil.clust = %dnr”,fil.clust);
printf(”-Open File fil.fsize = %dnr”,fil.fsize);
if (!rc) {
printf(”Open File to read successful…nr”);
}else {
printf(”Open File to read Failure…error = %unr”,rc);
}
printf(”nRead the file content from the Card:nr”);
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(”nr%u bytes read.nr”, numread);
}else {
printf(”read file Failure…error = %unr”,rc);
}
printf(”nClose the file.nr”);
rc = f_close(&fil); // close file
if (!rc) {
printf(”File closed.nr”);
}else {
printf(”File close Failure…error = %unr”,rc);
}
//————————-
//————————
// Directory testing
printf(”nOpen root directory.nr”);
rc = f_opendir(&dir, “”);
if (!rc) {
printf(”Open Dir OK.nr”);
}else {
printf(”Open Dir Failure…error = %unr”,rc);
}
printf(”nDirectory listing…nr”);
for (;;) {
rc = f_readdir(&dir, &fno); /* Read a directory item */
if (rc || !fno.fname) break; /* Error or end of dir */
if (fno.fattrib & AM_DIR)
printf(” %snr”, fno.fname); // is Directory
else
printf(”%8lu %snr”, fno.fsize, fno.fname); // is file
}
if (!rc) {
printf(”Listing Dir complete.nr”);
}else {
printf(”Listing Dir Failure…error = %unr”,rc);
}
printf(”nTest completed.nr”);
f_mount(0, NULL);/* Unregister work area prior to discard it */
// vTaskDelay(1000);
}
}_
Issue While Porting FAT32 Driver on Virtex -4
Issue While Porting FAT32 Driver on Virtex -4
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.