zynq 文件系统在sd卡启动,需要注意的一些事项

1、zynq对应的内核,是把bootargs写到u-boot代码中,需要修改bootargs参数,改成从sd分区2读取文件系统。重新编译uboot

1.1 进入u-boot,打开include/configs/zynq-common.h,将sdboot的参数修改如下:即,去除原来在分区1读取ramdisk的命令,修改bootm,去除ramdisk部分。[1]

 "sdboot=if mmcinfo; then " \
            "run uenvboot; " \
            "echo Copying Linux from SD to RAM... && " \
            "load mmc 0 ${kernel_load_address} ${kernel_image} && " \
            "load mmc 0 ${devicetree_load_address} ${devicetree_image} && " \
            "bootm ${kernel_load_address} - ${devicetree_load_address}; " \
        "fi\0" \

1.2 修改bootargs参数,在sd分区1,新建uEnv.txt,作为新的bootargs参数

bootargs=console=ttyPS0,115200n8 root=/dev/mmcblk0p2 rw earlyprintk rootfstype=ext4 rootwait rootdelay=5 devtmpfs.mount=1

2、增加rootdelay=5,是为了使linux在启动初始化时,等待一些模块加载完,再挂载文件系统,否则linux无法启动,并会出现下面错误:

VFS: Cannot open root device "mmcblk0p2" or unknown-block(0,0): error -6
Please append a correct "root=" boot option; here are the available partitions:
mmc0: new high speed SDHC card at address 0007

为了使rootdelay生效,需要修改linux代码[2],

+++ b/init/do_mounts.c
@@ -569,6 +569,8 @@ void __init prepare_namespace(void)
 		pr_info("Waiting %d sec before mounting root device...\n",
 			root_delay);
 		ssleep(root_delay);
+		/* Re-evaluate the root name to get the dev_t */
+		ROOT_DEV = name_to_dev_t(saved_root_name);
 	}

3、此时,启动好linux,还会发现,下面错误:

/etc/init.d/rcS: line 12: can't create /proc/sys/kernel/hotplug: nonexistent directory
mdev: /sys/class: No such file or directory

/usr/sbin/sshd: error while loading shared libraries: libdl.so.2: cannot open shared object file: No such file or directory
rcS Complete

/proc, /sys下面很多系统内容都是空的。mdev -s也无法执行

此时手动mount /dev/mmxxp1 /mnt会提示,

mount: mounting /dev/mmcblk0p1 on /mnt failed: No such file or directory

修改/bin/busybox属性为 chmod 4777 busybox,还是不见效。

一种解决方法:对sd卡上解压后的文件系统,手动删除原始ramdisk解压后的/proc, /sys,/mnt目录,手动创建这些空目录。

重新把sd卡放到zynq开发板,所有问题都解决了。

参考

[1]https://www.jianshu.com/p/6f2154c91eac

[2]https://lkml.org/lkml/2014/9/17/245

 

你可能感兴趣的:(zynq,linux)