uboot修改传递给内核的cmdline的方法:
1.setenv bootargs
| /*将数组转化为字符串*/ printf("setenv ipaddr!\n"); ip4s_to_string(ip_addr_local,ip_addr_local_str); puts(ip_addr_local_str); printf("\n"); /*设置ipaddr*/ //env_set("ipaddr",ip_addr_local_str); strcpy(str,"setenv ipaddr "); strcat(str,ip_addr_local_str); result = run_command(str,0); |
2.如何uboot使用了设备树,可以解析设备树中的bootargs节点,并对其进行编辑。
#include <common.h> extern unsigned int xilinx_ID; #ifdef CONFIG_OF_BOARD_SETUP strcat(addstr,U_BOOT_VERSION); /* find or create "/chosen" node. */ //printf(" addstr = %s len=%d\n",addstr,strlen(addstr)); return 0; |