🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# 主线Uboot ## Uboot基础编译 ### 安装交叉编译器 网盘地址:http://pan.baidu.com/s/1hsf22fq 国外用户:https://releases.linaro.org/components/toolchain/binaries/latest/arm-linux-gnueabihf/ ~~~ wget https://releases.linaro.org/components/toolchain/binaries/latest/arm-linux-gnueabihf/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf.tar.xz tar xvf gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf.tar.xz mv gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf /opt/ vim /etc/bash.bashrc # add: PATH="$PATH:/opt/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin" arm-linux-gnueabihf-gcc -v sudo apt-get install device-tree-compiler ~~~ ### 下载编译Uboot ~~~ git clone https://github.com/Lichee-Pi/u-boot.git -b v3s-current #or git clone https://github.com/Lichee-Pi/u-boot.git -b v3s-spi-experimental cd u-boot make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LicheePi_Zero_800x480LCD_defconfig #or make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LicheePi_Zero480x272LCD_defconfig #or make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LicheePi_Zero_defconfig make ARCH=arm menuconfig time make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- 2>&1 | tee build.log ~~~ 编译完成后,在当前目录下生成了u-boot-sunxi-with-spl.bin,可以烧录到8K偏移处启动。 ### Uboot结构简介 * 下面来看看该uboot中的目录结构 ~~~ ├── api 存放uboot提供的API接口函数 ├── arch 平台相关的部分我们只需要关心这个目录下的ARM文件夹 │ ├──arm │ │ └──cpu │ │ │ └──armv7 │ │ └──dts │ │ │ └──*.dts 存放设备的dts,也就是设备配置相关的引脚信息 ├── board 对于不同的平台的开发板对应的代码 ├── cmd 顾名思义,大部分的命令的实现都在这个文件夹下面。 ├── common 公共的代码 ├── configs 各个板子的对应的配置文件都在里面,我们的Lichee配置也在里面 ├── disk 对磁盘的一些操作都在这个文件夹里面,例如分区等。 ├── doc 参考文档,这里面有很多跟平台等相关的使用文档。 ├── drivers 各式各样的驱动文件都在这里面 ├── dts 一种树形结构(device tree)这个应该是uboot新的语法 ├── examples 官方给出的一些样例程序 ├── fs 文件系统,uboot会用到的一些文件系统 ├── include 头文件,所有的头文件都在这个文件夹下面 ├── lib 一些常用的库文件在这个文件夹下面 ├── Licenses 这个其实跟编译无关了,就是一些license的声明 ├── net 网络相关的,需要用的小型网络协议栈 ├── post 上电自检程序 ├── scripts 编译脚本和Makefile文件 ├── spl second program loader,即相当于二级uboot启动。 ├── test 小型的单元测试程序。 └── tools 里面有很多uboot常用的工具。 ~~~ 了解了uboot的基本结构,我们可以知道一些相关的配置在什么地方了。 * lichee的uboot配置文件放在confgs文件目录下面,名称为 ~~~ LicheePi_Zero_480x272LCD_defconfig LicheePi_Zero_800x480LCD_defconfig LicheePi_Zero_defconfig ~~~ 这3个配置是根据不同的Zero显示设备进行的配置,使用其中之一即可,可以在uboot目录下执行命令 `make LicheePi_Zero_defconfig` 这样配置就生效了。 ### 开机logo替换 Uboot的开机logo默认情况(只定义了 CONFIG_VIDEO_LOGO)是企鹅logo,这个是存在于uboot代码中的一个头文件(include/video_logo.h或 bmp_logo.h),这个是一个巨大的结构体,其中保存着图片每个像素点的色彩数据。: #### 准备一张jpeg图片,通过命令行处理为8bit BMP图片。 ~~~ #!/bin/sh #install Netpbm first jpegtopnm $1 | ppmquant 31 | ppmtobmp -bpp 8 > $2 ~~~ 使用方法: (脚本名) ( 待处理的JPG图片名) (输出文件名) //这种方式出来的图不如用专业图片处理软件的好 #### 将bmp文件放入/tools/logos中,并修改/tools/下的Makefile ~~~ # Generated LCD/video logo LOGO_H = $(OBJTREE)/include/bmp_logo.h LOGO-$(CONFIG_LCD_LOGO) += $(LOGO_H) LOGO-$(CONFIG_VIDEO_LOGO) += $(LOGO_H) ifeq ($(LOGO_BMP),) LOGO_BMP= logos/mylogo.bmp endif ifeq ($(VENDOR),atmel) LOGO_BMP= logos/atmel.bmp endif ifeq ($(VENDOR),esd) LOGO_BMP= logos/esd.bmp endif ifeq ($(VENDOR),freescale) LOGO_BMP= logos/freescale.bmp endif ifeq ($(VENDOR),ronetix) LOGO_BMP= logos/ronetix.bmp endif ifeq ($(VENDOR),syteco) LOGO_BMP= logos/syteco.bmp endif ~~~ 将mylogo.bmp替换成你生成的logo #### 确认配置文件 在include/configs/sun8i.h​中加入两个宏定义: ~~~ #define CONFIG_VIDEO_LOGO #define CONFIG_VIDEO_BMP_LOGO ~~~ 编译的时候,你的bmp文件会被tools/bmp_logo.c编译出的工具bmp_logo 制作成include/bmp_logo.h,并编译进uboot中。 四、重新编译u-boot即可得到显示新logo的u-boot。 注: 相关代码在drivers/video/cfb_console.c下 ~~~ #ifdef CONFIG_VIDEO_LOGO /* Plot the logo and get start point of console */ debug("Video: Drawing the logo ...\n"); video_console_address = video_logo(); ~~~ drv_video_init -> cfg_video_init