Access u-boot varibale from linux user space

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

Access u-boot varibale from linux user space

231 Views
kartheek
Contributor III

Hi,

Processor: IMX8M PLUS

Yocto : 5.15-kirkstone

While booting through SD card able to access fw_printenv/setenv by adding below line in image recipe of yocto build.

IMAGE_INSTALL += " u-boot-fw-utils"

u-boot configuration is as below.

CONFIG_ENV_SIZE=0x80000
CONFIG_ENV_OFFSET=0x380000
CONFIG_ENV_IS_NOWHERE=y
CONFIG_ENV_IS_IN_MMC=y
CONFIG_SYS_MMC_ENV_DEV=1
CONFIG_SYS_MMC_ENV_PART=0

 

 

 But when executing those commands on target gives below error.

~# fw_printenv
Configuration file wrong or corrupted

 
Kindly suggest a procedure to make fw_printenv/setenv work.

Thanks,
Kartheek

0 Kudos
Reply
3 Replies

165 Views
kartheek
Contributor III

Hi,

After configuring fw_env.config in etc folder and running saveenv in U-Boot, I can access U-Boot environment variables from Linux user space.

However, we plan to remove the serial debugger later. In that case, we won’t be able to execute saveenv at the U-Boot prompt. Is there a way to automatically save the environment during the boot process?

Thanks,
Kartheek

0 Kudos
Reply

115 Views
Zhiming_Liu
NXP TechSupport
NXP TechSupport

Hi,

You can define a command in uboot env, then run it in mmcboot(include/configs/<board>.h).


Best Regards,
Zhiming

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2263773%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EAccess%20u-boot%20varibale%20from%20linux%20user%20space%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2263773%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3EProcessor%3A%20%3CSTRONG%3EIMX8M%20PLUS%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EYocto%20%3A%20%3CSTRONG%3E5.15-kirkstone%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EWhile%20booting%20through%20SD%20card%20able%20to%20access%20fw_printenv%2Fsetenv%20by%20adding%20below%20line%20in%20image%20recipe%20of%20yocto%20build.%3C%2FP%3E%3CPRE%3E%3CSPAN%20class%3D%22%22%3EIMAGE_INSTALL%20%2B%3D%20%22%20u-boot-fw-utils%22%3C%2FSPAN%3E%3C%2FPRE%3E%3CP%3Eu-boot%20configuration%20is%20as%20below.%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3ECONFIG_ENV_SIZE%3D0x80000%0ACONFIG_ENV_OFFSET%3D0x380000%0ACONFIG_ENV_IS_NOWHERE%3Dy%0ACONFIG_ENV_IS_IN_MMC%3Dy%0ACONFIG_SYS_MMC_ENV_DEV%3D1%0ACONFIG_SYS_MMC_ENV_PART%3D0%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CP%3E%26nbsp%3BBut%20when%20executing%20those%20commands%20on%20target%20gives%20below%20error.%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E~%23%20fw_printenv%0AConfiguration%20file%20wrong%20or%20corrupted%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3CBR%20%2F%3EKindly%20suggest%20a%20procedure%20to%20make%26nbsp%3Bfw_printenv%2Fsetenv%20work.%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%2C%3CBR%20%2F%3EKartheek%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2264347%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Access%20u-boot%20varibale%20from%20linux%20user%20space%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2264347%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%3CBR%20%2F%3E%3CBR%20%2F%3EPlease%20refer%20patch%20here.%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fnxp-imx-support%2Fmeta-swupdate-imx%2Fblob%2Fkirkstone_5.15.71_2.2.0%2Frecipes-bsp%2Fu-boot%2Ffiles%2F0001-enable-env_redunand-bootcount-limit-LF_v5.15.71-2.2.0.patch%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fnxp-imx-support%2Fmeta-swupdate-imx%2Fblob%2Fkirkstone_5.15.71_2.2.0%2Frecipes-bsp%2Fu-boot%2Ffiles%2F0001-enable-env_redunand-bootcount-limit-LF_v5.15.71-2.2.0.patch%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fnxp-imx-support%2Fmeta-swupdate-imx%2Fblob%2Fkirkstone_5.15.71_2.2.0%2Frecipes-bsp%2Fu-boot%2Fu-boot-imx_%2525.bbappend%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fnxp-imx-support%2Fmeta-swupdate-imx%2Fblob%2Fkirkstone_5.15.71_2.2.0%2Frecipes-bsp%2Fu-boot%2Fu-boot-imx_%2525.bbappend%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3EBest%20Regards%2C%3CBR%20%2F%3EZhiming%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2265712%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Access%20u-boot%20varibale%20from%20linux%20user%20space%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2265712%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CSPAN%3EHi%2C%3C%2FSPAN%3E%3C%2FP%3E%3CDIV%3E%3CP%3EAfter%20configuring%20fw_env.config%20in%20etc%20folder%20and%20running%20saveenv%20in%20U-Boot%2C%20I%20can%20access%20U-Boot%20environment%20variables%20from%20Linux%20user%20space.%3C%2FP%3E%3CP%3EHowever%2C%20we%20plan%20to%20remove%20the%20serial%20debugger%20later.%20In%20that%20case%2C%20we%20won%E2%80%99t%20be%20able%20to%20execute%20saveenv%20at%20the%20U-Boot%20prompt.%20Is%20there%20a%20way%20to%20automatically%20save%20the%20environment%20during%20the%20boot%20process%3F%3C%2FP%3E%3CP%3EThanks%2C%3CBR%20%2F%3EKartheek%3C%2FP%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2266405%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Access%20u-boot%20varibale%20from%20linux%20user%20space%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2266405%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%3C%2FP%3E%0A%3CP%3EYou%20can%20define%20a%20command%20in%20uboot%20env%2C%20then%20run%20it%20in%20%3CSTRONG%3Emmcboot%3C%2FSTRONG%3E(include%2Fconfigs%2F%3CBOARD%3E.h).%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3EBest%20Regards%2C%3CBR%20%2F%3EZhiming%3C%2FBOARD%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E