Rockchip Uboot 环境变量工具使用
- 用于管理环境变量的工具为 fw_printenv 和 fw_setenv,这两个工具为同一个程序。
编译
- 进入 uboot 源码目录,执行命令
./make.sh env
即可完成编译。 - 编译产物位于目录
tools/env/fw_printenv
。
配置文件
-
配置文件名:fw_env.config
-
配置文件内容:
# Configuration file for fw_(printenv/setenv) utility. # Up to two entries are valid, in this case the redundant # environment sector is assumed present. # Notice, that the "Number of sectors" is not required on NOR and SPI-dataflash. # Futhermore, if the Flash sector size is omitted, this value is assumed to # be the same as the Environment size, which is valid for NOR and SPI-dataflash # Device offset must be prefixed with 0x to be parsed as a hexadecimal value. # /dev/mmcblk0 为存储环境变量的块设备名 # 0x3f8000 为存储环境变量的偏移值,字节为单位,需与 menuconfig 中 Environment -> Environment offset 值一致 # 0x80000 为环境变量的大小,字节为单位,需与 menuconfig 中 Environment -> Environment size 值一致 /dev/mmcblk0 0x3f8000 0x80000
安装
- 拷贝
fw_printenv
至开发板/usr/bin
目录。 - 执行命令
cp /usr/bin/fw_printenv /usr/bin/fw_setenv
,安装 fw_setenv 命令。 - 拷贝
fw_env.config
至开发板/etc
目录。
使用
-
查看环境变量的值:
# 语法:fw_printenv 变量名 # 举例:参看 bootargs 的值 fw_printenv bootargs
-
设置环境变量的值:
# 语法:fw_setenv 变量名 变量值 # 举例:设置 devnum 为 1 fw_setenv devnum 1
注意事项
- 当更新了 uboot 相关镜像之后。fw_printenv 以及 fw_setenv 也需要重新编译及安装。不然,会导致环境变量的读写不正确。