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

1,763 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
6 Replies

1,696 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

1,506 Views
vopal
Contributor I

If you carefully read the u-boot documentation, you'll find that u-boot provides a complete solution. During u-boot compilation, `make u-boot-initial-env` generates default u-boot environment variables. `fw_printenv`/`fw_setenv` can use the `-f` parameter on the first run to access this default u-boot environment variable file. This is also the method used by swupate on its first run.

0 Kudos
Reply

1,495 Views
vopal
Contributor I

If I remember correctly, yocto generates a default environment variable file for u-boot by default.

0 Kudos
Reply

1,486 Views
vopal
Contributor I
0 Kudos
Reply

1,646 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%3CLINGO-SUB%20id%3D%22lingo-sub-2267750%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-2267750%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EIf%20I%20remember%20correctly%2C%20yocto%20generates%20a%20default%20environment%20variable%20file%20for%20u-boot%20by%20default.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2267764%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-2267764%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F224056%22%20target%3D%22_blank%22%3E%40kartheek%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20link%20is%20helpful.%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fi-MX-Processors-Knowledge-Base%2Fu-boot-environment-preset-for-sdcard-mirror%2Fta-p%2F1702549%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fi-MX-Processors-Knowledge-Base%2Fu-boot-environment-preset-for-sdcard-mirror%2Fta-p%2F1702549%3C%2FA%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2267716%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-2267716%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EIf%20you%20carefully%20read%20the%20u-boot%20documentation%2C%20you'll%20find%20that%20u-boot%20provides%20a%20complete%20solution.%20During%20u-boot%20compilation%2C%20%60%3CSTRONG%3Emake%20u-boot-initial-env%3C%2FSTRONG%3E%60%20generates%20default%20u-boot%20environment%20variables.%20%60fw_printenv%60%2F%60fw_setenv%60%20can%20use%20the%20%60-f%60%20parameter%20on%20the%20first%20run%20to%20access%20this%20default%20u-boot%20environment%20variable%20file.%20This%20is%20also%20the%20method%20used%20by%20swupate%20on%20its%20first%20run.%3C%2FP%3E%3C%2FLINGO-BODY%3E