Hi, I've just updated the android-sdk-1.5_r3 bionic libc linux kernel headers to v2.6.31, to match a kernel version with linux- omap-2.6.31 with DSS2 and PM functionality.
The v2.6.31 update went better than the previous v2.6.30 libc update, and I've included proper diff patches in this post, in case someone would like to try it out. I'm going to now need to test it out on the overo. Best regards, Elvis Technote android-2.6.31-001: How to regenerate bionic/libc/common/ kernel headers for linux kernel v2.6.31 Overview This document describes how to regenerate android-sdk-1.5_r3 bionic/ libc linux kernel headers for linux kernel v2.6.31. Procedure Step 01.00: Download the android-sdk-1.3_r3 sources. $ mkdir android $ cd android $ repo init -u git://android.git.kernel.org/platform/manifest.git -b android-sdk-1.5_r3 Step 02.00: Create a new topic branch called omap-overo-2.6.29, to be able to switch between versions. To start a new topic branch using Repo: $ repo start omap-overo-2.6.29 bionic build development external/ iptables external/qemu external/wpa_supplicant frameworks/base hardware/libhardware_legacy To verify that the new branch has been created: $ repo status Step 03.00: Create a new topic branch called omap-overo-2.6.31. To start a new topic branch using Repo: $ repo start omap-overo-2.6.31 bionic build development external/ iptables external/qemu external/wpa_supplicant frameworks/base hardware/libhardware_legacy To verify that the new branch has been created: $ repo status $ repo branches Step 04.00: Checkout the bionic project. $ repo checkout omap-overo-2.6.31 bionic Remember to checkout the other projects, e.g. dalvik, external/ iptables, etc before editing them. Step 05.00: Backup the contents of the existing android/bionic before making any changes. Step 06.00: Copy the contents of the linux kernel v2.6.31 header files as follows: include/asm-generic to bionic/libc/kernel/original folder include/linux to bionic/libc/kernel/original folder include/mtd to bionic/libc/kernel/original folder Step 07.00: Delete the existing v2.6.29 bionic/libc/kernel folders. Delete the following folders: bionic/libc/kernel/arch-arm/asm bionic/libc/kernel/arch-x86/asm bionic/libc/kernel/common Step 08.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 bionic/libc/kernel/common folder. Step 09.00: Delete the bionic/libc/kernel/original folder. Step 10.00: Copy the architecture-specific headers. Copy the contents of the linux v2.6.31 architecture-specific asm folders to the following target location: arch/arm/include/asm to android/bionic/libc/kernel/arch-arm/ arch/x86/include/asm to android/bionic/libc/kernel/arch-x86/ Step 11.00: Commit the changes to contents of the bionic/libc/kernel folder. $ cd android/bionic/libc/kernel $ git add . $ git commit -a -m “libc: Imported and generated clean linux kernel headers for v2.6.31” Step 12.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 13.00: Delete the contents of the existing android/out folder, if it exists from a previous build. Step 14.00: Build the android sdk. $ cd android $ make -j4 Step 15.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 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: 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 Apply the following patch to bionic/libc/kernel/arch-arm/asm/memory.h diff --git a/libc/kernel/arch-arm/asm/memory.h b/libc/kernel/arch-arm/ asm/memory.h index 85763db..2c18a5e 100644 --- a/libc/kernel/arch-arm/asm/memory.h +++ b/libc/kernel/arch-arm/asm/memory.h @@ -13,9 +13,14 @@ #ifndef __ASM_ARM_MEMORY_H #define __ASM_ARM_MEMORY_H +/* Define OMAP3 Architecture, so that mach/memory.h + * PHYS_OFFSET gets set to UL(0x80000000) + */ +#define CONFIG_ARCH_OMAP3 + #include <linux/compiler.h> #include <linux/const.h> -#include <mach/memory.h> +#include "mach/memory.h" #include <asm/sizes.h> /* @@ -191,12 +196,12 @@ static inline void *phys_to_virt(unsigned long x) #define __pfn_to_bus(x) ((x) << PAGE_SHIFT) #endif -static inline __deprecated unsigned long virt_to_bus(void *x) +static inline unsigned long virt_to_bus(void *x) { return __virt_to_bus((unsigned long)x); } -static inline __deprecated void *bus_to_virt(unsigned long x) +static inline void *bus_to_virt(unsigned long x) { return (void *)__bus_to_virt(x); } 02. In file bionic/libc/include/netinet/tcp.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: diff --git a/libc/arch-arm/include/endian.h b/libc/arch-arm/include/ endian.h index 04204ed..8e42583 100644 --- a/libc/arch-arm/include/endian.h +++ b/libc/arch-arm/include/endian.h @@ -1,5 +1,8 @@ /* $OpenBSD: endian.h,v 1.3 2005/12/13 00:35:23 millert Exp $ */ +/* Define ARM big endian byte order. */ +#define __ARMEB__ + #ifdef __ARMEB__ #define _BYTE_ORDER _BIG_ENDIAN #else diff --git a/libc/arch-arm/include/machine/_types.h b/libc/arch-arm/ include/machine/_types.h index 6d10e12..e63093b 100644 --- a/libc/arch-arm/include/machine/_types.h +++ b/libc/arch-arm/include/machine/_types.h @@ -118,6 +118,9 @@ typedef int __rune_t; typedef void * __wctrans_t; typedef void * __wctype_t; +/* Define ARM big endian byte order. */ +#define __ARMEB__ + #ifdef __ARMEB__ #define _BYTE_ORDER _BIG_ENDIAN #else diff --git a/libc/kernel/arch-arm/asm/byteorder.h b/libc/kernel/arch- arm/asm/byteorder.h index 7737974..8c23ca8 100644 --- a/libc/kernel/arch-arm/asm/byteorder.h +++ b/libc/kernel/arch-arm/asm/byteorder.h @@ -15,6 +15,9 @@ #ifndef __ASM_ARM_BYTEORDER_H #define __ASM_ARM_BYTEORDER_H +/* Define ARM big endian byte order. */ +#define __ARMEB__ + #ifdef __ARMEB__ #include <linux/byteorder/big_endian.h> #else 03. In file frameworks/base/core/jni/ com_android_internal_os_ZygoteInit.cpp 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: diff --git a/libc/kernel/arch-arm/asm/posix_types.h b/libc/kernel/arch- arm/asm/posix_types.h index 2446d23..fcb4542 100644 --- a/libc/kernel/arch-arm/asm/posix_types.h +++ b/libc/kernel/arch-arm/asm/posix_types.h @@ -54,7 +54,7 @@ typedef struct { int val[2]; } __kernel_fsid_t; -#if defined(__KERNEL__) +#if !defined(__GLIBC__) || __GLIBC__ < 2 #undef __FD_SET #define __FD_SET(fd, fdsetp) \ 04. 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: diff --git a/libc/kernel/common/linux/sockios.h b/libc/kernel/common/ linux/sockios.h index fb42556..34300fb 100644 --- a/libc/kernel/common/linux/sockios.h +++ b/libc/kernel/common/linux/sockios.h @@ -55,7 +55,8 @@ #define SIOCGIFPFLAGS 0x8935 #define SIOCDIFADDR 0x8936 #define SIOCSIFHWBROADCAST 0x8937 -#define SIOCGIFCOUNT 0x8938 +#define SIOCGIFCOUNT 0x8938 +#define SIOCKILLADDR 0x8939 #define SIOCGIFBR 0x8940 #define SIOCSIFBR 0x8941 05. In file dalvik/vm/interp/Interp.c Error: target arm C: libdvm <= dalvik/vm/interp/Interp.c dalvik/vm/interp/Interp.c: In function 's4FromSwitchData': dalvik/vm/interp/Interp.c:390: warning: initialization discards qualifiers from pointer target type dalvik/vm/interp/Interp.c:717: error: expected declaration or statement at end of input Solution: diff --git a/vm/interp/Interp.c b/vm/interp/Interp.c index 27b9582..d2643de 100644 --- a/vm/interp/Interp.c +++ b/vm/interp/Interp.c @@ -389,6 +389,7 @@ static inline s4 s4FromSwitchData(const void* switchData) { static inline s4 s4FromSwitchData(const void* switchData) { u2* data = switchData; return data[0] | (((s4) data[1]) << 16); +} #endif /* 06. In file arch/arm/include/asm/param.h Error: warning redefinition of MAXHOSTNAMELEN in files bionic/libc/include/netdb.h #define MAXHOSTNAMELEN 256 arch/arm/include/asm/param.h /* max length of hostname */ #define MAXHOSTNAMELEN 64 Solution: diff --git a/libc/kernel/arch-arm/asm/param.h b/libc/kernel/arch-arm/ asm/param.h index 8b24bf9..0f5496a 100644 --- a/libc/kernel/arch-arm/asm/param.h +++ b/libc/kernel/arch-arm/asm/param.h @@ -24,8 +24,5 @@ #define NOGROUP (-1) #endif -/* max length of hostname */ -#define MAXHOSTNAMELEN 64 - #endif 07. 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 08. In file android/external/iptables/include/linux/netfilter_ipv4/ ipt_2ecn.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_2ecn.h #ifndef _IPT_ECN_H #define _IPT_ECN_H -#include <linux/netfilter_ipv4/ipt_dscp_.h> +#include <linux/netfilter_ipv4/ipt_dscp_.h> 09. In file external/icu4c/common/rbbidata.cpp Error: target SharedLib: libicuuc (out/target/product/generic/obj/ SHARED_LIBRARIES/libicuuc_intermediates/LINKED/libicuuc.so) /tool/android/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/../lib/ gcc/arm-eabi/4.2.1/../../../../arm-eabi/bin/ld: warning: type and size of dynamic symbol `icudt38_dat' are not defined out/target/product/generic/obj/SHARED_LIBRARIES/libicuuc_intermediates/ rbbidata.o: In function `icu_3_8::RBBIDataWrapper::init (icu_3_8::RBBIDataHeader const*, UErrorCode&)': external/icu4c/common/rbbidata.cpp:101: undefined reference to `utrie_unserialize_3_8' Solution: diff --git a/common/rbbidata.cpp b/common/rbbidata.cpp index 7897b44..c12bfc6 100644 --- a/common/rbbidata.cpp +++ b/common/rbbidata.cpp @@ -13,6 +13,7 @@ #include "rbbidata.h" #include "rbbirb.h" #include "utrie.h" +#include "utrie.c" #include "udatamem.h" #include "cmemory.h" #include "cstring.h" 10. 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 diff --git a/extensions/libipt_2tos.c b/extensions/libipt_2tos.c index 49dbac5..6b73a53 100644 --- a/extensions/libipt_2tos.c +++ b/extensions/libipt_2tos.c @@ -6,7 +6,7 @@ #include <getopt.h> #include <iptables.h> -#include <linux/netfilter_ipv4/ipt_tos_.h> +#include <linux/netfilter_ipv4/ipt_tos.h> /* TOS names and values. */ static 11. 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. 12. 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: diff --git a/linker/linker.c b/linker/linker.c index 300a95c..d077af4 100644 --- a/linker/linker.c +++ b/linker/linker.c @@ -1102,6 +1102,9 @@ unsigned unload_library(soinfo *si) * 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) { Elf32_Sym *symtab = si->symtab; 13. 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 bionic/libc/kernel/arch-arm/ asm/termios.h file diff --git a/libc/kernel/arch-arm/asm/termios.h b/libc/kernel/arch-arm/ asm/termios.h index 293e3f1..ae81c16 100644 --- a/libc/kernel/arch-arm/asm/termios.h +++ b/libc/kernel/arch-arm/asm/termios.h @@ -47,6 +47,23 @@ struct termio { #define TIOCM_OUT2 0x4000 #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 + /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ #ifdef __KERNEL__ 14. 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: diff --git a/libc/kernel/common/linux/if_ppp.h b/libc/kernel/common/ linux/if_ppp.h index 4171244..f91a903 100644 --- a/libc/kernel/common/linux/if_ppp.h +++ b/libc/kernel/common/linux/if_ppp.h @@ -73,20 +73,6 @@ struct ifpppcstatsreq { struct ppp_comp_stats stats; }; -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; -}; - #define ifr__name b.ifr_ifrn.ifrn_name #define stats_ptr b.ifr_ifru.ifru_data 15. 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: diff --git a/file.c b/file.c index b0f9715..2d02f9c 100644 --- a/file.c +++ b/file.c @@ -1511,7 +1511,7 @@ long addr; statbuf.f_bsize, statbuf.f_blocks, statbuf.f_bfree); 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], statbuf.f_namelen); #else /* !ALPHA */ tprintf("{f_type=%s, f_bsize=%lu, f_blocks=%lu, f_bfree=%lu, ", @@ -1523,7 +1523,7 @@ long addr; (unsigned long)statbuf.f_bavail, (unsigned long)statbuf.f_files, (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]); #ifdef LINUX tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen); #endif /* LINUX */ @@ -1584,7 +1584,7 @@ long addr; (unsigned long long)statbuf.f_bavail, (unsigned long long)statbuf.f_files, (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]); tprintf(", f_namelen=%lu", (unsigned long)statbuf.f_namelen); #ifdef _STATFS_F_FRSIZE tprintf(", f_frsize=%llu", (unsigned long long) statbuf.f_frsize); 16. In file 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 bionic/libc/kernel/common/linux/dirent.h as follows: diff --git a/libc/kernel/common/linux/dirent.h b/libc/kernel/common/ linux/dirent.h index 7799fe3..3f8628f 100644 --- a/libc/kernel/common/linux/dirent.h +++ b/libc/kernel/common/linux/dirent.h @@ -12,9 +12,24 @@ #ifndef _LINUX_DIRENT_H #define _LINUX_DIRENT_H +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]; 17. In file hardware/ril/reference-ril/atchannel.c Error: hardware/ril/reference-ril/atchannel.c:38:29: error: linux/ omap_csmi.h: No such file or directory hardware/ril/reference-ril/atchannel.c: In function 'readerLoop': hardware/ril/reference-ril/atchannel.c:474: error: 'OMAP_CSMI_TTY_ACK' undeclared (first use in this function) hardware/ril/reference-ril/atchannel.c:474: error: (Each undeclared identifier is reported only once hardware/ril/reference-ril/atchannel.c:474: error: for each function it appears in.) Solution: Copy the following files from v2.6.29 android/libc/kernel/common/ linux/ omap_csmi.h to the android/bionic/libc/kernel/common/linux/ folder. Step 16.00: Extract the patches for each project. $ cd bionic $ git format-patch android-sdk-1.5_r3 $ cd dalvik $ git format-patch android-sdk-1.5_r3 $ cd external/icu4c $ git format-patch android-sdk-1.5_r3 $ cd external/iptables $ git format-patch android-sdk-1.5_r3 $ cd external/strace $ git format-patch android-sdk-1.5_r3 --~--~---------~--~----~------------~-------~--~----~ unsubscribe: android-porting+unsubscr...@googlegroups.com website: http://groups.google.com/group/android-porting -~----------~----~----~----~------~----~------~--~---