Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Can't open a file saved on MMC

Status
Not open for further replies.

babybird

Newbie level 6
Joined
Feb 15, 2003
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
146
I am using fat16 system to create file in mmc with pic.
writing file name, attribute,time ,date,size ,first clusterhigh ,firstcluster low ok but when I open the file I cant open.I think something is missing.Please help me

Added after 54 minutes:

I can see the file in windows but when i try to open a message of error i only have. I can't open the file.
With a program like WINHEX i can open the ms and see all the operations work correctly.
My file size 0byte.I want only see the file in windows and open file
 

Re: create file in mmc

I've uploaded a report I did for PIC-MMC interfacing with FAT16 file system several years ago. It would highlight some of the primary issues with FAT16. My guess is that you may have screwed up your FAT.
 

Re: create file in mmc

hi
this is my first partition packet.
I am going 0x3E000 to write file information.

MmcBuffer[0]='M'; //mmc.txt
MmcBuffer[1]='M';
MmcBuffer[2]='C';
MmcBuffer[3]=' ';
MmcBuffer[4]=' ';
MmcBuffer[5]=' ';
MmcBuffer[6]=' ';
MmcBuffer[7]=' ';
MmcBuffer[8]='t';
MmcBuffer[9]='x';
MmcBuffer[10]='t';
MmcBuffer[11]=0x20; //archive
MmcBuffer[12]=0x18;
MmcBuffer[13]=0x38;
MmcBuffer[14]=0x59;
MmcBuffer[15]=0x66;
MmcBuffer[16]=0x0C;
MmcBuffer[17]=0x33;
MmcBuffer[18]=0x0C;
MmcBuffer[19]=0x33;
MmcBuffer[20]=0x00;
MmcBuffer[21]=0x00;
MmcBuffer[22]=0x59;
MmcBuffer[23]=0x66;
MmcBuffer[24]=0x0C;
MmcBuffer[25]=0x33;
MmcBuffer[26]=0x00;
MmcBuffer[27]=0x00;
MmcBuffer[28]=0x00;
MmcBuffer[29]=0x00;
MmcBuffer[30]=0x00;
MmcBuffer[31]=0x00;
for(i=32;i<512;i++) MmcBuffer=0x00;

MmcWriteSector(FirstRootDirSecNum,MmcBuffer);

and I can create file but when I want open the file windows says can't find the file mmc.txt.
 

Re: create file in mmc

babybird said:
hi
this is my first partition packet.
I am going 0x3E000 to write file information.

MmcBuffer[0]='M'; //mmc.txt
MmcBuffer[1]='M';
MmcBuffer[2]='C';
MmcBuffer[3]=' ';
MmcBuffer[4]=' ';
MmcBuffer[5]=' ';
MmcBuffer[6]=' ';
MmcBuffer[7]=' ';
MmcBuffer[8]='t';
MmcBuffer[9]='x';
MmcBuffer[10]='t';
MmcBuffer[11]=0x20; //archive
MmcBuffer[12]=0x18;
MmcBuffer[13]=0x38;
MmcBuffer[14]=0x59;
MmcBuffer[15]=0x66;
MmcBuffer[16]=0x0C;
MmcBuffer[17]=0x33;
MmcBuffer[18]=0x0C;
MmcBuffer[19]=0x33;
MmcBuffer[20]=0x00;
MmcBuffer[21]=0x00;
MmcBuffer[22]=0x59;
MmcBuffer[23]=0x66;
MmcBuffer[24]=0x0C;
MmcBuffer[25]=0x33;
MmcBuffer[26]=0x00;
MmcBuffer[27]=0x00;
MmcBuffer[28]=0x00;
MmcBuffer[29]=0x00;
MmcBuffer[30]=0x00;
MmcBuffer[31]=0x00;
for(i=32;i<512;i++) MmcBuffer=0x00;

MmcWriteSector(FirstRootDirSecNum,MmcBuffer);

and I can create file but when I want open the file windows says can't find the file mmc.txt.

This is the file entry. A quick glance shows that file size is zero. LO cluster is zero. HI cluster (which is supposed to be zero for fat12/16) is also zero. And is the first data stored in cluster zero? I don't really remember the exact specifications, but if you read what I've attached, I specifically stated that the first 2 clusters are reserved, so it should be.

