Reading FAT in 6502; Was: Checking syntax for 1541 and more...

From: Marko Mäkelä (
Date: 2007-08-29 11:27:34

Hi Ruud,

> > Then it wouldn't hurt either to use an existing file system ...
> That is why I asked in a previous email if anyone has experience with
> implemmenting a known FS in a self built suystem.

I'd be interested too.  You know, I still haven't gotten around to
writing that file system image generator for the VIC-20 all-in-one
cartridge (32k RAM and 4MB Flash ROM).  Several years ago, I implemented
in 6502 assembler a simple read-only file system that supports
subdirectories.  I never got around to writing the file system image
generator in C.  Okay, it'd only take a couple of weeks worth of
evenings, but somehow I haven't been motivated enough.

Some time ago, I come across some writings about the C64DTV.  It
contains some file system implementation, but apparently it is not
available under an OSI-approved license.  However, according to
this German forum thread, there is a read-only FAT implementation
for the C-One:

Unfortunately, sourceforget does not appear to be responding right now.

> > However, you'd have to use all 16 bits of the interface instead
> > of just 8 bits.
> You mention something I haven't realised at all. But it is not the size
> of the interface that matters but the size of the sector: 512 bytes
> instead of the 256 bytes I use now. I already found out that (all ???)
> CF cards support 8 bits interfaces ie. I was able to read a XP formatted
> card, all 512 bytes of a sector.

The native sector size of a flash device can be much larger than 512
bytes.  I would suppose that many flash memory cards do some kind of
internal buffering in RAM, so that they can avoid erasing a flash memory
page over and over again.  (Every time a page is erased, the device
wears out a little.)

On a related note, I've been thinking about developing a mobile data logger
that would use memory cards for storage.  It looks like using FAT would
be the most compatible solution.  To avoid wearing out the FAT (file
allocation table) blocks, I'd write to a preallocated file using the
native sector size when possible.  Then the firwmare would only have to
know where the file is stored, and overwrite the data blocks directly.
This is probably not an option for you.  I'm currently waiting until
some good-quality open source code becomes available for devices like
the AT90USBkey.  (The documentation of the AT90USB series is lacking,
and the sample source code has been released under a restrictive license.)

> It is just a matter of giving the right command to the card. I also
> tried to give the same command to some HD's I have but they unfortunately
> don't support this command :(

I'd forget about hard disk media.  Flash devices are already big enough
for storing Commodore files.


       Message was sent through the cbm-hackers mailing list

Archive generated by hypermail pre-2.1.8.