編譯全志H3的linux源碼

說明

 因爲須要用到全志的芯片的orangepi_zero的開源板子作項目,須要定製linux系統,對系統添加內置程序,修改鏡像大小和ubuntu系統版本。須要對源碼編譯生成ubuntu系統鏡像。linux

使用編譯環境

編譯內核使用的是docke容器,比較方便。封裝打包內核生成鏡像使用實體機ubuntu16.04 64位。由於打包鏡像在docker內運行會出錯。git

docker地址

docker pull registry.cn-shenzhen.aliyuncs.com/qusir/orangepi_zero:0.2

源碼地址

https://github.com/QUSIR/orangepi_h2_linux

依賴項安裝

設置dtc編譯uboot

運行容器github

docker run -it -v /home/orangepi_h2_linux:/data registry.cn-shenzhen.aliyuncs.com/qusir/orangepi_zero:0.2 bash

說明:將orangepi_h2_linux源碼目錄映射到容器的data文件夾docker

編譯dtc

dtc下載地址 連接:https://pan.baidu.com/s/1sndX30T 密碼:c2mwbootstrap

7z x dtc.7z
cd dtc
make

設置dtc環境變量

export PATH=/data/dtc/:$PATH

設置交叉編譯器環境變量

export PATH="$PWD/brandy/gcc-linaro/bin":"$PATH"

編譯過程

編譯uboot

make CROSS_COMPILE=arm-linux-gnueabi- orangepi_zero_defconfig

編譯內核

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- sun8iw7p1smp_linux_defconfig
make -j8 ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage modules

編譯文件生成文件拷貝

cp -rf ./linux-3.4/output/lib/* ./build/lib
cp -rf ./linux-3.4/arch/arm/boot/uImage ./build/uImage 
cp -rf ./u-boot-2016.7/u-boot-sunxi-with-spl.bin ./build/uboot 
cp -rf ./build/lib/* ../OrangePi-BuildLinux/orange/lib/
cp -rf ./build/uImage ../OrangePi-BuildLinux/orange/ 
cp -rf ./build/uboot/u-boot-sunxi-with-spl.bin ../OrangePi-BuildLinux/orange/
cp -rf ./build/uboot/boot.scr ../OrangePi-BuildLinux/orange/

依賴項安裝

實體機上ubuntu

apt-get install debootstrap qemu-user-static chroot

生成鏡像

./create_image
./image_from_dir linux-trusty orangepi ext4 zero

說明:linux-trust爲執行create_imge所生成系統目錄,orangepi爲生成鏡像名稱。bash

鏡像定製說明

修改 params.sh文件app

# =====================================================
# ==== P A R A M E T E R S ============================
# =====================================================


# *****************************************************
# Set to "yes" to create realy minimal image          *
# *****************************************************
ONLY_BASE="no"


# *****************************************************
# Set hostname, user to be created                    *
# and root and user passwords                         *
# *****************************************************
HOSTNAME="OrangePizero"  #主機名稱
USER="orangepi"          #用戶名
ROOTPASS="orangepi"      #root密碼
USERPASS="orangepi"      #orangepi密碼


# *****************************************************
# Set timezone, for default (HOST'S) set _timezone="" *
# *****************************************************
_timezone="Etc/UTC"
#_timezone=""


# *****************************************************
# SET IF YOU WANT TO INSTALL SPECIFIC LANGUAGE,       *
# COMMENT FOR DEFAULT (HOST) settings                 *
# *****************************************************
LANGUAGE="en"
LANG="en_US.UTF-8"


# *****************************************************
# Set the base name of your image.                    *
# Distro name is automaticaty appended, and the image *
# will be "image_name-distro.img"                     *
# --------------------------------------------------- *
# IF image_name="", image file won't be created,      *
# instalation will be created in local directories    *
# linux-$distro & boot-$distro                        *
# YOU CAN CREATE THE IMAGE LATER RUNNING:             *
# sudo ./image_from_dir <directory> <DEVICE|IMAGE>    *
# === IT IS THE RECOMMENDED WAY OF IMAGE CREATION === *
# --------------------------------------------------- *
# IF image_name is BLOCK DEVICE (/dev/sdXn)           *
# LINUX filesystem will be created directly on it     *
# Partition must exist !                              *
# IF _format="" partition will NOT be formated        *
# otherwyse it will be formated with specified format *
# *****************************************************
image_name=""
#image_name="minimal"
#image_name="/dev/sdg"


# *****************************************************
# Filesystem type for linux partition                 *
# If btrfs is selectet, partition will be mounted     *
# "compressed" option, you can save some sdcard space *
# --------------------------------------------------- *
# Used when creating the system directly on SDCard or *
# SDCard image file and in "image_from_dir" script    *
# *****************************************************
_format="ext4"  #文件系統
#_format="btrfs"


# *****************************************************
# SD Card partitions sizes in MB (1024 * 1024 bytes)  *
# --------------------------------------------------- *
# If creating on physical sdcard (not image) you can  *
# set "linuxsize=0" to use maximum sdcard size        *
# --------------------------------------------------- *
# When creating the image with "image_from_dir" script*
# "linuxsize" is calculated from directory size       *
# *****************************************************
fatsize=64
linuxsize=800  #生成鏡像大小


# *****************************************************
#   Select ubuntu/debian distribution and repository  *
#     === SELECT ONLY ONE distro AND ONE repo ===     *
# *****************************************************

# === Ubuntu ===
#distro="precise"
#distro="xenial"
distro="trusty"  #ubuntu版本
#distro="utopic"
#distro="vivid"
#distro="wily"
#repo="http://ports.ubuntu.com/ubuntu-ports"

repo="http://mirrors.ustc.edu.cn/ubuntu-ports"  #ubuntu鏡像源

# === Debian ===
#distro="wheezy"
#distro="jessie"
#repo="http://ftp.hr.debian.org/debian"
#raspbian="no"

# === Raspbian ===
#distro="wheezy"
#distro="jessie"
#repo="http://archive.raspbian.org/raspbian"
#raspbian="yes"

# ******************************************************
# If creating the image, you can xz compress the image *
# after creation and make the md5sum file              *
# to do that automatically, set  _compress="yes"       *
# ******************************************************
_compress="no"


# =====================================================
# IF YOU WANT TO HAVE BOOT FILES ON EXT4 PARTITION    =
# AND NOT ON SEPARATE FAT16 PARTITION                 =
# set  _boot_on_ext4="yes"  and                       =
# FAT partitin won't be created                       =
# --------------------------------------------------- =
# DO NOT CHANGE FOR NOW !                             =
# =====================================================
_boot_on_ext4="no"


# ^^^^ P A R A M E T E R S ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
相關文章
相關標籤/搜索