uboot 下脚本的开发
来源:互联网 发布:输入字符串统计java 编辑:程序博客网 时间:2024/05/18 01:28
首先在Linux环境创建一个文本文件,在该文件中写好要一起执行的命令,编写的格式和uboot命令行模式下的输入的命令一样。编写完成之后命名成.script文件,例如example.script。
然后将脚本制作成映像文件。使用uboot/tools/下的mkimage命令制作映像。例如mkimage -A ARM -O linux -T script -C none -a 0 -e 0 -n"example script" -d /home/zhangli/example.script example.img。
参数定义如下:
-A,指定目标映像的体系结构,本实验中是ARM
-O,指定目标映像的操作系统,本实验中是Linux;
-T,指定目标映像的类型,本实验中是脚本;
-C,指定目标映像的压缩类型,脚本不需要压缩,none;
-a,设置U-Boot的加载地址(loadaddress),本实验中设为0;
-e,设置U-Boot映像的入口点(entry point)地址,设为0,即从脚本的起始地方开始执行;
-n,设置映像的名称;
-d,制作映像的脚本文件
最后是生成的映像的文件名。参数具体的可选项可以参见http://bbs.chinaunix.net/archiver/?tid-1988490.html。在本实验中,执行上述mkimage命令,会得到如下信息:
接下来将制作好的映像(例如,example.img)下载到开发板上(本实验中使用的是DM355),并运行脚本。下载是使用tftp下载,下面以本实验为对命令进行说明。命令如下(加粗的是输入的):
DM355 IPNCVCA1 # tftp 0x82a00000 example.img //将镜像下载到内存的0x82a00000位置
Found DM9000 ID:90000a46 at address 4000000 !
DM9000 work in 16 bus width
[eth_init]MAC:0:11:22:33:44:55:
TFTP from server 10.10.104.251; our IPaddress is 10.10.104.116
Filename 'example.img'.
Load address: 0x82a00000
Loading: T #
done
Bytes transferred = 133 (85 hex)
DM355 IPNCVCA1 # autoscr 0x82a00000 //执行脚本映像,从内存0x82a00000开始运行
## Executing script at 0x82a00000
ipaddr=10.10.104.116 //脚本的内容,显示环境变量
ipaddr=10.10.104.116
以上是通过两条命令的执行运行脚本的。Uboot中可以自定义环境变量,将以上两条命令放到一个环境变量中,然后运行该环境变量即可。命令如下:
DM355 IPNCVCA1 # setenv testscript 'tftp 0x82a00000example.img;autoscr 0x82a00000'
DM355 IPNCVCA1 # saveenv
Saving Environment to NAND...
Erasing Nand...Writing to Nand... done
DM355 IPNCVCA1 # run testscript
Found DM9000 ID:90000a46 at address 4000000 !
DM9000 work in 16 bus width
[eth_init]MAC:0:11:22:33:44:55:
TFTP from server 10.10.104.251; our IPaddress is 10.10.104.116
Filename 'example.img'.
Load address: 0x82a00000
Loading: *T #
done
Bytes transferred = 133 (85 hex)
## Executing script at 80700000
ipaddr=10.10.104.116
ipaddr=10.10.104.116
上面所述的下载下来的脚本映像是放在内存中的,断电之后,再次运行就又需要重新下载,每次都这样十分麻烦,所以将脚本映像存到nand中,运行时再加载到内存。实现的命令如下:
DM355 IPNCVCA1 # tftp 0x82a00000example.img
DM355 IPNCVCA1 # nand write 0x82a000000xf00000 0x80000 //将内存0x82a00000位置开始 写到nand的0xf00000,长度为0x80000(这里的长度根据img文件的大小而定)
DM355 IPNCVCA1 #nand read 0x82a00000 0xf00000 0x80000 //将nand的内容读到内存中
NAND read: device 0 offset 0xf00000, size0x80000
524288 bytes read: OK
DM355 IPNCVCA1 # autoscr 0x82a00000
## Executing script at 82a00000
ipaddr=10.10.104.116
ipaddr=10.10.104.116
DM355 IPNCVCA1 # setenv testscript 'nand read 0x82a00000 0xf00000 0x80000;autosc
r0x82a00000'
DM355 IPNCVCA1 # printenv testscript //查看环境变量的值
testscript=nand read 0x82a00000 0xf00000 0x80000;autoscr 0x82a00000
DM355 IPNCVCA1 # saveenv
Saving Environment to NAND...
Erasing Nand...Writing to Nand... done
重新启动开发板:
Hit any key to stop autoboot: 0
DM355 IPNCVCA1 # run testscript //运行环境变量
NAND read: device 0 offset 0xf00000, size0x80000
524288 bytes read: OK
## Executing script at 82a00000
ipaddr=10.10.104.116
ipaddr=10.10.104.116
参考网址:http://blog.chinaunix.net/space.php?uid=20546441&do=blog&id=350968
版权声明:本文为博主原创文章,未经博主允许不得转载。
- uboot 下脚本的开发
- uboot 下脚本的开发
- uboot 下脚本的开发
- linux下脚本的创建
- tomcat的bin目录下脚本
- cocos2dx安卓平台下脚本开发和交叉编译
- windows下脚本若干问题
- ubuntu下脚本基础
- ie7下脚本添加的样式不生效问题
- Linux下脚本yifei.py权限rx的分析总结
- Linux系统下脚本对虚拟机的安装重置
- Unity Animation 录制模式下脚本修改值的问题
- 浅析linux下脚本拨号上网
- linux下脚本中多行注释
- linux 下脚本运行php
- linux下脚本书写注意事项
- ubuntu下脚本学习记录
- Linux下脚本对拍
- Apache Web Server -> httpd 的长连接配置
- 修改 Windows 8.1 的默认字体
- Leetcode #49 Anagrams
- 每天一个Linux命令-8(tar及解压缩相关命令)
- 算法导论 第二十二章:图的搜索
- uboot 下脚本的开发
- debian linux vitualbox 虚拟机镜像 vdi 下载集合
- 这是第一篇博客
- redhat linux vitualbox 虚拟机镜像 vdi 下载集合
- 嵌入式linux中的dhcp服务器
- 基于HT for Web矢量实现2D叶轮旋转
- redhat 9 vitualbox 虚拟机镜像 vdi 下载
- MKVToolNix v8.2
- linux mint vitualbox 虚拟机镜像 vdi 下载集合