Put CRAMFS Image to Flash

From Texas Instruments Embedded Processors Wiki

Jump to: navigation, search
Translate this page to   

Contents

Prerequisites

Writing the CRAMFS Image to Flash

This section details how to write the CRAMFS image to NOR and NAND Flash. For both types of flash you should follow the steps in the common section and then proceed to the section for your Flash device.

Common

These steps are common to both NOR and NAND flash and should be done before proceeding to the individual Flash sections.

The following steps are performed on the host Linux workstation.

These steps assume that the kernel compiled with CRAMFS support is located at /home/user/workdir/ti-davinci and that the tftp root is /tftpboot

   host$ cp /home/user/workdir/ti-davinci/arch/arm/boot/uImage /tftpboot
   host$ cp <path to cramfs image>/cramfs.image /tftpboot

The following steps are performed at the u-boot prompt on the target board

   DVEVM# setenv serverip <tftp server ip>
   DVEVM# setenv bootfile cramfs.image
   DVEVM# dhcp

The dhcp command will cause the file specified by "bootfile" to be downloaded to address 0x80700000 from the tftp server specified by the "serverip" variable. You should see output similar to:

   DVEVM # dhcp
   BOOTP broadcast 1
   DHCP client bound to address <board ip>
   TFTP from server <server ip>; our IP address is <board ip>
   Filename 'cramfs.image'.
   Load address: 0x80700000
   Loading: #################################################################
            #################################################################
            #################################################################
            #################################################################
            #################################################################
            #################################################################
            #################################################################
            #################################################################
            #####
   done
   Bytes transferred = 2686976 (290000 hex)

Take note of the Load address (0x80700000) and the Bytes transferred (0x290000) as these are needed in the following steps.

You may now proceed to the appropriate section for your Flash device depending on if you are using NOR Flash or NAND Flash

NOR Flash

This section will detail how to write the CRAMFS image to NOR Flash

   DVEVM# flinfo
   Bank # 1: INTEL 28F128P30T
     Size: 16 MB in 131 Sectors
     Sector Start Addresses:
       02000000        02020000        02040000 E      02060000   (RO) 02080000
       ....

NOTE: U-Boot resides in the first 5 sectors of flash so do not write the image in that location. Likewise be sure that if you are writting your kernel in flash you leave enough room between the end of U-Boot and the begining of the CRAMFS image for the kernel. For this example we will use address 0x2140000

   DVEVM# protect off 0x2140000 +0x290000
   Un-Protected 21 sectors
   
   DVEVM# erase 0x2140000 +0x290000
   Erasing sector 10 ... done.
   Erasing sector 11 ... done.
   Erasing sector 12 ... done.
   .
   .
    Erase Operation Completed.
   Erased 21 sectors
   DVEVM# cp.b 0x80700000 0x2140000 0x290000
   Copy to Flash...\done
   DVEVM# protect on 0x2140000 +0x290000

NAND Flash

This section will detail how to write the CRAMFS image to NAND Flash

   DVEVM# nand info
   Device 0: NAND 64MiB 1,8V 8-bit, sector size 16 KiB

Note the sector size listed at the end of the output from the nand info command. Since the NAND flash requires that I/O operations be done in increments of sector size you must round up the size of your CRAMFS image to the next full sector in order for the erase and write commands to work.

In this example the sector size is 16KB which is 0x4000 so the following calculation can be done

   CRAMFS image size = 0x290000
   Num sectors = 0x290000 / 0x4000 = A4 which does not need rounding
   Rounded size = Num sectors * 0x4000 = A4 * 0x4000 = 0x290000

NOTE: U-Boot resides in the first 5 sectors of flash so do not write the image in that location. Likewise be sure that if you are writting your kernel in flash you leave enough room between the end of U-Boot and the begining of the CRAMFS image for the kernel. For this example we will use offset 0x130000.

   DVEVM# nand erase 0x130000 0x290000
   NAND erase: device 0 offset 0x130000, size 0x290000
   Erasing at 0x3bc000 -- 100% complete.
   OK
   DVEVM# nand write 0x80700000 0x130000 0x290000
   NAND write: device 0 offset 0x130000, size 0x290000
    2686976 bytes written: OK

Boot CRAMFS Image

This section covers the bootargs that need to be set to boot the Linux kernel using a CRAMFS file system. In this example the kernel is loaded via tftp and the CRAMFS file system is stored in Flash. You will need to replace the offsets and sizes used here with the ones for your file system.

   DVEVM# setenv bootargs 'console=ttyS0,115200n8 ip=dhcp root=/dev/ram0 rw initrd=0x85000000,6M mem=120M'

Here we are using the CRAMFS image that was placed in memory at address 0x85000000 by the bootcmd.

For NAND Flash use:
   DVEVM# setenv bootcmd 'nand read 85000000 130000 290000; dhcp; bootm'
For NOR Flash use:
   DVEVM# setenv bootcmd 'cp.b 0x2140000 0x85000000 0x290000; dhcp; bootm'
   DVEVM# saveenv
   DVEVM# boot

You should see output similar to:

   DVEVM # boot
   NAND read: device 0 offset 0x130000, size 0x290000
    2686976 bytes read: OK
   BOOTP broadcast 1
   DHCP client bound to address <board ip>
   TFTP from server <server ip>; our IP address is <board ip>
   Filename 'uImage'.
   Load address: 0x80700000
   Loading: #################################################################
            #################################################################
            #################################################################
            #################################################################
            #########################################
   done
   Bytes transferred = 1538588 (177a1c hex)
   ## Booting image at 80700000 ...
      Image Name:   Linux-2.6.10_mvl401
      Image Type:   ARM Linux Kernel Image (uncompressed)
      Data Size:    1538524 Bytes =  1.5 MB
      Load Address: 80008000
      Entry Point:  80008000
      Verifying Checksum ... OK
   OK
   
   Starting kernel ...
   
   <kernel output removed here>
   
   RAMDISK: cramfs filesystem found at block 0
   RAMDISK: Loading 2624KiB [1 disk] into ram disk... done.
   VFS: Mounted root (cramfs filesystem) readonly.
   
   <kernel output removed here>
   
   Hello World!!!
   INIT: Entering runlevel: 3
   Starting internet superserver: inetd.
   
   MontaVista(R) Linux(R) Professional Edition 4.0.1 (0502020)
   
   login:
Leave a Comment
Personal tools
Namespaces
Variants
Actions
Navigation
Print/export
Toolbox