【openwrt】UBOOT传递参数到内核parameters

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;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值