uboot命令集环境变量
文章目录
- 前言
- 命令集
- 环境变量
- uboot中对Flash和DDR的管理
前言
uboot的命令因为适配自己的硬件,基本都经过裁剪,所以自己的命令集和其用法可能会有缺失
uboot文章连载:
1.uboot命令集&环境变量
2.uboot配置,编译,移植
3.uboot启动过程
4.uboot命令体系
5.uboot的环境变量
6.uboot的驱动
7.uboot启动Linux内核
Linux文章连载
命令集
0.help
执行help或者?:打印所有命令
执行help[name]或者?[name]:打印此命令的帮助文档
命令集:
? - alias for 'help'
autoscr - run script from memory
base - print or set address offset
bdinfo - print Board Info structure
boot - boot default, i.e., run 'bootcmd'
bootd - boot default, i.e., run 'bootcmd'
bootelf - Boot from an ELF image in memory
bootm - boot application image from memory
bootp - boot image via network using BootP/TFTP protocol
bootvx - Boot vxWorks from an ELF image
cmp - memory compare
coninfo - print console devices and information
cp - memory copy
crc32 - checksum calculation
dcache - enable or disable data cache
dhcp - invoke DHCP client to obtain IP/boot params
dnw - initialize USB device and ready to receive for Windows server (specific)
echo - echo args to console
erase - erase FLASH memory
exit - exit script
ext2format - disk format by ext2
ext2load- load binary file from a Ext2 filesystem
ext2ls - list files in a directory (default /)
ext3format - disk format by ext3
fastboot- use USB Fastboot protocol
fatformat - disk format by FAT32
fatinfo - print information about filesystem
fatload - load binary file from a dos filesystem
fatls - list files in a directory (default /)
fdisk - fdisk for sd/mmc.
flinfo - print FLASH memory information
go - start application at address 'addr'
help - print online help
icache - enable or disable instruction cache
iminfo - print header information for application image
imls - list all images found in flash
imxtract- extract a part of a multi-image
itest - return true/false on integer compare
loadb - load binary file over serial line (kermit mode)
loads - load S-Record file over serial line
loady - load binary file over serial line (ymodem mode)
loop - infinite loop on address range
md - memory display
mm - memory modify (auto-incrementing)
MMC sub systemprint MMC informationmovi - sd/mmc r/w sub system for SMDK board
mtest - simple RAM test
mw - memory write (fill)
mycmd - print monitor version
nfs - boot image via network using NFS protocol
nm - memory modify (constant address)
ping - send ICMP ECHO_REQUEST to network host
printenv- print environment variables
protect - enable or disable FLASH write protection
rarpboot- boot image via network using RARP/TFTP protocol
reset - Perform RESET of the CPU
reginfo - print register information
reset - Perform RESET of the CPU
run - run commands in an environment variable
saveenv - save environment variables to persistent storage
sdfuse - read images from FAT partition of SD card and write them to booting device.
setenv - set environment variables
sleep - delay execution for some time
test - minimal test like /bin/sh
tftpboot- boot image via network using TFTP protocol
version - print monitor version
1.printenv/print 打印环境变量
2.set/setenv 设置环境变量,delete[name]删除环境变量=set [name] 空
设置环境变量到DRAM,要是需要设置到flash中需要使用save命令。save的过程:var保存到flash中:
3.save
4.fastboot:插上USB线
uboot上执行fastboot之后,接下来的所有命令都是在Windows上执行的:
最常用的三个命令:
查看设备:fastboot devices
烧录命令:
fastboot flash bootloader android2.3/uboot.bin 烧uboot
fastboot flash kernel android2.3/zImage 烧linux kernel
fastboot flash system android2.3/x210.img 烧rootfs
重启命令:fastboot reboot
5.ping:插上网线
uboot ping windows 结果:不通
注意Windows中有线网卡的地址设置(设置本地连接)。设置主机windows的本地连接IPv4地址为192.168.1.10。(网络->网络和共享中心->更改适配器设置(这里还可以看到VMWare的两个虚拟网卡)->以太网->属性->双击internet协议版本4->点击“使用下面的IP地址”->将IP地址设置为192.168.1.10)
确认开发板中uboot里几个网络相关的环境变量的值对不对。最重要的是ipaddr(这个环境变量表示当前开发板的IP地址),这个地址必须和主机windows的IP地址在同一个网段。
windows ping uboot
ping不了
uboot ping ubuntu 结果:通
ubuntu ping uboot 结果:通
开发板Linux ping windows 结果:通
在linux下使用ifconfig命令将开发板中linux系统的IP地址设置为和主机windows同一网段(我们这里设置:主机windows地址192.168.1.10,开发板uboot或linux的地址为192.168.1.20,虚拟机ubuntu地址为192.168.1.141)
将防火墙全部关掉。
windows ping 开发板Linux 结果:通
windows中打开cmd命令行。
开发板linux ping ubuntu 结果:通
虚拟机的网卡设置可以选择好几种方式,常用的就是NAT(虚拟机寄生在主机上,没有IP地址)和桥接(bridged,在外部看来相当于有两个主机)。
第一步:虚拟机设置成桥接方式。
第二步:虚拟机的菜单中有个“虚拟网络编辑器”,这里面要设置为桥接到有线网卡。
第三步:在虚拟机ubuntu中设置IP地址为192.168.1.141(可以通过/etc/network/interfaces文件来设置静态的然后重启;也可以直接命令行ifconfig去设置)
ubuntu ping 开发板linux 结果:通
步骤和上面一样
6.tftp
uboot从主机将kernel下载到开发板上,可以通过tftp或者fastboot
tftp方式下载时实际上uboot扮演的是tftp客户端程序角色,主机windows或虚拟机ubuntu中必须有一个tftp服务器。
检查开发板uboot的环境变量,注意serverip必须设置为虚拟机ubuntu的ip地址。然后在开发板的uboot下先ping通虚拟机ubuntu,然后再尝试下载:tftp 0x30000000 zImage-qt(在开发板上)(uboot内存地址从0x30000000~0x50000000)
镜像下载到开发板的DDR中后,uboot就可以用movi指令进行镜像的烧写了。
其使用的是阉割过的tftp,因为uboot没有文件系统,所以不存在将文件下载到什么目录中,只有下载到指定的内存区域:
tftp MemoryAddress FileName
7.nfs
nfs [loadAddress] [[hostIPaddr:]bootfilename]
boot image via network using NFS protocol
8.movi
开发板如果用SD卡/EMMC/iNand等作为Flash,则在uboot中操作flash的指令为movi(或mmc)
uboot代码中将iNand分成了很多个分区,每个分区有地址范围和分区名,uboot程序操作中可以使用直接地址来操作iNand分区,也可以使用分区名来操作分区。注意地址0x30000000也可以直接写作30000000(uboot的命令行中所有数字都被默认当作十六进制处理,不管你加不加0x都一样)。
NandFlash操作指令nand
理解方法和操作方法完全类似于movi指令
9.启动/执行命令
go
函数指针指向一个内存地址然后直接调用那个函数,实质就是PC直接跳转到一个内存地址去运行。go命令可以用来在uboot中执行任何的裸机程序(有一种调试裸机程序的方法就是事先启动uboot,然后在uboot中去下载裸机程序,用go命令去执行裸机程序)
boot/bootd
命令执行不带参数,直接去启动内核,其执行bootcmd这个环境变量中的内容。
bootelf [add]
去执行一个elf文件,从指定的内存中取出。
bootm [add]
专门用来启动kernel,会传参给内核,传参内容为bootargs这个环境变量中的内容
bootp [ loadAddress ] [ bootfilename ] (在我的uboot上执行失败)
boot image via network using BootP/TFTP protocol
bootvx [address] (没用过)
Boot vxWorks from an ELF image
rarpboot [loadAddress] [bootfilename] 和bootp类似,也执行失败
boot image via network using RARP/TFTP protocol
10.erase
慎用,会写到flash中。erase FLASH memory
- erase start end
erase FLASH from addr ‘start’ to addr ‘end’ - erase start +len
erase FLASH from addr ‘start’ to the end of sect w/addr ‘start’+‘len’-1 - erase N:SF[-SL]
erase sectors SF-SL in FLASH bank # N - erase bank N
erase FLASH bank # N - erase all
erase all FLASH banks
11.protect
enable or disable FLASH write protection
- protect on start end
protect FLASH from addr ‘start’ to addr ‘end’ - protect on start +len
protect FLASH from addr ‘start’ to end of sect w/addr ‘start’+‘len’-1 - protect on N:SF[-SL]
protect sectors SF-SL in FLASH bank # N - protect on bank N
protect FLASH bank # N - protect on all
protect all FLASH banks - protect off start end
make FLASH from addr ‘start’ to addr ‘end’ writable - protect off start +len
make FLASH from addr ‘start’ to end of sect w/addr ‘start’+‘len’-1 wrtable - protect off N:SF[-SL]
make sectors SF-SL writable in FLASH bank # N - protect off bank N
make FLASH bank # N writable - protect off all
make all FLASH banks writable
12.cp、cmp
复制内存中的内容
cp [.b, .w, .l] source target count
比较内存中的内容(没什么用)
cmp [.b, .w, .l] addr1 addr2 count
13.echo
和Linux一样用
14.dhcp
invoke DHCP client to obtain IP/boot params
dhcp 192.168.1.141 不知道有什么用
15.dcache
dcache :查看data cache是否开启
dcache on/off 打开/关闭data cache
16.icache
icache:查看icache是否开启
icache on/off 打开/关闭icache
17.dnw
三星的下载工具
配合Windows上的dnw使用,dnw [download address]
18.run
运行环境变量,我的uboot可以用来运行bootcmd,当我们自定义一个环境变量,并且可运行时,我们可以用run来运行
19.exit 退出程序 - exit script
20.fdisk
fdisk for sd/mmc.给sd/mmc分区
fdisk -c <device_num> - create partition.
fdisk -p <device_num> - print partition information
21.flinfo
print FLASH memory information
Bank # 1: MX: 1x MX29LV640EB (64Mbit)Size: 8 MB in 135 SectorsSector Start Addresses:80000000 80002000 80004000 80006000 80008000 .....807B0000 807C0000 807D0000 807E0000 807F0000
22.ext2相关
ext2format - disk format by ext2
ext2format <interface(only support mmc)> <dev:partition num>
ext2load
ext2load <interface> <dev[:part]> [addr] [filename] [bytes]
load binary file ‘filename’ from ‘dev’ on 'interface’to address ‘addr’ from ext2 filesystem
从Ext2文件系统加载二进制文件
ext2ls - list files in a directory (default /)
ext2ls <interface> <dev[:part]> [directory]
ext3format - disk format by ext3
23.有关文件系统的命令
fatformat - disk format by FAT32
FAT32的磁盘格式
fatinfo - print information about filesystem
fatload - load binary file from a dos filesystem
fatls - list files in a directory (default /)
24.内存相关
内存内容显示:
md [.b, .w, .l] address [# of objects]
内存内容修改:
mm [.b, .w, .l] address 地址递增
nm [.b, .w, .l] address 地址不变
内存内容写入:
mw [.b, .w, .l] address value [count]
mtest
mtest [start [end [pattern]]]
simple RAM test
25.SD卡相关
从SD卡的FAT分区读取镜像,并将其写入引导设备。
sdfuse info
插入SD卡时打印信息如下:
[Fusing Image from SD Card.]
[Partition table on MoviNAND]
ptn 0 name='bootloader' start=0x0 len=N/A (use hard-coded info. (cmd: movi))
ptn 1 name='kernel' start=N/A len=N/A (use hard-coded info. (cmd: movi))
ptn 2 name='ramdisk' start=N/A len=0x300000(~3072KB) (use hard-coded info. (cmd: movi))
ptn 3 name='config' start=0xB11E00 len=0x1024BC00(~264495KB)
ptn 4 name='system' start=0x10D5DA00 len=0x1024BC00(~264495KB)
ptn 5 name='cache' start=0x20FA9600 len=0x6751800(~105798KB)
ptn 6 name='userdata' start=0x276FAE00 len=0xC3CC2A00(~3207946KB)
sdfuse will read images from the followings:sd/mmc device : mmc 1:1directory : /x210booting device : MoviNAND
拔出SD卡时打印:
sdmmc init is failed.
... //之后和上面的打印内容一样
sdfuse flashall - flash boot.img, system.img,erase userdata, cache, and reboot.
插入SD卡时打印信息如下:
[Fusing Image from SD Card.]
[Partition table on MoviNAND]
ptn 0 name='bootloader' start=0x0 len=N/A (use hard-coded info. (cmd: movi))
ptn 1 name='kernel' start=N/A len=N/A (use hard-coded info. (cmd: movi))
ptn 2 name='ramdisk' start=N/A len=0x300000(~3072KB) (use hard-coded info. (cmd: movi))
ptn 3 name='config' start=0xB11E00 len=0x1024BC00(~264495KB)
ptn 4 name='system' start=0x10D5DA00 len=0x1024BC00(~264495KB)
ptn 5 name='cache' start=0x20FA9600 len=0x6751800(~105798KB)
ptn 6 name='userdata' start=0x276FAE00 len=0xC3CC2A00(~3207946KB)
Partition: bootloader, File: /x210/uboot.bin
Partition1: Start Address(0x7a10), Size(0xf2b1d0)
reading /x210/uboot.bin
Failed to read /x210/uboot.bin
拔出SD卡时打印信息如下:
sdmmc init is failed.
[Fusing Image from SD Card.]
[Partition table on MoviNAND]
...
Partition: bootloader, File: /x210/uboot.bin
** Can't read from device 1 **
** Invalid partition **
sdfuse flash < partition > [ <filename> ] - write a file to a partition.
sdfuse erase <partition> - erase (format) a partition.
26.image相关
iminfo - print header information for application image
imls - list all images found in flash
imxtract- extract a part of a multi-image
27.crc32
crc32 address count [addr]
compute CRC32 checksum [save at addr]
28.sleep
sleep 30 睡眠30秒
29.version
print monitor version
30.reset重启
31.loop
loop [.b, .w, .l] address number_of_objects
地址范围上的无限循环
32.mycmd
打印监视器版本
我打出来的是rsl,不知道为什么
33.itest
itest [.b, .w, .l, .s] []value1 []value2
整数比较时返回true/false
34.串口传输文件
loadb
loadb [ off ] [ baud ]
通过串行线加载二进制文件(kermit模式)
loads
通过串行线加载S-Record文件
loady
通过串行线加载二进制文件(YMODE模式)
环境变量
环境变量有2份,一份在Flash中,另一份在DDR中。uboot开机时一次性从Flash中读取全部环境变量到DDR中作为环境变量的初始化值,然后使用过程中都是用DDR中这一份。
环境变量在uboot中是用字符串表示的。
1.启动相关
(1)bootdelay
uboot启动后会开机自动倒数bootdelay秒,如果没有人按下回车打断启动,则uboot会自动执行启动命令来启动内核。
(2)bootcmd
uboot开机自动启动时实际就是执行了bootcmd的值所对应的命令集。
最常用的两个bootcmd:
//1.从flash的kernel分区读内核
bootcmd=movi read kernel 30008000; bootm 30008000 //2.tftp远程读取内核
bootcmd=tftp 30008000 zImage; bootm 30008000
(3)bootargs
启动内核时会传给Linux的参数,bootm启动命令会负责将参数传给Linux
最常用的两个bootargs:
//1.从sd0中读取根文件系统
bootargs=console=ttySAC2,115200 root=/dev/mmcblk0p2 rw init=/linuxrc rootfstype=ext3
//控制台使用串口2,波特率115200.
//根文件系统在SD卡端口0设备(iNand)第2分区,根文件系统是可读可写的
//linux的进程1(init进程)的路径
//根文件系统的类型是ext3//2.从挂载的nfs文件夹中读取根文件系统
bootargs=root=/dev/nfs nfsroot=192.168.1.141:/root/rootfs/rootfs ip=192.168.1.10:192.168.1.141:192.168.1.1:255.255.255.0::eth0:off init=/linuxrc console=ttySAC2,115200
// 跟文件是nfs网络文件,是主机上的文件
//主机的目录
//主机的网卡,off表示关闭DHCP分配
//init进程的名称
2.网络相关
(1)ipaddr是开发板的本地IP地址
(2)serverip是开发板通过tftp指令去tftp服务器下载东西时,tftp服务器的IP地址。
(3)gatewayip是开发板的本地网关地址
(4)netmask是子网掩码
(5)ethaddr是开发板的本地网卡的MAC地址。
3.其他
(1)mtdpart
(2)baudrate
(3)filesize
(4)fileaddr
uboot中对Flash和DDR的管理
在uboot中是没有操作系统的,因此我们对Flash(相当于硬盘)的管理必须事先使用分区界定(实际上在uboot中和kernel中都有个分区表,分区表就是我们在做系统移植时对Flash的整体管理分配方法)。
分区方法不是固定的,是可以变动的。但是在一个移植中必须事先设计好定死,定的标准是:
uboot:uboot必须从Flash起始地址开始存放(也许是扇区0,也许是扇区1,也许是其他,取决于SoC的启动设计),uboot分区的大小必须保证uboot肯定能放下,一般设计为512KB或者1MB;
环境变量:环境变量分区一般紧贴着uboot来存放,大小为32KB或者更多一点。
kernel:kernel可以紧贴环境变量存放,大小一般为3MB或5MB或其他。
rootfs:······
剩下的就是自由分区,一般kernel启动后将自由分区挂载到rootfs下使用
总结:一般规律如下:
(1)各分区彼此相连,前面一个分区的结尾就是后一个分区的开头。
(2)整个flash充分利用,从开头到结尾。
(3)uboot必须在Flash开头,其他分区相对位置是可变的。
(4)分区在系统移植前确定好,在uboot中和kernel中使用同一个分区表。将来在系统部署时和系统代码中的分区方法也必须一样。
uboot阶段DDR的分区
(1)DDR的分区和Flash的分区不同
(2)内存的分区主要是在linux内核启动起来之前,linux内核启动后内核的内存管理模块会接管整个内存空间,那时候就不用我们来管了。
(3)注意内存分区关键就在于内存中哪一块用来干什么必须分配好,以避免各个不同功能使用了同一块内存造成的互相踩踏。譬如说我们tftp 0x23E00000 zImage去下载zImage到内存的0x23E00000处就会出错,因为这个内存处实际是uboot的镜像所在。
uboot命令集环境变量相关推荐
- [uboot]在uboot里面添加环境变量使用run来执行
转自:http://blog.csdn.net/yangzheng_yz/article/details/41038259 在移植uboot的时候,可以在uboot里面添加定义一些自己的环境变量,这些 ...
- 【Linux】5.linux下的export命令和环境变量
linux下的export命令和环境变量 linux中在 profile 或者 bashrc 或者其他类似的文件中设置环境变量时(比如PATH),如果没有export,那么只能在直接启动的shell中 ...
- linux如何用命令寻找环境变量?
linux如何用命令寻找环境变量? 要在Linux中查找环境变量,您可以使用以下命令: printenv:此命令将列出所有已设置的环境变量. env:此命令也将列出所有已设置的环境变量. echo $ ...
- uboot的常用环境变量(bootdelay、ipaddr、serverip、gatewayip、netmask、ethaddr、bootcmd、bootargs)
文章目录 Part1:环境变量如何参与程序运行 Part2:自动运行倒计时 Part3:网络设置 Part4:自动运行命令设置 Part5:uboot给kernel传参 Part6:新建.更改.删除一 ...
- u-boot中filesize环境变量【转载】
转载地址:https://blog.csdn.net/fzs333/article/details/48518559 U-Boot中的环境命令可以使用$(filesize)来确定刚下载(传输)得到的文 ...
- UBOOT手动设置环境变量
Arm板系统文件一般有三个--bootloader(uboot).kernel(uImage)及根文件系统(rootfs). 在arm板上电后,按uboot->kernel->rootfs ...
- u-boot中filesize环境变量
U-Boot中的环境命令可以使用$(filesize)来确定刚下载(传输)得到的文件大小. 因为使用类似tftp命令传输文件后,会自动更新filesize环境变量. 如:setenv updatero ...
- uboot源码——环境变量
以下内容源于朱有鹏嵌入式课程的学习,如有侵权,请告知删除. 参考资料:http://www.cnblogs.com/biaohc/p/6398515.html. 一.uboot的环境变量基础 1.环境 ...
- 在linux系统中通过fw_printenv查看和设置u-boot中的环境变量
uboot下可以通过命令访问(printenv)和修改环境变量(setenv),但是如果需要在Linux系统下访问这些数据该怎么办呢?其实uboot早就帮我们想好了. 1.编译fw_printenv ...
最新文章
- java在线编程题_阿里笔试题(2017在线编程题)-- 数串分组 --Java实现
- osg中运用Shader(osg初级篇2)
- python subprocess.Popen 实时输出 stdout
- golang中的栈帧
- 在这里的周末休息也就是看看奥运
- android 城市列表数据,用RecyclerView写的城市列表
- pat 乙级 1041 考试座位号(C++)
- python selenium对象怎么序列化_python selenium爬取斗鱼
- 错过校招_您可能错过的Web优化技巧
- 列表推导(list comprehension)--Python
- 把zabbix图形整合至运维平台
- php自动加载 依赖,php自动加载
- 手机号归属地区编码_关于手机号码的详细解析~
- R语言也能玩ps?magick包你值得拥有
- Word导出pdf时Origin图片出现重影(重叠)
- python中imag是什么意思_Python-在imag中查找对象的中心
- html图片热区map、area的使用
- arcgis把jpg转成栅格图像,[转载]在ArcGIS中配准(TIF、JPEG)栅格图像并矢量化(转)...
- 温故知新——五大常用算法总结
- python求平均数保留两位小数_python求平均数、方差、中位数的例子
热门文章
- 《财富》评论:盛大新游戏——陈天桥欲打造中国迪斯尼
- 软考程序员 c java 二选一_下半年参加软考的初级程序员考试,有什么参考书推荐么?...
- WiFi(Wireless Fidelity)基础(六)
- 学生DW网页设计作业成品 HTML+CSS+JS大作业——汽车设备营销企业模板(13页) 静态HTML网页设计模板
- CSS3实现loading(加载)动画效果
- Grads转成Netcdf
- 现代计算机模型要求程序在执行前,大学计算机基础考试考点
- win7怎么打开html 文件夹,win7系统怎么设置一个窗口打开多个文件夹
- 网页设计的目的是什么
- Win10 Terminal更换背景图片,设置透明度