The method of uboot to modify the cmdline passed to the kernel:
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. How uboot uses the device tree, you can parse the bootargs node in the device tree and edit it.
#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; |