最近的項目中需要在仿真機haps及VDK上集成rootfs,中間遇到一些問題,在此整理記錄以備忘。
rootfs里面集成的busybox版本1.29.3 (buildroot環境中自帶)
kernel版本4.14
u-boot傳遞bootcmdline參數給kernel
在arch/arm64/configs中修改defconfig文件配置initramfs的文件路徑
CONFIG_BLK_DEV_INITRD=y
CONFIG_INITRAMFS_SOURCE="./rootfs_test"
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
CONFIG_BUILD_ARM64_APPENDED_DTB_IMAGE_NAMES="jxx/jxx_jxx890_xyz"
CONFIG_BUILD_ARM64_APPENDED_DTB_IMAGE=y
rootfs需要支持:
1./dev management (Dynamic using devtmpfs + mdev)
2.busybox啟動時的配置文件inittab的改動:
::sysinit:/bin/mount -t proc proc /proc
::sysinit:/bin/mount -o remount,rw /
::sysinit:/bin/mkdir -p /dev/pts /dev/shm
::sysinit:/bin/mount -a
::sysinit:/sbin/swapon -a
null::sysinit:/bin/ln -sf /proc/self/fd /dev/fd
null::sysinit:/bin/ln -sf /proc/self/fd/0 /dev/stdin
null::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout
null::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr
::sysinit:/bin/hostname -F /etc/hostname
# now run any rc scripts
::sysinit:/etc/init.d/rcS
# Put a getty on the serial port
#ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100 # GENERIC_SERIAL
console::respawn:-/bin/sh #start console
# Stuff to do for the 3-finger salute
#::ctrlaltdel:/sbin/reboot
# Stuff to do before rebooting
::shutdown:/etc/init.d/rcK
::shutdown:/sbin/swapoff -a
::shutdown:/bin/umount -a -r
3.遇到的問題
console一直進不去:
一開始懷疑是ttySx這個沒對應的問題,也懷疑過bootcmdline有問題,甚至懷疑是kernel沒有啟動busybox。
最后發現是/dev目錄下面的文件沒有被正常創建的問題。
etc/init.d/S10mdev這個文件里面:
echo "Starting mdev..."
echo /sbin/mdev >/proc/sys/kernel/hotplug
/sbin/mdev -s (再啟動時會執行創建/dev目錄下面的文件)
S10mdev該文件會在init的時候執行,所以需要有可執行權限。若沒有會提示:permission denied.
改過之后發現就可以正常打開console輸入命令了。