2一、u-boot下载编译
一、介绍
二、下载
u-boot源码下载地址
官方uboot下载:https://github.com/u-boot/u-boot、
https://ftp.denx.de/pub/u-boot/
NXP提供uboot下载 :https://source.codeaurora.org/external/imx/uboot-imx
三、u-boot源码目录分析
1.介绍
我们可以将整个uboot源码目录总结如下:
开发板相关目录 board cpu体系结构相关目录 arch通用的函数 common、lib通用的设备驱动、网络协议
程序 driver、net、disk、fs、postuboot实例程序、工具、文档 doc、examples、tools
2.arch目录
存放与架构有关的文件,这里只关注arch/arm文件夹即可
– mach开头的文件夹跟具体的设备有关
– cpu文件夹里是和cpu架构有关的
3.board目录
和具体的板子有关的,打开freescale文件夹,freescale芯片的板子都在此文件夹下
– mx6ul开头的,表示使用IMX6UL芯片的板子
– mx6ull开头的,表示使用IMX6ULL芯片的板子
– mx6ullevk是NXP官方的IMX6ULL开发板
4.configs目录
存放uboot配置文件,一般半导体或开发板厂商会制作好一个配置文件,供用户在此基础上进行修改,配
置文件统一命名为“ xxx_defconfig ”,xxx表示开发板名字
5.include目录
存放的是uboot源码需要的头文件,这里我们关注** include/configs **目录,这个目录下存放的都是和具
体某一块开发板相关的头文件。如:mx6ullevk.h
四、编译
在u-boot的configs目录下有u-boot支持的开发板的默认配置文件,我们需要根据自己实际开发的开发板和
芯片来选择相应的配置文件。
我们的小车使用的是imx6ull芯片,NXP官方基于这款芯片做了EVK开发板,我们可以使用** mx6ull_14x1
4_evk_defconfig **配置文件来进行u-boot配置。配置方法如下:
配置完成以后会生成** .config **文件。在u-boot编译的时候,Makefile就会根据.config里面的配置,选
择相关的代码进行编译。
2.菜单配置
u-boot和Linux内核一样支持菜单配置,菜单配置命令如下:
uboot-imx-rel_imx_4.1.15_2.1.0_ga$ make menuconfig
uboot-imx-rel_imx_4.1.15_2.1.0_ga$ make menuconfig
3.源码编译
uboot-imx-rel_imx_4.1.15_2.1.0_ga$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
ARCH :后面用来指定具体的CPU架构
CROSS_COMPILE :后面用来指定交叉开发工具链前缀
uboot-imx-rel_imx_4.1.15_2.1.0_ga$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
ARCH :后面用来指定具体的CPU架构-
CROSS_COMPILE :后面用来指定交叉开发工具链前缀
四、u-boot编译生成文件说明
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS
{
. = 0x00000000;
. = ALIGN(4);
.text :{*(.__image_copy_start)*(.vectors)arch/arm/cpu/armv7/start.o (.text*)*(.text*)}
. = ALIGN(4);
.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
. = ALIGN(4);
.data : {*(.data*)}
. = ALIGN(4);
. = .;
. = ALIGN(4);
.u_boot_list : {KEEP(*(SORT(.u_boot_list*)));}
. = ALIGN(4);
.image_copy_end :{*(.__image_copy_end)}
.rel_dyn_start :{*(.__rel_dyn_start)}
.rel.dyn : {*(.rel*)}
.rel_dyn_end :{*(.__rel_dyn_end)}
.end :{*(.__end)}_image_binary_end = .;
. = ALIGN(4096);
.mmutable : {*(.mmutable)}
.bss_start __rel_dyn_start (OVERLAY) : {KEEP(*(.__bss_start));__bss_base = .;}
.bss __bss_base (OVERLAY) : {
*(.bss*). = ALIGN(4);__bss_limit = .;}
.bss_end __bss_limit (OVERLAY) : {KEEP(*(.__bss_end));}
.dynsym _image_binary_end : { *(.dynsym) }
.dynbss : { *(.dynbss) }
.dynstr : { *(.dynstr*) }
.dynamic : { *(.dynamic*) }
.plt : { *(.plt*) }
.interp : { *(.interp*) }
.gnu.hash : { *(.gnu.hash) }
.gnu : { *(.gnu*) }
.ARM.exidx : { *(.ARM.exidx*) }
.gnu.linkonce.armexidx : { *(.gnu.linkonce.armexidx.*) }
}


cmd_u-boot-dtb.bin := cat u-boot-nodtb.bin dts/dt.dtb > u-boot-dtb.bin
uboot-imx-rel_imx_4.1.15_2.1.0_ga$ cat .u-boot.bin.cmd
cmd_u-boot.bin := cp u-boot-nodtb.bin u-boot.bin
uboot-imx-rel_imx_4.1.15_2.1.0_ga$ cat .u-boot.imx.cmd
cmd_u-boot.imx := ./tools/mkimage -n board/freescale/mx6ullevk/imximage.cfg.cfgtmp-T imximage -e 0x87800000 -d u-boot.bin u-boot.imx >/dev/null
uboot-imx-rel_imx_4.1.15_2.1.0_ga$ cat .u-boot.srec.cmd
cmd_u-boot.srec := arm-linux-gnueabihf-objcopy --gap-fill=0xff -j .text -j .secure_text-j .rodata -j .hash -j .data -j .got -j .got.plt -j .u_boot_list-j .rel.dyn -O srec u-boot u-boot.srec
五、u-boot测试
uboot-imx-rel_imx_4.1.15_2.1.0_ga$ cp u-boot.bin ../../tftpboot/
=> tftp 878000000 u-boot.bin
Using FEC0 device
TFTP from server 192.168.1.100; our IP address is 192.168.1.200
Filename 'u-boot.bin'.
Load address: 0x78000000
Loading: #############################2.7 MiB/s
done
Bytes transferred = 416472 (65ad8 hex)
=> go 87800000
## Starting application at 0x87800000 ...