二、编译全志A64的内核
1.查看帮助
$cd lichee
$ ./build.sh -h
Top level build script for lichee
Examples:
1. Set the config option
$ ./build.sh config
2. Build lichee using preset config value
$ ./build.sh
3. Pack a linux, dragonboard image
$ ./build.sh pack
4. Build lichee using command argument
$ ./build.sh -p <platform>
flags:
-p,--platform: platform to build, e.g. sun9iw1p1 (default: '')
-k,--kernel: kernel to build, e.g. 3.3 (default: 'linux-3.4')
-b,--board: board to build, e.g. evb (default: '')
-m,--module: module to build, e.g. buildroot, kernel, uboot, clean (default: '')
-h,--[no]help: show this help (default: false)
2.利用build.sh配置内核,选择主板型号
litin@linuxService:~/Android/allwinner/cqa64_android_v5.1/lichee$ ./build.sh config
Welcome to mkscript setup progress
All available chips:
0. sun50iw1p1
Choice: 0
All available platforms:
0. android
1. ubuntu
2. linuxqt
Choice: 0
All available kernel:
0. linux-3.10
Choice: 0
All available boards:
0. t1
1. t1_v1
Choice: 0
3.编译安卓内核
litin@linuxService:~/Android/allwinner/cqa64_android_v5.1/lichee$ ./build.sh
INFO: ----------------------------------------
INFO: build lichee ...
INFO: chip: sun50iw1p1
INFO: platform: android
INFO: kernel: linux-3.10
INFO: board: t1
INFO: output: out/sun50iw1p1/android/t1
INFO: ----------------------------------------
INFO: build buildroot ...
external toolchain has been installed
external toolchain_32 has been installed
INFO: build buildroot OK.
INFO: build kernel ...
INFO: prepare toolchain ...
三.编译安卓源码
1.选择产品型号
我的产品型号是 tulip_t1,则选择:7
litin@linuxService:~/Android/allwinner/cqa64_android_v5.1/android$ source build/envsetup.sh
including device/softwinner/common/vendorsetup.sh
including device/softwinner/tulip-t1/vendorsetup.sh
including device/softwinner/tulip-t1_v1/vendorsetup.sh
including device/generic/mini-emulator-arm64/vendorsetup.sh
including device/generic/mini-emulator-mips/vendorsetup.sh
including device/generic/mini-emulator-x86/vendorsetup.sh
including device/generic/mini-emulator-armv7-a-neon/vendorsetup.sh
including device/generic/mini-emulator-x86_64/vendorsetup.sh
including device/moto/shamu/vendorsetup.sh
including device/asus/flo/vendorsetup.sh
including device/samsung/manta/vendorsetup.sh
including device/htc/flounder/vendorsetup.sh
including sdk/bash_completion/adb.bash
litin@linuxService:~/Android/allwinner/cqa64_android_v5.1/android$ lunch
You're building on Linux
Lunch menu... pick a combo:
1. aosp_arm-eng
2. aosp_arm64-eng
3. aosp_mips-eng
4. aosp_mips64-eng
5. aosp_x86-eng
6. aosp_x86_64-eng
7. tulip_t1-eng
8. tulip_t1-user
9. tulip_t1_v1-eng
10. tulip_t1_v1-user
11. mini_emulator_arm64-userdebug
12. mini_emulator_mips-userdebug
13. mini_emulator_x86-userdebug
14. m_e_arm-userdebug
15. mini_emulator_x86_64-userdebug
16. aosp_shamu-userdebug
17. aosp_flo-userdebug
18. aosp_manta-userdebug
19. aosp_flounder-userdebug
Which would you like? [aosp_arm-eng] 7
2.拷贝安卓内核到源码目录
$ extract-bsp
/home/litin/Android/allwinner/cqa64_android_v5.1/android/device/softwinner/tulip-t1/bImage copied!
/home/litin/Android/allwinner/cqa64_android_v5.1/android/device/softwinner/tulip-t1/modules copied!
3.开始编译安卓源码
litin@linuxService:~/Android/allwinner/cqa64_android_v5.1/android$ make -j8
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=5.1.1
TARGET_PRODUCT=tulip_t1
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm64
TARGET_ARCH_VARIANT=armv8-a
TARGET_CPU_VARIANT=generic
TARGET_2ND_ARCH=arm
TARGET_2ND_ARCH_VARIANT=armv7-a-neon
TARGET_2ND_CPU_VARIANT=cortex-a15
HOST_ARCH=x86_64
HOST_OS=linux
HOST_OS_EXTRA=Linux-4.4.0-98-generic-x86_64-with-Ubuntu-14.04-trusty
HOST_BUILD_TYPE=release
BUILD_ID=LVY48E
OUT_DIR=out
============================================
Checking build tools versions...
including ./abi/cpp/Android.mk ...
including ./art/Android.mk ...
.............................................................................
Installed file list: out/target/product/tulip-t1/installed-files.txt
Target system fs image: out/target/product/tulip-t1/obj/PACKAGING/systemimage_intermediates/system.img
Running: mkuserimg.sh -s out/target/product/tulip-t1/system out/target/product/tulip-t1/obj/PACKAGING/systemimage_intermediates/system.img ext4 system 1610612736 out/target/product/tulip-t1/root/file_contexts
make_ext4fs -s -T -1 -S out/target/product/tulip-t1/root/file_contexts -l 1610612736 -a system out/target/product/tulip-t1/obj/PACKAGING/systemimage_intermediates/system.img out/target/product/tulip-t1/system
Creating filesystem with parameters:
Size: 1610612736
Block size: 4096
Blocks per group: 32768
Inodes per group: 8192
Inode size: 256
Journal blocks: 6144
Label:
Blocks: 393216
Block groups: 12
Reserved block group size: 95
Created filesystem with 1969/98304 inodes and 140794/393216 blocks
Install system fs image: out/target/product/tulip-t1/system.img
out/target/product/tulip-t1/system.img+out/target/product/tulip-t1/obj/PACKAGING/recovery_patch_intermediates/recovery_from_boot.p maxsize=1644331392 blocksize=4224 total=552394391 reserve=16612992
#### make completed successfully (01:35:12 (hh:mm:ss)) ####
三、全志平台中编译的时候遇到的大坑
1.内核编译出错
make[1]: 没有什么可以做的为 `dtbs'。
CHK include/generated/compile.h
CHK kernel/config_data.h
LD drivers/net/wireless/rtl8188eu/built-in.o
/home/litin/Android/allwinner/cqa64_android_v5.1/lichee/out/sun50iw1p1/android/common/buildroot/external-toolchain/bin/aarch64-linux-gnu-ar: drivers/net/wireless/rtl8188eu/built-in.o: 权限不够
make[4]: *** [drivers/net/wireless/rtl8188eu/built-in.o] 错误 1
make[3]: *** [drivers/net/wireless/rtl8188eu] 错误 2
make[3]: *** 正在等待未完成的任务....
CC drivers/switch/switch_class.o
CC drivers/thermal/thermal_core.o
CC drivers/tty/tty_io.o
CC drivers/tty/n_tty.o
make[2]: *** [drivers/net/wireless] 错误 2
make[1]: *** [drivers/net] 错误 2
make[1]: *** 正在等待未完成的任务....
SHIPPED drivers/tty/vt/defkeymap.c
CC drivers/tty/vt/consolemap_deftbl.o
CC drivers/tty/vt/defkeymap.o
CC drivers/tty/serial/kgdboc.o
CC drivers/tty/serial/sunxi-uart.o
LD drivers/tty/serial/built-in.o
LD drivers/tty/vt/built-in.o
LD drivers/tty/built-in.o
make: *** [drivers] 错误 2
ERROR: build kernel Faile
提示权限不够,用root权限编译才能顺利编译完成,真是无语,内核全部是普通用户,且都有读写的权限,竟然还要用root才能编译。。。
2../build.sh pack打包失败
Service:~/Android/allwinner/cqa64_android_v5.1/lichee$ ./build.sh pack
INFO: packing firmware ...
copying tools file
copying configs file
./out/aultls32.fex
./out/aultools.fex
./out/cardscript.fex
./out/cardtool.fex
./out/diskfs.fex
./out/env_burn.cfg
./out/env.cfg
./out/image.cfg
./out/image_linux.cfg
./out/split_xxxx.fex
./out/sunxi.fex
./out/sys_config_1024x600.fex
./out/sys_config_1024x768.fex
./out/sys_config_800x480.fex
./out/sys_config.fex
./out/sys_config_hdmi_lcd_1080p.fex
./out/sys_config_tm121sds01.fex
./out/sys_config_vga_768p.fex
./out/sys_partition_dragonboard.fex
./out/sys_partition_dump.fex
./out/sys_partition.fex
./out/sys_partition_linux.fex
./out/sys_partition_private.fex
./out/test_config.fex
./out/toc0.fex
./out/toc1.fex
./out/usbtool.fex
./out/usbtool_test.fex
copying boot resource
copying boot file
Script_to_dts: Can not find [sun50iw1p1-t1_v1.dts]. Will use common dts file instead.
FATAL ERROR: Couldn't open output file /home/litin/Android/allwinner/cqa64_android_v5.1/lichee/out/sun50iw1p1/android/common/sunxi.dtb: Permission denied #######权限不够
Conver script to dts ok.
merge_uboot: u-boot.fex will merge monitor.fex, generate u-boot.fex, mode secmonitor
merge_uboot: num 746660 randto1k
merge_uboot: num 41016 randto1k
file1_len = b6800, file2_len = a400
file[secmonitor] offset b6800,size a400
merge_uboot:genrate /home/litin/Android/allwinner/cqa64_android_v5.1/lichee/tools/pack/out/u-boot.fex ok
merge_uboot: u-boot.fex will merge scp.fex, generate u-boot.fex, mode scp
merge_uboot: num 104660 randto1k
file1_len = c0c00, file2_len = 19c00
file[scp] offset c0c00,size 19c00
merge_uboot:genrate /home/litin/Android/allwinner/cqa64_android_v5.1/lichee/tools/pack/out/u-boot.fex ok
packing for android
normal
/home/litin/Android/allwinner/cqa64_android_v5.1/lichee/tools/pack/pctools/linux/eDragonEx/
/home/litin/Android/allwinner/cqa64_android_v5.1/lichee/tools/pack/out
Begin Parse sys_partion.fex
Add partion boot-resource.fex BOOT-RESOURCE_FEX
Add partion very boot-resource.fex BOOT-RESOURCE_FEX
FilePath: boot-resource.fex
FileLength=4f6400Add partion env.fex ENV_FEX000000000
Add partion very env.fex ENV_FEX000000000
FilePath: env.fex
FileLength=20000Add partion boot.fex BOOT_FEX00000000
Add partion very boot.fex BOOT_FEX00000000
FilePath: boot.fex
FileLength=f99000Add partion system.fex SYSTEM_FEX000000
Add partion very system.fex SYSTEM_FEX000000
FilePath: system.fex
FileLength=1f0b7938Add partion recovery.fex RECOVERY_FEX0000
Add partion very recovery.fex RECOVERY_FEX0000
FilePath: recovery.fex
FileLength=10c6000Add partion diskfs.fex DISKFS_FEX000000
Add partion very diskfs.fex DISKFS_FEX000000
FilePath: diskfs.fex
.........................................................
diskfs.fex Len: 0x200
Vdiskfs.fex Len: 0x4
open file arisc.fex Faied!
BuildImage level_2 Failed 615
BuildImg 615
Dragon execute image.cfg Failed ! ArgCnt = 3, 615
pack finish
解决方法:同样是权限不够,导致打包失败,用以下命令即可成功。
sudo ./build.sh pack
百度一下,发现其他人也遇到这个问题,但原因不一:
(1)打包安卓系统遇到bootfex CreateFile failed 2和Dragon execute imagecfg Failed ! 错误
(2)求助!全志方案pack打包镜像出错,Dragon execute image.cfg Failed ! ArgCnt = 3, 400 [问题点数:20分,结帖人sgsxcwen]
3.pack打包的时候要求配置安卓镜像输出的路径“ERROR: please specify ANDROID_IMAGE_OUT env”
litin@linuxService:~/Android/allwinner/cqa64_android_v5.1/lichee$ sudo ./build.sh pack
[sudo] password for litin:
INFO: packing firmware ...
copying tools file
copying configs file
./out/aultls32.fex
./out/aultools.fex
./out/cardscript.fex
./out/cardtool.fex
./out/diskfs.fex
./out/env_burn.cfg
./out/env.cfg
./out/image.cfg
./out/image_linux.cfg
./out/split_xxxx.fex
./out/sunxi.fex
./out/sys_config_1024x600.fex
./out/sys_config_1024x768.fex
./out/sys_config_800x480.fex
./out/sys_config.fex
./out/sys_config_hdmi_lcd_1080p.fex
./out/sys_config_tm121sds01.fex
./out/sys_config_vga_768p.fex
./out/sys_partition_dragonboard.fex
./out/sys_partition_dump.fex
./out/sys_partition.fex
./out/sys_partition_linux.fex
./out/sys_partition_private.fex
./out/test_config.fex
./out/toc0.fex
./out/toc1.fex
./out/usbtool.fex
./out/usbtool_test.fex
copying boot resource
copying boot file
Script_to_dts: Can not find [sun50iw1p1-t1.dts]. Will use common dts file instead.
iniparser: syntax error in /home/litin/Android/allwinner/cqa64_android_v5.1/lichee/out/sun50iw1p1/android/common/../../../../tools/pack/out/sys_config_fix.fex (312):
-> spi-cpha
iniparser: syntax error in /home/litin/Android/allwinner/cqa64_android_v5.1/lichee/out/sun50iw1p1/android/common/../../../../tools/pack/out/sys_config_fix.fex (313):
-> spi-cpol
iniparser: syntax error in /home/litin/Android/allwinner/cqa64_android_v5.1/lichee/out/sun50iw1p1/android/common/../../../../tools/pack/out/sys_config_fix.fex (314):
-> spi-cs-high
.....................................................................................
merge_uboot: u-boot.fex will merge monitor.fex, generate u-boot.fex, mode secmonitor
merge_uboot: num 746660 randto1k
merge_uboot: num 41016 randto1k
file1_len = b6800, file2_len = a400
file[secmonitor] offset b6800,size a400
merge_uboot:genrate /home/litin/Android/allwinner/cqa64_android_v5.1/lichee/tools/pack/out/u-boot.fex ok
merge_uboot: u-boot.fex will merge scp.fex, generate u-boot.fex, mode scp
merge_uboot: num 104660 randto1k
file1_len = c0c00, file2_len = 19c00
file[scp] offset c0c00,size 19c00
merge_uboot:genrate /home/litin/Android/allwinner/cqa64_android_v5.1/lichee/tools/pack/out/u-boot.fex ok
packing for android
ERROR: please specify ANDROID_IMAGE_OUT env
解决方法:在pack文件里面配置安卓的编译输出路径“ANDROID_IMAGE_OUT”即可
vi lichee/tools/pack/
添加下面路径即可
ANDROID_IMAGE_OUT=~/Android/allwinner/cqa64_android_v5.1/android/out/target/product/tulip-t1_v1/
4.全志内核的配置文件在哪?
第一次使用全志平台,在编译内核的时候由于找不到内核配置文件,会让人找不到方向,其实它就在linux内核源码里面
litin@linuxService:~/Android/allwinner/cqa64_android_v5.1/lichee$ ls linux-3.10/arch/arm64/configs/
defconfig sun50iw1p1smp_android_defconfig sun50iw1p1smp_defconfig sun50iw1p1smp_min_defconfig
5.全志的fex系统配置文件在哪?
litin@linuxService:~/Android/allwinner/cqa64_android_v5.1/lichee$ find . -name "sys_config.fex"
./tools/pack/chips/sun50iw1p1/configs/t1/sys_config.fex
./tools/pack/chips/sun50iw1p1/configs/t1_v1/sys_config.fex
./tools/pack/out/sys_config.fex
6.全志lvds屏幕怎样配置时序
1.标准时序图
2.现用的1024x768的lvds液晶屏幕数据手册以及sys_config.fex文件配置
7.编译内核的时候,提示rtl8723bs模块生成是权限不足
litin@linuxService:~/Android/allwinner/cqa64_android_v5.1/lichee$ ./build.sh
INFO: ----------------------------------------
INFO: build lichee ...
INFO: chip: sun50iw1p1
INFO: platform: android
INFO: kernel: linux-3.10
INFO: board: t1
INFO: output: out/sun50iw1p1/android/t1
INFO: ----------------------------------------
INFO: build buildroot ...
external toolchain has been installed
external toolchain_32 has been installed
INFO: build buildroot OK.
INFO: build kernel ...
INFO: prepare toolchain ...
Building kernel
/home/litin/Android/allwinner/cqa64_android_v5.1/lichee/linux-3.10/output/lib/modules/3.10.65
lichee_chip = sun50iw1p1
Using default config sun50iw1p1smp_android_defconfig ...
scripts/kconfig/conf --silentoldconfig Kconfig
drivers/net/wireless/bcmdhd/Kconfig:50:warning: defaults for choice values not supported
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
CC scripts/mod/devicetable-offsets.s
CALL scripts/checksyscalls.sh
GEN scripts/mod/devicetable-offsets.h
HOSTCC scripts/mod/file2alias.o
HOSTLD scripts/mod/modpost
make[1]: 没有什么可以做的为 `dtbs'。
CHK include/generated/compile.h
GZIP kernel/config_data.gz
CHK kernel/config_data.h
LD drivers/net/wireless/rtl8188eu/built-in.o
/home/litin/Android/allwinner/cqa64_android_v5.1/lichee/out/sun50iw1p1/android/common/buildroot/external-toolchain/bin/aarch64-linux-gnu-ar: drivers/net/wireless/rtl8188eu/built-in.o: 权限不够
make[4]: *** [drivers/net/wireless/rtl8188eu/built-in.o] 错误 1
make[3]: *** [drivers/net/wireless/rtl8188eu] 错误 2
make[3]: *** 正在等待未完成的任务....
make[2]: *** [drivers/net/wireless] 错误 2
make[1]: *** [drivers/net] 错误 2
make[1]: *** 正在等待未完成的任务....
make: *** [drivers] 错误 2
ERROR: build kernel Failed
错误原因:编译该wifi模块要用root权限,具体原因不明。
解决方法:从内核配置项注释掉8723相关选项,可以直接在
vi linux-3.10/arch/arm64/configs/sun50iw1p1smp_android_defconfig
由于config不允许直接注释,再次编译linux内核的时候会提示8723模块程序要怎样配置,这时选择"n"就行了。
litin@linuxService:~/Android/allwinner/cqa64_android_v5.1/lichee$ ./build.sh
INFO: ----------------------------------------
INFO: build lichee ...
INFO: chip: sun50iw1p1
INFO: platform: android
INFO: kernel: linux-3.10
INFO: board: t1
INFO: output: out/sun50iw1p1/android/t1
INFO: ----------------------------------------
INFO: build buildroot ...
external toolchain has been installed
external toolchain_32 has been installed
INFO: build buildroot OK.
INFO: build kernel ...
INFO: prepare toolchain ...
Building kernel
/home/litin/Android/allwinner/cqa64_android_v5.1/lichee/linux-3.10/output/lib/modules/3.10.65
lichee_chip = sun50iw1p1
Using default config sun50iw1p1smp_android_defconfig ...
scripts/kconfig/conf --silentoldconfig Kconfig
drivers/net/wireless/bcmdhd/Kconfig:50:warning: defaults for choice values not supported
*
* Restart config...
*
*
* Wireless LAN
*
Wireless LAN (WLAN) [Y/n/?] y
USB ZD1201 based Wireless device support (USB_ZD1201) [N/m/y/?] n
Wireless RNDIS USB support (USB_NET_RNDIS_WLAN) [N/m/y/?] n
Enable WiFi control function abstraction (WIFI_CONTROL_FUNC) [N/y/?] n
Broadcom FullMAC wireless cards support (BCMDHD) [M/n/y/?] m
Firmware path (BCMDHD_FW_PATH) [/system/vendor/modules/fw_bcmdhd.bin] /system/vendor/modules/fw_bcmdhd.bin
NVRAM path (BCMDHD_NVRAM_PATH) [/system/vendor/modules/nvram.txt] /system/vendor/modules/nvram.txt
Enable Chip Interface
> 1. SDIO bus interface support (BCMDHD_SDIO)
choice[1]: 1
Interrupt type
> 1. Out-of-Band Interrupt (BCMDHD_OOB)
2. In-Band Interrupt (BCMDHD_SDIO_IRQ)
choice[1-2?]: 1
Broadcom IEEE802.11n embedded FullMAC WLAN driver (BRCMFMAC) [N/m/y/?] n
IEEE 802.11 for Host AP (Prism2/2.5/3 and WEP/TKIP/CCMP) (HOSTAP) [N/m/y/?] n
Marvell 8xxx Libertas WLAN driver support (LIBERTAS) [N/m/y/?] n
Marvell WiFi-Ex Driver (MWIFIEX) [N/m/y/?] n
Realtek 8188E USB WiFi (RTL8188EU) [N/m/y/?] (NEW) n
Realtek 8723B SDIO or SPI WiFi (RTL8723BS) [N/m/y/?] (NEW) n
Realtek 8723BS_VQ0 WiFi (RTL8723BS_VQ0) [N/m/y/?] (NEW) n
Realtek 8189F SDIO WiFi (RTL8189FS) [N/m/y/?] (NEW) n
#
# configuration written to .config
#
8.利用“PhoenixUSBPro.exe”刷机一直没反应
串口输出信息如下
shell@tulip-t1_v1:/ $ set pll start
set pll end
beign to init dram
DRAM driver version: V1.0
DRAM Type = 3 (2:DDR2,3:DDR3,6:LPDDR2,7:LPDDR3)
DRAM clk = 672 MHz
DRAM zq value: 003b3bbb
rsb_send_initseq: rsb clk 400Khz -> 3Mhz
PMU: AXP81X
ddr voltage = 1500 mv
DRAM single rank full DQ OK
DRAM size = 1024 MB
DRAM init ok
init dram ok
问题分析:对比正常烧录固件,发现多了一个bootloader的启动信息
set pll start
set pll end
beign to init dram
DRAM driver version: V1.0
DRAM Type = 3 (2:DDR2,3:DDR3,6:LPDDR2,7:LPDDR3)
DRAM clk = 672 MHz
DRAM zq value: 003b3bbb
rsb_send_initseq: rsb clk 400Khz -> 3Mhz
PMU: AXP81X
ddr voltage = 1500 mv
DRAM single rank full DQ OK
DRAM size = 1024 MB
DRAM init ok
init dram ok
U-Boot 2014.07 (Sep 16 2015 - 18:08:34) Allwinner Technology
uboot commit : ad5f4db37d600c2566902ed7e243eaa9b670a563
uboot:normal mode
without secure monitor
[ 2.522]pmbus: ready
axp read error
probe axp81X failed
axp_probe error
[ 2.556]PMU: cpux 408 Mhz,AXI=136 Mhz
PLL6=600 Mhz,AHB1=200 Mhz, APB1=100Mhz AHB2=200Mhz MBus=400Mhz
DRAM: 496 MiB
fdt addr: 0x56eb8460
Relocation Offset is: 15f0a000
In: serial
Out: serial
Err: serial
gic: normal mode
问题解决:重新编译镜像文件,特别是bootloader部分,可能由于某些原因修改了bootloader信息,只有恢复正常的bootloader即可正常烧录镜像。