Disk Storage

 

File System Structure

 

The file system of Linux starts from the root '/', which is read-only, located in the 1 MB ROM file system. Under the root, the directories on the device are:

 

/bin

RO

system executable files

/dev

RO

device driver entries

/etc

RO

system settings

/proc

RO

system statistics

/usr

RW

user RAM file

/swap

RW

system temporary RAM file

/var

RW

system temporary RAM file

/tmp

RW

system temporary RAM file

/flash

RW

user disk space on flash (jffs2 file system)

/usb

RW

reserved for mounting USB disk

/sd

RW

reserved for mounting SD card

* RO=Read Only. RW=Read / Write

 

 

Disks

 

The system has several disks with different characteristics can be used as storage.

 

Internal

RAM FS

Volatile

Fast

1 MBRAM files

Internal

JFFS2

Non-volatile

Slow

2.5 / 6.5 MB - NOR Flash

External

VFAT

Non-volatile

Medium

USB disktypical 1 GB32 GB

External

VFAT

Non-volatile

Medium

SD disktypical 1 GB32 GB

 

The internal RAM and JFFS2 disks are mounted automatically when system starts so they can be accessed anytime. On the other hand, external disks (USB, SD) are removealbe disks, must be mounted by users.

 

mount SD card

mount -t vfat /dev/sda1 /sd

umount SD card

umount /sd

mount USB disk

mount -t vfat /dev/sda1 /usb

umount USB disk

umount /usb

 

Both SD card device and USB disk device share the same logical device name /dev/sda1. When you use both devices at the same time, one of them will become /dev/sdb1, that sometimes will cause confusion in applications. Since these devices provide similar capacity, we recommend that users use only one of them, not both.

 

In programs, the system() function can be used to invoke these shell mount and umount commands.

 

 

JFFS2 User Disk

 

The jffs2 NOR flash file system uses 2.5 / 6.5 MB ROM space to construct a very convenient R/W disk. Data can be written to and read from this disk anytime you want, very much like using a hard disk drive. jffs2 is a read/write, compressed, journaling, automatic leveling and hard power-down safe Flash filesystem that is designed to be used on Flash memory devices.

 

The journaling aspect of jffs2 is quite dynamic and works very well on Flash. The jffs2 filesystem is simply a list of nodes or log entries that contain information about a file. Each node may contain data to be inserted into a file or instructions to be deleted from a file. When a jffs2 filesystem is mounted, the entire log is scanned to determine how a file is to be created. Nodes are written to Flash sequentially starting at the first block. If additional writes are needed, blocks are consecutively written to until the end of Flash is reached, then starts at the beginning again.

 

With overhead and fragments, on average, the actual data can be stored is about 80% to 90% of the space it consumed. In consequence, the real storage available for users will be in the range of 2 MB to 2.3 MB, which is adequate for most applications. If larger space is required, you may consider using external SD card or USB disk, whose capacity usually starts from 1000 MB.

 

In the user disk /flash directory, additional directories are defined:

 

/flash/bin

User programs are stored here. The program path has been set to /bin:/flash/bin.

/flash/config

System and user configuration.

'app.ini' is the current working setting.

'app-default.ini' is the system default setting.

/flash/www

Web related HTML, image and CGI program.

 

 

Notes on Writing Data to JFFS2 Disk

 

Indeed, the JFFS2 disk is as powerful as it may be. Keep in mind, however, the FLASH chip has limited erase/write cycles which are usually around 100,000. Moreover, the speed of JFFS2 writing is very slow. Neither DMA, nor block transfer is used. They are written and verified word by word with software driver.

 

The FLASH we used has architecture of 64KB sector size. Even if you write as few as 1 byte data to /flash directory, the file system driver needs to update many sectors, that is, multiple of 64KB data, will probably be erased and rewritten. To the extreme, if you write data into to a file in /flash directory every second, the FLASH chip will be end of its life within a few days.

 

Before having further statistics on reliability, we recommend that the interval between writing data to JFFS2 disk should be at least 10 minutes. DO NOT use it as a RAM disk.

 

 

RAM File System

 

The /usr, /swap, /tmp, and /var directories are RAM FS which share together the 1 MB RAM space. Unlike traditional RAM disks that use fixed amount of RAM, the memories used by RAM FS grow and shrink dynamically. RAM FS is an ideal area of temporary storage, for applications can read/write data from/to these directories at very high speed..

 

Therefore, RAM FS can be used as a companion to JFFS2 disk. Real-time data should first be written to RAM files. Only when data is large enough, or after a predefined interval is expired, then the data is further transferred from RAM files to JFFS2 disk. This scheme can minimize the possibility of excessive writing of Flash chip and degenerating system reliability.