全志V3s 编译

环境:

PC:ubuntu 22.04
目标芯片:全志V3s
uboot版本:2017.01-rc2(进入u-boot目录,执行grep "#define PLAIN_VERSION" -nr进行查看)
kernel版本:4.13(进入linux目录,执行cat Makefile | head -n 5查看)

下载交叉编译器

安装交叉编译器
网盘地址:http://pan.baidu.com/s/1hsf22fq
国外用户:https://releases.linaro.org/components/toolchain/binaries/latest/arm-linux-gnueabihf/

解压交叉编译器文件

tar xvf gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf.tar.xz

将gcc-linaro-6.3.1-2017.02-x86_64_arm-linux-gnueabihf拷贝到/opt/目录下:

sudo cp -r gcc-linaro-6.3.1-2017.02-x86_64_arm-linux-gnueabihf /opt/

vim ~/.bashrc 在文件最后添加:

export CROSS_COMPILE=arm-linux-gnueabihf-
export ARCH=arm
export PATH=$PATH:/opt/gcc-linaro-6.3.1-2017.02-x86_64_arm-linux-gnueabihf/bin

source ~/.bashrc 重新打开命令行

coolx@ubuntu:~$ arm-linux-gnueabihf-gcc -v
使用内建 specs。
COLLECT_GCC=arm-linux-gnueabihf-gcc
COLLECT_LTO_WRAPPER=/opt/gcc-linaro-6.3.1-2017.02-x86_64_arm-linux-gnueabihf/bin/../libexec/gcc/arm-linux-gnueabihf/6.3.1/lto-wrapper
目标:arm-linux-gnueabihf
配置为:/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/snapshots/gcc-linaro-6.3-2017.02/configure SHELL=/bin/bash --with-mpc=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu --with-mpfr=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gmp=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gnu-as --with-gnu-ld --disable-libmudflap --enable-lto --enable-objc-gc --enable-shared --without-included-gettext --enable-nls --disable-sjlj-exceptions --enable-gnu-unique-object --enable-linker-build-id --disable-libstdcxx-pch --enable-c99 --enable-clocale=gnu --enable-libstdcxx-debug --enable-long-long --with-cloog=no --with-ppl=no --with-isl=no --disable-multilib --with-float=hard --with-mode=thumb --with-tune=cortex-a9 --with-arch=armv7-a --with-fpu=vfpv3-d16 --enable-threads=posix --enable-multiarch --enable-libstdcxx-time=yes --enable-gnu-indirect-function --with-build-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/_build/sysroots/arm-linux-gnueabihf --with-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu/arm-linux-gnueabihf/libc --enable-checking=release --disable-bootstrap --enable-languages=c,c++,fortran,lto --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/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu
线程模型:posix
gcc 版本 6.3.1 20170109 (Linaro GCC 6.3-2017.02) 

下载u-boot

git clone https://github.com/Lichee-Pi/u-boot.git -b v3s-current

编译uboot

cd u-boot
make LicheePi_Zero_defconfig
make menuconfig 
make

这里make编译的时候报错

  HOSTLD  tools/mkenvimage
  HOSTCC  tools/aisimage.o
In file included from tools/../include/libfdt.h:54,
                 from tools/fdt_host.h:11,
                 from tools/imagetool.h:24,
                 from tools/aisimage.c:8:
/usr/include/libfdt_env.h:27:30: error: conflicting types for ‘fdt64_t’; have ‘uint64_t’ {aka ‘long unsigned int’}
   27 | typedef uint64_t FDT_BITWISE fdt64_t;
      |                              ^~~~~~~
In file included from <command-line>:
././include/libfdt_env.h:19:16: note: previous declaration of ‘fdt64_t’ with type ‘fdt64_t’ {aka ‘long long unsigned int’}
   19 | typedef __be64 fdt64_t;

u-boot的libfdt-dev比较旧,PC上的libfdt-dev比较新,有冲突,删掉PC上的,后面需要的话可以再装回来

sudo apt-get remove libfdt-dev

u-boot编译完后,会在目录下生成u-boot-sunxi-with-spl.bin文件

编译kernel

下载kernel源码

git clone https://github.com/Lichee-Pi/linux.git -b zero-4.13.y
cd linux
make licheepi_zero_defconfig
make menuconfig
make

这里make报错:

 HOSTLD  scripts/dtc/dtc
/usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x10): multiple definition of `yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [scripts/Makefile.host:110:scripts/dtc/dtc] 错误 1

解决方法:

vim scripts/dtc/dtc-lexer.lex.c_shipped

在634行:YYLTYPE yylloc; 前面加上extern

继续执行make编译内核
然后编译设备树:make dtbs
编译模块到out目录:make INSTALL_MOD_PATH=out modules
安装模块到out目录:make INSTALL_MOD_PATH=out modules_install

修改可以从tf卡启动

如果不修改这个,后面添加的内核和文件系统都不能启动,但是uboot可以启动(这个真是血的教训)
修改 include/configs/sun8i.h, 使u-boot可以直接从tf卡启动:

 vim include/configs/sun8i.h 

#include <configs/sunxi-common.h>
后面加入:

#define CONFIG_BOOTCOMMAND   "setenv bootm_boot_mode sec; " \
	                            "load mmc 0:1 0x41000000 zImage; "  \
	                            "load mmc 0:1 0x41800000 sun8i-v3s-licheepi-zero-dock.dtb; " \
	                            "bootz 0x41000000 - 0x41800000;"
	
	#define CONFIG_BOOTARGS      "console=ttyS0,115200 panic=5 rootwait root=/dev/mmcblk0p2 earlyprintk rw  vt.global_cursor_default=0"

buildroot

maek menuconfig
然后参考:https://blog.csdn.net/lengyuefeng212/article/details/118861717的buildroot配置
make编译,报错:

External toolchain uses the unsuported OABI
	make: *** [package/pkg-generic.mk:220:/home/coolx/v3s/buildroot-2017.08/output/build/toolchain-external-custom/.stamp_configured] 错误 1

解决:

	#zh_CN.UTF-8
	coolx@ubuntu:~/v3s/buildroot-2017.08$ export LC_ALL=C
	coolx@ubuntu:~/v3s/buildroot-2017.08$ export LANG=C

报错:

libfakeroot.c: In function 'chown':
	libfakeroot.c:99:40: error: '_STAT_VER' undeclared (first use in this function)
	   99 | #define INT_NEXT_STAT(a,b) NEXT_STAT64(_STAT_VER,a,b)

解决:

vim output/build/host-fakeroot-1.20.2/libfakeroot.c 

97行加入:

#ifndef _STAT_VER
	 #if defined (__aarch64__)
	  #define _STAT_VER 0
	 #elif defined (__x86_64__)
	  #define _STAT_VER 1
	 #else
	  #define _STAT_VER 3
	 #endif
	#endif

sudo make
编译完后再output/image/目录下生成rootfs.tar

下载bsp linux

http://pan.baidu.com/s/1eRJrViy

下载sunxi-tools
https://gitee.com/bailong_v3s/V3S_all
或git clone https://github.com/linux-sunxi/sunxi-tools

下载bsp linux的交叉编译器:gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf.tar.xz
https://releases.linaro.org/components/toolchain/binaries/4.9-2017.01/arm-linux-gnueabihf/

	tar vxf gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf.tar.xz
	mv gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf /opt/
	sync
vim ~/.bashrc 在文件最后修改
	export CROSS_COMPILE=arm-linux-gnueabihf-
	export ARCH=arm
	#export PATH=$PATH:/opt/gcc-linaro-6.3.1-2017.02-x86_64_arm-linux-gnueabihf/bin
	export PATH=$PATH:/opt/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin

source ~/.bashrc 重新打开命令行

	coolx@ubuntu:~/v3s/buildroot-2017.08$ arm-linux-gnueabihf-gcc -v
	Using built-in specs.
	COLLECT_GCC=arm-linux-gnueabihf-gcc
	COLLECT_LTO_WRAPPER=/opt/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/../libexec/gcc/arm-linux-gnueabihf/4.9.4/lto-wrapper
	Target: arm-linux-gnueabihf
	Configured with: /home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/snapshots/gcc-linaro-4.9-2017.01/configure SHELL=/bin/bash --with-mpc=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu --with-mpfr=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gmp=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gnu-as --with-gnu-ld --disable-libmudflap --enable-lto --enable-objc-gc --enable-shared --without-included-gettext --enable-nls --disable-sjlj-exceptions --enable-gnu-unique-object --enable-linker-build-id --disable-libstdcxx-pch --enable-c99 --enable-clocale=gnu --enable-libstdcxx-debug --enable-long-long --with-cloog=no --with-ppl=no --with-isl=no --disable-multilib --with-float=hard --with-mode=thumb --with-tune=cortex-a9 --with-arch=armv7-a --with-fpu=vfpv3-d16 --enable-threads=posix --enable-multiarch --enable-libstdcxx-time=yes --with-build-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/_build/sysroots/arm-linux-gnueabihf --with-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu/arm-linux-gnueabihf/libc --enable-checking=release --disable-bootstrap --enable-languages=c,c++,fortran,lto --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/docker-trusty-amd64-tcwg-build/target/arm-linux-gnueabihf/_build/builds/destdir/x86_64-unknown-linux-gnu
	Thread model: posix
	gcc version 4.9.4 (Linaro GCC 4.9-2017.01) 

进入bsp linux的linux目录
https://gitee.com/bailong_v3s/V3S_all里获取config/lichee_BSP_config
cp config/lichee_BSP_config .config
然后make编译

至此全志V3s的编译就完成了

参考:
https://www.jianshu.com/p/ad3619db9b3d
https://blog.csdn.net/zhoukaiqili/article/details/126191871
https://www.kancloud.cn/lichee/lpi0/418673
https://blog.51cto.com/axlrose/1296324
https://blog.csdn.net/qq_31301437/article/details/119948386

https://blog.csdn.net/lengyuefeng212/article/details/118861717

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值