2015年9月29日 星期二

create an initramfs on mdm9x40


利用linux提供的script建立initramfs在先前的文章已經提過,可參考如何利用kvm/qemu練習linux module之new update,基本上就是呼叫gen_initramfs_list.sh建立file system清單,使用gen_init_cpio將清單轉成CPIO格式後,在使用gzip做壓縮。相關指令如下:
W=/home/brook/projects/9x40/apps_proc
RD=/home/brook/projects/initramfs
CPIO=/home/brook/projects/initramfs.cpio
SYSROOT=${W}/oe-core/build/tmp-eglibc/sysroots/
OUTPUT=/home/brook/projects/9x40-initramfs.img
sh ${W}/kernel/scripts/gen_initramfs_list.sh -d ${RD} > /tmp/gen_initramfs_list
${W}/oe-core/build/tmp-eglibc/sysroots/mdm9640/usr/src/kernel/usr/gen_init_cpio /tmp/gen_initramfs_list > ${CPIO}
gzip -c ${CPIO} > ${CPIO}.gz


我是copy recipes/linux-quic/linux-quic_git.bb裡面的do_deploy(),接著修改成另外一個script,來建立image,指令如下:
${SYSROOT}/x86_64-linux/usr/bin/mkbootimg --kernel ${SYSROOT}/mdm9640/boot/zImage-3.10.49 --dt ${SYSROOT}/mdm9640/boot/masterDTB --ramdisk ${CPIO}.gz --cmdline "dynamic_debug.verbose=1 root=/dev/ram rootfstype=ramfs console=ttyHSL0,115200,n8 androidboot.hardware=qcom ehci-hcd.park=3 msm_rtb.filter=0x37" --base 0x81C00000 --tags-addr 0x81900000 --pagesize 2048 --ramdisk_offset 0xd32000 --output ${OUTPUT}

這裡的重點是cmdline要改成"root=/dev/ram rootfstype=ramfs",否則在lk的lk/app/aboot/aboot.c:update_cmdline()會塞一些information給kernel,導致無法由initramfs開機。

相關檔案位置: https://www.codeaurora.org/cgit/quic/le/mdm/manifest/tree/?id=LNX.LE.5.0.1-57014-9x40
LNX.LE.5.0.1-57014-9x40.xml: repo manifest file,

https://www.codeaurora.org/cgit/quic/le/kernel/lk/tree/app/aboot/aboot.c?id=LNX.LE.5.0.1-57014-9x40
lk/app/aboot/aboot.c: unsigned char *update_cmdline(const char * cmdline)

https://www.codeaurora.org/cgit/quic/le/oe/recipes/tree/conf/machine/mdm9640.conf?h=LNX.LE.5.0.1_rb1.7
conf/machine/mdm9640.conf: MACHINE_KERNEL_TAGS_OFFSET = "0x81900000"

https://www.codeaurora.org/cgit/quic/le/oe/recipes/tree/recipes/linux-quic/linux-quic_git.bb?id=LNX.LE.5.0.1-57014-9x40
recipes/linux-quic/linux-quic_git.bb: do_deploy()



熱門文章