高级会员
- 积分
- 813
- 金钱
- 813
- 注册时间
- 2021-2-26
- 在线时间
- 117 小时
|
前面我们添加了分区以及将相应的文件烧录到了分区里面去,那么紧张而激动的第一次上电的时刻终于来到了。
上电开机,串口有输出,uboot一切正常,kernel也boot起来了,分区也正确认识到了,但是很遗憾,kernel panic
查看kernel panic的log
- [20210303_21:04:12] Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/init.txt for guidance.
- [20210303_21:04:12] ---[ end Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/init.txt for guidance.
复制代码
很明显,这是由于rootfs没有正确mount上而导致的。那我们来看看uboot的bootargs里面的rootfs是怎么配置的。
进到uboot,执行printenv,会显示如下env:
- [20210303_21:04:23] => printenv
- [20210303_21:04:23] baudrate=115200
- [20210303_21:04:23] board_name=EVK
- [20210303_21:04:23] board_rev=14X14
- [20210303_21:04:23] boot_fdt=try
- [20210303_21:04:23] bootcmd=run findfdt;mmc dev ${mmcdev};mmc dev ${mmcdev}; if mmc rescan; then if run loadbootscript; then run bootscript; else if run loadimage; then run mmcboot; else run netboot; fi; fi; else run netboot; fi
- [20210303_21:04:23] bootcmd_mfg=run mfgtool_args;bootz ${loadaddr} ${initrd_addr} ${fdt_addr};
- [20210303_21:04:23] bootdelay=3
- [20210303_21:04:23] bootscript=echo Running bootscript from mmc ...; source
- [20210303_21:04:23] console=ttymxc0
- [20210303_21:04:23] ethact=FEC1
- [20210303_21:04:23] ethprime=FEC
- [20210303_21:04:23] fdt_addr=0x83000000
- [20210303_21:04:23] fdt_file=undefined
- [20210303_21:04:23] fdt_high=0xffffffff
- [20210303_21:04:23] findfdt=if test $fdt_file = undefined; then setenv fdt_file imx6ull-alientek-emmc.dtb; fi;
- [20210303_21:04:23] image=zImage
- [20210303_21:04:23] initrd_addr=0x83800000
- [20210303_21:04:23] initrd_high=0xffffffff
- [20210303_21:04:23] ip_dyn=yes
- [20210303_21:04:23] loadaddr=0x80800000
- [20210303_21:04:23] loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};
- [20210303_21:04:23] loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}
- [20210303_21:04:23] loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
- [20210303_21:04:23] mfgtool_args=setenv bootargs console=${console},${baudrate} rdinit=/linuxrc g_mass_storage.stall=0 g_mass_storage.removable=1 g_mass[20210303_21:04:23] _storage.file=/fat g_mass_storage.ro=1 g_mass_storage.idVendor=0x066F g_mass_storage.idProduct=0x37FF g_mass_storage.iSerialNumber="[20210303_21:04:23] " clk_ignore_unused
- [20210303_21:04:23] mmcargs=setenv bootargs console=${console},${baudrate} root=${mmcroot}
- [20210303_21:04:23] mmcautodetect=yes
- [20210303_21:04:23] mmcboot=echo Booting from mmc ...; run mmcargs; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if run loadfdt; then bootz[20210303_21:04:23] ${loadaddr} - ${fdt_addr}; else if test ${boot_fdt} = try; then bootz; else echo WARN: Cannot load the DT; fi; fi; else bootz; fi;
- [20210303_21:04:23] mmcdev=1
- [20210303_21:04:23] mmcpart=1
- [20210303_21:04:23] mmcroot=/dev/mmcblk1p2 rootwait rw
- [20210303_21:04:23] netargs=setenv bootargs console=${console},${baudrate} root=/dev/nfs ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp
- [20210303_21:04:23] netboot=echo Booting from net ...; run netargs; if test ${ip_dyn} = yes; then setenv get_cmd dhcp; else setenv get_cmd tftp; fi; ${g[20210303_21:04:23] et_cmd} ${image}; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if ${get_cmd} ${fdt_addr} ${fdt_file}; then bootz ${load[20210303_21:04:23] addr} - ${fdt_addr}; else if test ${boot_fdt} = try; then bootz; else echo WARN: Cannot load the DT; fi; fi; else bootz; fi;
- [20210303_21:04:23] panel=TFT7016
- [20210303_21:04:23] script=boot.scr
- [20210303_21:04:23]
- [20210303_21:04:23] Environment size: 2188/8188 bytes
复制代码
我们先来看bootcmd
- bootcmd=run findfdt;mmc dev ${mmcdev};mmc dev ${mmcdev}; if mmc rescan; then if run loadbootscript; then run bootscript; else if run[20210302_18:54:28] loadimage; then run mmcboot; else run netboot; fi; fi; else run netboot; fi
复制代码
这么看很费劲,手动编辑缩进一下:
- bootcmd=run findfdt;
- mmc dev ${mmcdev};
- mmc dev ${mmcdev};
- if mmc rescan; then
- if run loadbootscript; then
- run bootscript;
- else if run loadimage; then
- run mmcboot;
- else run netboot;
- fi;
- fi;
- else
- run netboot;
- fi
复制代码
结合各种环境变量,最终会跑到 run mmcboot这一行,具体就不在这里讲解了,大家可以直接顺一下逻辑。
我们再来看mmcboot是什么。
- mmcboot=echo Booting from mmc ...; run mmcargs; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if run loadfdt; then bootz[20210302_18:54:28] ${loadaddr} - ${fdt_addr}; else if test ${boot_fdt} = try; then bootz; else echo WARN: Cannot load the DT; fi; fi; else bootz; fi;
复制代码 我们手动编辑缩进一下:
- mmcboot=echo Booting from mmc ...;
- run mmcargs;
- if test ${boot_fdt} = yes || test ${boot_fdt} = try; then
- if run loadfdt; then
- bootz ${loadaddr} - ${fdt_addr};
- else if test ${boot_fdt} = try; then
- bootz;
- else
- echo WARN: Cannot load the DT;
- fi;
- fi;
- else
- bootz;
- fi;
复制代码 简而言之,执行mmcargs,然后load image,最后用bootz启动kernel
然而:
- mmcargs=setenv bootargs console=${console},${baudrate} root=${mmcroot}
- console=ttymxc0
- baudrate=115200
- mmcroot=/dev/mmcblk1p2 rootwait rw
复制代码 看到了,这里指定了mmcroot=/dev/mmcblk1p2,但是我们当前的分区情况来看,rootfs_a ====> /dev/mmcblk1p5,rootfs_b ====> /dev/mmcblk1p6
那我们就来修改一下mmcroot
修改成如下:
- mmcroot=/dev/mmcblk1p5 rootwait rw
- saveenv
复制代码
重启板子,你会发现,他还是出现rootfs挂在不上的问题
重启到uboot,printenv发现,我们修改完的mmcroot有变回去了,又是mmcblk1p2了,这是怎么回事呢?
我们首先来查找一下uboot的这些env是在哪里定义的,需要关注的是2个文件
[uboot]/include/env_default.h
[uboot]/configs/mx6ull_alientek_emmc.h
我们先来看[uboot]/include/env_default.h,可以看到这里都是使用宏定义来判断并且设定default env的。我们关注的bootargs是由CONFIG_BOOTARGS这个宏来定义的。
- #ifdef DEFAULT_ENV_INSTANCE_EMBEDDED
- env_t environment __PPCENV__ = {
- ENV_CRC, /* CRC Sum */
- #ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT
- 1, /* Flags: valid */
- #endif
- {
- #elif defined(DEFAULT_ENV_INSTANCE_STATIC)
- static char default_environment[] = {
- #else
- const uchar default_environment[] = {
- #endif
- #ifdef CONFIG_ENV_CALLBACK_LIST_DEFAULT
- ENV_CALLBACK_VAR "=" CONFIG_ENV_CALLBACK_LIST_DEFAULT "\0"
- #endif
- #ifdef CONFIG_ENV_FLAGS_LIST_DEFAULT
- ENV_FLAGS_VAR "=" CONFIG_ENV_FLAGS_LIST_DEFAULT "\0"
- #endif
- #ifdef CONFIG_BOOTARGS
- "bootargs=" CONFIG_BOOTARGS "\0"
- #endif
- #ifdef CONFIG_BOOTCOMMAND
- "bootcmd=" CONFIG_BOOTCOMMAND "\0"
- #endif
- #ifdef CONFIG_RAMBOOTCOMMAND
- "ramboot=" CONFIG_RAMBOOTCOMMAND "\0"
- #endif
- #ifdef CONFIG_NFSBOOTCOMMAND
- "nfsboot=" CONFIG_NFSBOOTCOMMAND "\0"
- #endif
- #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0)
- "bootdelay=" __stringify(CONFIG_BOOTDELAY) "\0"
- #endif
- #if defined(CONFIG_BAUDRATE) && (CONFIG_BAUDRATE >= 0)
- "baudrate=" __stringify(CONFIG_BAUDRATE) "\0"
- #endif
- #ifdef CONFIG_LOADS_ECHO
- "loads_echo=" __stringify(CONFIG_LOADS_ECHO) "\0"
- #endif
- #ifdef CONFIG_ETHPRIME
- "ethprime=" CONFIG_ETHPRIME "\0"
- #endif
- #ifdef CONFIG_IPADDR
- "ipaddr=" __stringify(CONFIG_IPADDR) "\0"
- #endif
- #ifdef CONFIG_SERVERIP
- "serverip=" __stringify(CONFIG_SERVERIP) "\0"
- #endif
- #ifdef CONFIG_SYS_AUTOLOAD
- "autoload=" CONFIG_SYS_AUTOLOAD "\0"
- #endif
- #ifdef CONFIG_PREBOOT
- "preboot=" CONFIG_PREBOOT "\0"
- #endif
- #ifdef CONFIG_ROOTPATH
- "rootpath=" CONFIG_ROOTPATH "\0"
- #endif
- #ifdef CONFIG_GATEWAYIP
- "gatewayip=" __stringify(CONFIG_GATEWAYIP) "\0"
- #endif
- #ifdef CONFIG_NETMASK
- "netmask=" __stringify(CONFIG_NETMASK) "\0"
- #endif
- #ifdef CONFIG_HOSTNAME
- "hostname=" __stringify(CONFIG_HOSTNAME) "\0"
- #endif
- #ifdef CONFIG_BOOTFILE
- "bootfile=" CONFIG_BOOTFILE "\0"
- #endif
- #ifdef CONFIG_LOADADDR
- "loadaddr=" __stringify(CONFIG_LOADADDR) "\0"
- #endif
- #ifdef CONFIG_CLOCKS_IN_MHZ
- "clocks_in_mhz=1\0"
- #endif
- #if defined(CONFIG_PCI_BOOTDELAY) && (CONFIG_PCI_BOOTDELAY > 0)
- "pcidelay=" __stringify(CONFIG_PCI_BOOTDELAY)"\0"
- #endif
- #ifdef CONFIG_ENV_VARS_UBOOT_CONFIG
- "arch=" CONFIG_SYS_ARCH "\0"
- "cpu=" CONFIG_SYS_CPU "\0"
- "board=" CONFIG_SYS_BOARD "\0"
- "board_name=" CONFIG_SYS_BOARD "\0"
- #ifdef CONFIG_SYS_VENDOR
- "vendor=" CONFIG_SYS_VENDOR "\0"
- #endif
- #ifdef CONFIG_SYS_SOC
- "soc=" CONFIG_SYS_SOC "\0"
- #endif
- #endif
- #ifdef CONFIG_EXTRA_ENV_SETTINGS
- CONFIG_EXTRA_ENV_SETTINGS
- #endif
- "\0"
- #ifdef DEFAULT_ENV_INSTANCE_EMBEDDED
- }
- #endif
- };
复制代码
那么,这些宏都是在哪里定义的呢?很明显就是[uboot]/configs/mx6ull_alientek_emmc.h
我们详细查看这个文件,就发现了除了CONFIG_EXTRA_ENV_SETTINGS其余都没有定义,而且CONFIG_EXTRA_ENV_SETTINGS里的内容都是hardcode写死的。这就是为什么当我们去修改mmcboot的时候,修改的时候我们可以保存成功,但是一重启,代码就又变回default了。
- #define CONFIG_EXTRA_ENV_SETTINGS \
- CONFIG_MFG_ENV_SETTINGS \
- "script=boot.scr\0" \
- "image=zImage\0" \
- "console=ttymxc0\0" \
- "fdt_high=0xffffffff\0" \
- "initrd_high=0xffffffff\0" \
- "fdt_file=undefined\0" \
- "fdt_addr=0x83000000\0" \
- "boot_fdt=try\0" \
- "ip_dyn=yes\0" \
- "panel=TFT7016\0" \
- "mmcdev="__stringify(CONFIG_SYS_MMC_ENV_DEV)"\0" \
- "mmcpart=" __stringify(CONFIG_SYS_MMC_IMG_LOAD_PART) "\0" \
- "mmcroot=" CONFIG_MMCROOT " rootwait rw\0" \
- "mmcautodetect=yes\0" \
- "mmcargs=setenv bootargs console=${console},${baudrate} " \
- CONFIG_BOOTARGS_CMA_SIZE \
- "root=${mmcroot}\0" \
- "loadbootscript=" \
- "fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \
- "bootscript=echo Running bootscript from mmc ...; " \
- "source\0" \
- "loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}\0" \
- "loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}\0" \
- "mmcboot=echo Booting from mmc ...; " \
- "if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
- "if run loadfdt; then " \
- "bootz ${loadaddr} - ${fdt_addr}; " \
- "else " \
- "if test ${boot_fdt} = try; then " \
- "bootz; " \
- "else " \
- "echo WARN: Cannot load the DT; " \
- "fi; " \
- "fi; " \
- "else " \
- "bootz; " \
- "fi;\0" \
- "netargs=setenv bootargs console=${console},${baudrate} " \
- CONFIG_BOOTARGS_CMA_SIZE \
- "root=/dev/nfs " \
- "ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \
- "netboot=echo Booting from net ...; " \
- "run netargs; " \
- "if test ${ip_dyn} = yes; then " \
- "setenv get_cmd dhcp; " \
- "else " \
- "setenv get_cmd tftp; " \
- "fi; " \
- "${get_cmd} ${image}; " \
- "if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
- "if ${get_cmd} ${fdt_addr} ${fdt_file}; then " \
- "bootz ${loadaddr} - ${fdt_addr}; " \
- "else " \
- "if test ${boot_fdt} = try; then " \
- "bootz; " \
- "else " \
- "echo WARN: Cannot load the DT; " \
- "fi; " \
- "fi; " \
- "else " \
- "bootz; " \
- "fi;\0" \
- "findfdt="\
- "if test $fdt_file = undefined; then " \
- "setenv fdt_file imx6ull-alientek-emmc.dtb; " \
- "fi;\0" \
复制代码
针对我们的case,解决方法也很简单,在[uboot]/configs/mx6ull_alientek_emmc.h添加宏定义:
#define CONFIG_BOOTARGS "console=ttymxc0,115200 root=/dev/mmcblk1p5 rootwait rw"
删除CONFIG_EXTRA_ENV_SETTINGS 里删除run mmcargs;
重新编译uboot烧录,上电启动,一切正常。
既然启动没问题了,下面我们就要实现自动A/B启动了,敬请期待。
|
|