之前使用CubieBoard7开发板提供的代码编译基于安卓系统固件时遇到了一些问题,简单描述一下解决方式。
CubieBoard7开发板资料下载:!
进入到CubieBoard7/Cubietech_Release/Source/Android/Android-SDK-V2.1(当时最新版本)文件夹 找到android5.1_sdk_s700_v2.1.tar.gz和android5.1_sdk_s700_v2.1.tar.gz.md5,拷贝到linux系统内进行开始编译前的准备工作:
1.首先切换到管理员用户:
在管理员用户下做相关编译工作,防止编译过程中出现权限不足的情况;
2.源码md5校验:
根据资料中提供的源码和md5文件,在源码同级目录下输入:
1. 输入:find android5.1_sdk_s700_v2.1.tar.gz | xargs md5sum > android5.1_sdk_s700_v2.1_1.md5
生成md5文件;
2. 输入:diff android5.1_sdk_s700_v2.1_1.md5 android5.1_sdk_s700_v2.1.tar.gz.md5
如果没有显示MD5值说明文件没有被破坏可以使用(MD5值相同);
3.创建源码保存文件夹:
输入:mkdir android5.1_sdk_s700
创建android5.1_sdk_s700文件夹;
4.解压源码到保存文件夹:
输入:tar -zxpf android5.1_sdk_s700_v2.1.tar.gz -C android5.1_sdk_s700
源码解压到android5.1_sdk_s700文件夹;
5.进入源码文件夹:
输入:cd android5.1_sdk_s700/android5.1_sdk_s700_v2.1/
进入到源码文件夹;
6.从git托管中检出源码:
代码从当前文件夹中看不到,需要检出源码:
1. 输入:cp .repo/sync.sh ./
2. 输入:./sync.sh
等待源码检出完成;
7.设置shell:
1. 输入:rm –rf /bin/sh
如果提示“rm: cannot remove ‘–rf’: No such file or directory”直接忽略掉就行;
2. 输入:ln -s /bin/bash /bin/sh
3. 输入:ls -l /bin/sh
如果提示:“lrwxrwxrwx 1 root root 9 11月 26 20:55 /bin/sh -> /bin/bash”,表示软链接成功;
8.linux环境搭建:
如果已经搭建好OpenJdk和编译依赖文件直接参考下面编译步骤!
如果还没有搭建环境,请参考“ linux环境搭建参考”,继续向下看,
特别说明:
1. jdk请下载1.7.0-1.8.0范围内的OpenJdk;
2. gcc与g++不需要选择降级(使用4.8.0或以上的版本);
9.检查代码分支:
特别说明:这个源码属于当前(我下载的时候)最新发布分支,只需要保证代码完整即可;
1. 输入:repo status
如果提示“The program ‘repo’ is currently not installed. You can install it by typing:
sudo apt-get install phablet-tools”,需要安装相关工具;
正常情况下显示:
project android/ branch s700-release
project kernel/ branch s700-release
project owl/s700/ branch s700-release
project owl/scripts/ branch s700-release
project owl/tools/adb_drv/ branch s700-release
project owl/tools/burn_tool/ branch s700-release
project owl/tools/fw_maker/ branch s700-release
project owl/tools/utils/ branch s700-release
project toolchain/aarch64-linux-gnu/ branch s700-release
project toolchain/arm-linux-gnueabihf/ branch s700-release
project u-boot/ branch s700-release
2. 安装相关工具(可以正常显示分支信息的机器不用安装):
输入:apt-get install phablet-tools
到这里,编译前的准备工作做好了,现在开始编译固件:
1.指定编译类型:
输入:./autobuild.sh config
输出下列信息:
Select board type:
1. s700_aio
2. s700_cb7
3. s700_miniPC
根据需要选择相关类型,我选择的是“2. s700_cb7”;
2.开始编译固件:
输入:./autobuild.sh
3.编译完成后,固件存放位置:
固件存放位置与编译类型有关,路径大概位置:android5.1_sdk_s700_v2.1/
owl/out/s700_android_(s700_cb7(这个是指定的编译类型))
/images/s700_android_s700_(s700_cb7)_(生成时间)*.fw
到这里,固件编译完成了,下面说下编译过程中可能出现的问题:
1./bin/sh: 1: source: not found:
完整错误如下:
cp /home/linux/Documents/andriod_kernel/ats/android5.1_sdk_s700_v2.1/owl/out/s700_android_s700_aio/misc/modules/g_android.ko /home/linux/Documents/andriod_kernel/ats/android5.1_sdk_s700_v2.1/owl/../android/device/actions/s700_aio/recovery/
cp /home/linux/Documents/andriod_kernel/ats/android5.1_sdk_s700_v2.1/owl/out/s700_android_s700_aio/misc/modules/u_serial.ko /home/linux/Documents/andriod_kernel/ats/android5.1_sdk_s700_v2.1/owl/../android/device/actions/s700_aio/recovery/
cd /home/linux/Documents/andriod_kernel/ats/android5.1_sdk_s700_v2.1/owl/../android && source build/envsetup.sh && lunch s700_aio-userdebug && make -j$((3+1))
/bin/sh: 1: source: not found
make: *** [system] Error 127
这种情况出现的问题属于,没有修改shell造成的,请参考 “6.设置shell:”;在单独编译安卓源码和linux内核中发现,没有指定shell为bash时,内核也无法编译成功;
2.make[3]: * [arch/x86/platform/efi/efi.o] Error 1:
完整错误如下:
arch/x86/platform/efi/efi.c: In function ‘efi_init’:
arch/x86/platform/efi/efi.c:643:5: error: ‘struct efi’ has no member named ‘config_table’
efi.config_table = (unsigned long)efi.systab->tables;
^
arch/x86/platform/efi/efi.c:644:5: error: ‘struct efi’ has no member named ‘fw_vendor’
efi.fw_vendor = (unsigned long)efi.systab->fw_vendor;
^
arch/x86/platform/efi/efi.c:645:5: error: ‘struct efi’ has no member named ‘runtime’
efi.runtime = (unsigned long)efi.systab->runtime;
^
make[3]: *** [arch/x86/platform/efi/efi.o] Error 1
make[2]: *** [arch/x86/platform/efi] Error 2
make[1]: *** [arch/x86/platform] Error 2
make: *** [arch/x86] Error 2 (kernel)
打开kernel/arch/x86/platform/efi/efi.c,根据指定行位置注释掉提示的这三行代码;
3.make[2]: * [fs/pstore/ram.o] Error 1:
完整错误如下:
fs/pstore/ram.c:46:37: error: ‘SZ_256K’ undeclared here (not in a function)
static ulong ramoops_console_size = SZ_256K;
^
fs/pstore/ram.c:59:23: error: ‘SZ_512K’ undeclared here (not in a function)
static ulong mem_size=SZ_512K;
^
make[2]: *** [fs/pstore/ram.o] Error 1
make[1]: *** [fs/pstore] Error 2
make: *** [fs] Error 2
打开fs/pstore/ram.c,在#define MIN_MEM_SIZE 4096UL下增加:
#define SZ_1K 1024
#define SZ_256K (256 * SZ_1K)
#define SZ_512K (512 * SZ_1K)
文章到这里结束了,如果编译过程中遇到别的问题,可以在文章下方留言~