赞
踩
本文主要基于S5PV210探讨uboot的命令,tftp服务器搭建,uboot的源码树分析和编译。
uboot
部署:uboot(180~400K的裸机程序)在Flash(可上电读取)、OS在FLash(nand)
启动过程:上电后先执行uboot、uboot初始化DDR和Flash,将OS从Flash中读到DDR中启动OS,uboot结束
特点:开机直接启动,引导操作系统内核启动并给内核传参
uboot对Flash和DDR管理:uboot在Flash起始地址(扇区0/1,SoC决定,大小512KB/1MB),环境变量大小32KB左右,kernel大小3MB/5MB,rootfs大小2/3G,其余为自由分区,各分区紧挨排布,不堆叠
tftp服务器搭建
预备:
windows10
unbuntu14.04
S5PV210开发板
网络配置:
windows10配置:以太网配置IP:192.168.100.99,255.255.255.0,192.168.100.1
ubuntu配置:NAT网卡连接网络,桥接网卡(网络模式选择以太网对应模式):192.168.100.100,255.255.255.0,192.168.100.1
uboot(已烧录ubbot到210的sd卡)
- set ipaddr 192.168.100.27
-
- set gatewayip 192.168.100.1
-
- set serverip 192.168.100.100
-
- save
-
uboot的IP配置及网络测试
ubuntu部署tftp
- apt-get install tftp-hpa tftpd-hpa xinetd -y
-
- vim /etc/default/tftpd-hpa
-
- # /etc/default/tftpd-hpa
-
- TFTP_USERNAME="tftp"
- TFTP_DIRECTORY="/root/tftp_file"
- TFTP_ADDRESS="0.0.0.0:69"
- TFTP_OPTIONS="-l -c -s"
-
-
- vim /etc/xinetd.d/tftp
-
- service tftp
- {
- socket_type = dgram
- wait = yes
- disable = no
- user = root
- protocol = udp
- server = /usr/sbin/in.tftpd
- server_args = -s /root/tftp_file
- #log_on_success += PID HOST DURATION
- #log_on_failure += HOST
- per_source = 11
- cps =100 2
- flags =IPv4
- }
-
-
- service tftpd-hpa start
-
-
- mkdir /root/tftp_file
-
- chmod 777 /root/tftp_file
-
- 测试
-
- cd ~
-
- touch /root/tftp_file/a.txt
-
- tftp 127.0.0.1
-
- get a.txt
-
- quit
-
- ls /root/a.txt
-
- root目录下有下载完成的a.txt(来自/root/tftp_file)
tftp测试
- ububtu:上传zImage到/root/tftp_file
-
- uboot:
-
- tftp 30008000 zImage
-
- movi read kernel 30008000
-
- bootm 30008000
uboot命令
基础
bdinfo:查看开发板基础信息
- x210 # bdinfo
- arch_number = 0x00000998
- env_t = 0x00000000
- boot_params = 0x30000100
- DRAM bank = 0x00000000
- -> start = 0x30000000
- -> size = 0x10000000
- DRAM bank = 0x00000001
- -> start = 0x40000000
- -> size = 0x10000000
- ethaddr = 00:40:5C:26:0A:5B
- ip_addr = 192.168.1.88
- baudrate = 115200 bps
version:查看uboot版本
- x210 # version
-
- U-Boot 1.3.4-dirty (May 21 2016 - 18:17:00) for x210
print/printenv:打印环境变量
set/setenv:设置(删除)环境变量
save/saveenv:保存环境变量
reset:重启
poweroff:关机
注意:设置和打印和删除的环境变量均为uboot启动时从flash中读到DDR中的环境变量,save可将set设置的命令同步到flash中
ddr
md:打印内存值
md [.b, .w, .l] address [# of objects]
b:byte(1字节),w:word(2字节),l:long(4字节)
address:起始地址,后跟字节长度
- x210 # help md
- md [.b, .w, .l] address [# of objects]
- - memory display
-
- x210 # md.b 30000000
- 30000000: f2 28 3e 74 83 cc 34 9a ae 9a 98 a2 c6 d7 49 9b .(>t..4.......I.
- 30000010: ff ab bb b1 db fa 55 3c 9f ff ff f4 7e be ff d1 ......U<....~...
- 30000020: f3 fc 3f d7 fe ff fe e2 9f b7 de eb 9f ff ae ef ..?.............
- 30000030: 8e f5 de e7 3d f9 7c e2 6e f8 1f f8 dc ed 7e fd ....=.|.n.....~.
- x210 # md.w 30000000
- 30000000: 28f2 743e cc83 9a34 9aae a298 d7c6 9b49 .(>t..4.......I.
- 30000010: abff b1bb fadb 3c55 ff9f f4ff be7e d1ff ......U<....~...
- 30000020: fcf3 d73f fffe e2fe b79f ebde ff9f efae ..?.............
- 30000030: f58e e7de f93d e27c f86e f81f eddc fd7e ....=.|.n.....~.
- 30000040: afbf fb93 7d6d 41ef febf edd8 6ffb 4bee ....m}.A.....o.K
- 30000050: c259 79ed dd59 ae78 c718 cdca 2f49 fcea Y..yY.x.....I/..
- 30000060: fdb5 8e6a 3def e3be 6eab feed def7 eeab ..j..=...n......
- 30000070: f6f1 f6be 0935 59bd f0ff eab6 0f9b dc5b ....5..Y......[.
- x210 # md.l 30000000
- 30000000: 743e28f2 9a34cc83 a2989aae 9b49d7c6 .(>t..4.......I.
- 30000010: b1bbabff 3c55fadb f4ffff9f d1ffbe7e ......U<....~...
- 30000020: d73ffcf3 e2fefffe ebdeb79f efaeff9f ..?.............
- 30000030: e7def58e e27cf93d f81ff86e fd7eeddc ....=.|.n.....~.
- 30000040: fb93afbf 41ef7d6d edd8febf 4bee6ffb ....m}.A.....o.K
- 30000050: 79edc259 ae78dd59 cdcac718 fcea2f49 Y..yY.x.....I/..
- 30000060: 8e6afdb5 e3be3def feed6eab eeabdef7 ..j..=...n......
- 30000070: f6bef6f1 59bd0935 eab6f0ff dc5b0f9b ....5..Y......[.
- 30000080: 1141df55 9f98bd6a e3d83e9e 39fcabf5 U.A.j....>.....9
- 30000090: ac479f9a dca771e2 6b61c763 cec95d3d ..G..q..c.ak=]..
- 300000a0: a4c8ceff ffbbebaa ea22aebf fa8ecf9e ..........".....
- 300000b0: ed7bfffe a1277d2b f4b4ff56 cb81deff ..{.+}'.V.......
- 300000c0: d59d27e4 af0d3eed beed2ebf b399b789 .'...>..........
- 300000d0: 5cd5bd57 ffa8bef9 b52cf9a9 ede94ff6 W..\......,..O..
- 300000e0: 3eedc9f7 9ecab7ff 6a0bf777 6b1b46f9 ...>....w..j.F.k
- 300000f0: 73e639bb 255a8ccf 2ebfb8cb 7a3a5d37 .9.s..Z%....7]:z
- x210 #
nm:修改指定内存地址的数据
nm [.b, .w, .l] address
- x210 # md.b 30000000
- 30000000: f2 28 3e 74 83 cc 34 9a ae 9a 98 a2 c6 d7 49 9b .(>t..4.......I.
- 30000010: ff ab bb b1 db fa 55 3c 9f ff ff f4 7e be ff d1 ......U<....~...
- 30000020: f3 fc 3f d7 fe ff fe e2 9f b7 de eb 9f ff ae ef ..?.............
- 30000030: 8e f5 de e7 3d f9 7c e2 6e f8 1f f8 dc ed 7e fd ....=.|.n.....~.
- x210 # nm.b 30000000
- 30000000: f2 ? 11
- 30000000: 11 ? q
- x210 # md.b 30000000
- 30000000: 11 28 3e 74 83 cc 34 9a ae 9a 98 a2 c6 d7 49 9b .(>t..4.......I.
- 30000010: ff ab bb b1 db fa 55 3c 9f ff ff f4 7e be ff d1 ......U<....~...
- 30000020: f3 fc 3f d7 fe ff fe e2 9f b7 de eb 9f ff ae ef ..?.............
- 30000030: 8e f5 de e7 3d f9 7c e2 6e f8 1f f8 dc ed 7e fd ....=.|.n.....~.
mm:递归修改指定内存地址的数据
mm [.b, .w, .l] address
- x210 # mm.b 30000000
- 30000000: 11 ? f2
- 30000001: 28 ? 11
- 30000002: 3e ? q
- x210 # md.b 30000000
- 30000000: f2 11 3e 74 83 cc 34 9a ae 9a 98 a2 c6 d7 49 9b ..>t..4.......I.
- 30000010: ff ab bb b1 db fa 55 3c 9f ff ff f4 7e be ff d1 ......U<....~...
- 30000020: f3 fc 3f d7 fe ff fe e2 9f b7 de eb 9f ff ae ef ..?.............
- 30000030: 8e f5 de e7 3d f9 7c e2 6e f8 1f f8 dc ed 7e fd ....=.|.n.....~.
mw:指定的数据填充内存
mw [.b, .w, .l] address value [count]
value:数据 count:数据的长度
- x210 # mw.b 30000000 668899 2
- x210 # md.b 30000000
- 30000000: 99 99 3e 74 83 cc 34 9a ae 9a 98 a2 c6 d7 49 9b ..>t..4.......I.
- 30000010: ff ab bb b1 db fa 55 3c 9f ff ff f4 7e be ff d1 ......U<....~...
- 30000020: f3 fc 3f d7 fe ff fe e2 9f b7 de eb 9f ff ae ef ..?.............
- 30000030: 8e f5 de e7 3d f9 7c e2 6e f8 1f f8 dc ed 7e fd ....=.|.n.....~.
- x210 # mw.b 30000000 668899 4
- x210 # md.b 30000000
- 30000000: 99 99 99 99 83 cc 34 9a ae 9a 98 a2 c6 d7 49 9b ......4.......I.
- 30000010: ff ab bb b1 db fa 55 3c 9f ff ff f4 7e be ff d1 ......U<....~...
- 30000020: f3 fc 3f d7 fe ff fe e2 9f b7 de eb 9f ff ae ef ..?.............
- 30000030: 8e f5 de e7 3d f9 7c e2 6e f8 1f f8 dc ed 7e fd ....=.|.n.....~.
- x210 #
cp将原地址数据复制到目标地址
cp [.b, .w, .l] source target count
- x210 # md.b 30000000
- 30000000: 99 99 99 99 83 cc 34 9a ae 9a 98 a2 c6 d7 49 9b ......4.......I.
- 30000010: ff ab bb b1 db fa 55 3c 9f ff ff f4 7e be ff d1 ......U<....~...
- 30000020: f3 fc 3f d7 fe ff fe e2 9f b7 de eb 9f ff ae ef ..?.............
- 30000030: 8e f5 de e7 3d f9 7c e2 6e f8 1f f8 dc ed 7e fd ....=.|.n.....~.
- x210 # md.b 30008000
- 30008000: f2 28 7f f7 9f ef ff ba bf ba f8 eb d6 f7 ba ff .(..............
- 30008010: ff ab f3 e3 db fa 4d 3e df df c6 f6 be ab ee f9 ......M>........
- 30008020: f7 fc bf ff 7f ff bf e3 bf 9f df ef 97 ff ee e3 ................
- 30008030: 8e f5 de ef 39 f9 fe e7 ff ff ff fa ff ff ff fb ....9...........
- x210 # cp.b 30000000 30008000 4
- x210 # md.b 30008000
- 30008000: 99 99 99 99 9f ef ff ba bf ba f8 eb d6 f7 ba ff ................
- 30008010: ff ab f3 e3 db fa 4d 3e df df c6 f6 be ab ee f9 ......M>........
- 30008020: f7 fc bf ff 7f ff bf e3 bf 9f df ef 97 ff ee e3 ................
- 30008030: 8e f5 de ef 39 f9 fe e7 ff ff ff fa ff ff ff fb ....9...........
cmp:比较两个地址段数据
cmp [.b, .w, .l] addr1 addr2 count
- x210 # md.b 30000000
- 30000000: 99 99 99 99 83 cc 34 9a ae 9a 98 a2 c6 d7 49 9b ......4.......I.
- 30000010: ff ab bb b1 db fa 55 3c 9f ff ff f4 7e be ff d1 ......U<....~...
- 30000020: f3 fc 3f d7 fe ff fe e2 9f b7 de eb 9f ff ae ef ..?.............
- 30000030: 8e f5 de e7 3d f9 7c e2 6e f8 1f f8 dc ed 7e fd ....=.|.n.....~.
- x210 # md.b 30008000
- 30008000: 99 99 99 99 9f ef ff ba bf ba f8 eb d6 f7 ba ff ................
- 30008010: ff ab f3 e3 db fa 4d 3e df df c6 f6 be ab ee f9 ......M>........
- 30008020: f7 fc bf ff 7f ff bf e3 bf 9f df ef 97 ff ee e3 ................
- 30008030: 8e f5 de ef 39 f9 fe e7 ff ff ff fa ff ff ff fb ....9...........
- x210 # md.b 30009000
- 30009000: 5e f3 dd ff d7 f9 db e5 dc 9f df e7 f3 73 fd f4 ^............s..
- 30009010: 3c ff b6 ef c7 f5 bf f4 6f fd a6 f7 ff f2 a5 f7 <.......o.......
- 30009020: f7 ff ff ff f6 d7 e9 f3 cf 3f b3 ef ff 7f fc e1 .........?......
- 30009030: dc fd 77 f3 cd ff fd fb ed 93 ff ef 3f ff fe ec ..w.........?...
- x210 # cmp.b 30000000 30008000 1
- Total of 1 byte were the same
- x210 # cmp.b 30000000 30009000 1
- byte at 0x30000000 (0x99) != byte at 0x30009000 (0x5e)
- Total of 0 bytes were the same
- x210 #
网络
ipaddr:地址
serverip:tftp服务器地址
dhcp:自动获取地址
ping:查看网络
启动
boot:读取环境变量bootcmd启动Linux
bootz:启动 zImage
bootm: 启动 uImage
Image为内核映像文件
zImage为映像压缩文件
uImage是uboot映像文件,在zImage前加上64字节头,说明内核的版本、加载位置、生成时间、大小等信息
flash
nand scrub:擦除整个NAND,擦除bad block标记
nand erase addr1 count:擦除NAND,count擦除字节数
nand write addr offset count:内存数据写入NAND,offset是偏移地址
nand read addr offset count :NAND数据读取到内存
nand bad:测试NAND FLASH坏块
mmc info 设备的信息
- x210 # mmcinfo
- Device: S3C_HSMMC0
- Manufacturer ID: 11
- RCA: 0
- OEM: 100
- Name: 004GA
- Tran Speed: 52000000
- Rd Block Len: 512
- MMC version 4.0
- High Capacity: Yes
- Size: 3776MB (block: 7733248)
- Bus Width: 4-bit
mmc rescan [mode] 扫描开发板上MMC设备,包括EMMC和SD卡
mmc list 查看开发板MMC设备
- x210 # mmc list
- S3C_HSMMC0_dev0
- S3C_HSMMC2_dev1
mmc dev 切换当前MMC设备:mmc dev [dev] [part]
[dev]切换MMC设备号,[part]分区号
mmc part查看分区
mmc read 读取mmc设备数据
movi init 初始化moviNAND并显示信息
movi read {u-boot | kernel} {addr} [bytes(hex)] 读取某地址sd/mmc信息
movi write {fwbl1 | u-boot | kernel} {addr} [bytes(hex)]写入数据sd/mmc的某地址
uboot源码树
api:硬件功能函数API
api_examples:硬件功能函数API示例代码
board:开发板相关,部分依据厂商名分类,部分依据芯片型号分类
common:cmd和env相关及控制台、crc校验等
cpu:架构相关(arch目录)
doc:说明文档
drivers:驱动代码
examples:示例代码
fs:文件系统
include:头文件
lib相关:库文件,lib_arm是arm架构库文件,lib_generic是通用库文件
libfdt:设备树
nand_spl:nand相关
net:网络相关
onenand:onenand相关
post:上电自检程序
sd_fusing:烧录uboot到SD卡的代码
tools:工具
Makefile:uboot源代码的主Makefile(主要)
arm_config.mk:arm架构编译的makefile
PLATFORM_CPPFLAGS += -DCONFIG_ARM -D__ARM__
config.mk:配置相关的Makefile
rules.mk:uboot的Makefile使用规则
- _depend: $(obj).depend
-
- $(obj).depend: $(src)Makefile $(TOPDIR)/config.mk $(SRCS)
- @rm -f $@
- @for f in $(SRCS); do \
- g=`basename $$f | sed -e 's/\(.*\)\.\w/\1.o/'`; \
- $(CC) -M $(HOST_CFLAGS) $(CPPFLAGS) -MQ $(obj)$$g $$f >> $@ ; \
- done
mkconfig:uboot配置阶段开发板类型配置(主要)
mk:编译脚本
- #!/bin/sh
- make distclean
- make x210_sd_config
- make -j4
MAKEALL:协助编译uboot的脚本
image_split:分割uboot.bin到BL1的脚本
split -b 8064 u-boot.bin bl2.bin
mkmovi:iNand/SD卡启动有关
Changelog文:版本修改记录
gitignore:git工具文件
git ls-files -i --exclude-standard
COPYING:GPL许可版权声明
MAINTAINERS:维护者
CREDITS:鸣谢
README:导读
编译uboot
基于210官方的qt包中的uboot包编译烧录
- 解压包
-
- tar -jxvf qt_x210v3s_160307.tar.bz2 -C qt_x210v3s_160307
-
- cd qt_x210v3s_160307/uboot
-
-
- 配置编译工具链(配置自己的工具链路径)
-
- vim Makefile
-
- #CROSS_COMPILE = arm-linux-
- #CROSS_COMPILE = /usr/local/arm/4.4.1-eabi-cortex-a8/usr/bin/arm-linux-
- #CROSS_COMPILE = /usr/local/arm/4.2.2-eabi/usr/bin/arm-linux-
- #CROSS_COMPILE = /usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi-
- CROSS_COMPILE = /root/arm-2009q3/bin/arm-none-linux-gnueabi-
-
- #############方式(1)##############
-
- 生成开发板配置
-
- make x210_sd_config
-
- 编译
-
- make -j4
-
- 生成u-boot.bin可用于烧录
-
- ############方式(2)###############
-
- ./mk
-
- 生成u-boot.bin可用于烧录
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。