1. fw_printenv & fw_setenv
build,
see: u-boot-2020.04/tools/env/README
cd u-boot-2020.04
make CROSS_COMPILE=arm-linux- envtools
You should then create a symlink from fw_setenv to fw_printenv.
2. test
2.1 read
2.2 write
会自动保存到emmc/flash中
3. config
3.1 emmc
vi /etc/fw_env.config
可以选择保存env的设备和分区,如使用/dev/mmcblk0p7作为env分区
env分区为mmcblk0p7,offset为0,size为1024k(0x100000)
3.2 nor
使用nor mtd4作为env分区
vi /etc/fw_env.config
4. code
4.1 fw_printenv
u-boot-2020.04\tools\env\fw_env_main.c
main -> fw_printenv -> fw_env_open -> flash_io -> open & flash_read -> flash_read_buf -> read ---> emmc/nor flash
4.2 fw_setenv
u-boot-2020.04\tools\env\fw_env_main.c
1)emmc
main -> fw_env_set -> fw_env_flush -> flash_io(O_RDWR) -> open & flash_io_write -> flash_write -> flash_write_buf -> write ---> emmc
2)nor flash
main -> fw_env_set -> fw_env_flush -> flash_io(O_RDWR) -> open & flash_io_write -> flash_write -> flash_write_buf -> ioctl(fd, MEMERASE, &erase) & write ---> nor flash
标签:uboot,io,fw,flash,write,env,linux,main,环境变量 From: https://blog.csdn.net/u012247418/article/details/142443553