How to use 128k of Flash as a file system on the uCdimm
Thank you very much to
Jakub Trznadel
and Phil Whilshire
for helping me getting this to work.
Basically, what this does is use the uCbootstrap loader routines
which makes use of a special series of system calls into
the bootstrap system. These calls are described in the header file
and the Manual of the uCdimm.
In order for this to work correctly, you must have the correct
header files for your system, namely
- boostd.h
- flash.h
- booterr.h
Flash Layout for the 2MB type on the uCdimm
As described in the uCdimm manual, the Flash layout is as follows:
Address Range | Size hex (dec) | Function |
---|---|---|
0x10C00000 - 0x10C0FFFF | 0x10000 (65536) | Bootloader Flash Image |
0x10C10000 - 0x10DDFFFF | 0x1D0000 (1,900,544 or 185,6k) | OS Flash Image |
0x10DE0000 - 0x10dFFFFF | 0x20000 (131,072 or 128k) | Ext2 Flash Image |
My uCdimm has an Atmel Chip AT49BV1614. Atmel suggests the use of the AT49V160 series for new designs.
Flash Procedure
Make sure that the kernel size does not extend into the Flash area. This means that you sould leave the last 128k of the Flash untouched by the Linux kernel. Usually, the kernel size is safely below 1.9MByte.
Create a ext2 file system image with a size of 128 x 1024 byte blocks (128k or 131.072 bytes) on the host system by doing something like this (this is or could be part of a Makefile):
# Create e2fs.img with a size of 128kByte: cd /home/uwe/src/uclinux/flash dd if=/dev/zero of=e2fs.img bs=1024 count=128 /sbin/mke2fs -F e2fs.img
Alternatively, because 16 inodes are probably too few to call your own on this image, and 6 blocks for the superuser is way too little for you, you might do a:
/sbin/mke2fs -N 64 -m 50 -F e2fs.img
or something similar. Also see man mke2fs for this ;-)
# Test the ext2 image: mkdir -p mnt [sudo] mount -t ext2 e2fs.img mnt -o loop echo "Hello from the file system" > mnt/hello.txt [sudo] umount mnt rmdir mnt
Thanks to Jakob Trznadel and Phil Wilshire,
I could use a little a little
Flash loader program
which I compiled under the user source tree
of the uClinux-dist.
You should make sure
that the include files bootstd.h and flash.h
are correct for your hardware. Mine are from Rt-Control
and I don't think I am allowed to provide those here(?)
Ok, in order to have this image on the target system,
you should do this in a directory which is accessible
via e.g. NFS. In my case, I have /home/uwe/src/uclinux
mounted on /usr on the target system.
On the target system, I do the following to upload
the image into Flash memory and them download
it into ram:
# cd /usr/flash # ./fload u e2fs.img Flashfs emulator, v 0.0.2, Jakub Trznadel / Phil Wilshire -Eras\ng success dev 10c00000 1E0000 1FFFFF Programming success - from 10c00000 1E0000...+20000 # ./fload d /dev/ram1 Flashfs emulator, v 0.0.2, Jakub Trznadel / Phil Wilshire Starting from address 10de0000 [10DE0000] Downloaded sucessfully # mkdir /mnt/ram # mount -t ext2 /dev/ram1 /mnt/ram # cd /mnt/ram # ls -la drwxr-xr-x 3 500 500 1024 Sep 18 2002 . drwxr-xr-x 7 0 0 1024 Nov 30 00:02 .. -rw-r--r-- 1 500 500 27 Sep 18 2002 hello.txt drwxr-xr-x 2 0 0 12288 Sep 18 2002 lost+found # cat hello.txt Hello from the file system #
Ha, it works! Now you can create/write files to /mnt/ram and, when you want to write the file system back to flash, do a:
# fload u /dev/ram1 Flashfs emulator, v 0.0.2, Jakub Trznadel / Phil Wilshire -Eras\ng success dev 10c00000 1E0000 1FFFFF Programming success - from 10c00000 1E0000...+20000
Notes Somehow Pertaining to the Avove, Just for Reference
mkrd: This example script shows how an expandable ramfs could be created:
#!/bin/sh # mkrd - make a ram disk image SIZE=64 BYTESPERINODE=2048 dd if=/dev/zero of=/dev/ram0 bs=1k count=${SIZE} mke2fs -vm0 -O none -i ${BYTESPERINODE} /dev/ram0 ${SIZE} tune2fs -i 0 /dev/ram0 mount /dev/ram0 /mnt rmdir /mnt/lost+found umount /mnt dd if=/dev/ram0 of=ramfs${SIZE} bs=1k count=${SIZE} ./holes ramfs${SIZE} > ramfs${SIZE}.img