Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.

Put CRAMFS Image to Flash

From Texas Instruments Wiki
Jump to: navigation, search

Prerequisites

  • A CRAMFS file system image.
  • A terminal application for communicating with the DVEVM. i.e. minicom or hyperterminal
  • A copy of the U-Boot bootloader running on the target
    • If you do not have U-Boot running on the target please see the RBL, UBL and host program article for how to get the U-Boot bootloader installed on your board first
  • A kernel with CRAMFS support enabled
  • A tftp server for loading the kernel image used in this example.
    • NOTE: You can also write the kernel image to Flash rather than using tftp boot but this is outside the scope of this document.

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.

  • Copy the kernel image with CRAMFS support to the tftp root directory

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
  • Copy the CRAMFS file system image to the tftp root directory
   host$ cp <path to cramfs image>/cramfs.image /tftpboot

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

  • Download the CRAMFS file system image via TFTP
   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

  • Determine the location in Flash to store the CRAMFS image
   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

  • Erase the NOR Flash
   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
  • Copy the CRAMFS image from RAM into Flash
   DVEVM# cp.b 0x80700000 0x2140000 0x290000
   Copy to Flash...\done
  • Protect the CRAMFS image in NOR (optional)
   DVEVM# protect on 0x2140000 +0x290000

NAND Flash

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

  • Determine the sectore size of your NAND Flash and round the CRAMFS image size up to a multiple of sectore size
   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
  • Erase the NAND Flash

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
  • Copy the CRAMFS image from RAM to NAND
   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.

  • Set the bootargs to use CRAMFS
   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.

  • Set the bootcmd to copy the CRAMFS image to DDR and boot the kernel (if using tftp be sure to reset the bootfile variable to the kernel image)
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'
  • Boot the board.
   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: