荔枝派 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就是根文件系統。