
如何存取和更改 linux 中的 u-Boot 環境變數。使用u boot目錄中的u-boot/tools/env目錄:
u-boot$ make env
其中創建了可執行檔fw_printenv
。我將其複製到 /usr/sbin 和目標 etc/fw_env.config 檔案上:
# Configuration file for fw_(printenv/saveenv) utility.
# Up to two entries are valid, in this case the redundand
# environment sector is assumed present.
# MTD device name Device offset Env. size Flash sector size
/dev/mtd0 0x00000 0x20000 0x20000
target#./fw_printenv
SEGV
是什麼導致了這個錯誤?
/proc/mtd
dev: size erasesize name
mtd0: 00020000 00020000 "flash_uboot_env"
mtd1: 002e0000 00020000 "flash_linux_image"
mtd2: 00900000 00020000 "flash_jffs2"
mtd3: 00900000 00020000 "flash_data"
答案1
你的fw_env.config
和我的不一樣。我的 u-boot 環境位於 0x00260000-0x00280000 範圍內。我記得,fw_env 檔案非常敏感,如果您忘記了某些列,fw_setenv 將回退到某個預設值,這可能會導致各種奇怪的錯誤。
僅供參考,這是我的 fw_env.config
root@linux:~# cat /etc/fw_env.config
# Dev. name offset env. size flash sector size nbr. sectors
/dev/mtd1 0x00 0x2000 0x20000 1
您可以交叉編譯strace
並使用它來進行故障排除。