问题描述
在为嵌入式目标设置启动时,我遇到了大量(半个)问题;情况是:
我有一个嵌入式目标,该目标带有一个较小但可靠的闪存(1600万字节)和一个可能较大(目前为8GB)但不太可靠的SD卡。
SD卡的不可靠性主要是由于硬件设置(直接连接到电源,所以如果它被“严重”唤醒,则无法对其进行硬件重置)我无法更改。 这主要是影响u-boot(Linux处理似乎更稳定)。
由于我需要相对较高的可靠性,即使在软件更新期间/之后,我也选择了具有“恢复”后备功能的拨号系统(先更新休眠的系统,然后重新启动)。
不幸的是,我在Flash中没有足够的空间来容纳适当的initramfs以及完整的恢复系统,因此我正在尝试将启动系统与恢复结合起来。
因此,我有一个完整的Flash系统,并带有一个小的/init
脚本来选择启动模式。
/init
脚本类似于:
#!/bin/ash
set -x
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
boot_prod() {
mount -t proc none /proc
mount -t sysfs none /sys
mount $1 /mnt && [ -x /mnt/sbin/init ] || return 1
echo "switching to $1"
cd /mnt
mount --move /sys sys
umount /proc # /proc is remounted by BusyBox /dev/inittab
mount --move /dev dev
config_set sys $2
pivot_root . mnt
umount mnt
exec chroot . sbin/init <dev/console >dev/console 2>&1
}
case $tryboot; in
A)
boot_prod /dev/mmcblk0p6 A
;;
B)
boot_prod /dev/mmcblk0p7 B
;;
R)
[ -x /mnt/sbin/init ] && exec /mnt/sbin/init
;;
*)
;;
esac
echo "Could not boot cleanly; running a shell"
mount -t proc none /proc
mount -t sysfs none /sys
exec setsid cttyhack sh
这显然是从bootargs
包含tryboot=A/B/R
开始的。
我没有使用BusyBox switch_root
,因为这不是真正的initramfs,而是生活在Flash上的SquashFS;我当前的u-Boot环境包括:
BOOT_A_GOOD=y
BOOT_CURRENT=B
SYstem_R=/dev/mtdblock5
boot_a=echo "Loading System A";part=A;run boot_x
boot_b=echo "Loading System B";part=B;run boot_x
boot_Now=if test "${BOOT_CURRENT}" = A; then run boot_a; elif test "${BOOT_CURRENT}" = B; then run boot_b; fi; if env exists BOOT_A_GOOD; then run boot_a; fi; if env exists BOOT_B_GOOD; then run boot_b; fi; run boot_r
boot_r=echo "Loading Recovery";part=R;run boot_x
boot_x=setenv bootargs "${default_bootargs} mtdparts=${mtdparts} root=${part}" && bootm bc050000
bootcmd=rub boot_Now
bootdelay=2
default_bootargs=earlyprintk rootwait console=ttyS2,115200
mtdids=nor0=spi0.0
mtdparts=spi0.0:312k(u-boot),4k(env),4k(factory),2368k(kernel),-(filesystem)
当前问题是系统死于exec chroot . sbin/init ...
并显示“内核崩溃-不同步:试图杀死init!”错误没有打印“罪魁祸首” + exec chroot . sbin/init <dev/console >dev/console 2>&1
行。
注意1:我确定sbin/init
存在于新的根fs上(这是到bin/busyBox
的符号链接
注2:即使我注释掉了先前的umount mnt
,错误仍然存在。
我在做什么错了?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)