All Forums
 Embedded Linux
 Linux FAQ
 Using the onboard flash memory
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Author Topic  

jlackey

213 Posts

Posted - 17 May 2002 :  15:18:59  Show Profile  Email Poster
The default number of On-Board Flash partitions depends on the location of the bootloader. Boards with a separate bootloader ROM chip are divided into 3 partitions and boards with the bootloader in On-Board Flash memory have 4.

    All recent boards including the Bitsies, AGC, and AGX
    The Bitsy, Bitsy Plus, BitsyX, AGC, and AGX have flash upgradable bootloaders. Therefore, the first partition on these boards is the bootloader. The second partition holds the kernel zImage. A compressed ramdisk (ramdisk.gz) is usually stored in the third partition.

    GraphicsClient Plus & GraphicsMaster
    The GraphicsClient Plus and GraphicsMaster have separate bootloader ROMs so no partition is required for the bootloader on these boards. The kernel zImage is stored in the first partition and a ramdisk.gz is usually in the second.

Note that for releases prior to 2.4.19_rmk7_pxa2_adsx4, the default mtd partitions included an initial partition that covered the whole flash. This was rarely if ever used and caused confusion and has been removed starting with this release. The BitsyX and the AGX and subsequent boards use this partitioning scheme - earlier boards and releases still retain this initial partition.

Also note that the instructions provided below are for adding a flash file system in addition to a ramdisk root file system. Consult the Linux Bootloader Manual (Ver 4.0 or later) for information regarding using a flash file system as the root file system and for elimination of the ramdisk partition.

To program the On-Board Flash partitions, copy the zImage and ramdisk.gz files to an ATA flash card and follow the instructions in the Linux Bootloader Manual for your board. To change the size or number of partitions, you must have Ver 4.0 or later of the ADS Linux Bootloader. Again, consult your manual for instructions on how to do this.

The last partition is typically used for a flash file system. Before writing to the on board flash, this partition must be erased with the 'erase' command.

On the BitsyX and the AGX, the command is:
    erase /dev/mtdc6

on the Bitsy, Bitsy Plus and AGC, the command is:
    erase /dev/mtdc8

and on the GraphicsClient Plus and GraphicsMaster, it is:
    erase /dev/mtdc6


JFFS2

JFFS2 (journalling flash file system, version 2) is a compressed file system designed for use on flash memory. It is a load leveling file system that avoids burning out some sections of flash before others when writing to flash memory but does not compress as well as cramfs.

Note: Version 2 is not available in 2.4.1 kernels. If you are using a 2.4.1 kernel and need a flash file system, you can use jffs (version 1) but you should consider upgrading your kernel.

To put a jffs2 file system on the flash, follow these instructions:

1. Boot your board and login as root. Enter the commands:
    BitsyX & AGX
    mkdir /flash
    erase /dev/mtdc6
    mount -t jffs2 /dev/mtdb3 /flash
    ls /flash
    echo "test the flash file system" > /flash/test.txt
    ls /flash

    Bitsy, Bitsy Plus, & AGC
    mkdir /flash
    erase /dev/mtdc8
    mount -t jffs2 /dev/mtdb4 /flash
    ls /flash
    echo "test the flash file system" > /flash/test.txt
    ls /flash

    GraphicsClient Plus & GraphicsMaster
    mkdir /flash
    erase /dev/mtdc6
    mount -t jffs2 /dev/mtdb3 /flash
    ls /flash
    echo "test the flash file system" > /flash/test.txt
    ls /flash

The /flash directory will be empty when you list it the first time and will have 'test.txt' in it when you list it the second time. The 'echo' command may take a while to complete - subsequent writes should be faster.

2. If you want to avoid manually entering the mount command each time you boot, you must update your ramdisk. Follow the instructions in Making permanent changes to the ramdisk and make these changes:

