u-boot编译与命令

来源:互联网 发布:淘宝商家从哪里进货 编辑:程序博客网 时间:2024/05/28 22:11

U-boot的编译

]$ patch -p0 < u-boot-2010.09-fl2440.patchpatching file u-boot-2010.09/arch/arm/cpu/arm920t/s3c24x0/speed.cpatching file u-boot-2010.09/arch/arm/cpu/arm920t/s3c24x0/timer.cpatching file u-boot-2010.09/arch/arm/cpu/arm920t/start.Spatching file u-boot-2010.09/arch/arm/cpu/arm920t/u-boot.ldspatching file u-boot-2010.09/arch/arm/include/asm/arch-s3c24x0/s3c24x0_cpu.hpatching file u-boot-2010.09/arch/arm/include/asm/arch-s3c24x0/s3c24x0.hpatching file u-boot-2010.09/board/lingyun/fl2440/config.mkpatching file u-boot-2010.09/board/lingyun/fl2440/fl2440.cpatching file u-boot-2010.09/board/lingyun/fl2440/flash.cpatching file u-boot-2010.09/board/lingyun/fl2440/lowlevel_init.Spatching file u-boot-2010.09/board/lingyun/fl2440/Makefilepatching file u-boot-2010.09/board/lingyun/fl2440/nand_read.cpatching file u-boot-2010.09/boards.cfgpatching file u-boot-2010.09/common/cmd_nand.cpatching file u-boot-2010.09/common/env_common.cpatching file u-boot-2010.09/common/serial.cpatching file u-boot-2010.09/drivers/mtd/nand/s3c2410_nand.cpatching file u-boot-2010.09/drivers/net/dm9000x.cpatching file u-boot-2010.09/include/configs/fl2440.hpatching file u-boot-2010.09/include/serial.hpatching file u-boot-2010.09/Makefile

注意patch -p0 < u-boot-fl2440.patch 和 patch -p1 < ../u-boot-fl2440.patch 的区别。用-p1时候是在u-boot-2010.09目录里面,而-p0是和u-boot-2010.09在同一个目录下。

]$ cd u-boot-2010.09
u-boot-2010.09]$ make fl2440_config
Configuring for fl2440 board...
u-boot-2010.09]$ make
.... ....
/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-objcopy --gap-fill=0xff -O binary u-boot u-boot.bin
mv u-boot.bin u-boot-s3c2440.bin
u-boot-2010.09]$ ls
api boards.cfg COPYING doc fs MAINTAINERS mkconfig onenand_ipl rules.mk tools u-boot.map
arch common CREDITS drivers include MAKEALL nand_spl post snapshot.commit u-boot u-boot-s3c2440.bin
board config.mk disk examples lib Makefile net README System.map u-boot.lds u-boot.srec
u-boot-2010.09]$ ls u-boot-s3c2440.bin tools/mkimage
u-boot-2010.09]$ sudo cp tools/mkimage /usr

把tools/mkimage 拷贝在/usr/bin/路劲下,因为/usr/bin/下是默认的环境变量。用的时候可以系统会默认直接往里面找,当然也可以自己设置环境变量,不过为了一条命令而设置一个环境变量太麻烦了,直接添加在系统默认的/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin下找方便很多将来也很好管理。

patch与diff命令

diff 和 patch 是一对工具,使用这对工具可以获取更新文件与历史文件的差异,并将更新应用到历史文件上。在数学上说,diff就是对两个集合的差运算,patch就是对两个集合的和运算。在数学上我们知道: A - B = C, 这样我们知道 A、B、C中任意两个数都可以得到第三个数:

假设u-boot-2010.09(A) 是官方下载解压缩后的源代码,而u-boot-2010.09-fl2440(B)是针对相应硬件(fl2440)做源码修改后的代码。这时我们可以使用下面diff命令制作一个补丁文件 u-boot-2010.09-fl2440.patch(C) :
diff -Nuar u-boot-2010.09 u-boot-2010.09-fl2440 > u-boot-2010.09-fl2440.patch

假设现在有A(u-boot-2010.09)和C(u-boot-2010.09-fl2440.patch)通过patch命令即可得到B(u-boot-2010.09-fl2440

u-boot的常用命令

u-boot>version 查看u-boot版本
u-boot>v u-boot命令支持缩写
u-boot>help 查看u-boot支持的命令帮助信息
u-boot>help tftp 查看nand命令的使用方法

u-boot>set serverip 192.168.1.8 设置u-boot serverip环境变量
u-boot>set serverip 取消u-boot serverip环境变量
u-boot>printenv 打印环境变量
u-boot>save 保存环境变量

这里写图片描述