1. 程式人生 > >編譯U-boot和Linux核心的步驟和詳解

編譯U-boot和Linux核心的步驟和詳解

1、準備材料

linux核心和uboot的原始碼包—- 6818GEC.tar.gz 環境:VMware12.0 Ubuntu16.04(64位)

(1)先將 6818GEC.tar.gz 放在Ubuntu的共享目錄下,然後將 6818GEC.tar.gz 拷貝到家目錄下進行解壓。
解壓命令: [email protected]:~$ tar -zxvf 6818GEC.tar.gz

2、如何編譯u-boot

(2)[email protected]:~/6818GEC$ ./mk -u

編譯輸出
LD u-boot —–>連結成u-boot可執行映像檔案
OBJCOPY u-boot.srec
OBJCOPY u-boot.bin —>將u-boot可執行映像檔案進行格式轉換,轉換成bin格式的檔案
./tools/mk6818 GECuboot.bin nsih.txt 2ndboot u-boot.bin —->將nsih.txt 2ndboot u-boot.bin打包生成GECuboot.bin–>eMMC
NSIH : 189 line processed.
NSIH : 512 bytes generated.
Generate destination file: GECuboot.bin
‘/home/gec/6818GEC/GEC6818uboot/GECuboot.bin’ -> ‘/home/gec/6818GEC/out/release/GECuboot.bin’
‘/home/gec/6818GEC/GEC6818uboot/readme.txt’ -> ‘/home/gec/6818GEC/out/release/readme.txt’
‘/home/gec/6818GEC/GEC6818uboot/env.txt’ -> ‘/home/gec/6818GEC/out/release/env.txt’
‘/home/gec/6818GEC/GEC6818uboot/GEC6818-sdmmc.sh’ -> ‘/home/gec/6818GEC/out/release/GEC6818-sdmmc.sh’
^_^ uboot path: /home/gec/6818GEC/out/release/GECuboot.bin —->將GECuboot.bin拷貝到out/release/下

3、如何編譯linux核心

(3) [email protected]:~/6818GEC$ ./mk -k

編譯輸出:
Kernel: arch/arm/boot/Image is ready
Kernel: arch/arm/boot/zImage is ready
UIMAGE arch/arm/boot/uImage
Image Name: Linux-3.4.39-gec
Created: Mon Feb 26 22:06:56 2018
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 5532568 Bytes = 5402.90 kB = 5.28 MB
Load Address: 40008000
Entry Point: 40008000
Image arch/arm/boot/uImage is ready
boot.img -> /home/gec/6818GEC/out/release
‘/home/gec/6818GEC/kernel/arch/arm/boot/uImage’ -> ‘/home/gec/6818GEC/out/target/product/GEC6818//boot/uImage’
make_ext4fs -s -T -1 -l 67108864 -a boot /home/gec/6818GEC/out/target/product/GEC6818//boot.img /home/gec/6818GEC/out/target/product/GEC6818//boot
Creating filesystem with parameters:
Size: 67108864
Block size: 4096
Blocks per group: 32768
Inodes per group: 4096
Inode size: 256
Journal blocks: 1024
Label:
Blocks: 16384
Block groups: 1
Reserved block group size: 7
Created filesystem with 18/4096 inodes and 4212/16384 blocks
‘/home/gec/6818GEC/out/target/product/GEC6818//boot.img’ -> ‘/home/gec/6818GEC/out/release/boot.img’

核心映像檔案的生成過程:
核心原始碼—>Image–>壓縮–>zImage—>使用mkimage工具,在zImage的前面加一個頭–>uImage—>經過檔案系統打包,生成boot.img
/home/gec/6818GEC/out/release/boot.img

4、原始碼包的分析

1、GEC6818uboot
—–>u-boot的原始碼包
[email protected]:~/6818GEC$ ls GEC6818uboot/
2ndboot board config.mk doc env.txt GEC6818-sdmmc.sh Kbuild MAKEALL net nsih-2G16b-533M.txt nsih.txt readme.txt System.map u-boot u-boot.map
api boards.cfg CREDITS drivers examples GECuboot.bin lib Makefile nsih-1G16b-533M.txt nsih-2G16b-800M.txt post scripts test u-boot.bin u-boot.srec
arch common disk dts fs include Licenses mkconfig nsih-1G16b-800M.txt nsih-2G8b.txt README snapshot.commit tools u-boot.lds