If you are still not clear, go download the fat specifications.
**broken link removed**
 

Re: create file in mmc

if I wrote data to file first cluster is 2 .you are wright.but I did't write data .my file size is 0byte. so cluster lo (MmcBuffer[26],MmcBuffer[27])
and cluster hi is 0x00 (MmcBuffer[20],MmcBuffer[21])
I read documents but they didn't help me.

could you sen me your piece of code that creating file ?
 

Re: create file in mmc

As I mentioned, the first 2 clusters are RESERVED. You can't use them, even if you have a file with no data. Although I'm not too sure if the FAT entry for that cluster should be 0x0 or 0xFFFF. (I got a hunch it should be 0x0, but dont quote me for this.)

I no longer have my code, so I can't give it to you.
 

Re: create file in mmc

I tried using 2.cluster for cluster lo.but still windows can't find the file .
I upload file using cardwriter with windows and I see fat entry is 0xFFFF when file size bigger then 0kbyte.if file size is 0 kbyte there is no fat entry.
 

Re: create file in mmc

If that's the case, the problem may be in the other fields. Seriously, I haven't checked that every single field is valid. Why not you compare them with the specifications again. The microsoft link I gave is the most comprehensive specifications on FAT that I have found.

On the other hand, why not try out with a non-empty file. Does it work?
 

Re: create file in mmc

:D
I tried non empty file too.
I wrote file entry to root directory, data to first data sector,0xFFFF to fat1 and fat2 table.
winhex see file properly.windows see but says "can't find"...
 

Re: create file in mmc

To create a file > 0 bytes you must
find an un-used cluster
find an un-used directory entry
create a new directory entry
write to the cluster, if more than one cluster in size, find another un-used cluster, and update fat.
close the file with right file size & update fat with an end of cluster chain.

It seems that you are only creating a new directory entry. It is also hard wired to the first directory entry.
 

Re: create file in mmc

How can I calculate the address of first directory entry?
I know only Root directory entry and I did not see first directory entry in documents
 

Re: create file in mmc

babybird said:
How can I calculate the address of first directory entry?
There are 32 bytes per directory entry.
The root dir for fat 16 is a range of sectors, starting from the end of the last FAT and has room for BPB_RootEntCnt dir entries.
The start of first FAT sector is the sector where the partion begins + BPB_RsvdSecCnt and one FAT has room for BPB_FATSz16 and there are BPB_NumFATs number of FATs
so
The root dir begin sector = where the partion begins + BPB_RsvdSecCnt + (BPB_FATSz16 * BPB_NumFATs)
The byte offset from the root dir begin sector for a particular dir entry can be calculated by mpy by 32.
All this and more is all in the microsoft white paper
 

Re: create file in mmc

BootSector=0
FirstSectorLba=00000000
BPB_BytsPerSec=0200h
BPB_SecPerClus=04h
BPB_RsvdSecCnt=0006h
BPB_NumFats=02h
BPB_RootEntCnt=0200h
BPB_TotSec16=0000h
BPB_Media=f8h
BPB_FATSz16=00f5h
BPB_TotSec32=0003d400h
BPB_FATSz32=c4290000h
Fat1Lba=00000006h
RootDirSectors=00000020h
FirstRootDirSecNum=000001f0
FirstDataSector=00000210
CountOfClusters=0000f47c
Volume is Fat16
************************************
FILE ENTRY AT 0x000001F0
4D4D43202020202074787420184D6C580F330F3300006A580F33020003000000
FIRST DATA SECTOR AT 0x00000210
4D4D430000000000000000000000000000000000000000000000000000000000
FAT1 AT 0x00000006
F8FFFFFFFFFF0000000000000000000000000000000000000000000000000000
FAT2 AT 0x000000FB
F8FFFFFFFFFF0000000000000000000000000000000000000000000000000000
MMC initialized

My mmc partition entry is like this.
root dir begin sector =0x000001F0
and fat table begins 0x00000006

what is wrong here?.What will I do other than these.
 

Re: create file in mmc

Ok I solved the problem.Extension must be capital.Now I open the file...
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top