unable to set environment variable in compile time of uBoot

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

unable to set environment variable in compile time of uBoot

跳至解决方案
2,869 次查看
aravindchakrava
Contributor II

Hi, 

I am trying to bring net-console in uboot. For that, I first added 'ncip' in "uboot-imx/include/configs/imx8mm_evk.h" as following. Later, DFMC_SWUG is called at the end of CONFIG_EXTRA_ENV_SETTINGS

 

#define DFMC_SWUG \
	"setenv ncip 192.168.100.98 \0" \
	"ethaddr=00:80:A3:CA:B5:77 \0" \
	"swugip=192.168.100.16 \0" \
	"ipaddr=192.168.100.2 \0" \
	"serverip=192.168.100.16 \0" \
	"bootdelay=3\0" \

 

 

 

#define CONFIG_EXTRA_ENV_SETTINGS		\
	CONFIG_MFG_ENV_SETTINGS \
	JAILHOUSE_ENV \
	"script=boot.scr\0" \
	--
        --
        --
        "fi;\0" \
        DFMC_SWUG

 

 

 Interestingly, I was able to set 'ethaddr', "swugip" and other variables except "ncip". I guess, I am doing some formatting mistakes in line --> "setenv ncip 192.168.100.98 \0" \

Later I tried setting some dummy variables named dummy_var_1dummy_var_2, dummy_var_3. Even they are not getting set. 

aravindchakrava_1-1638967803130.png

Can some one please guide me here?

Regards, 

Aravind

 

标签 (2)
标记 (2)
0 项奖励
回复
1 解答
2,843 次查看
BiyongSUN
NXP Employee
NXP Employee

 

my colleague has given you very clear example.

you use the "setenv ncip 192.168.100.98" in imx8mm_evk.h 

because you think you are still at runtime in front of i.mx8mm board's debug console. and type the command

"setenv ncip 192.168.100.98" to change the variable ncip using setenv command. 

now you are at compile time, you should use the "=" as my colleague's previous reply. 

in the header file imx8mm_evk.h , you should use "ncip=192.168.100.98".

If you want to use the command, you should create your own command then chain to the bootcmd.

like this,  "set_ncip=setenv ncip 192.168.100.98". then use the "run set_ncip" in bootcmd chain.

or directly use setenv ncip 192.168.100.98  in bootcmd. 

u-boot only runs bootcmd. and like mmcboot is in the chain of the bootcmd. 

 

run mmcargs  of mmc boot is an example 

 

"mmcargs=setenv bootargs ${jh_clk} console=${console} root=${mmcroot}\0 " \
"loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${bsp_script};\0" \
"bootscript=echo Running bootscript from mmc ...; " \
"source\0" \
"loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}\0" \
"loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr_r} ${fdtfile}\0" \
"mmcboot=echo Booting from mmc ...; " \
"run mmcargs; " \
"if test ${boot_fit} = yes || test ${boot_fit} = try; then " \

 

 

在原帖中查看解决方案

5 回复数
2,853 次查看
AldoG
NXP TechSupport
NXP TechSupport

Hello,

I think you shouldn’t use setenv and just create the variable as is, i.e.

#define DFMC_SWUG \
        "ncip=192.168.100.98 \0" \
        "ethaddr=00:80:A3:CA:B5:77 \0" \
        "swugip=192.168.100.16 \0" \
        "ipaddr=192.168.100.2 \0" \
        "serverip=192.168.100.16 \0" \
        "bootdelay=3\0" \

Best regards,
Aldo.

0 项奖励
回复
2,825 次查看
aravindchakrava
Contributor II

Hi Aldo, 

Thank you very much! It worked!

- Aravind

2,857 次查看
aravindchakrava
Contributor II

Basically my requirement is to bring 'netconsole' straight after u-boot booting. I will not have serial cable in the end product.

0 项奖励
回复
2,844 次查看
BiyongSUN
NXP Employee
NXP Employee

 

my colleague has given you very clear example.

you use the "setenv ncip 192.168.100.98" in imx8mm_evk.h 

because you think you are still at runtime in front of i.mx8mm board's debug console. and type the command

"setenv ncip 192.168.100.98" to change the variable ncip using setenv command. 

now you are at compile time, you should use the "=" as my colleague's previous reply. 

in the header file imx8mm_evk.h , you should use "ncip=192.168.100.98".

If you want to use the command, you should create your own command then chain to the bootcmd.

like this,  "set_ncip=setenv ncip 192.168.100.98". then use the "run set_ncip" in bootcmd chain.

or directly use setenv ncip 192.168.100.98  in bootcmd. 

u-boot only runs bootcmd. and like mmcboot is in the chain of the bootcmd. 

 

run mmcargs  of mmc boot is an example 

 

"mmcargs=setenv bootargs ${jh_clk} console=${console} root=${mmcroot}\0 " \
"loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${bsp_script};\0" \
"bootscript=echo Running bootscript from mmc ...; " \
"source\0" \
"loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}\0" \
"loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr_r} ${fdtfile}\0" \
"mmcboot=echo Booting from mmc ...; " \
"run mmcargs; " \
"if test ${boot_fit} = yes || test ${boot_fit} = try; then " \

 

 

2,820 次查看
aravindchakrava
Contributor II

Hi BiyongSUN,

You caught my mistake!! You are absolutely correct. 

I was thinking that, the commands/statements entered in between Quotation marks ("   ") gets executed during run time! 

But your answer helped me! 

Thanks, 

Aravind

0 项奖励
回复