Create a mount point for the filesystem (if it doesn't exist already
    mkdir /flash

edit etc/inittab and include one of the following lines to mount the file system
    BitsyX & AGX
    mt:23:once:/bin/mount -t jffs2 /dev/mtdb3 /flash

    Bitsy, Bitsy Plus, & AGC
    mt:23:once:/bin/mount -t jffs2 /dev/mtdb4 /flash

    GraphicsClient Plus & GraphicsMaster
    mt:23:once:/bin/mount -t jffs2 /dev/mtdb3 /flash

3. If you are using an ATA flash card to update your ramdisk image, make sure there is no flashfs1 file on the card:
    mount -t vfat /dev/hde1 /mnt/flash1
    rm /mnt/flash1/flashfs1
    cp ramdisk.gz /mnt/flash1
    umount /mnt/flash1

4. Insert the card in your board and follow the instructions in the Boot ROM Manual for programming the on board flash from an ATA flash card. Reset the board and wait for ramdisk.gz to be copied to the on board flash. (Connect a terminal to see when it's done.)

5. Turn the board power off, remove the card, and configure your board for normal operation. Restore the power and the system will boot and mount the file system automatically.

6. To 'populate' the flash file system, you can:
    A. Use tar to create an archive file on the flash ATA card. Mount the card on your board and use tar to put the archived files into /flash.

    B. Use ftp to move the files over the network to /flash.

    C. Create a jffs2 file containing the stuff in 'dir' and copy it to an ATA flash card:
      mkfs.jffs2 -e 0x40000 -p -r dir > file
      cp file /mnt/flash1/flashfs1

      Note: that the 0x40000 is the 256k (2 chips * 128k block size) for the intel 28f640 chips.


    Insert the card in your board and follow the instructions in the Linux Bootloader Manual for programming the on board flash from an ATA flash card. Reset the board and wait for flashfs1 image to be copied to the on board flash. (Connect a terminal to see when it's done.)

    Turn the board power off, remove the card, and configure your board for normal operation. Restore the power and the /flash directory will have the files in dir.

CRAMFS

The cramfs file system is a compressed read only file system. Follow these instructions to put a cramfs file system on the flash:

1. Create a directory that includes everything you want to have in the filesystem. This directory is exactly the directory structure that you will mount on the board and can include subdirectories. Lets call that directory 'foo' (it can have any name).

2. Create the file system on your development system with the command:
    mkcramfs foo foo_fs_image

This creates a file 'foo_fs_image' that is an image of the file system
and contains all of the files and subdirectories in 'foo'.

3. Put this file on a flash ATA card in the file flashfs1:
    mkdir /mnt/flash1
    mount -t vfat /dev/hde1 /mnt/flash1
    cp foo_fs_image /mnt/flash1/flashfs1
    umount /mnt/flash1

    Note: If you want to only rewrite the flash file system, then be sure to remove files named ramdisk.gz and zImage from the top level directory of the flash ATA card.

4. Insert the card in your board and follow the instructions in the Boot ROM Manual for programming the on board flash from an ATA flash card. Reset the board and wait for flashfs1 image to be copied to the on board flash. (Connect a terminal to see when it's done.)

5. Turn the board power off, remove the card, and configure your board for normal operation. Restore the power and the system will boot and mount the file system automatically.

6. Login as root and enter the commands:
    BitsyX & AGX
    mkdir /flash
    mount /dev/mtdb3 /flash
    ls /flash

    Bitsy, Bitsy Plus, & AGC
    mkdir /flash
    mount /dev/mtdb4 /flash
    ls /flash

    GraphicsClient Plus & GraphicsMaster
    mkdir /flash
    mount /dev/mtdb3 /flash
    ls /flash

You should see the files you want in the /flash directory.

7. To avoid manually entering the mount command each time you boot, update your ramdisk. Follow the instructions in Making permanent changes to the ramdisk and make these changes:

Create a mount point for the filesystem (if it doesn't exist already)
    mkdir /mnt/loop/flash

edit etc/inittab and include one of the following lines to mount the file system
    BitsyX & AGX
    mt:23:once:/bin/mount -t cramfs /dev/mtdb3 /flash

    Bitsy, Bitsy Plus, & AGC
    mt:23:once:/bin/mount -t cramfs /dev/mtdb4 /flash

    GraphicsClient Plus & GraphicsMaster
    mt:23:once:/bin/mount -t cramfs /dev/mtdb3 /flash

8. If you are using an ATA flash card to update your ramdisk, make sure there is no flashfs1 file on the card:
    mount -t vfat /dev/hde1 /mnt/flash1
    rm /mnt/flash1/flashfs1
    cp ramdisk.gz /mnt/flash1
    umount /mnt/flash1

9. Insert the card in your board and follow the instructions in the Linux Bootloader Manual for programming the on board flash from an ATA flash card. Reset the board and wait for ramdisk.gz to be copied to the on board flash. (Connect a terminal to see when it's done.)

10. Turn the board power off, remove the card, and configure your board for normal operation. Restore the power and the system will boot and mount the file system automatically.

How do I backup my flash file system to a file?

First unmount the file system:
    umount /flash

Then issue one of these commands:
    BitsyX & AGX
    gzip -c < /dev/mtdc6 > /mnt/flash.gz

    Bitsy, Bitsy Plus, & AGC
    gzip -c < /dev/mtdc8 > /mnt/flash.gz

    GraphicsClient Plus & GraphicsMaster
    gzip -c < /dev/mtdc6 > /mnt/flash.gz

To restore it, again unmount the file system:
    umount /flash

Then issue one of these sets of commands:
    BitsyX & AGX
    erase /dev/mtdc6
    gunzip -c < /mnt/flash.gz > /dev/mtdc6
    mount -t jffs2 /dev/mtdb3 /flash

    Bitsy, Bitsy Plus, & AGC
    erase /dev/mtdc8
    gunzip -c < /mnt/flash.gz > /dev/mtdc8
    mount -t jffs2 /dev/mtdb4 /flash

    GraphicsClient Plus & GraphicsMaster
    erase /dev/mtdc6
    gunzip -c < /mnt/flash.gz > /dev/mtdc6
    mount -t jffs2 /dev/mtdb3 /flash

You can also use cat to copy a partition. For example, to compare two Bitsy bootloaders, issue the command:
    cat /dev/mtdc2 > /mnt/bootimage
on each Bitsy and then sum or diff the resulting files.

Notes:
  • These procedures assume you have an ATA flash card or network drive mounted on /mnt.

  • These procedures copy the entire partition including any unused portions.

  • The zImage and ramdisk.gz partitions have headers. If you use this procedure to copy their partitions, the resulting files will not be in the same format as a zImage or ramdisk.gz.

  • An alternative to these procedures is to create a tar archive while the file system is mounted.



02-Jan-04: jlackey - note that these instrucions are for using a flash file system in addition to a ramdisk root file system
27-Aug-2003: rwhaley - update for BitsyX and AGX

Edited by - jlackey on 08 Nov 2002 17:17:06

jlackey

213 Posts

Posted - 08 Oct 2003 :  16:31:04  Show Profile  Email Poster
When using a flash based file system like JFFS2 or CRAMFS, usually it's still a good idea to keep some files in a RAM. See storing temporary files in a RAM file system for more information on this topic and instructions for setting up a mixed flash/RAM root file system.
Go to Top of Page

rwhaley

628 Posts

Posted - 28 Aug 2007 :  17:14:24  Show Profile  Email Poster
Newer boards (like the BitsyXb, Sphere, VGX, Portal, TurboXb and BitsyG5) flexible flash layout determined by the root_config.txt files loaded by the u-boot boot loader.

The raw flash device names are now:

/dev/mtd0, /dev/mtd1, /dev/mtd2, etc.

The erase commmand is now named flash_eraseall. So to erase the the kernel for a bitsyxb the command would be:

flash_eraseall /dev/mtd2

Go to Top of Page
  Topic  
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Jump To:
Eurotech Support Forums © Eurotech Inc. Go To Top Of Page
This page was generated in 0.05 seconds. Snitz Forums 2000