unable to set environment variable in compile time of uBoot

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

unable to set environment variable in compile time of uBoot

Jump to solution
2,159 Views
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

 

Labels (2)
Tags (2)
0 Kudos
1 Solution
2,133 Views
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 " \

 

 

View solution in original post

5 Replies
2,143 Views
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 Kudos
2,115 Views
aravindchakrava
Contributor II

Hi Aldo, 

Thank you very much! It worked!

- Aravind

2,147 Views
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 Kudos
2,134 Views
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,110 Views
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 Kudos