Building fw printenv and fw setenv
2015-11-03 17:04
218 查看
Building fw printenv and fw setenv
[hide] |
[edit]Overview
You can access and change the U-Boot environment from Linux userspace using the "U-Boot tools" fw_printenv and fw_setenv, which you can build from the current U-Boot sourceand install on the target system. You can see the source for those in the U-Boot source directory, under tools/env/.
[edit]Building
the tools
From the top of the U-Boot source code, you need to explicitly identify the GCC cross-compiler you want to use for the build, as in (for example):$ make HOSTCC=arm-arago-linux-gnueabi-gcc env
This will create the cross-compiled executable tools/env/fw_printenv. Note that the Makefile will also try to strip that executable but the README file fails to mention that you'd
need to also identify the cross-compile version of the strip command, as in HOSTSTRIP=arm-arago-linux-gnueabi-strip. That's not a fatal problem since stripping the executable is optional, so that's up to you.
[edit]Installing
the executable(s) and config file
The resulting executable fw_printenv actually does double duty for both printing and setting U-Boot environment variables, so you need to install it in the root filesystem and createan additional symlink to it on the target system. For example (assuming you're logged into the target):
# cd /usr/bin # ... copy fw_printenv here # ln -s fw_printenv fw_setenv
Now you can run that single executable by either name and it will do the right thing.
[edit]Creating
the config file
Finally, you need to create the U-Boot environment config file /etc/fw_env.config file on the target system which identifies the properties of the U-Boot environment flash partition.A sample file is in the U-Boot tools/env source directory and it should be fairly self-explanatory. In my case, since the U-Boot environment was in the very first NAND flash partition and was 128K in size with a flash sector size also of 128K, my fw_env.config file
looked like:
# MTD device Offset Env size Flash sector size /dev/mtd0 0x0 0x20000 0x20000
[edit]Printing
the U-Boot environment
If all goes well, once you boot, you can list the U-Boot environment from Linux userspace:# fw_printenv DE:AD:BE:EF:01:02== ethaddr baudrate=115200 bootargs=console=ttyS2,115200n8 root=/dev/mtdblock5 rootfstype=jffs2 ip=off bootcmd=nand read C0700000 200000 300000; bootm C0700000 bootdelay=10 bootfile="uImage" davinci_emac.ethaddr=DE:AD:BE:EF:01:02 ethact=DaVinci-EMAC ethaddr=DE:AD:BE:EF:01:02 fileaddr=C0700000 filesize=21362C ipaddr=192.168.3.12 serverip=192.168.3.2 stderr=serial stdin=serial stdout=serial #
and use fw_setenv to change it as well.
[edit]Changing
U-Boot environment variables with fw_setenv
Pretty straightforward, but you need to make sure the U-Boot environment partition in flash isn't set as write-protected in your kernel partition table; otherwise, any attempt to change environmentinformation will give you a permission violation. You can still use fw_printenv to list it, of course.
相关文章推荐
- Web Service单元测试工具实例介绍之SoapUI
- Easyui的一些简单用法
- 关于论文Silhouteete-based human action recognition using sequences of key poses
- ios UITextView的placeHolder的设置
- easyUI datagrid导出excel(所见即所得)
- Codeforces Round #328 (Div. 2)B. The Monster and the Squirrel
- UITableView和UITableViewCell 图解
- Android设计模式源码解析之Builder模式
- NavigationController界面跳转,UITableView基本用法
- gitlab Sign in 报错:You have to confirm your account before continuing.
- Zoho Recruit助人力外包公司提供满意服务
- Servlet、Request、Response、filter、listener
- django 与 百度 ueditor 富文本编辑器集成
- iOS开发UI中懒加载的使用方法
- [MySQL FAQ]系列 — 线上环境到底要不要开启query cache
- Frequency Distribution
- easyUI,递归tree
- hdu 1711 Number Sequence
- UICollectionView(二)自定义布局UICollectionViewLayout
- 设置segue跳转页面