What should I do to use fw_printenv/setenv on imx8mm?

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

What should I do to use fw_printenv/setenv on imx8mm?

Jump to solution
1,766 Views
takeshi100
Contributor III

Hi!

What should I do to use fw_printenv/setenv on imx8mm?

【Conditions

・hardware: imx8mm(on custom board)

・bsp: imx 6.1.55-2.2.0

・base image: core-image-minimal
・IMAGE_INSTALL += "u-boot-fw-utils"
MACHINE = 'imx8mm-lpddr4-evk'

・boot storage:emmc

【log】

root@XXX:~# fw_printenv
Configuration file wrong or corrupted

root@XXX:~# strace fw_printenv
(omit)
openat(AT_FDCWD, "/etc/fw_env.config", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, "Configuration file wrong or corr"..., 38Configuration file wrong or corrupted
) = 38
exit_group(-9) = ?
+++ exited with 247 +++

root@XXX:~# fdisk -l
Disk /dev/mmcblk2: 7456 MB, 7818182656 bytes, 15269888 sectors
119296 cylinders, 4 heads, 32 sectors/track
Units: sectors of 1 * 512 = 512 bytes

Device Boot StartCHS EndCHS StartLBA EndLBA Sectors Size Id Type
/dev/mmcblk2p1 * 128,0,1 1023,3,32 16384 186775 170392 83.1M c Win95 FAT32 (LBA)
/dev/mmcblk2p2 1023,3,32 1023,3,32 196608 1596821 1400214 683M 83 Linux
/dev/mmcblk2p3 1023,3,32 1023,3,32 1605632 2968779 1363148 665M c Win95 FAT32 (LBA)
Disk /dev/mmcblk2boot0: 4 MB, 4194304 bytes, 8192 sectors
128 cylinders, 4 heads, 16 sectors/track
Units: sectors of 1 * 512 = 512 bytes

Disk /dev/mmcblk2boot0 doesn't contain a valid partition table
Disk /dev/mmcblk2boot1: 4 MB, 4194304 bytes, 8192 sectors
128 cylinders, 4 heads, 16 sectors/track
Units: sectors of 1 * 512 = 512 bytes

Disk /dev/mmcblk2boot1 doesn't contain a valid partition table

 

0 Kudos
Reply
1 Solution
1,648 Views
takeshi100
Contributor III

This problem is solved.

1. The following is set in the config of u-boot.
CONFIG_SYS_MMC_ENV_DEV=2
CONFIG_SYS_MMC_ENV_PART=2
CONFIG_ENV_OFFSET=0x0

2. The following is set in /etc/fw_env.config
/dev/mmcblk2boot1 0x0 0x4000

N.B.
- CONFIG_SYS_MMC_ENV_DEV=2 means that there are u-boot-env in the mmcblk2.
- CONFIG_SYS_MMC_ENV_PART=2 means that there are u-boot-env in the mmcblk2boot1.
- CONFIG_ENV_OFFSET=0x0 means that u-boot-env is putted on no offset of the mmcblk2boot1.
- 0x4000 is default value of CONFIG_ENV_SIZE in imx8mm-evk.
- However, you cannot use fw_printenv/fw_setenv unless you run saveenv once in uboot or write u-boot-imx-initial-env-sd to mmcblk2boot1, because nothing is set in mmcblk2boot1.

View solution in original post

0 Kudos
Reply
5 Replies
1,649 Views
takeshi100
Contributor III

This problem is solved.

1. The following is set in the config of u-boot.
CONFIG_SYS_MMC_ENV_DEV=2
CONFIG_SYS_MMC_ENV_PART=2
CONFIG_ENV_OFFSET=0x0

2. The following is set in /etc/fw_env.config
/dev/mmcblk2boot1 0x0 0x4000

N.B.
- CONFIG_SYS_MMC_ENV_DEV=2 means that there are u-boot-env in the mmcblk2.
- CONFIG_SYS_MMC_ENV_PART=2 means that there are u-boot-env in the mmcblk2boot1.
- CONFIG_ENV_OFFSET=0x0 means that u-boot-env is putted on no offset of the mmcblk2boot1.
- 0x4000 is default value of CONFIG_ENV_SIZE in imx8mm-evk.
- However, you cannot use fw_printenv/fw_setenv unless you run saveenv once in uboot or write u-boot-imx-initial-env-sd to mmcblk2boot1, because nothing is set in mmcblk2boot1.

0 Kudos
Reply
1,627 Views
tavim
Contributor I

