BMFS (Bare Metal File System) - Entry #1
I am going to detail the creation of my file system here, and will number each entry as development evolves into something that actually works.
Anvil-6502 has 4MB of fast working SRAM that is used as a frame buffer, media storage, operating system, executable sandbox, and an IDE with assembler. Of course, program code and media such as sounds and graphics must come from someplace, so A65 will need access to a good amount of non-volatile mass storage.
I have decided to support any kind of mass storage available, from a simple 128MB serial Prom right up to multi Gigabyte flash memory. I have also decided to make my own files system for several reasons...
- It will make loading as fast as possible.
- I like to design things.
- Isolation form modern technology.
By isolation form modern technology, I mean that I don't want it to be easy to link A65 to a PC. I am building this 6502 super computer to become my main programming platform, and I intend it to be a fully stand alone unit. Using something like FAT16 on an SD card would make it all too tempting to start cross-platform developing. A65 is coming alive to defy the current sad state of technology, and not to embrace it.
Internally, the path from mass storage to 6502 looks like this...
- An AVR connects directly to the mass storage hardware (whatever it may be).
- The 6502 can make calls to the AVR driver to set addresses and read / write data.
- The FPGA chipset monitors bus access and plays traffic cop.
Currently, I have everything running from an old 2GB SD Card running in SPI mode.
During power on, the AVR just hurls a 4MB binary image to the SRAM.
This image contains the OS, the IDE, Assembler, and a test program with graphics.
There is no addressing or further calling of mass storage at this point.
So now I am going to start on BMFS so that I can read from the mass storage properly.
Here is what I am going to try for BMFS Version One...
BMFS File System Description
Disk Information Block (128 Bytes at Address Zero)
- Disk Name (32 Bytes)
- Block Size (32 Bytes)
- Total Blocks (32 Bytes)
- Free Blocks (32 Bytes)
- Padding (Up to Block End)
TOC Entry (128 Bytes at Next Block Address) x 8191
- File Name (32 Bytes)
- Start Block (32 Bytes)
- Bytes Length (32 Bytes)
- File Info (32 Bytes)
- Padding (Up to Block End)
The File Info segment in the TOC entry will contain flags to set the current status of the file, such as Valid, Erased, Version, Type, etc. there will be 8191 concurrent TOC entries before the start of actual data. I can't imagine a 6502 computer needing more than 8000 file handles!
When writing a new file, the BMFS driver will search all of the TOC entries to find the most suitable space to write the new file (least amount of empty space).
If no such space is found in the current TOC, then a new TOC entry will be made. This will be a crude wear leveling and anti-fragmenting technique.
Since I will probably end up using a multi gigabyte NAND flash as a kind of SSD, the wear leveling and anti-fragmenting offered by simply looking for the "next best fit" will probably work just fine.
Only the first block in the mass storage will not have any wear leveling, but since code is worked on directly in the 4MB SRAM and only saved once and a while, this should not be an issue. With a conservative life cycle rating of 100k writes, this will be a goodly long time.
I also plan to socket the "SSD", so that it can be upgraded or replaced if required.
I may even add a port so that mass storage can be connected externally.
Ok, so that's my file system plan so far.
It almost seems too easy, but that's not a bad thing at all.
Cheers!
Radical Brad
