Forums

Formatting a CompactFlash card and using it.

Started by Anupama July 27, 2004
Hi,
I am trying to write a program in C language to format a Compact Flash
card. I have the CompactFlash Association specification.  I am unable
to figure out how to read and write to the flash card and configure
the various registers to support memory mode. If anybody could give me
some tips or sources of information, it will be very helpful.
With Regards,
Anupama.
>Hi, >I am trying to write a program in C language to format a Compact Flash >card. I have the CompactFlash Association specification. I am unable >to figure out how to read and write to the flash card and configure >the various registers to support memory mode. If anybody could give me >some tips or sources of information, it will be very helpful. >With Regards, >Anupama.
Don't be misslead by the term "memory mapped mode". This does NOT mean that one or more sectors would be mapped into your host cpu's memory for random access. The mode is fairly similar to the normal interfacing in that you must read and write sectors into the RAM of the host cpu modify it there and write it back sector by sector. I found the app notes from Sandisk quite helpfull along with the docs you aparently already have. With regard to formatting - well, there you need to wirte the information to it acording to the filesystem that should reside there. If it's FAT then it's fairly easy, but it still requires that you make yourself comfortable with the FAT filesystem layout. There are several sources about this topic like i.e. http://www.win.tue.nl/~aeb/linux/fs/fat/fat-1.html or http://osdev.berlios.de/osd-fs.html I'm sure there is a ton more information around. Markus
This is a bookmark I have which may be helpful :

Zel electronics on flash disks :

http://www.angelfire.com/de2/zel/
Markus Zingg <m.zingg@nct.ch> wrote in message news:<55kcg054obo5pitane35r0rlhce0hs2r6p@4ax.com>...
> >Hi, > >I am trying to write a program in C language to format a Compact Flash > >card. I have the CompactFlash Association specification. I am unable > >to figure out how to read and write to the flash card and configure > >the various registers to support memory mode. If anybody could give me > >some tips or sources of information, it will be very helpful. > >With Regards, > >Anupama.
You should use ATA mode. All Compact Flash storage cards implement ATA/IDE mode. Some IO cards (ex. ethernet cards) uses memory mode for buffered access.
> > Don't be misslead by the term "memory mapped mode". This does NOT mean > that one or more sectors would be mapped into your host cpu's memory > for random access. The mode is fairly similar to the normal > interfacing in that you must read and write sectors into the RAM of > the host cpu modify it there and write it back sector by sector.
The spec allows paged memory implementations; however, not too many devices are implemented this way.
> > I found the app notes from Sandisk quite helpfull along with the docs > you aparently already have. > > With regard to formatting - well, there you need to wirte the > information to it acording to the filesystem that should reside there. > If it's FAT then it's fairly easy, but it still requires that you make > yourself comfortable with the FAT filesystem layout. There are several > sources about this topic like i.e. > http://www.win.tue.nl/~aeb/linux/fs/fat/fat-1.html > or > http://osdev.berlios.de/osd-fs.html > > I'm sure there is a ton more information around. > > Markus
>The spec allows paged memory implementations; however, not too many devices >are implemented this way.
Err - no, they don't. All they say is that in memory mapped mode, if A10 is high, the device will ignore all other address lines. This allows that the host CPU can use block move operations because the data register is located at address '0'. This IS an advantage over true IDE mode but its definately not compareable to what's otherwise usually understood with memory mapping in general. A CompactFlash card that IS a CompactFlash card MUST implement this behaviour or else it would not be a CompactFlash card. Markus
Markus Zingg <m.zingg@nct.ch> wrote in message news:<mmhdg09nj5kkb41fbu90d636fe8k7teubg@4ax.com>...
> >The spec allows paged memory implementations; however, not too many devices > >are implemented this way. > > Err - no, they don't. All they say is that in memory mapped mode, if > A10 is high, the device will ignore all other address lines. This
This can't be true in general. Some I/O cards (CF ethernet and/or wifi) use all 11 addresses (including A10). It might be a specific implementation.
> allows that the host CPU can use block move operations because the > data register is located at address '0'. This IS an advantage over > true IDE mode but its definately not compareable to what's otherwise > usually understood with memory mapping in general. A CompactFlash card
Sound like you are descripting I/O mode, rather than memory mode.
> that IS a CompactFlash card MUST implement this behaviour or else it > would not be a CompactFlash card. > > Markus