Embedded Systems Firmware Demystified

At this point, the monitor design has enough features to complete a basic shell around the hardware. I have the boot-up, serial port, and flash drivers and a solid command-line interface. The next few chapters put icing on the cake. In this chaper, I will start work on a flash file system, called Tiny File System (TFS). Flash file systems in embedded systems are still a bit sparse, but as we see more and more use of higher-density flash parts and removable flash media, we will surely see more and more appearances of flash file systems. A flash file system is usually considered a frivolous luxury; hence, programmers must often interface their application to the flash device using some home grown set of primitives. A flash file system certainly makes the embedded system easier to manage, but writing one from scratch is likely to be more complicated than you first expected.
This chapter presents a mechanism that allows the programmer to treat the memory space allocated to flash as namespace instead of address space. TFS solves some of the basic problems of interfacing to flash. For instance, TFS provides an API that is independent of the underlying flash device yet does not inhibit the program from directly accessing the raw memory if necessary. TFS offers an efficient alternative for applications that need a flash file system but don t require a sophisticated implementation with wear-leveling, directory hierarchy, and DOS-file-format compatibility. TFS provides an API accessible to both MicroMonitor and the application...