You will face big problem saving env to eMMC boot partition than in user partition.

 

 

0 Kudos
Reply
1,615 Views
takeshi100
Contributor III

Hi, tavim.

Thanks for reply.
What kind of problem will be occurred?

0 Kudos
Reply
1,734 Views
Rita_Wang
NXP TechSupport
NXP TechSupport
0 Kudos
Reply
1,700 Views
takeshi100
Contributor III

I'm not sure where the address of uboot env is set...

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-1974088%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EWhat%20should%20I%20do%20to%20use%20fw_printenv%2Fsetenv%20on%20imx8mm%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1974088%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi!%3C%2FP%3E%3CP%3EWhat%20should%20I%20do%20to%20use%20fw_printenv%2Fsetenv%20on%20imx8mm%3F%3C%2FP%3E%3CP%3E%E3%80%90C%3CSPAN%3Eonditions%3C%2FSPAN%3E%E3%80%91%3C%2FP%3E%3CP%3E%E3%83%BBhardware%3A%20imx8mm(on%20custom%20board)%3C%2FP%3E%3CP%3E%E3%83%BBbsp%3A%20imx%206.1.55-2.2.0%3C%2FP%3E%3CP%3E%E3%83%BBbase%20image%3A%20core-image-minimal%3CBR%20%2F%3E%E3%83%BBIMAGE_INSTALL%20%2B%3D%20%22u-boot-fw-utils%22%3CBR%20%2F%3E%E3%83%BB%3CSPAN%3EMACHINE%3C%2FSPAN%3E%3CSPAN%3E%20%3D%20%3C%2FSPAN%3E%3CSPAN%3E'imx8mm-lpddr4-evk'%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%E3%83%BBboot%20storage%EF%BC%9Aemmc%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%E3%80%90log%E3%80%91%3C%2FSPAN%3E%3C%2FP%3E%3CP%3Eroot%40XXX%3A~%23%20fw_printenv%3CBR%20%2F%3EConfiguration%20file%20wrong%20or%20corrupted%3C%2FP%3E%3CP%3Eroot%40XXX%3A~%23%20strace%20fw_printenv%3CBR%20%2F%3E(omit)%3CBR%20%2F%3Eopenat(AT_FDCWD%2C%20%22%2Fetc%2Ffw_env.config%22%2C%20O_RDONLY)%20%3D%20-1%20ENOENT%20(No%20such%20file%20or%20directory)%3CBR%20%2F%3Ewrite(2%2C%20%22Configuration%20file%20wrong%20or%20corr%22...%2C%2038Configuration%20file%20wrong%20or%20corrupted%3CBR%20%2F%3E)%20%3D%2038%3CBR%20%2F%3Eexit_group(-9)%20%3D%20%3F%3CBR%20%2F%3E%2B%2B%2B%20exited%20with%20247%20%2B%2B%2B%3C%2FP%3E%3CP%3Eroot%40XXX%3A~%23%20fdisk%20-l%3CBR%20%2F%3EDisk%20%2Fdev%2Fmmcblk2%3A%207456%20MB%2C%207818182656%20bytes%2C%2015269888%20sectors%3CBR%20%2F%3E119296%20cylinders%2C%204%20heads%2C%2032%20sectors%2Ftrack%3CBR%20%2F%3EUnits%3A%20sectors%20of%201%20*%20512%20%3D%20512%20bytes%3C%2FP%3E%3CP%3EDevice%20Boot%20StartCHS%20EndCHS%20StartLBA%20EndLBA%20Sectors%20Size%20Id%20Type%3CBR%20%2F%3E%2Fdev%2Fmmcblk2p1%20*%20128%2C0%2C1%201023%2C3%2C32%2016384%20186775%20170392%2083.1M%20c%20Win95%20FAT32%20(LBA)%3CBR%20%2F%3E%2Fdev%2Fmmcblk2p2%201023%2C3%2C32%201023%2C3%2C32%20196608%201596821%201400214%20683M%2083%20Linux%3CBR%20%2F%3E%2Fdev%2Fmmcblk2p3%201023%2C3%2C32%201023%2C3%2C32%201605632%202968779%201363148%20665M%20c%20Win95%20FAT32%20(LBA)%3CBR%20%2F%3EDisk%20%2Fdev%2Fmmcblk2boot0%3A%204%20MB%2C%204194304%20bytes%2C%208192%20sectors%3CBR%20%2F%3E128%20cylinders%2C%204%20heads%2C%2016%20sectors%2Ftrack%3CBR%20%2F%3EUnits%3A%20sectors%20of%201%20*%20512%20%3D%20512%20bytes%3C%2FP%3E%3CP%3EDisk%20%2Fdev%2Fmmcblk2boot0%20doesn't%20contain%20a%20valid%20partition%20table%3CBR%20%2F%3EDisk%20%2Fdev%2Fmmcblk2boot1%3A%204%20MB%2C%204194304%20bytes%2C%208192%20sectors%3CBR%20%2F%3E128%20cylinders%2C%204%20heads%2C%2016%20sectors%2Ftrack%3CBR%20%2F%3EUnits%3A%20sectors%20of%201%20*%20512%20%3D%20512%20bytes%3C%2FP%3E%3CP%3EDisk%20%2Fdev%2Fmmcblk2boot1%20doesn't%20contain%20a%20valid%20partition%20table%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1974088%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3Ei.MX%208%20Family%20%7C%20i.MX%208QuadMax%20(8QM)%20%7C%208QuadPlus%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Ei.MX%208M%20%7C%20i.MX%208M%20Mini%20%7C%20i.MX%208M%20Nano%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ELinux%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EYocto%20Project%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1980689%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20What%20should%20I%20do%20to%20use%20fw_printenv%2Fsetenv%20on%20imx8mm%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1980689%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%20tavim.%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%20for%20reply.%3CBR%20%2F%3EWhat%20kind%20of%20problem%20will%20be%20occurred%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1980555%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20What%20should%20I%20do%20to%20use%20fw_printenv%2Fsetenv%20on%20imx8mm%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1980555%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EYou%20will%20face%20big%20problem%20saving%20env%20to%20eMMC%20boot%20partition%20than%20in%20user%20partition.%3C%2FP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1980174%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20What%20should%20I%20do%20to%20use%20fw_printenv%2Fsetenv%20on%20imx8mm%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1980174%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThis%20problem%20is%20solved.%3C%2FP%3E%3CP%3E1.%20The%20following%20is%20set%20in%20the%20config%20of%20u-boot.%3CBR%20%2F%3ECONFIG_SYS_MMC_ENV_DEV%3D2%3CBR%20%2F%3ECONFIG_SYS_MMC_ENV_PART%3D2%3CBR%20%2F%3ECONFIG_ENV_OFFSET%3D0x0%3CBR%20%2F%3E%3CBR%20%2F%3E2.%20The%20following%20is%20set%20in%20%2Fetc%2Ffw_env.config%3CBR%20%2F%3E%2Fdev%2Fmmcblk2boot1%200x0%200x4000%3CBR%20%2F%3E%3CBR%20%2F%3EN.B.%3CBR%20%2F%3E-%20CONFIG_SYS_MMC_ENV_DEV%3D2%20means%20that%20there%20are%20u-boot-env%20in%20the%20mmcblk2.%3CBR%20%2F%3E-%20CONFIG_SYS_MMC_ENV_PART%3D2%20means%20that%20there%20are%20u-boot-env%20in%20the%20mmcblk2boot1.%3CBR%20%2F%3E-%20CONFIG_ENV_OFFSET%3D0x0%20means%20that%20u-boot-env%20is%20putted%20on%20no%20offset%20of%20the%20mmcblk2boot1.%3CBR%20%2F%3E-%200x4000%20is%20default%20value%20of%20CONFIG_ENV_SIZE%20in%20imx8mm-evk.%3CBR%20%2F%3E-%20However%2C%20you%20cannot%20use%20fw_printenv%2Ffw_setenv%20unless%20you%20run%20saveenv%20once%20in%20uboot%20or%20write%20u-boot-imx-initial-env-sd%20to%20mmcblk2boot1%2C%20because%20nothing%20is%20set%20in%20mmcblk2boot1.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1977878%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20What%20should%20I%20do%20to%20use%20fw_printenv%2Fsetenv%20on%20imx8mm%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1977878%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI'm%20not%20sure%20where%20the%20address%20of%20uboot%20env%20is%20set...%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1974864%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20What%20should%20I%20do%20to%20use%20fw_printenv%2Fsetenv%20on%20imx8mm%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1974864%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EYou%20can%20refer%20to%20this%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fi-MX-Processors-Knowledge-Base%2FLinux-fw-printenv-fw-setenv-to-access-U-Boot-s-environment%2Fta-p%2F1121201%22%20target%3D%22_blank%22%3ELinux%20fw_printenv%20fw_setenv%20to%20access%20U-Boot's%20environment%20variables%20-%20NXP%20Community%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E