Steps for Reading and Modifying U-Boot Environment Variables at the Kernel Stage

Forlinx

Apr 23, 2023
107
Joined
Apr 23, 2023
Messages
107
1. Compile the fw_printenv tool


Execute under the uboot source path, and then generate the executable file of the fw _ printenv under tools/env.

. /opt/fsl-imx-x11/4.1.15-2.0.0/environment-setup-cortexa7hf-neon-poky-linux-gnueabimake env


2. Configure fw_env.config file


Modify the fw_env.config file under tools/env in the uboot source directory according to the mtd partition, the location and size of the UBOOT environment variables, etc. See the instructions in the fw_env.config file and the /tools/env/README file for specific modifications.

Among them, Device offset, Env size, and Flash sector size should correspond respectively to the three macro definitions CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, and CONFIG_ENV_SECT_SIZE in the include/configs/xxxx.h file in the U-Boot source code directory.

vi include/configs/mx6ul_14x14_evk.h

Take the test 256nand as an example:

file.php


CONFIG_ENV_OFFSET = 0x600000

ONFIG_ENV_SECT_SIZE = 0x20000

file.php


Open the tools/env/fw_env.config and modify as shown in the following figures:

file.php


Take the test 1gnand as an example:

file.php


CONFIG_ENV_OFFSET = 0x1000000

ONFIG_ENV_SECT_SIZE = 0x20000

file.php


nand model number MT29F8G08ABACA

file.php


Refer to the manual to change the ENV_SECT_SIZE value to 256K.

file.php


Open the tools/env/fw_env.config and modify as shown in the following figures:

file.php


nand model number MT29F8G08ABABA

file.php


Refer to the manual to change the ENV_SECT_SIZE value to 512K.

file.php


Open the tools/env/fw_env.config and modify as shown in the following figures:

file.php



3. Copy the file


Copy tools/env/fw_env.config to the /etc path of the development board;

Copy tools/env/fw_printenv to the root file system of the development board under the path /usr/bin.

And create a soft link to fw_setenv ln -s /usr/bin/fw_printenv /usr/bin/fw_setenv


4. Read and write environment variable test


Read environment:

file.php


Write environment variable:

file.php


The uboot phase has been modified synchronously.

file.php



5. Problems and solutions


Problem: make env reports an error in the uboot source code

file.php


Solution: Comment out the CC in the top-level Makefile and use the environment variable in the CC.

file.php


 
Top