With U-Boot it is possible to store a ramdisk image in flash and use that as a root filesystem for the Linux kernel. The following example shows how to build, and download a ramdisk image to flash and boot the kernel in flash using this ramdisk image.
Instructions for creating the ramdisk image see Booting with a ramdisk root file system. Once this filesystem image has been created it needs to be converted into a U-Boot image file:
host% ./tools/mkimage -A sh -O linux -T ramdisk -a 0x8C800000 -n "ST40 Linux ramdisk" -d initrd.img /export/ramdisk.ub Image Name: ST40 Linux ramdisk Created: Fri Nov 7 17:00:42 2008 Image Type: SuperH Linux RAMDisk Image (gzip compressed) Data Size: 4739544 Bytes = 4628.46 KiB = 4.52 MiB Load Address: 0x8C800000 Entry Point: 0x8C800000
Note: the address given for the "-a" argument should be located shortly beyond the address where the Linux kernel resides in SDRAM. Typically, add about 8MiB to the kernel's load addresses.
MB618> nfs $load_addr /export/ramdisk.ub Warning: MAC addresses don't match: HW MAC address: FF:FF:FF:FF:FF:FF "ethaddr" value: AA:00:04:00:0F:0F Using MAC Address AA:00:04:00:0F:0F STM-GMAC: SMSC LAN8700 found STM-GMAC: 100Mbs full duplex link detected File transfer via NFS from server 164.129.15.56; our IP address is 164.129.15.15 Filename '/export/ramdisk.ub'. Load address: 0x8c000000 Loading: ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################ done Bytes transferred = 4739608 (485218 hex) MB618> iminfo $fileaddr ## Checking Image at 8c000000 ... Image Name: ST40 Linux ramdisk Image Type: SuperH Linux RAMDisk Image (gzip compressed) Data Size: 4739544 Bytes = 4.5 MiB Load Address: 8c800000 Entry Point: 8c800000 Verifying Checksum ... OK
The ramdisk image can then by copied in to flash:
MB618> prot off 1:27-63 Un-Protect Flash Sectors 27-63 in Bank # 1 ..................................... done MB618> erase 1:27-63 Erase Flash Sectors 27-63 in Bank # 1 ..................................... done MB618> cp.b $fileaddr A0300000 $filesize Copy to Flash ................................................................................ ................................................................................ ................................................................................ ................................................. done MB618> iminfo A0300000 ## Checking Image at a0300000 ... Image Name: ST40 Linux ramdisk Image Type: SuperH Linux RAMDisk Image (gzip compressed) Data Size: 4739544 Bytes = 4.5 MiB Load Address: 8c800000 Entry Point: 8c800000 Verifying Checksum ... OK
At this point, there will typically be 2 U-Boot images burned in the flash - one for the kernel, and one for the ramdisk. All U-Boot images in flash can be easily seen (and verified) using the "imls" command:
MB618> imls Image at A0060000: Image Name: Linux-2.6.23.17_stm23_0117-mb618 Image Type: SuperH Linux Kernel Image (gzip compressed) Data Size: 1845268 Bytes = 1.8 MiB Load Address: 8c001000 Entry Point: 8c002000 Verifying Checksum ... OK Image at A0300000: Image Name: ST40 Linux ramdisk Image Type: SuperH Linux RAMDisk Image (gzip compressed) Data Size: 4739544 Bytes = 4.5 MiB Load Address: 8c800000 Entry Point: 8c800000 Verifying Checksum ... OK
To use a ramdisk image when booting a kernel, set the appropriate value for "bootargs", and add the address of the ramdisk image (in flash) to the "bootm" command, after the address of the linux kernel image (in flash). See Booting The Linux Kernel With A RAM Disk Root Filesystem for further details.