目录
- (一)环境
- (二)流程分析
- (三)具体步骤
在裸机启动流程里涉及到BL1,BL2为系统的加载启动项,全称为BootLoader。
Boot Loader 是在操作系统内核运行之前运行的一段小程序。通过这段小程序,我们可以初始化硬件设备、建立内存空间的映射图,从而将系统的软硬件环境带到一个合适的状态,以便为最终调用操作系统内核准备好正确的环境。通常,Boot Loader 是严重地依赖于硬件而实现的,特别是在嵌入式世界。因此,在嵌入式世界里建立一个通用的 Boot Loader 几乎是不可能的,但是通过研究人员的努力,设计了一个通用的BootLoader,满足大部分的开发板的需求。
(一)环境
- uboot_tiny4412-sdk1506.tar.bz2
- Ubuntu 16.04
- linux交叉编译环境(我已经安装过,没有安装的可以下载arm-linux-gcc-4.5.1-v6-vfp-20120301.tgz)
获取帮助的地方: uboot官方
获取uboot源代码的地方:uboot源码
(二)流程分析
1、 先将uboot的源代码复制到Ubuntu下的目录中(推荐在根目录下创建driver目录)
这里以 uboot_tiny4412-sdk1506.tar.bz2的uboot为例操作,自己根据自己下载的uboot进行解压
2、对uboot进行解压操作
tar -xvf uboot_tiny4412-sdk1506.tar.bz2
3、进入uboot的目录,分析uboot的目录架构
在Linux文件中每一个目录均有自己独有的功能,一般情况下,目录中都会有一个所谓README文件,该文件描述了对应目录下文件的作用
阅读README文件:
In general, all boards for which a configuration option exists in the Makefile have been
tested to some extent and can be considered "working". In fact, many of them are used in
production systems.
说明在uboot的makefile文件中配置的开发板可以直接使用该版本的uboot#目录结构:
/api U-Boot machine/arch independent API for external apps
/arch Architecture specific files/arm Files generic to ARM architecture/cpu CPU specific files/arm720t Files specific to ARM 720 CPUs/arm920t Files specific to ARM 920 CPUs/at91rm9200 Files specific to Atmel AT91RM9200 CPU/imx Files specific to Freescale MC9328 i.MX CPUs/s3c24x0 Files specific to Samsung S3C24X0 CPUs/arm925t Files specific to ARM 925 CPUs/arm926ejs Files specific to ARM 926 CPUs/arm1136 Files specific to ARM 1136 CPUs/ixp Files specific to Intel XScale IXP CPUs/pxa Files specific to Intel XScale PXA CPUs/s3c44b0 Files specific to Samsung S3C44B0 CPUs/sa1100 Files specific to Intel StrongARM SA1100 CPUs/lib Architecture specific library files/avr32 Files generic to AVR32 architecture/cpu CPU specific files/lib Architecture specific library files/blackfin Files generic to Analog Devices Blackfin architecture/cpu CPU specific files/lib Architecture specific library files/i386 Files generic to i386 architecture/cpu CPU specific files/lib Architecture specific library files/m68k Files generic to m68k architecture/cpu CPU specific files/mcf52x2 Files specific to Freescale ColdFire MCF52x2 CPUs/mcf5227x Files specific to Freescale ColdFire MCF5227x CPUs/mcf532x Files specific to Freescale ColdFire MCF5329 CPUs/mcf5445x Files specific to Freescale ColdFire MCF5445x CPUs/mcf547x_8x Files specific to Freescale ColdFire MCF547x_8x CPUs/lib Architecture specific library files/microblaze Files generic to microblaze architecture/cpu CPU specific files/lib Architecture specific library files/mips Files generic to MIPS architecture/cpu CPU specific files/lib Architecture specific library files/nios2 Files generic to Altera NIOS2 architecture/cpu CPU specific files/lib Architecture specific library files/powerpc Files generic to PowerPC architecture/cpu CPU specific files/74xx_7xx Files specific to Freescale MPC74xx and 7xx CPUs/mpc5xx Files specific to Freescale MPC5xx CPUs/mpc5xxx Files specific to Freescale MPC5xxx CPUs/mpc8xx Files specific to Freescale MPC8xx CPUs/mpc8220 Files specific to Freescale MPC8220 CPUs/mpc824x Files specific to Freescale MPC824x CPUs/mpc8260 Files specific to Freescale MPC8260 CPUs/mpc85xx Files specific to Freescale MPC85xx CPUs/ppc4xx Files specific to AMCC PowerPC 4xx CPUs/lib Architecture specific library files/sh Files generic to SH architecture/cpu CPU specific files/sh2 Files specific to sh2 CPUs/sh3 Files specific to sh3 CPUs/sh4 Files specific to sh4 CPUs/lib Architecture specific library files/sparc Files generic to SPARC architecture/cpu CPU specific files/leon2 Files specific to Gaisler LEON2 SPARC CPU/leon3 Files specific to Gaisler LEON3 SPARC CPU/lib Architecture specific library files
/api Machine/arch independent API for external apps
/board Board dependent files
/common Misc architecture independent functions存放着和设置环境变量及设置配置参数相关的文件
/disk Code for disk drive partition handling
/doc Documentation (don't expect too much)
/drivers Commonly used device drivers
/examples Example code for standalone applications, etc.
/fs Filesystem code (cramfs, ext2, jffs2, etc.)
/include Header Files
/lib Files generic to all architectures/libfdt Library files to support flattened device trees/lzma Library files to support LZMA decompression/lzo Library files to support LZO decompression
/net Networking code
/post Power On Self Test
/rtc Real Time Clock drivers
/tools Tools to build S-Record or U-Boot images, etc.
在Linux系统中,一般的cfg或者config均为配置文件
boards.cfg:列举了该版本的uboot所支持的所有开发板的名称及相关信息
Target:目标名称
ARCH:指的是架构名称
CPU:处理器名
Board name:板子名称
Vendor:厂商名
SoC: 片上系统名
Options:选项,一般无
如:
tiny4412 arm armv7 tiny4412 samsung exynos
每一个名字都对应了uboot的目录结构下的某一个目录,这些目录中存放着对应开发版的先关资源文件,编译的时候需要
从README可知,uboot可以引导多种平台架构的开发板,如何选择其引导自己的开发板??
Selection of Processor Architecture and Board Type:
For all supported boards there are ready-to-use default
configurations available; just type "make <board_name>_config".Example: For a TQM823L module type:cd u-bootmake TQM823L_config
make -j8:编译可以加速
-j [N], --jobs[=N] 同时允许 N 个任务;无参数表明允许无限个任务。
(三)具体步骤
首先将SD卡插入度开启并连接到Ubuntu系统
1、进行开发板和处理器选型
make <board_name>_config
//这里的board_name可以在board.cfg配置信息找到
2、make
make
3、将uboot烧写到SD卡
为什么要烧写到SD卡?
以后的嵌入式开发中,通常会先用SD卡或者TF卡进行测试,当功能调试成功再放到emmc。
cd sd_fuse
make
cd tiny4412/
./sd_fusing.sh 你的sd卡挂在点
好了做完上面的你就完成了uboot的制作,接下来把SD卡拔出来插入开发板使用串口工具可以进入uboot的交互模式进行控制。