安装 ncurses 库
sudo apt-get install build-essential
sudo apt-get install libncurses5
sudo apt-get install libncurses5-dev
进入uboot顶层目录
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- xxx_defconfig//对应自己的defconfig文件
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
顶层 Kconfig 文件调用了很多其他子目录下的 Kcofig 文件,这些子目录下的 Kconfig 文件在主菜单中生成各自的菜单项。
Kconfig 文件的最终目的就是在.config 文件中生成以“CONFIG_”开头的变量。
Uboot menuconfig 认识
1. Architecture select (ARM architecture) —> 处理器架构选择,单选
- ARM architecture—> 选择arm处理器架构
2. ARM architecture —> ARM 架构子选项
- Target select (xxx-xxx) —> 目标芯片选择
- ARM debug —> 调试
3.General setup —> 通用配置
- Local version - append to U-Boot release —> 版本号
- Automatically append version information to the version strin
- Optimize for size —> 优化大小
- Enable malloc() pool before relocation —> 使能malloc池在引导之前
- (0x400) Size of malloc() pool before relocation —> malloc大小
- Configure standard U-Boot features (expert users) —> 配置标准的uboot特性
4.Boot images —> 镜像
- Support Flattened Image Tree —> 支持扁平镜像树,关于适配板子的imximage.cfg信息
5.Command line interface —> 命令行接口
- Info commands —>输出信息命令bdinfo/coninfo/license
- Boot commands —> 启动命令bootd/bootm/go/run/iminfo/imls/imxtract
- Environment commands —> 环境命令env export/env import/editenv/saveenv
- Memory commands —> 内存命令md/mm/nm/mw/cp/base/loop/base/meminfo/crc32/loopw/memtest
- Device access commands —> 设备控制命令dm/demo/loads/loadb/nand/sspi/i2c/usb/fpga/erase/flinfo
- Shell scripting commands —> 脚本命令echo/itest/source
- Network commands —> 网络命令tftpboot/tftp/tftpsrv/nfs/ping/cdp/dns/linklocal/dhcp
- Misc commands —> 函数命令time/sleep/timer
备注:
细心的话应该会发现,在 mx6xxx.h 里面配置使能了 dhcp 和 ping 命令,但是在图形化界面中 dhcp 和 ping 前面的“[ ]”并不是“[ * ]”,也就是说不编译 dhcp 和 ping命令,这不是冲突了吗?实际情况是 dhcp 和 ping 是会编译的。之所以在图形化界面中没有体现出来是因为直接在 mx6xxx.h 中定义的CONFIG_CMD_PING 和CONFIG_CMD_DHCP,而 menuconfig 是通过读取.config 文件来判断使能了哪些功能,.config里面并没有宏CONFIG_CMD_PING和CONFIG_CMD_DHCP,所以menuconfig就会识别出错。
6.Device Tree Control —> 设备树控制
- Run-time configuration via Device Tree
- Default Device Tree for DT control
7.Networking support —> 网络支持
8.Device Drivers —> 设备驱动
9.File systems —> 文件系统
10.Library routines —> 库程序
在uboot添加自定义菜单
- 在主界面中添加一个名为“My test menu”,此菜单内部有一个配置项。
- 配置项为“MY_TESTCONFIG”,此配置项处于菜单“My test menu”中。
- 配置项的为变量类型为 bool,默认值为 y。
- 配置项菜单名字为“This is my test config”。
- 配置项的帮助内容为“This is a empty config, just for tset!”。
在顶层Kconfig,添加如下代码:
1 menu "My test menu"
2
3 config MY_TESTCONFIG
4 bool "This is my test config"
5 default y
6 help
7 This is a empty config, just for tset!
8
9 endmenu # my test menu
添加完成以后打开图形化配置界面
Uboot更新
Uboot启动流程分析
1)概述
对于CPU来说整个启动分两步,第一步是固化在芯片内部的引导,主要加载uboot.bin。这段固件应该要先判断uboot是在那个存储里面,拷贝完之后进行跳转,执行uboot.bin。第二阶段uboot.bin先初始化外设,然后初始化系统允许环境
2)初始化外设的代码
arch/arm/cpu/armv7/start.S
board/samsung/myboard/lowlevel_init.S
arch/arm/lib/crt0.S
arch/arm/lib/board.c
start.S
1、设置CPU为SVC模式,uboot需要更多的权限所以需要打开
2、关闭MMU,uboot操作的都是实际地址
3、关闭Cache,cache主要是做缓存的,因为内存的初始化比CPU初始化慢半拍,上电之初就操作存储可能会导致问题
4、跳转到lowerlevel_init.s low_level_init
lowlevel_init.S
5、初始化时钟
6、初始化内存
7、初始化串口,看门狗
8、跳转到crt0.S _main
crt0.S
9、设置栈
10、初始化C运行环境
11、调用board_init_f()
board.c
12、board_init_f对全局信息GD结构体进行填充
13、代码重定位
3)准备环境阶段
arch/arm/lib/crt0.S
arch/arm/lib/board.c
1. board_init_r()是进入定制板目录的入口common/main.c
2. main_loop()中关闭中断,执行命令以及加载引导内核
4)uboot是如何加载内核的
1.uboot需要先初始化好DRAM,因为要把内核搬运到这里面
2.初始化一个串口
3.uboot需要把板子类型传给内核,按照arch/arm/tools/mach-types中的描述,将板子编号存储在r1寄存器,这里板子类型有什么用?
4.建立内核参数,包含内存位置,内存大小及根文件系统的位置等
5.加载ramfs文件系统
6.启动内核镜像