UBOOT系列文章
第二章 UBOOT参数传递
前言
Uboot向内核传递的方式有多种,这里介绍一种简单的参数传递方式,通过bootargs传递
一、为啥要uboot参数传递?
在某些时候,需要uboot通过bootargs参数传递给内核,然后通过传入的参数进行一些特殊的操作
二、操作方法
1.uboot更改
代码如下(示例):
static void boot_prep_linux(bootm_headers_t *images)
{
/*此处省略*/
board_prep_linux(images);
}
需自己更改添加一个board_prep_linux函数,进行参数传递
void board_prep_linux(bootm_headers_t *images)
{
void *fdt = images->ft_addr;
const char *orig_bootargs;
int nodeoffset, len;
char *new_cmdline;
u32 newlen;
int ret;
if (!(CONFIG_IS_ENABLED(OF_LIBFDT) && images->ft_len)) {
printf("Warning: no FDT present for current image!\n");
return;
}
/* find or create "/chosen" node. */
nodeoffset = fdt_find_or_add_subnode(fdt, 0, "chosen");
if (nodeoffset < 0)
return;