2011年4月21日 星期四

u-boot boot uImage with ramdisk

CNS3420 VB v2.1, 2.6.38, CodeSourcery glibc arm-2009q1
* the u-boot didn't enable CONFIG_CMDLINE_TAG until v1.1; and v1.1 didn't enable CONFIG_INITRD_TAG, i.e. one have to enable them and build u-boot from source.

  1. bootargs or CONFIG_CMDLINE should have root=/dev/ram0
  2. u-boot enable CONFIG_INITRD_TAG
  3. kernel config should have:
    CONFIG_BLK_DEV_INITRD=y
    CONFIG_BLK_DEV_RAM=y
  4. mkimage uramdisk.img
    mkimage -A arm -O linux -T ramdisk -C none -a 0x3000000 -n "ramdisk" -d ramdisk.img.gz u-boot-ramdisk.img
  5. transfer uImage and uramdisk.img to RAM
  6. bootm 0x_addr_of_uImage 0x_addr_of_uramdisk_img
    set initrd_start 0x6000000;
    set bootcmd 'tftp $(ramaddr) $(kfile);tftp $(initrd_start) uramdisk.img;bootm $(ramaddr) $(initrd_start)';
    set bootargs 'root=/dev/ram0 rw init=/linuxrc mem=256M console=ttyS0,38400 lpj=4188160 user_debug=31 console=tty0 rootwait';
    Some source mentioned "initrd=0x3000000 ramdisk_size=40960": initrd doesn't exist in 2.6.38. ramdisk_size do, it is the size of ramdisk, if actual ramdisk size is larger than configured, the content get trimmed, so better leave it alone.


How to extract the ramdisk content from uboot format ramdisk image
http://qustion1234.blogspot.com/2009/09/how-to-extract-ramdisk-content-from.html

假設有一包ramdisk "initrd.gz",使用u-boot下的mkimage建立uboot format ramdisk image (ramdisk-uboot.img)在原本的ramdisk image前加64 bytes檔頭資訊:
tools/mkimage -A arm -O linux -T ramdisk -C none -a 0x20800000 -n "ramdisk" -d initrd.gz ramdisk-uboot.img
可以用下面的指令 extract the ramdisk content (init.gz) from uboot format ramdisk image
dd if=ramdisk-uboot.img of=ramdisk.img.gz bs=1 skip=64

INITRD: 0x05000040+0x009aad81 extends beyond physical memory - disabling initrd

沒有留言: