5 Flash Partitioning
Linux Software Developers Kit (SDK) User Guide
39
Otherwise issue:
dBUG> set kcl noinitrd rw rootfstype=jffs2 root=/dev/mtdblock5
And run the freshly installed new ROMFS with
dBUG> gfl
ROMFS root + JFFS2 + AUFS
This variation is created when you use the AUFS profile. The instruction to get the resulting files
on the flash are identical to the ones described in the “ ROMFS root + blank JFFS2”
section.
One area where this feature might be very handy is configuration files. Just think of storing a
static ip address for the device. Since the end user should be able to assign a static IP to the
device, it needs to be stored on persistent storage. The problem is that /etc resides on a read-
only file system. There are 3 possible solutions to this approach:
Put /etc on a writeable file system - this was the approach taken in the previous section.
Create a symbolic link for /etc/netcfg to a different file system that is write-enabled - that
approach is used by the ROMFS + JFFS2 file system layouts.
Use a stackable file system like AUFS
Let's look into the last solution.
Here we create /etc on our ROMFS partition. But we overlay /etc with a write-enabled JFFS2
partition. That means that Linux can use the files from ROMFS unless there is a version of the
same file stored in the corresponding directory on the JFFS2 partition. For applications it looks
like /etc is a regular write-enabled file system. But the big difference to the JFFS2 only solution
we discussed in a previous section is that we always have a known good configuration in ROMFS
to which can reverted to if something goes wrong with the JFFS2 partition. By omitting the overlay
mount and since configuration and applications are cleanly separated, a firmware update is now
possible.
Let's assume we have mounted our JFFS2 partition under /usr/local.
mkdir /etc.romfs
mount -o rebind /etc /etc.romfs
This allows access to the files that are really on the ROMFS partition in /etc via /etc.romfs.
[ -d /usr/local/etc ] || mkdir /usr/local/etc
mount -t aufs -o br:/usr/local/etc:/etc.romfs none /etc
From now on all changes made to files in /etc are actually written to /usr/local/etc.
This is exactly how the aufs profile is implemented. It can be found in <install-dir>/linux/linux-
2.6.x/drivers/mtd/maps/m520x.c
This approach could be easily extended to overlap /bin for example. The ROMFS partition could
include all absolutely essential software and additional applications could be stored in a separate
partition. Even more layers are thinkable (JFFS2 on top of CRAMFS on top of ROMFS)
Custom Layout
It is possible to customize the flash layout by writing the image files to the desired addresses, and
modifying the kernel command line options appropriately. But the recommended approach is to
adjust <install-dir>/linux/linux-2.6.x/drivers/mtd/maps/m520x.c and recompile the kernel.