In some cases, such as mass production or preparing a demo.
We need u-boot environment stored in demo sdcard mirror image.
Here is a way:
HW: i.MX8MP evk
SW: LF_v5.15.52-2.1.0_images_IMX8MPEVK.zip
The idea is to use fw_setenv to set the sdcard mirror as the operation on a real emmc/sdcard.
Add test=ABCD in u-boot-initial-env for test purpose.
And use fw_printenv to check and use hexdump to double confirm it.
The uboot env is already written into sdcard mirror(imx-image-multimedia-imx8mpevk.wic).
All those operations are on the host x86/x64 PC.
./fw_setenv -c fw_env.config -f u-boot-initial-env
Environment WRONG, copy 0
Cannot read environment, using default
./fw_printenv -c fw_env.config
Environment OK, copy 0
jh_root_dtb=imx8mp-evk-root.dtb
loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${bsp_script};
mmc_boot=if mmc dev ${devnum}; then devtype=mmc; run scan_dev_for_boot_part; fi
arch=arm
baudrate=115200
......
......
......
splashimage=0x50000000
test=ABCD
usb_boot=usb start; if usb dev ${devnum}; then devtype=usb; run scan_dev_for_boot_part; fi
vendor=freescale
hexdump -s 0x400000 -n 2000 -C imx-image-multimedia-imx8mpevk.wic
00400000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
hexdump -s 0x400000 -n 10000 -C imx-image-multimedia-imx8mpevk.wic
00400000 5f a4 9b 97 20 6a 68 5f 72 6f 6f 74 5f 64 74 62 |_... jh_root_dtb|
00400010 3d 69 6d 78 38 6d 70 2d 65 76 6b 2d 72 6f 6f 74 |=imx8mp-evk-root|
00400020 2e 64 74 62 00 20 6c 6f 61 64 62 6f 6f 74 73 63 |.dtb. loadbootsc|
00400030 72 69 70 74 3d 66 61 74 6c 6f 61 64 20 6d 6d 63 |ript=fatload mmc|
00400040 20 24 7b 6d 6d 63 64 65 76 7d 3a 24 7b 6d 6d 63 | ${mmcdev}:${mmc|
00400050 70 61 72 74 7d 20 24 7b 6c 6f 61 64 61 64 64 72 |part} ${loadaddr|
00400060 7d 20 24 7b 62 73 70 5f 73 63 72 69 70 74 7d 3b |} ${bsp_script};|
00400070 00 20 6d 6d 63 5f 62 6f 6f 74 3d 69 66 20 6d 6d |. mmc_boot=if mm|
......
......
......
00401390 76 3d 31 00 73 6f 63 3d 69 6d 78 38 6d 00 73 70 |v=1.soc=imx8m.sp|
004013a0 6c 61 73 68 69 6d 61 67 65 3d 30 78 35 30 30 30 |lashimage=0x5000|
004013b0 30 30 30 30 00 74 65 73 74 3d 41 42 43 44 00 75 |0000.test=ABCD.u|
004013c0 73 62 5f 62 6f 6f 74 3d 75 73 62 20 73 74 61 72 |sb_boot=usb star|
004013d0 74 3b 20 69 66 20 75 73 62 20 64 65 76 20 24 7b |t; if usb dev ${|
004013e0 64 65 76 6e 75 6d 7d 3b 20 74 68 65 6e 20 64 65 |devnum}; then de|
flash the sdcard mirror into i.MX8MP evk board emmc to check
uuu -b emmc_all imx-boot-imx8mp-lpddr4-evk-sd.bin-flash_evk imx-image-multimedia-imx8mpevk.wic
The first time boot, the enviroment is already there.
How to achieve that:
a. fw_setenv/fw_printenv:
https://github.com/sbabic/libubootenv.git
Note: Please do not use uboot fw_setenv/fw_printenv
Compile it on the host x86/x64 PC. It is used on host.
b. u-boot-initial-env
Under uboot, make u-boot-initial-env
Note: Yocto deploys u-boot-initial-env by default
c. fw_env.config
imx-image-multimedia-imx8mpevk.wic 0x400000 0x4000
0x400000 0x4000 are from uboot-imx\configs\imx8mp_evk_defconfig
CONFIG_ENV_SIZE=0x4000
CONFIG_ENV_OFFSET=0x400000
Now, you can run
./fw_setenv -c fw_env.config -f u-boot-initial-env