板子helper2416 芯片是三星的s3c2416 arm平台 本机系统: opensuse
只是记录过程,写的可能有些乱
android源码下载方法参考以下链接
http://source.android.com/source/downloading.html
得安装有git与curl
ub安装方法
apt-get install git-core curl
suse安装方法zypper install git-core curl
安装repo
确定有~/bin 并且在PATH环境变量中
没有可以自己弄
$ mkdir ~/bin
$ PATH=~/bin:$PATH
下载 repo
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
$ mkdir android_src
$ cd android_src
下载最新源码 (下面的过程是android4的,只是编译过,运行有问题,尝试过android的多个版本, 运行比较好的是1.6的版本)
$ repo init -u https://android.googlesource.com/platform/manifest
$ repo sync
用repo sync 在抓去 android source code 的时候,会经常出现一些错误导致 repo sync 中断,每次都要手动开始。 可以用如下的命令,来自动重复: $?=1; while [ $? -ne 0 ] ; do repo sync ; done
repo好像还用到python,如果有依赖,请自行安装python
这个需要好几小时,似乎有超过5个G的东西要下载
helper2416 用的是s3c2416的arm9 cpu, 类型是armv5te
make TARGET_ARCH_VARIANT=armv5te TARGET_TOOLS_PREFIX=/opt/toolchains/arm-jyxtec-linux-gnueabi/bin/arm-linux-
build/core/main.mk:42: ********************************************************************************
build/core/main.mk:43: * You are using version 3.82 of make.
build/core/main.mk:44: * Android can only be built by version 3.81.
build/core/main.mk:45: * see http://source.android.com/source/download.html
build/core/main.mk:46: ********************************************************************************
build/core/main.mk:47: *** stopping。 停止。
似乎是 make版本必须为3.8.1
http://ftp.gnu.org/gnu/make/
下载3.8.1的make源码编译安装
如果用3.8.2 make过程会出现下面的问题
*** glibc detected *** make: free(): invalid next size (fast): 0x10af4100 ***
======= Backtrace: =========
/lib/libc.so.6(+0x6de2b)[0xb775de2b]
/lib/libc.so.6(+0x6ebab)[0xb775ebab]
/lib/libc.so.6(cfree+0x6d)[0xb7762a6d]
.............
错误
build/core/config.mk:268: *** Error: could not find jdk tools.jar, please install JDK6, which you can download from java.sun.com。 停止。
这个原因是机子上装的是openJDK,但是要求的是sunJDK,似乎是说openJDK有一些问题
不管它了,直接暴力注释掉,尝试使用openJDK编译 (建议用sunJDK)
#ifeq ($(wildcard $(HOST_JDK_TOOLS_JAR)),)
#$(error Error: could not find jdk tools.jar, please install JDK6, \
# which you can download from java.sun.com)
#endif
错误
which: no javac in (/usr/lib/mpi/gcc/openmpi/bin:/home/zengming/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib/jvm/jre/bin)
未安装java的开发包,安装java-1.6.0-openjdk-devel解决
错误
You are attempting to build with the incorrect version
of java.
Your version is: java version "1.6.0_24".
The correct version is: Java SE 1.6.
build/core/main.mk 119行处,注释掉下面三行
#ifneq ($(shell java -version 2>&1 | grep -i openjdk),)
#java_version :=
#endif
编译出错
/opt/toolchains/arm-jyxtec-linux-gnueabi/bin/../lib/gcc/arm-jyxtec-linux-gnueabi/4.4.6/../../../../arm-jyxtec-linux-gnueabi/bin/ld: unrecognized option '--icf=safe'
/opt/toolchains/arm-jyxtec-linux-gnueabi/bin/../lib/gcc/arm-jyxtec-linux-gnueabi/4.4.6/../../../../arm-jyxtec-linux-gnueabi/bin/ld: use the --help option for usage information
collect2: ld returned 1 exit status
make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/libdl_intermediates/LINKED/libdl.so] 错误 1
看来不是顺便的编译器都可以的
make TARGET_ARCH_VARIANT=armv5te TARGET_TOOLS_PREFIX=./prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
出错
error: template with C linkage
make TARGET_ARCH_VARIANT=armv5te (后面这部分可不加)TARGET_TOOLS_PREFIX=./prebuilt/linux-x86/toolchain/arm-linux-androideabi-4.4.x/bin/arm-linux-androideabi-
没有上面问题
不过后面还是出错
host/linux-x86/bin/dexopt: symbol lookup error: /home/zengming/workspace/android_src/out/host/linux-x86/bin/../lib/libdvm.so: undefined symbol: ucal_getAvailable_46
尝试降版本,再编译还是不行
repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.4_r1
似乎上面的不工作 中间不加链接 直接 repo init -b android-1.6_r2 repo sync 就可以切换版本到1.6了
repo sync
make TARGET_ARCH_VARIANT=armv5te
查了下google,这个声明与定义是分别是在以下文件
ucal.h, libicui18n.so 这个应该是icu4c提供的,但是在此源码下的icu4c并没有这个函数的定义
只有ucal_getAvailable
external/icu4c/common/unicode/urename.h:
如果U_DISABLE_RENAMING 为非0
#define ucal_getAvailable U_ICU_ENTRY_POINT_RENAME(ucal_getAvailable)
这里会把ucal_getAvailable变成ucal_getAvailable_46,问题可能出现在这里
external/icu4c/common/unicode/platform.h
/* Determine whether to disable renaming or not. This overrides the
setting in umachine.h which is for all platforms. */
#ifndef U_DISABLE_RENAMING
#define U_DISABLE_RENAMING 0 //尝试这里0改成1 还是出问题
#endif
改成1后问题如下
host/linux-x86/bin/dexopt: symbol lookup error: android_src/out/host/linux-x86/bin/../lib/libdvm.so: undefined symbol: unum_countAvailable
无意中/usr/local/lib发现下面有libicui18n.so,看来真凶在此,运行过程加载的是这里的lib,所以会出现问题,把它删掉,或者用编译生成的lib替换它
host/linux-x86/bin/dexopt: symbol lookup error: android_src/out/host/linux-x86/bin/../lib/libicui18n.so: undefined symbol: _ZNK3icu17StringEnumeration5cloneEv
其原型应该是virtual StringEnumeration *clone() const;
icu4的源码中strenum.h声明的,而在/usr/local/include下也发现了它,这里才记得自己曾经源码编译过libicu版本为4.8的,删除/usr/local/include/unicode 结果还是不能解决
看了下andorid源码中已经有定义了
external/icu4c/common/ustrenum.cpp
StringEnumeration *
StringEnumeration::clone() const {
return NULL;
}
sudo rm /usr/local/lib/libicuuc.so*
编译过程会出现qadd16的一些error
webrtc中用到了汇编优化,这里qadd16是个armv6指令,定位出错位置在:webrtc/src/common_audio/signal_processing_library/main/interface/spl_inl.h, google it 发现TeamICS已经打出了patch,直接patch下spl_inl.h替代里面不被支持的指令即可
修改
./external/webrtc/src/common_audio/signal_processing_library/main/interface/spl_inl.h
#ifdef WEBRTC_ANDROID
//注意+表示新增加的代码-表示删掉的代码
+__asm (
+ // On Android gcc compiler, the clz instruction is not supported with a
+ // target smaller than armv7, despite it being legal for armv5+.
+" .arch armv7-a\n"
+//" clz %0, %1 \n"
+//"=r" (leading_zeroes)
+//"r" (data)
+);
+
WEBRTC_INLINE WebRtc_Word32 WEBRTC_SPL_MUL(WebRtc_Word32 a, WebRtc_Word32 b)
{
WebRtc_Word32 tmp;
- __asm__("mul %0, %1, %2":"=r"(tmp):"r"(a), "r"(b));
+ __asm__("smmul %0, %1, %2":"=r"(tmp):"r"(a), "r"(b)); //changed mul to smmul.
return tmp;
}
@@ -66,7 +75,7 @@ WEBRTC_INLINE WebRtc_Word16 WebRtcSpl_AddSatW16(WebRtc_Word16 a,
{
WebRtc_Word32 s_sum;
- __asm__("qadd16 %0, %1, %2":"=r"(s_sum):"r"(a), "r"(b));
+ __asm__("qadd %0, %1, %2":"=r"(s_sum):"r"(a), "r"(b));
return (WebRtc_Word16) s_sum;
}
@@ -86,7 +95,7 @@ WEBRTC_INLINE WebRtc_Word16 WebRtcSpl_SubSatW16(WebRtc_Word16 var1,
{
WebRtc_Word32 s_sub;
- __asm__("qsub16 %0, %1, %2":"=r"(s_sub):"r"(var1), "r"(var2));
+ __asm__("qsub %0, %1, %2":"=r"(s_sub):"r"(var1), "r"(var2));
return (WebRtc_Word16)s_sub;
}
再编译
PassFailButtons.java:191: android.app.Activity 中的 onCreateDialog(int,android.os.Bundle) 无法实现 com.android.cts.verifier.PassFailButtons.PassFailActivity 中的 onCreateDialog(int,android.os.Bundle);正在尝试指定更低的访问权限;为 public
private static <T extends android.app.Activity & PassFailActivity
这个问题是使用openJDK的原因
找到cts/下的Android.mk文件,注释掉里面代码
#include cts/CtsNativeTestCase.mk
#include cts/CtsTestCoverage.mk
#include $(call all-subdir-makefiles)
在android根目录里面有一个out目录里会包含已经生成好的文件系统。
android_src/out/target/product/generic> ls
android-info.txt data installed-files.txt previous_build_config.mk root system userdata.img
clean_steps.mk dex_bootjars obj ramdisk.img symbols system.img
将system目录和data目录拷贝到root目录下,root目录里面本来就有system目录和data目录,但是都是空的,需要用上层的system目录和data目录来替换和覆盖。这样,就制作好了root目录了,这个目录就是android文件系统的根目录。可以用mkyaffs工具打包然后烧写flash,但是我是用的nfs来载入android文件系统的
init (1): /proc/1/oom_adj is deprecated, please use /proc/1/oom_score_adj instead.
init: cannot open '/initlogo.rle'
init: Unable to open persistent property directory /data/property errno: 2
init: cannot find '/system/etc/install-recovery.sh', disabling 'flash_recovery'
sh: can't access tty; job control turned off
$ warning: `rild' uses 32-bit capabilities (legacy support in use)
init: untracked pid 45 exited
init: untracked pid 73 exited
未解决
logcat输出很多
W/SurfaceFlinger( 1402): ANDROID_WAIT_FOR_FB_WAKE failed (Bad file number)
The fix is to make sure CONFIG_WAKELOCK and CONFIG_EARLYSUSPEND and CONFIG_FB_EARLYSUSPEND are enabled in the kernel.
menuconfig
power management options ---> [*] Wake lock
User-space screen access (Sysfs interface) --->
E/keystore( 117): chdir: /data/misc/keystore: No such file or directory
根下mkdir data/misc/keystore -p
menuconfig
Choose double buffering support (S3C double buffering supported) --->
drivers/video/s3cfb.h 下加
void s3c_fb_change_buff(int req_winNum, int req_fb);
1842 0 0% S 5 17736K 4864K fg media /system/bin/mediaserver
1843 0 0% S 5 6352K 904K fg root /system/bin/netd
这两个进程会不断重启
I/ServiceManager( 40): service 'media.audio_flinger' died
init: untracked pid 314 exited
init: untracked pid 315 exited
I/ServiceManager( 40): service 'media.player' died
I/ServiceManager( 40): service 'media.camera' died
I/ServiceManager( 40): service 'media.audio_policy' died
I/Netd ( 337): Netd 1.0 starting
E/Netd ( 337): Unable to create netlink socket: Protocol not supported
E/Netd ( 337): Unable to open quota2 logging socket
I/ ( 336): ServiceManager: 0x145c958
netd的问题解决方法
需要CONFIG_QUOTA_NETLINK_INTERFACE
menuconfig
File systems --->[*] Quota support
[*] Report quota messages through netlink interface
因为是在nfs中启动, 在init.rc中的改动如下:
# mount mtd partitions
# Mount /system rw first to give the filesystem a chance to save a checkpoint
#mount yaffs2 mtd@system /system
#mount yaffs2 mtd@system /system ro remount
#mount yaffs2 mtd@userdata /data nosuid nodev
#mount yaffs2 mtd@cache /cache nosuid nodev
注释掉上面几行
init: Unable to open persistent property directory /data/property errno: 2
解决方法:
在data目录下自己手动建立一个property文件夹
模拟
./out/host/linux-x86/bin/emulator-arm -kernel ~/workspace/android_kernel/samsung/arch/arm/boot/zImage -sysdir ~/workspace/android_src/out/target/product/generic/ -system system.img -data userdata.img -ramdisk ramdisk.img -partition-size 500 -verbose -show-kernel -shell -debug-enable
作者:帅得不敢出门 c++哈哈堂群:31843264 转载请保留此信息