Hi,
I'm working on trying to port android to linux-omap-2.6.30
kernel version. I've managed to successfully compile the kernel image.
When performing the port to a new kernel version, the bionic/libc
headers also require an update to linux kernel 2.6.30.
I was wondering if someone would be able to validate the changes and
modifications that I have made so far, and suggest some better fixes,
for example, I've had to disable boot animation, to get the
compilation to proceed, due to a linker error. Since this is a first
iteration, at this port, I thought it was acceptable just to try to
see how far it goes. I haven't tested it yet, but was wondering if
someone would be interested in trying this out in parallel, and get
android 1.5 SDK running on android-2.6.30 kernel version.
The reason for attempting this is to update the kernel version for the
gumstix overo, to better take advantage of the power management
functionality currently under development in kevin hilman's linux-omap-
pm pm branch.
Best regards,
Elvis
Technote android-2.6.30-001: How to regenerate bionic/libc/common/
kernel headers for linux kernel v2.6.30
Overview
This document describes how to update the android/bionic/libc/kernel
headers to linux kernel v2.6.30.
Procedure
Step 01.00: Backup the existing android/bionic/libc folder.
You will need the following header files from the existing v2.6.29
linux kernel headers at a later step:
android-alarm.h
android-pmem.h
android_power.h
ashmem.h
binder.h
msm_adsp.h
msm_audio.h
msm_mdp.h
keychord.h
Step 02.00: Clean up the existing android/bionic/libc/kernel folder.
Delete the contents of the following folders
android/bionic/libc/kernel/arch-arm
android/bionic/libc/kernel/arch-x86
android/bionic/libc/kernel/common
Step 03.00: Copy the required linux kernel v2.6.30 headers to the
android/bionic/libc/kernel/original folder.
[TODO: Insert steps on how to clone linux-omap-2.6 git repository and
switch to the omap-2.6.30 branch].
Copy the contents of the following folder to the specific target
location:
linux-omap-2.6/include/asm-generic to android/bionic/libc/kernel/
original/
linux-omap-2.6/include/linux to android/bionic/libc/kernel/original/
linux-omap-2.6/include/mtd to android/bionic/libc/kernel/original/
Step 04.00: Generate the clean linux headers.
Run the tools/update_all.py script to generate the clean linux
headers.
$ cd android/bionic/libc/kernel
$ tools/update_all.py
This will generate the headers into the android/bionic/libc/kernel/
common folder.
Step 05.00: Copy the following headers from the backup v2.6.29 bionic/
libc/kernel/common/linux folder to the new android/bionic/libc/kernel/
common/linux folder.
android-alarm.h
android-pmem.h
android_power.h
ashmem.h
binder.h
msm_adsp.h
msm_audio.h
msm_mdp.h
keychord.h
Step 06.00: Copy the architecture-specific headers.
Copy the contents of the architecture-specific asm folders to the
following target location:
linux-omap-2.6/arch/arm/include/asm to android/bionic/libc/kernel/arch-
arm/
linux-omap-2.6/arch/x86/include/asm to android/bionic/libc/kernel/arch-
x86/
Step 07.00: Delete the contents of the android/out folder.
Step 08.00: Build the android sdk.
$ cd android
$ make -j4
Step 09.00: Apply the following patches for the errors that pop up
during the build process.
Fixes for errors that can come up during compilation
01. In file bionic/libc/kernel/arch-arm/asm/memory.h
Error:
target thumb C++: libjni_latinime <= packages/inputmethods/LatinIME/
dictionary/src/dictionary.cpp
In file included from bionic/libc/kernel/arch-arm/asm/page.h:197,
from bionic/libc/include/sys/mman.h:34,
from packages/inputmethods/LatinIME/dictionary/src/
dictionary.cpp:20:
bionic/libc/kernel/arch-arm/asm/memory.h:18:25: error: mach/memory.h:
No such file or directory
Solution:
Modify bionic/libc/kernel/arch-arm/asm/memory.h
-#include <mach/memory.h>
+#include "mach/memory.h"
Copy the following file to the specified target folder:
linux-omap-2.6/arch/arm/plat-omap/include/mach/memory.h to bionic/libc/
kernel/arch-arm/asm/mach
02. In file bionic/libc/kernel/arch-arm/asm/memory.h
Error:
target thumb C++: libjni_latinime <= packages/inputmethods/LatinIME/
dictionary/src/dictionary.cpp
In file included from bionic/libc/kernel/arch-arm/asm/page.h:197,
from bionic/libc/include/sys/mman.h:34,
from packages/inputmethods/LatinIME/dictionary/src/
dictionary.cpp:20:
bionic/libc/kernel/arch-arm/asm/memory.h: In function 'long unsigned
int virt_to_phys(void*)':
bionic/libc/kernel/arch-arm/asm/memory.h:167: error:
'CONFIG_DRAM_BASE' was not declared in this scope
bionic/libc/kernel/arch-arm/asm/memory.h: In function 'void*
phys_to_virt(long unsigned int)':
bionic/libc/kernel/arch-arm/asm/memory.h:172: error:
'CONFIG_DRAM_BASE' was not declared in this scope
bionic/libc/kernel/arch-arm/asm/memory.h: At global scope:
bionic/libc/kernel/arch-arm/asm/memory.h:194: error: expected
initializer before 'unsigned'
bionic/libc/kernel/arch-arm/asm/memory.h:199: error: expected
initializer before 'void'
Solution:
Modify bionic/libc/kernel/arch-arm/asm/mach/memory.h
#ifndef __ASM_ARCH_MEMORY_H
#define __ASM_ARCH_MEMORY_H
+#define CONFIG_ARCH_OMAP3
Modify bionic/libc/kernel/arch-arm/asm/memory.h
-#ifndef PHYS_OFFSET
-#define PHYS_OFFSET (CONFIG_DRAM_BASE)
+#ifndef CONFIG_DRAM_BASE
+#define CONFIG_DRAM_BASE (PHYS_OFFSET)
-static inline __deprecated unsigned long virt_to_bus(void *x)
+static inline unsigned long virt_to_bus(void *x)
-static inline __deprecated void *bus_to_virt(unsigned long x)
+static inline void *bus_to_virt(unsigned long x)
03. In file bionic/libc/kernel/arch-arm/asm/byteorder.h
Error:
In file included from bionic/libc/include/netinet/tcp.h:32,
from frameworks/base/core/jni/
android_net_LocalSocketImpl.cpp:37:
bionic/libc/kernel/common/linux/tcp.h:62: error: a function call
cannot appear in a constant-expression
Solution:
Modify the file bionic/libc/kernel/arch-arm/asm/byteorder.h
#ifndef __ASM_ARM_BYTEORDER_H
#define __ASM_ARM_BYTEORDER_H
+#define __ARMEB__
04. In file bionic/libc/include/sys/types.h
Error:
target thumb C++: libandroid_runtime <= frameworks/base/core/jni/
com_android_internal_os_ZygoteInit.cpp
frameworks/base/core/jni/com_android_internal_os_ZygoteInit.cpp: In
function 'jint
android::com_android_internal_os_ZygoteInit_selectReadable(JNIEnv*,
_jobject*, _jobjectArray*)':
frameworks/base/core/jni/com_android_internal_os_ZygoteInit.cpp:272:
error: '__FD_ZERO' was not declared in this scope
frameworks/base/core/jni/com_android_internal_os_ZygoteInit.cpp:288:
error: '__FD_SET' was not declared in this scope
frameworks/base/core/jni/com_android_internal_os_ZygoteInit.cpp:317:
error: '__FD_ISSET' was not declared in this scope
make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/
libandroid_runtime_intermediates/com_android_internal_os_ZygoteInit.o]
Error 1
Solution:
Modify the android/bionic/libc/kernel/arch-arm/asm/posix_types.h
-#if defined(__KERNEL__)
+#if !defined(__GLIBC__) || __GLIBC__ < 2
05. In file bionic/libc/unistd/sigsuspend.c
Error:
target thumb C: libc_common <= bionic/libc/unistd/sigsuspend.c
bionic/libc/unistd/sigsuspend.c: In function 'sigsuspend':
bionic/libc/unistd/sigsuspend.c:36: error: aggregate value used where
an integer was expected
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/
libc_common_intermediates/unistd/sigsuspend.o] Error 1
Solution:
int sigsuspend(const sigset_t * _mask)
{
- unsigned int mask = (unsigned int) * _mask;
+ unsigned int mask = (unsigned int) & _mask;
}
06. In file bionic/libc/unistd/sigwait.c
Error:
target thumb C: libc_common <= bionic/libc/unistd/sigsuspend.c
target thumb C: libc_common <= bionic/libc/unistd/sigwait.c
bionic/libc/unistd/sigwait.c: In function 'sigwait':
bionic/libc/unistd/sigwait.c:56: error: incompatible types in
assignment
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/
libc_common_intermediates/unistd/sigwait.o] Error 1
Solution:
int sigwait(const sigset_t *set, int *sig)
{
- u.kernel_sigset[0] = *set;
+ u.kernel_sigset[0] = &set;
}
07. In file bionic/libc/kernel/common/linux/sockios.h
Error:
target thumb C: libnetutils <= system/core/libnetutils/ifc_utils.c
system/core/libnetutils/ifc_utils.c: In function
'ifc_reset_connections':
system/core/libnetutils/ifc_utils.c:249: error: 'SIOCKILLADDR'
undeclared (first use in this function)
system/core/libnetutils/ifc_utils.c:249: error: (Each undeclared
identifier is reported only once
system/core/libnetutils/ifc_utils.c:249: error: for each function it
appears in.)
make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/
libnetutils_intermediates/ifc_utils.o] Error 1
Solution:
#define SIOCGIFCOUNT 0x8938
+#define SIOCKILLADDR 0x8939
08. In file included from external/iptables/extensions/
libipt_conntrack.c
Error:
external/iptables/extensions/libipt_conntrack.c:12:47: error: linux/
netfilter_ipv4/ip_conntrack.h: No such file or directory
external/iptables/extensions/libipt_conntrack.c:13:53: error: linux/
netfilter_ipv4/ip_conntrack_tuple.h: No such file or directory
In file included from external/iptables/extensions/libipt_conntrack.c:
15:
Solution:
Copy from the v2.6.29 bionic/libc/kernel/common/linux/netfilter_ipv4
ip_conntrack.h
ip_conntrack_tuple.h
to
bionic/libc/kernel/common/linux/netfilter_ipv4
09. In file included from external/iptables/extensions/
libipt_conntrack.c
Error:
In file included from external/iptables/extensions/libipt_conntrack.c:
15:
external/iptables/extensions/../include/linux/netfilter_ipv4/
ipt_conntrack.h:11:27: error: linux/version.h: No such file or
directory
Solution:
Copy the v2.6.29 bionic/libc/kernel/common/linux/version.h file
to the
bionic/libc/kernel/common/linux/ folder.
10. In file android/external/iptables/include/linux/netfilter_ipv4/
ipt_2ech.h
Error:
In file included from external/iptables/extensions/libipt_2ecn.c:17:
external/iptables/include/linux/netfilter_ipv4/ipt_2ecn.h:11:44:
error: linux/netfilter_ipv4/ipt_dscp_.h: No such file or directory
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/
libext_intermediates/extensions/libipt_2ecn.o] Error 1
Solution:
Modify file android/external/iptables/include/linux/netfilter_ipv4/
ipt_2ech.h
#ifndef _IPT_ECN_H
#define _IPT_ECN_H
-#include <linux/netfilter_ipv4/ipt_dscp_.h>
+#include <linux/netfilter_ipv4/ipt_dscp_.h>
11. In file external/iptables/extensions/libipt_2tos.c.
Error:
external/iptables/extensions/libipt_2tos.c:9:43: error: linux/
netfilter_ipv4/ipt_tos_.h: No such file or directory
Solution:
Modify file android/external/iptables/extensions/libipt_2tos.c
#include <iptables.h>
-#include <linux/netfilter_ipv4/ipt_tos_.h>
+#include <linux/netfilter_ipv4/ipt_tos.h>
12. In file external/iptables/extensions/libipt_DNAT.c
Error:
external/iptables/extensions/libipt_DNAT.c:9:46: error: linux/
netfilter_ipv4/ip_nat_rule.h: No such file or directory
Solution
Copy the following files from v2.6.29 android/libc/kernel/common/linux/
netfilter_ipv4
ip_nat.h
ip_nat_rule.h
to the android/bionic/libc/kernel/common/linux/netfilter_ipv4 folder.
13. In file bionic/linker/linker.c
Error:
bionic/linker/linker.c: In function 'reloc_library':
bionic/linker/linker.c:1237: error: 'R_ARM_NONE' undeclared (first use
in this function)
Solution:
/* TODO: don't use unsigned for addrs below. It works, but is not
* ideal. They should probably be either uint32_t, Elf32_Addr, or
unsigned
* long.
*/
+#define R_ARM_NONE 0
static int reloc_library(soinfo *si, Elf32_Rel *rel, unsigned count)
{
14. In file android/external/ppp/pppd/sys-linux.c
Error:
target thumb C: pppd <= external/ppp/pppd/sys-linux.c
In file included from external/ppp/pppd/sys-linux.c:124:
bionic/libc/kernel/common/linux/if_ppp.h:80: error: expected specifier-
qualifier-list before 'aligned_u64'
external/ppp/pppd/sys-linux.c:173: error: 'N_TTY' undeclared here (not
in a function)
external/ppp/pppd/sys-linux.c:174: error: 'N_PPP' undeclared here (not
in a function)
Solution:
Add the following missing entries to the android/bionic/libc/kernel/
arch-arm/asm/termios.h file
#define TIOCM_LOOP 0x8000
+#define N_TTY 0
+#define N_SLIP 1
+#define N_MOUSE 2
+#define N_PPP 3
+#define N_STRIP 4
+#define N_AX25 5
+#define N_X25 6
+#define N_6PACK 7
+#define N_MASC 8
+#define N_R3964 9
+#define N_PROFIBUS_FDL 10
+#define N_IRDA 11
+#define N_SMSBLOCK 12
+#define N_HDLC 13
+#define N_SYNC_PPP 14
+#define N_HCI 15
15. In file android/bionic/libc/kernel/common/linux/if_ppp.h
Error:
In file included from external/ppp/pppd/sys-linux.c:124:
bionic/libc/kernel/common/linux/if_ppp.h:80: error: expected specifier-
qualifier-list before 'aligned_u64'
Solution:
Modify file android/bionic/libc/kernel/common/linux/if_ppp.h and
delete the following entries:
-struct pppol2tp_ioc_stats {
-__u16 tunnel_id;
-__u16 session_id;
-__u32 using_ipsec:1;
-aligned_u64 tx_packets;
-aligned_u64 tx_bytes;
-aligned_u64 tx_errors;
-aligned_u64 rx_packets;
-aligned_u64 rx_bytes;
-aligned_u64 rx_seq_discards;
-aligned_u64 rx_oos_packets;
-aligned_u64 rx_errors;
-};
16. In file android/external/strace/file.c
Error:
external/strace/file.c: In function 'printstatfs':
external/strace/file.c:1526: error: '__kernel_fsid_t' has no member
named '__val'
Solution:
Modify android/external/strace/file.c as follows:
@@+1514
tprintf("f_bavail=%u, f_files=%u, f_ffree=%u, f_fsid={%d, %d},
f_namelen=%u",
statbuf.f_bavail,statbuf.f_files, statbuf.f_ffree,
- statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1],
+ statbuf.f_fsid.val[0], statbuf.f_fsid.val[1],
@@+1526
(unsigned long)statbuf.f_ffree,
- statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
+ statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
@@+1587
(unsigned long long)statbuf.f_ffree,
- statbuf.f_fsid.__val[0], statbuf.f_fsid.__val[1]);
+ statbuf.f_fsid.val[0], statbuf.f_fsid.val[1]);
17. In file android/bionic/libc/kernel/common/linux/dirent.h
Error:
In file included from external/strace/file.c:71:
bionic/libc/kernel/common/linux/dirent.h:16: error: expected specifier-
qualifier-list before 'u64'
Solution:
Modify the android/bionic/libc/kernel/common/linux/dirent.h as
follows:
+struct dirent {
+long d_ino;
+__kernel_off_t d_off;
+ unsigned short d_reclen;
+ char d_name[256];
+};
+struct dirent64 {
+ __u64 d_ino;
+ __s64 d_off;
+ unsigned short d_reclen;
+ unsigned char d_type;
+ char d_name[256];
+};
struct linux_dirent64 {
- u64 d_ino;
- s64 d_off;
+ __u64 d_ino;
+ __s64 d_off;
unsigned short d_reclen;
unsigned char d_type;
char d_name[0];
};
18. In file android/bionic/libc/kernel/common/linux/dirent.h
Error:
target SharedLib: libsurfaceflinger (out/target/product/generic/obj/
SHARED_LIBRARIES/libsurfaceflinger_intermediates/LINKED/
libsurfaceflinger.so)
out/target/product/generic/obj/SHARED_LIBRARIES/
libsurfaceflinger_intermediates/SurfaceFlinger.o: In function
`android::SurfaceFlinger::readyToRun()':
frameworks/base/libs/surfaceflinger/SurfaceFlinger.cpp:455: undefined
reference to `android::BootAnimation::BootAnimation
(android::sp<android::ISurfaceComposer> const&)'
collect2: ld returned 1 exit status
make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/
libsurfaceflinger_intermediates/LINKED/libsurfaceflinger.so] Error 1
Solution:
Modify android/frameworks/base/libs/surfaceflinger/SurfaceFlinger.cpp
and comment out the boot animation temporarily
// the boot animation!
//if (mDebugNoBootAnimation == false)
// mBootAnimation = new BootAnimation(this);
--~--~---------~--~----~------------~-------~--~----~
unsubscribe: [email protected]
website: http://groups.google.com/group/android-porting
-~----------~----~----~----~------~----~------~--~---