//环境设置
//2.1 安装工具
ubuntu1604
sudo apt-get install build-essential git-core libncurses5-dev u-boot-tools
sudo apt-get install flex bison texinfo zip unzip zlib1g-dev gettext
sudo apt-get install gperf libsdl-dev libesd0-dev
sudo apt-get install g++ xz-utils
sudo apt-get install subversion
sudo apt-get install libc6-i386 lib32stdc++6 lib32z1
实际安装时候:
sudo apt-get install build-essential git-core libncurses5-dev u-boot-tools
sudo apt-get install flex bison texinfo zip unzip zlib1g-dev gettext
sudo apt-get install gperf libesd0-dev
sudo apt-get install g++ xz-utils
sudo apt-get install subversion
sudo apt-get install libc6-i386 lib32stdc++6 lib32z1
sudo apt-get install libsdl-dev
改成:
sudo aptitude install libsdl-dev
依赖太多了,先不装了
//SDL库安装
sudo apt-get install libsdl2-2.0 ===>yes
sudo apt-get install libsdl2-dev
// 交叉编译工具
//2.2 设置交叉编译工具
xz -d gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar.xz
tar xvf gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar
export WORKDIR="/home/xcz/work-dir/AM4378/"
export PATH=$PATH:$WORKDIR/Toolchain/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/bin
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabihf-
//验证交叉编译工具:
arm-linux-gnueabihf-gcc -v
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabihf-gcc
COLLECT_LTO_WRAPPER=/home/xcz/work-dir/AM4378/Toolchain/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/bin/../libexec/gcc/arm-linux-gnueabihf/5.3.1/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: /home/tcwg-buildslave/workspace/tcwg-make-release/label/tcwg-x86_64-ex40/target/arm-linux-gnueabihf/snapshots/gcc-linaro-5.3-2016.02/configure SHELL=/bin/bash --with-bugurl=https://bugs.linaro.org --with-mpc=/home/tcwg-buildslave/workspace/tcwg-make-release/label/tcwg-x86_64-ex40/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu --with-mpfr=/home/tcwg-buildslave/workspace/tcwg-make-release/label/tcwg-x86_64-ex40/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gmp=/home/tcwg-buildslave/workspace/tcwg-make-release/label/tcwg-x86_64-ex40/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gnu-as --with-gnu-ld --disable-libstdcxx-pch --disable-libmudflap --with-cloog=no --with-ppl=no --with-isl=no --disable-nls --enable-c99 --with-tune=cortex-a9 --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-multilib --enable-multiarch --with-build-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/label/tcwg-x86_64-ex40/target/arm-linux-gnueabihf/_build/sysroots/arm-linux-gnueabihf --enable-lto --enable-linker-build-id --enable-long-long --enable-shared --with-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/label/tcwg-x86_64-ex40/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu/arm-linux-gnueabihf/libc --enable-languages=c,c++,fortran,lto --enable-checking=release --disable-bootstrap --with-bugurl=https://bugs.linaro.org --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --target=arm-linux-gnueabihf --prefix=/home/tcwg-buildslave/workspace/tcwg-make-release/label/tcwg-x86_64-ex40/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu
Thread model: posix
gcc version 5.3.1 20160113 (Linaro GCC 5.3-2016.02)
//嵌入式linux系统构建框架
openWRT, Buildroot, Yocto, Arago
TI 官方提供了使用Arago构建系统的方法和相应的文件系统镜像文件
//Bootloader 编译
//3.1 Bootloader
cd Bootloader/uboot-master/
清除编译:
make distclean
编译:
make configs/myd_c437x_evm_defconfig
生成img:
Bootloader/uboot-master/u-boot.bin
Bootloader/uboot-master/MLO
编译报错1:
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
SHIPPED scripts/kconfig/zconf.tab.c
SHIPPED scripts/kconfig/zconf.lex.c
SHIPPED scripts/kconfig/zconf.hash.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
***
*** Can't find default configuration "arch/../configs/configs/myd_c437x_evm_defconfig"!
***
scripts/kconfig/Makefile:114: recipe for target 'configs/myd_c437x_evm_defconfig' failed
make[1]: *** [configs/myd_c437x_evm_defconfig] Error 1
Makefile:477: recipe for target 'configs/myd_c437x_evm_defconfig' failed
make: *** [configs/myd_c437x_evm_defconfig] Error 2
make menuconfig
make
//编译报错1:
CC arch/sandbox/cpu/sdl.o
arch/sandbox/cpu/sdl.c:9:21: fatal error: SDL/SDL.h: No such file or directory
compilation terminated.
arch/sandbox/cpu/Makefile:23: recipe for target 'arch/sandbox/cpu/sdl.o' failed
make[1]: *** [arch/sandbox/cpu/sdl.o] Error 1
Makefile:1216: recipe for target 'arch/sandbox/cpu' failed
make: *** [arch/sandbox/cpu] Error 2
SDL是Simple DirectMedia Layer(简易直控媒体层)的缩写。它是一个跨平台的多媒体库,以用于直接控制底层的多媒体硬件的接口。主要用在开发游戏上!
Ubuntu的新得立已经包含SDL库,所以通过几个简单的命令就可以安装,比windows还傻瓜!
sudo apt-get install libsdl1.2-dev(比较大,10M左右)
附加包:
sudo apt-get install libsdl-image1.2-dev
sudo apt-get install libsdl-mixer1.2-dev
sudo apt-get install libsdl-ttf2.0-dev
sudo apt-get install libsdl-gfx1.2-dev
安装完成之后,在目录/usr/include中,就会有个SDL文件夹,里面包含了所需要的头文件。
安装之后
xcz@xcz-OptiPlex-7070:/usrfind -name SDL.h
./local/include/SDL/SDL.h
电脑重启后这个报错没有了
//编译报错2:
cmd/bootm.c: In function ‘do_imls_nor’:
cmd/bootm.c:326:7: error: ‘CONFIG_SYS_MAX_FLASH_BANKS’ undeclared (first use in this function)
重新设置编译工具后:
include/asm-generic/bitops/__ffs.h: In function '__ffs':
include/asm-generic/bitops/__ffs.h:19:8: warning: right shift count >= width of type [-Wshift-count-overflow]
word >>= 32;
^
CC arch/sandbox/cpu/sdl.o
arch/sandbox/cpu/sdl.c:9:21: fatal error: SDL/SDL.h: No such file or directory
compilation terminated.
arch/sandbox/cpu/Makefile:23: recipe for target 'arch/sandbox/cpu/sdl.o' failed
make[1]: *** [arch/sandbox/cpu/sdl.o] Error 1
Makefile:1216: recipe for target 'arch/sandbox/cpu' failed
make: *** [arch/sandbox/cpu] Error 2
换个方式编译
cp configs/myd_c437x_evm_defconfig .config
make //====》后面出来许多的配置项目,选yes后
//报错
./scripts/dtc-version.sh: line 17: dtc: command not found
./scripts/dtc-version.sh: line 18: dtc: command not found
*** Your dtc is too old, please upgrade to dtc 1.4 or newer
Makefile:1375: recipe for target 'checkdtc' failed
make: *** [checkdtc] Error 1
解决:
sudo apt-get install device-tree-compiler
//编译成功
OBJCOPY spl/u-boot-spl-nodtb.bin
COPY spl/u-boot-spl.bin
MKIMAGE MLO
CFG spl/u-boot-spl.cfg
COPY u-boot.dtb
MKIMAGE u-boot-dtb.img
//总结
make distclean
cp configs/myd_c437x_evm_defconfig .config
make
说明:
编译完成之后生成MLO和u-boot.img可以用于TF卡启动和EMMC启动,优先选择从TF卡启动,
启动过程中,通过按空格键可以进入U-Boot命令控制台执行需要的命令。
//上面之后
1-第一步
make myd_c437x_evm_defconfig
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
SHIPPED scripts/kconfig/zconf.tab.c
SHIPPED scripts/kconfig/zconf.lex.c
SHIPPED scripts/kconfig/zconf.hash.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
#
# configuration written to .config
#
2-第二步
make
// 内核 编译
//3.2 编译Linux内核
cd AM4378/Kernel/linux-master
make mrproper
make myd_c437x_evm_defconfig
make zImage
make dtbs
编译生成的img:
arch/arm/boot/zImage
arch/arm/boot/dts/myd_c437x_evm.dtb
其他的dtb文件:
am437x-gp-evm-hdmi.dtb
am437x-gp-evm.dtb
am437x-idk-evm.dtb
am437x-sk-evm.dtb
am43x-epos-evm-hdmi.dtb
am43x-epos-evm.dtb
myd_c437x_evm.dtb
myd_c437x_evm_hdmi.dtb
myd_c437x_idk.dtb
myd_c437x_idk_lcd.dtb
myir_ricoboard.dtb
myir_ricoboard_hdmi.dtb
在编译内核之前到底应该使用make mrproper,make distclean,make clean中的哪个命令呢?
1. 先找到描述这三个命令的相关信息
在内核目录下使用make help命令可以获取相关信息,信息如下:
Cleaning targets:
clean - Remove most generated files but keep the config and
enough build support to build external modules
mrproper - Remove all generated files + config + various backup files
distclean - mrproper + remove editor backup and patch files
2. 从1即可获取相关信息,下面逐一分析
make clean: 删除大部分生成的文件但是保留配置文件和足够的构建外部模块的构建支持
make mrproper: 删除所有生成的文件,配置和各种各样备份的文件
make distclean: 相当于执行一次make mrproper,然后再删除编辑器备份和补丁文件
3. 删除文件的范围比较
make clean < make mrproper < make distclean