Looks like kernel ignored Bootargs.
The code is located in the Build_dir...arch/mips/ralink PROM.C
static __init void Prom_init_cmdline (int argc, char **argv)
{
int i;
Manfeel, mod to pr_info from Pr_debug
Pr_info ("prom:fw_arg0=%08x fw_arg1=%08x fw_arg2=%08x fw_arg3=%08x\n",
(unsigned int) fw_arg0, (unsigned int) fw_arg1,
(unsigned int) fw_arg2, (unsigned int) fw_arg3);
ARGC = fw_arg0;
argv = (char * *) kseg1addr (FW_ARG1);
if (!ARGV) {
Manfeel, mod to pr_info from Pr_debug
Pr_info ("argv=%p is invalid, skipping\n",
ARGV);
Return
}
for (i = 0; i < argc; i++) {
Char *p = (char *) kseg1addr (argv[i]);
if (CPHYSADDR (p) && *p) {
Manfeel, mod to pr_info from Pr_debug
Pr_info ("argv[%d]:%s\n", I, p);
Strlcat (Arcs_cmdline, "", sizeof (Arcs_cmdline));
Strlcat (Arcs_cmdline, p, sizeof (arcs_cmdline));
}
}
Pr_info ("Arcs_cmdline:%s\n", arcs_cmdline);
}
In Prom.c, the Bootargs in Uboot is read into the arcs_cmdline.
However, SETUP.C did not read this arcs_cmdline. Why.
In the area involving Arcs_cmdline, the diagnostic output, the start time, the following information was found in the console:
SoC is Ralink mt7620n ver:2 eco:3
prom:fw_arg0=00000003 fw_arg1=83f02fb0 fw_arg2=83f033d0 fw_arg3=00000000
ARGV[1]: Root=/dev/root
ARGV[2]: Debug
0 arch/mips/ralink/prom.c,arcs_cmdline = root=/dev/root Debug
Bootconsole [EARLY0] Enabled
CPU revision is:00019650 (MIPS 24KEc)
1 arch/mips/kernel/prom.c,arcs_cmdline = root=/dev/root Debug
2 Arch/mips/kernel/prom.c,arcs_cmdline = console=ttys0,57600
Mips:machine is Wrtnode
It can be determined that arcs_cmdline is properly placed in the RALINK/PROM.C, but is modified in KERNEL/PROM.C to the system default ...
We followed the entry, and a probe.
void __init early_init_devtree (void *params)
{
/* Setup Flat device-tree pointer * *
Initial_boot_params = params;
/* Retrieve various informations from The/chosen node of the
* Device-tree, including the platform type, INITRD location and
* Size, and more ...
*/
Pr_info ("1%s,arcs_cmdline =%s\n", __file__,arcs_cmdline);
Of_scan_flat_dt (Early_init_dt_scan_chosen, arcs_cmdline);
Pr_info ("2%s,arcs_cmdline =%s\n", __file__,arcs_cmdline);
/* Scan Memory nodes * *
Of_scan_flat_dt (Early_init_dt_scan_root, NULL);
Of_scan_flat_dt (Early_init_dt_scan_memory_arch, NULL);
/* Try to load the MIPS machine name * * *
Of_scan_flat_dt (Early_init_dt_scan_model, NULL);
}
After careful study, the key code is found in the call Of_scan_flat_dt (Early_init_dt_scan_chosen, arcs_cmdline);
callback function in the Early_init_dt_scan_chosen, which is located in the drivers/of/fdt.c
int __init Early_init_dt_scan_chosen (unsigned long node, const char *uname,
int depth, void *data)
{
unsigned long l;
Char *p;
Pr_debug ("Search \" chosen\ ", Depth:%d, uname:%s\n", depth, uname);
if (depth!= 1 | | |!data | |
(strcmp (uname, "chosen")!= 0 && strcmp (uname, "chosen@0")!= 0))
return 0;
EARLY_INIT_DT_CHECK_FOR_INITRD (node);
/* Retrieve command line * *
p = Of_get_flat_dt_prop (node, "Bootargs", &l);
if (P!= NULL && L > 0)
strlcpy (data, p, min ((int) L, command_line_size));
p = Of_get_flat_dt_prop (node, "Bootargs-append", &l);
if (P!= NULL && L > 0)
Strlcat (data, p, min (strlen (data) + (int) L, command_line_size));
/*
* Config_cmdline is meant to being a default in case nothing else
* Managed to set the command line, unless Config_cmdline_force
* is set in which case we override whatever was found earlier.
*/
#ifdef Config_cmdline
#ifndef Config_cmdline_force
if (!) ( (char *) data) [0])
#endif
strlcpy (data, Config_cmdline, command_line_size);
#endif/* Config_cmdline * *
Pr_debug ("Command line is:%s\n", (char*) data);
/* Break Now * *
return 1;
}
The *data inside is arcs_cmdline.
Config_cmdline and Config_cmdline_force from the Kernel_menuconfig:
Kernel Hacking---> [] built-in Kernel command line
There is a paragraph in the description:
Config_cmdline_bool: For most systems, it's firmware or second stage bootloader that By default specifies the kernel command line options. However, It might be necessary or advantageous to either override the Default kernel command line or add a few extra the options to it. For such cases, this option allows you to hardcode your own command line options directly into the kernel. For this, you Should choose ' Y ' here, and fill in the extra boot arguments In Config_cmdline. The built-in options would be concatenated to the default command Line if cmdline_override are set to ' N '. Otherwise, the default command line is ignored and replaced by the built-in string. Most MIPS systems'll normally expect ' N ' here and rely upon The command line from the firmware or the Second-stage bootloader. Symbol:cmdline_bool [=n] Type:boolean Prompt:built-in Kernel command line Location: -> Kernel Hacking Defined at arch/mips/kconfig.debug:23 |
Once again, these switches do not open, which means there is a problem with the Of_get_flat_dt_prop function.
/* Retrieve command line * *
p = Of_get_flat_dt_prop (node, "Bootargs", &l);
if (P!= NULL && L > 0)
strlcpy (data, p, min ((int) L, command_line_size));
p = Of_get_flat_dt_prop (node, "Bootargs-append", &l);
if (P!= NULL && L > 0)
Strlcat (data, p, min (strlen (data) + (int) L, command_line_size));
Bootargs in PROM.C has been successfully read out, why here still want to continue to toss it?-_-| |
Suddenly realize that this code is reading the attribute value in DTS.
Find the Mt7620n.dtsi inside the Target/linux/ramips/dts, and find that there is such a definition:
chosen {
Bootargs = "console=ttys0,57600";
};
Decisively delete the definition of this section.
Set Bootargs to Root=/dev/sda2 ROOTFSTYPE=EXT4 in Uboot CONSOLE=TTYS0,57600N8
Note: CONSOLE=TTYS0,57600N8 is critical, otherwise the console will not be visible until later in the boot.
After recompiling, kernel finally able to handle the Bootargs. But it's still panic.
Kernel Panic-not syncing:VFS:Unable to mount Root fs on Unknown-block (0,0)
AutoMount Rootfs has been closed:
<*> Memory Technology Device (MTD) Support--->
OpenWrt specific MTD Options--->
[*] Automatically set ' Rootfs ' partition to be root filesystem
In OpenWrt's menuconfig, USB storage support has been added.
Where is the problem? Will not be in the setting Rootfs time, the storage driver has not loaded yet.
Some kernel need to refer to this article: HTTPS://GITHUB.COM/8DEVICES/U-BOOT/ISSUES/3