uboot 传递参数给 kernel 内核

uboot通过环境变量 bootargs 传递参数给 kernel 内核,bootargs存储在设备树的 chosen 节点中,则 kernel 内核是通过读取设备树的 chosen 节点中的 bootargs 属性获取 uboot 传递过来的参数。

 

U_BOOT_CMD(
    bootz,  CONFIG_SYS_MAXARGS, 1,  do_bootz,
    "boot Linux zImage image from memory", bootz_help_text
);
bootz ${loadaddr} - ${fdt_addr}
do_bootz()---> do_bootm_states() ---> bootm_os_get_boot_func()(得到函数do_bootm_linux())boot_fn()(实际就是函数do_bootm_linux()) ---> boot_prep_linux() ---> image_setup_linux() ---> image_setup_libfdt() ---> fdt_chosen()
在函数 fdt_chosen() 函数中,读取环境变量 bootargs 的值,并设置到设备树的 chosen 节点下
 
 
bootargs 内容包括:
1、设置控制台 console 用哪个
2、设置根文件系统在哪个存储设备的哪个分区
 
 
posted @ 2023-01-15 18:36  流水灯  阅读(954)  评论(0编辑  收藏  举报