2、kernel
——>linux核心的原始碼
[email protected]:~/6818GEC$ ls kernel
android COPYING Documentation fs init Kconfig MAINTAINERS modules.builtin net samples sound usr vmlinux.o
arch CREDITS drivers gec6818_linux_config ipc kernel Makefile modules.order README scripts System.map virt
block crypto firmware include Kbuild lib mm Module.symvers REPORTING-BUGS security tools vmlinux

3、prebuilts
——>編譯u-boot和kernel的編譯器
[email protected]:~/6818GEC/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8/bin$ ./arm-eabi-gcc -v
Using built-in specs.
COLLECT_GCC=./arm-eabi-gcc
COLLECT_LTO_WRAPPER=/home/gec/6818GEC/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8/bin/../libexec/gcc/arm-eabi/4.8/lto-wrapper
Target: arm-eabi
Configured with: /tmp/AOSP-toolchain/build/../gcc/gcc-4.8/configure –prefix=/tmp/toolchain-build-eabi/prefix –target=arm-eabi –host=x86_64-linux-gnu –build=x86_64-linux-gnu –with-gnu-as –with-gnu-ld –enable-languages=c,c++ –with-gmp=/tmp/toolchain-build-eabi/temp-install –with-mpfr=/tmp/toolchain-build-eabi/temp-install –with-mpc=/tmp/toolchain-build-eabi/temp-install –with-cloog=/tmp/toolchain-build-eabi/temp-install –with-isl=/tmp/toolchain-build-eabi/temp-install –with-ppl=/tmp/toolchain-build-eabi/temp-install –disable-ppl-version-check –disable-cloog-version-check –disable-isl-version-check –enable-cloog-backend=isl –with-host-libstdcxx=’-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm’ –disable-libssp –enable-threads –disable-nls –disable-libmudflap –disable-libgomp –disable-libstdc__-v3 –disable-sjlj-exceptions –disable-shared –disable-tls –disable-libitm –with-float=soft –with-fpu=vfp –with-arch=armv5te –enable-target-optspace –with-abi=aapcs –enable-initfini-array –disable-nls –prefix=/tmp/toolchain-build-eabi/prefix –with-sysroot=/tmp/toolchain-build-eabi/prefix/sysroot –with-binutils-version=2.23 –with-mpfr-version=3.1.1 –with-mpc-version=1.0.1 –with-gmp-version=5.0.5 –with-gcc-version=4.8 –with-gdb-version=7.6 –with-gxx-include-dir=/tmp/toolchain-build-eabi/prefix/include/c++/4.8 –with-bugurl=http://source.android.com/source/report-bugs.html –disable-bootstrap –disable-libquadmath –enable-plugins –enable-libgomp –disable-libsanitizer –enable-gold –enable-graphite=yes –with-cloog-version=0.18.0 –with-isl-version=0.11.1 –enable-eh-frame-hdr-for-static –with-arch=armv5te –disable-gold –disable-libgomp –program-transform-name=’s&^&arm-eabi-&’
Thread model: single
gcc version 4.8 (GCC)

4、out
——>編譯生成的u-boot和kernel的映像檔案
/out/release/GECuboot.bin
/out/release/boot.img

5、prototype
——->linux核心使用的一些韌體程式,這些韌體程式是針對S5P6818底層外設,如:串列埠、看門狗、定時器、USB.、、、、

6、tools
——->編譯u-boot或kernel使用的一些工具

7、linux
——->linux核心使用的一些韌體程式,這些韌體程式是針對S5P6818中視訊處理模組的。

8、buildroot
——->生成跟檔案系統的內容

5、GEC6818更新系統的方法

1、使用fastboot
2、使用恢復卡(micro SD==TF卡)