荔枝派 Zero 编译记录

开发环境选择

	本次实验采用主线Uboot+主线linux进行。
	系统配置为dts设备树配置。
	主线uboot: https://github.com/Lichee-Pi/u-boot
	主线linux: https://github.com/Lichee-Pi/linux
	实验硬件平台为lichee zero + 480×272分辨率显示屏,8G SD卡。
	编译平台为Ubuntu 16.04 LTS。

主线Uboot

1.安装交叉编译器

先安装一些必须的软件以及依赖;

sudo apt-get update
sudo apt-get install iputils-ping vim git wget xz-utils bzip2 gcc device-tree-compiler python time make

下载交叉编译器

wget https://releases.linaro.org/components/toolchain/binaries/7.1-2017.08/arm-linux-gnueabihf/gcc-linaro-7.1.1-2017.08-x86_64_arm-linux-gnueabihf.tar.xz

下载完成后解压并将其移动到/opt/目录下

tar xvf gcc-linaro-7.1.1-2017.08-x86_64_arm-linux-gnueabihf.tar.xz
mv gcc-linaro-7.1.1-2017.08-x86_64_arm-linux-gnueabihf /opt/

添加环境变量

vim /etc/bash.bashrc

在bash.bashrc的最后一行添加 PATH="$PATH:/opt/gcc-linaro-7.1.1-2017.08-x86_64_arm-linux-gnueabihf/bin"在这里插入图片描述
更新一下

source /etc/bash.bashrc

查看版本:arm-linux-gnueabihf-gcc -v
在这里插入图片描述
最后安装一下设备树编译器:sudo apt-get install device-tree-compiler

2.下载编译Uboot

从作者的github上获取源代码:git clone https://github.com/Lichee-Pi/u-boot.git -b v3s-current
下载完成后进入uboot文件夹
设置一下配置文件:make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LicheePi_Zero_480x272LCD_defconfig

进入内核配置选项配置一下所需要的东西,第一次编译使用默认的就可以了

make ARCH=arm menuconfig

编译内核:time make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- 2>&1 | tee build.log

编译完成后可以在uboot目录下看到刚刚生成的u-boot-sunxi-with-spl.bin文件,稍后将其烧录到SD卡的8K偏移处即可。
在这里插入图片描述

3.Uboot配置

Uboot配置命令:  `make ARCH=arm menuconfig`

其余更详细的配置可参考官网教程。

主线Kernel

1.安装交叉编译器

下载交叉编译器

wget https://releases.linaro.org/components/toolchain/binaries/7.1-2017.08/arm-linux-gnueabihf/gcc-linaro-7.1.1-2017.08-x86_64_arm-linux-gnueabihf.tar.xz 

这里使用的是更新版本的。
下载完成将压缩包解压

tar -xvf gcc-linaro-7.1.1-2017.08-x86_64_arm-linux-gnueabihf.tar.xz 

将解压出来的文件夹移动到/opt/目录

mv gcc-linaro-7.1.1-2017.08-x86_64_arm-linux-gnueabihf /opt/

在bash中添加环境变量

vim /etc/bash.bashrc

在最后一行添加指向的目录

PATH="$PATH:/opt/gcc-linaro-7.1.1-2017.08-x86_64_arm-linux-gnueabihf/bin"

在这里插入图片描述

2.编译Linux源码

从作者的github上获取源码:

git clone https://github.com/Lichee-Pi/linux.git

生成默认配置文件

CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm make licheepi_zero_defconfig

编译内核

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j9

在这里插入图片描述
编译设备树

 make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- dtbs

在这里插入图片描述
zImage在arch/arm/boot/下,驱动模块在out/下

根文件系统buildroot

1.下载安装

安装一些依赖apt-get install linux-headers-$(uname -r)
然后下载根文件系统,下载完后解压

wget https://buildroot.org/downloads/buildroot-2017.08.tar.gz
tar xvf buildroot-2017.08.tar.gz

2.配置根文件系统

进入到刚下载的根文件系统文件夹里make menuconfig

cd buildroot-2017.08/
make menuconfig

Target options
Target Architecture (ARM (little endian))
Target Architecture Variant (cortex-A7)
在这里插入图片描述
Toolchain
在这里插入图片描述
选择外部工具链
Toolchain Path:/opt/gcc-linaro-7.1.1-2017.08-x86_64_arm-linux-gnueabihf/
Toolchain prefix :arm-linux-gnueabihf
External toolchain gcc version (7.x)
External toolchain kernel headers series (4.10.x)
External toolchain C library (glibc/eglibc)

System configuration
在这里插入图片描述
System configuration里面可以设置主机名,root密码等。

Target packages
Target packages 里面可以选择一下软件包等等。

其他的选项可以自行学习一下。

3.编译

执行make命令进行编译。
在这里插入图片描述
编译完成后,在output/images/文件夹下的rootfs.tar就是根文件系统。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章