CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

create file in mmc using FAT16

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








create file in mmc using FAT16
PostPosted: Wed Aug 17, 2005 8:45 am     Reply with quote

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

I want to create mmc.txt and load "mmc" into the file
When I initialize MMC like this winhex see file properly.windows see,too. but says "can't find the file..."

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



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Wed Aug 17, 2005 1:47 pm     Reply with quote

It's a long time since I worked with this. You have the basic items a duplicate FAT table ( FAT1 and FAT2 and a cluster table to allocate sectors.
Windows will expect a tile fully describing the file attributes and a filesize in bytes. A way to probe into this is to create a file within windows mmcw.txt and compare it with what you have done with mmc.txt and your PIC code using winhex. Windows messages are notoriously non specific so "file not found" might mean there is no file size or the file name tile isn't fully described ( a catch all if something is not quite right). Remember the file name tile thing was a bit of a microsoftee kludge to get compatability between DOS 8.3 names and windows names of longer length.... you'll need to reproduce the tiles as kludgy as the softees expect them to avoid a possible catch all error trap ("file not found").
erhan



Joined: 17 Aug 2005
Posts: 7

View user's profile Send private message

PostPosted: Wed Aug 17, 2005 1:56 pm     Reply with quote

When I create file within windows and compare to pic it is completely same.mbr,rootdirsector,fat1table,fat2table and datasector is same.But still says can't find the file
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Wed Aug 17, 2005 2:27 pm     Reply with quote

Well if it's truly identical then there is no reason or way for windows to detect any difference so perhaps there is something different between your PIC created file and windows
I found these comments I have in my code from a long time ago.
look at byte 11 it is either 00 or 0F if I have this right you have 20 there


Next what are you writing for the filesize it should be zero on a create and incremented as bytes are added to the file? You will need to look at the data area pointed to by the first cluster and compare between the windows created file and the PIC created file.
Also I think Microsoft needs an 0A termination byte in the data area.
They may at times cross check the filesize to the actual bytes in the file by reading up to the 0A.
Code:

// decode the FAT16 entries
// a tile is 32 bytes
// std dos files take one tile
// a long file name has multiple tiles
// starting with the last down to the first and
// then a std dos tile is found
// byte 11 is 0x0f for LNF tiles and 0x00 for std
// we skip the LNF and goto STD tile

sseidman



Joined: 14 Mar 2005
Posts: 159

View user's profile Send private message

PostPosted: Wed Aug 17, 2005 2:59 pm     Reply with quote

http://www.mpic3.com/downloads/ has code written in CCS to read FAT16 off of a CF card. I don't know if it supports writes, but maybe it will help

Scott
Guest








PostPosted: Thu Aug 18, 2005 1:01 am     Reply with quote

there is no MBR after formatted the MMC.first partition boot record starts address 0x00
is this the reason why I can't create file properly
but windows can create Sad
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Thu Aug 18, 2005 5:23 am     Reply with quote

In one post you say
Quote:
When I create file within windows and compare to pic it is completely same.mbr,rootdirsector,fat1table,fat2table and datasector is same.But still says can't find the file

Now you say
Quote:

there is no MBR after formatted the MMC.first partition boot record starts address 0x00
is this the reason why I can't create file properly
but windows can create

The above posts appear inconsistent to me but maybe they're not.

It might be difficult to accept but the most likely source of your issue is probably something you might have done carelessly.
I would double /triple check your assumptions about things being identical.
I have some code in the library section of this forum that opens a file that might be of help to you. I believe this code would error your PIC created file with file not found ( byte 11 counting from zero is 20) as you say windows is doing.
erhan



Joined: 17 Aug 2005
Posts: 7

View user's profile Send private message

PostPosted: Thu Aug 18, 2005 6:35 am     Reply with quote

I create mmc.txt and load "MMC" within windows.

this is file entry at 0x3E000

4D4D43202020202054585420183A777A1233123300008D5C1233020005000000

these are file data at 0x42000
4D4D430D0A000000000000000000000000000000000000000000000000000000

these are in FAT1 at 0x000C00
F8FFFFFFFFFF0000000000000000000000000000000000000000000000000000

these are in FAT2 at 0x01F600
F8FFFFFFFFFF0000000000000000000000000000000000000000000000000000

I am writing to same location and same data.When I write 0x00 to attribute still says can't find.

Sorry I Am wrong about MBR.I wanted to say partition record in my first message
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Thu Aug 18, 2005 8:40 am     Reply with quote

I'd do the following
Under windows
format the MMC
don't create a seperate folder(sub directory) at this stage wait till things are working
create a file MMCW.TXT
add using note pad the payload MMCW to the file.
Check you can read the file with windows

With your PIC code
create a flie MMC.TXT
add a payload of MMC to your file

Read the MMC with windows to see if MMCW.txt and/or MMC.txt show up

If both don't show you probably messed things up big time.
If MMCW.txt shows but MMC.txt doesn't you probably only messed up the PIC create.
Using winhex compare both files....I seem to remember WINHEX uses a relative ( logical) address so the displacements aren't physical but it shouldn't matter as far as comparing goes. The only differences in content ( aprt from that fact that the pointers will reference different locations)should be the extra "W" in the 32 byte filename tile, an extra "W" in the file payload and an extra byte in the filesize count.
You may not have noticed but most people post their code when asking for help....your create file code would be a good place for you to start.
Even PGM programmer, Mark and others who have taught me more than I ever dreamed, still from time to time need to look at actual code.
erhan



Joined: 17 Aug 2005
Posts: 7

View user's profile Send private message

PostPosted: Thu Aug 18, 2005 9:39 am     Reply with quote

I feel terrible.I am sorry Douglas.I wasted your time.I did big mistake.I learned that extension must be capital.I changed 747874 to 545854 and I open the file now.
Thanks for your help...
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group