Friday 1 July 2011

Flashy FIGnition!



I'm the designer and developer of the
FIGnition DIY 8-bit computer from nichemachines and I'd like to share a major milestone in its development with you.

FIGnition contains 512KB or 1Mb of raw Amic Flash storage. I've been working for quite a while on making the chips work like a proper disk, like USB memory sticks do and at last it appears to work and this is a momentous achievement!

Making Flash work like a proper disk is hard, because Flash memory is a development of an old technology called EPROM, which could only be written once and then required sitting under a UV light for 20 minutes to re-initialise it all (losing all the previous data). The only difference with Flash is that you can erase it electronically. Using Flash memory is like trying to write a book with an old mechanical typewriter and without tippex, but with a portable recycling unit. Every time you make a mistake on a page or need to change it you need to pick up a new clean page. Moreover, you're not allowed to change the orders of pages so you'd end up with all the page numbers in the wrong order. It's one redeeming feature is that you can take 16 or 32 consecutively edited pages and stick them through the recycling unit to give you new clean pages.

If everyone had to type like that I figure no-one would have ever bothered.

But that's how Flash is. On the (easier-to-use) Amic chips you can write a block of up to 256b at a time ( a page ), but you can't rewrite it; and you can recycle 16 pages at a time.

This FIGnition firmware is therefore so amazing it needs a blog of its own. As far as I know it's the smallest virtual flash disk software around at only 1.5Kb of compiled 'C' code (on an AVR Microcontroller). The firmware abstracts the Flash memory so that you can read and write 512b blocks to your hearts content; it remaps them to physical flash pages on the fly and recycles all the modified pages. The algorithm is so short you could port it to the internal Flash memory of a Microcontroller and use it as a proper disk and could be converted to work with as little as 4 original 28F010 devices (128Kb drive) (or 1 AMD 29F010 device (80Kb drive)).

To give you an idea of how good this is, it's worth comparing with existing uses of Flash chips. Most standard introductions to the embedded use of Flash memory tell you to create the memory image on the host and simply write it to the target. AmForth, for example uses internal Flash memory to store programs, but if you make a mistake you have to erase the lot again: you can't Forget definitions. Butterfly basic (for the MSP430) is similar, you can write and edit over individual lines of code, but once the Flash is all used up (even if there are reclaimable areas of flash) you have to erase the lot. UCLinux (a fairly complex embedded OS) can either use the rather large MTD flash driver or be restricted to the write-once blkmem driver. The original Psion SSDs on both the Organiser II and Psion 3 systems (both far more complex than FIGnition) used sequential, variable-length records and you had to copy the entire SSD to another one when it ran out.

VDsk FIGnition's VDsk flash system is also a bit of a 19 year personal dream. In the early 1990s I was working at a embedded company called Micro control systems where we developed solid-state storage systems using the then brand-new Intel 28F010 Flash memory chips and a bit later, the early PCMCIA flash cards. They were MS-DOS based systems and you could prepare MS-DOS formatted disks in a sort of write-once procedure. I spent quite a bit of time working on a truly general purpose flash disk system, which could have appeared at the same time as the first San-Disk Flash disks. But it was never in the company's commercial interest, so it could never be justified.

Later still, I worked at Teleca.com where we base-ported Symbian OS (Nokia and SonyErricon's Smartphone platform in the early 00's) to new phone hardware. The Flash drivers were good, but formidably complex! Inbetween I toyed with variants of simple Flash filing, either targetted at an old Apple IIc or ficticious embedded systems.

But now it's done - a simple, purging, embedded Flash Disk system which supports wear-levelling and is reasonably robust in the face of sudden power failures. It's been tested for over 60,000 block re-writes (30K on 2 different device types) with no errors. Enjoy.