Android 2.3 GingerBread for VirtualBox x86編譯指南

時間有限,格式未調整,見諒。
編譯的問題主要參考
謝謝原作者。
 

About-GingerBread-x86

 

展開源碼,用AOSP的bionic目錄替換(gingerbread)的bionic
刪除bootable/diskinstaller,拷貝froyo-x86的newinstaller到bootable目錄下;拷貝gingerbread的bootable/diskinstaller/libdiskconfig目錄到bootable/newinstaller目錄下
修改build/core/Makefile,註釋掉bootable/diskinstaller/config.mk的引用
鏈接froyo-x86的kernel;cd /work/gb; ln -sf /work/x86/kernel/ .
將x86/build/core/kernel.mk拷貝過來,並include在build/core/Makefile中
 
$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
        $(call pretty,"Target boot image: $@")
        $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
        $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE),raw)
endif # TARGET_BOOTIMAGE_USE_EXT2
 
include $(BUILD_SYSTEM)/kernel.mk
 
else    # TARGET_NO_KERNEL
# HACK: The top-level targets depend on the bootimage.  Not all targets
# can produce a bootimage, though, and emulator targets need the ramdisk
# instead.  Fake it out by calling the ramdisk the bootimage.
# TODO: make the emulator use bootimages, and make mkbootimg accept
#       kernel-less inputs.
INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET)
endif
 
將froyo_x86的device/vm拷貝到device目錄下,在AndroidBoard.mk中註釋掉TARGET_PREBUILT_APPS
將build/core/target/board/generic_x86下面的buildspec*拷貝到根目錄的buildspec.mk並修改BUILD_ENV_SEQUENCE_NUMBER爲10
編譯環境設置(每次編譯前不要忘記lunch vm-eng以防止編譯錯誤目標)
carl@carl-amd64:/work/gb$ . build/envsetup.sh 
including device/htc/passion/vendorsetup.sh
including device/samsung/crespo/vendorsetup.sh
including device/vm/vm/vendorsetup.sh
carl@carl-amd64:/work/gb$ lunch vm-eng
 
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.3.1
TARGET_PRODUCT=vm
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=x86
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=GINGERBREAD
============================================
 
將下面兩行加入build/target/product/generic_x86.mk末尾
GENERIC_X86_CONFIG_MK := $(SRC_TARGET_DIR)/board/generic_x86/BoardConfig.mk
GENERIC_X86_ANDROID_MK := $(SRC_TARGET_DIR)/board/generic_x86/AndroidBoard.mk
 
開始編譯內核
carl@carl-amd64:/work/gb$ m -j3 kernel
 
 
消除LOCAL_MODULE_TAGS的問題(external/grub),設置LOCAL_MODULE_TAGS := optional
build/core/base_rules.mk:74: *** Module name: grub_stage1
build/core/base_rules.mk:75: *** Makefile location: external/grub
build/core/base_rules.mk:76: * 
build/core/base_rules.mk:77: * Each module must use a LOCAL_MODULE_TAGS in its
build/core/base_rules.mk:78: * Android.mk. Possible tags declared by a module:
build/core/base_rules.mk:79: * 
build/core/base_rules.mk:80: *     optional, debug, eng, tests, samples
build/core/base_rules.mk:81: * 
build/core/base_rules.mk:82: * If the module is expected to be in all builds
build/core/base_rules.mk:83: * of a product, then it should use the
build/core/base_rules.mk:84: * "optional" tag: 
build/core/base_rules.mk:85: * 
build/core/base_rules.mk:86: *    Add "LOCAL_MODULE_TAGS := optional" in the
build/core/base_rules.mk:87: *    Android.mk for the affected module, and add
build/core/base_rules.mk:88: *    the LOCAL_MODULE value for that component
build/core/base_rules.mk:89: *    into the PRODUCT_PACKAGES section of product
build/core/base_rules.mk:90: *    makefile(s) where it's necessary, if
build/core/base_rules.mk:91: *    appropriate.
build/core/base_rules.mk:92: * 
build/core/base_rules.mk:93: * If the component should be in EVERY build of ALL
build/core/base_rules.mk:94: * products, then add its LOCAL_MODULE value to the
build/core/base_rules.mk:95: * PRODUCT_PACKAGES section of
build/core/base_rules.mk:96: * build/target/product/core.mk
build/core/base_rules.mk:97: * 
build/core/base_rules.mk:98: *** user tag detected on new module - user tags are only supported on legacy modules.  Stop.
make: Leaving directory `/work/gb'
 
去掉多餘的libdiskconfig目標
build/core/base_rules.mk:158: *** bootable/newinstaller/libdiskconfig: MODULE.TARGET.SHARED_LIBRARIES.libdiskconfig already defined by system/core/libdiskconfig.  Stop.
註釋掉bootable/newinstaller/libdiskconfig/Android.mk中libdiskconfig相關代碼
 
###########################
# shared library for target
#include $(CLEAR_VARS)
 
#LOCAL_SRC_FILES := $(commonSources)
 
#LOCAL_CFLAGS := -O2 -g -W -Wall -Werror
 
#LOCAL_MODULE := libdiskconfig
#LOCAL_MODULE_TAGS := system_builder
#LOCAL_SYSTEM_SHARED_LIBRARIES := libcutils liblog libc
 
#include $(BUILD_SHARED_LIBRARY)
 
將編譯好的kernel拷貝到prebuilt下相應目錄
carl@carl-amd64:/work/gb$ cp device/vm/vm/vm_defconfig prebuilt/android-x86/kernel/kernel_config_VirtualBox 
carl@carl-amd64:/work/gb$ cp out/target/product/vm/kernel /work/gb/prebuilt/android-x86/kernel/kernel
 
 
 
開始全編譯
carl@carl-amd64:/work/gb$ m -j3
 
stlport的問題解決
 
external/stlport/src/num_put_float.cpp: In function 'bool std::priv::_Stl_is_nan_or_inf(double)':
external/stlport/src/num_put_float.cpp:143: error: 'IsNANorINF' was not declared in this scope
external/stlport/src/num_put_float.cpp: In function 'bool std::priv::_Stl_is_inf(double)':
external/stlport/src/num_put_float.cpp:144: error: 'IsNANorINF' was not declared in this scope
external/stlport/src/num_put_float.cpp:144: error: 'IsINF' was not declared in this scope
external/stlport/src/num_put_float.cpp: In function 'bool std::priv::_Stl_is_neg_inf(double)':
external/stlport/src/num_put_float.cpp:145: error: 'IsINF' was not declared in this scope
external/stlport/src/num_put_float.cpp: In function 'bool std::priv::_Stl_is_neg_nan(double)':
external/stlport/src/num_put_float.cpp:146: error: 'IsNegNAN' was not declared in this scope
external/stlport/src/num_put_float.cpp: In function 'char* std::priv::_Stl_ecvtR(double, int, int*, int*, char*)':
external/stlport/src/num_put_float.cpp:280: error: 'ecvt_r' was not declared in this scope
external/stlport/src/num_put_float.cpp: In function 'char* std::priv::_Stl_fcvtR(double, int, int*, int*, char*)':
external/stlport/src/num_put_float.cpp:282: error: 'fcvt_r' was not declared in this scope
external/stlport/src/num_put_float.cpp: In function 'char* std::priv::_Stl_ecvtR(long double, int, int*, int*, char*)':
external/stlport/src/num_put_float.cpp:285: error: 'qecvt_r' was not declared in this scope
external/stlport/src/num_put_float.cpp: In function 'char* std::priv::_Stl_fcvtR(long double, int, int*, int*, char*)':
external/stlport/src/num_put_float.cpp:287: error: 'qfcvt_r' was not declared in this scope
target thumb C++: libstlport <= external/stlport/src/time_facets.cpp
make: *** [out/target/product/vm/obj/SHARED_LIBRARIES/libstlport_intermediates/src/num_put_float.o] Error 1
編輯external/stlport/Android.mk修改libstlport_cflags := -D_GNU_SOURCE -DUSE_SPRINTF_INSTEAD
 
 
bitwise.c的問題解決
 
In file included from external/tremolo/Tremolo/bitwise.c:43:
external/tremolo/Tremolo/misc.h:82: error: redefinition of 'union magic'
In file included from external/tremolo/Tremolo/codebook.c:45:
external/tremolo/Tremolo/misc.h:82: error: redefinition of 'union magic'
make: *** [out/target/product/vm/obj/SHARED_LIBRARIES/libvorbisidec_intermediates/Tremolo/bitwise.o] Error 1
make: *** Waiting for unfinished jobs....
In file included from external/tremolo/Tremolo/mdct.h:42,
                 from external/tremolo/Tremolo/dsp.c:40:
external/tremolo/Tremolo/misc.h:82: error: redefinition of 'union magic'
external/tremolo/Tremolo/codebook.c: In function 'decode_map':
external/tremolo/Tremolo/codebook.c:763: warning: pointer of type 'void *' used in arithmetic
make: *** [out/target/product/vm/obj/SHARED_LIBRARIES/libvorbisidec_intermediates/Tremolo/codebook.o] Error 1
 
在external/tremolo/Tremolo/misc.h中加入
#include <endian.h>
 
__dso_handle的問題解決
 
external/stlport/src/monetary.cpp:39: undefined reference to `__dso_handle'
out/target/product/vm/obj/SHARED_LIBRARIES/libstlport_intermediates/src/locale.o: In function `__static_initialization_and_destruction_0':
external/stlport/src/locale.cpp:29: undefined reference to `__dso_handle'
out/target/product/vm/obj/SHARED_LIBRARIES/libstlport_intermediates/src/locale_impl.o: In function `__static_initialization_and_destruction_0':
external/stlport/src/locale_impl.cpp:31: undefined reference to `__dso_handle'
out/target/product/vm/obj/SHARED_LIBRARIES/libstlport_intermediates/src/locale_impl.o: In function `std::_Locale_impl::make_classic_locale()':
external/stlport/src/locale_impl.cpp:670: undefined reference to `__dso_handle'
external/stlport/src/locale_impl.cpp:667: undefined reference to `__dso_handle'
out/target/product/vm/obj/SHARED_LIBRARIES/libstlport_intermediates/src/locale_impl.o:external/stlport/src/locale_impl.cpp:604: more undefined references to `__dso_handle' follow
collect2: ld returned 1 exit status
 
修改external/stlport/dll_main.cpp加入
extern "C" {
void * __dso_handle = 0;
}
 
dnsmasq的dbus引用問題解決
 
external/dnsmasq/src/dbus.c:21:23: error: dbus/dbus.h: No such file or directory
external/dnsmasq/src/dbus.c:60: error: expected specifier-qualifier-list before 'DBusWatch'
external/dnsmasq/src/dbus.c:65: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'add_watch'
external/dnsmasq/src/dbus.c:84: error: expected ')' before '*' token
external/dnsmasq/src/dbus.c:100: error: expected ')' before '*' token
external/dnsmasq/src/dbus.c:261: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'message_handler'
 
修改external/dnsmasq/src/config.h
/* #define HAVE_DBUS */
#ifdef __ANDROID__
#undef HAVE_DBUS
#endif
 
 
libnfc-nxp的問題解決
target arm C: libnfc <= external/libnfc-nxp/src/phLibNfc.c
cc1: error: unrecognized command line option "-mapcs"
cc1: error: unrecognized command line option "-mno-sched-prolog"
cc1: error: unrecognized command line option "-mabi=aapcs-linux"
cc1: error: unrecognized command line option "-mno-thumb-interwork"
 
修改external/libnfc-nxp/Android.mk將
LOCAL_CFLAGS += -DNXP_MESSAGING -DINCLUDE_DALINIT_DEINIT -pipe -fomit-frame-pointer -Wall -Wno-trigraphs -Werror-implicit-function-declaration  -fno-strict-aliasing -mapcs -mno-sched-prolog -mabi=aapcs-linux -mno-thumb-interwork -msoft-float -Uarm -fno-common –fpic
改爲
LOCAL_CFLAGS += -DNXP_MESSAGING -DINCLUDE_DALINIT_DEINIT -pipe -fomit-frame-pointer -Wall -Wno-trigraphs -Werror-implicit-function-declaration  -fno-strict-aliasing -msoft-float -Uarm -fno-common -fpic
 
in mkuserimg.sh PATH=out/host/linux-x86/bin/:/boot/jdk/bin:/home/carl/bin:/opt/android/tools:/opt/android/platform-tools:/opt/depot_tools:/boot/jdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/work/gb/out/host/linux-x86/bin:/work/gb/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin:/work/gb/development/emulator/qtools:/work/gb/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin:/work/gb/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin
Only ext4 is supported!
修改各個image的文件系統支持
直接修改build/target/board/generic_x86/BoardConfig.mk
 
TARGET_USERIMAGES_USE_EXT4 := true
TARGET_BOOTIMAGE_USE_EXT2 := true
TARGET_SYSTEMIMAGES_USE_EXT2 := true
 
修改build/core/Makefile
 
ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
 ## generate an ext2 image
 # $(1): output file
 define build-systemimage-target
     @echo "Target system fs image: $(1)"
     $(call build-userimage-ext-target, $(TARGET_OUT), $(1), system, $(INTERNAL_USERIMAGES_EXT_VARIANT), $(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
 endef
改爲
ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
  ifeq ($(TARGET_SYSTEMIMAGES_USE_EXT2),true)
    -include external/genext2fs/Config.mk
    ## generate an ext2 image
    # $(1): output file
    define build-systemimage-target
      @echo "Target system fs image: $(1)"
      $(call build-userimage-ext2-target,$(TARGET_OUT),$(1),system,)
    endef
    else
    define build-systemimage-target
      @echo "Target system fs image: $(1)"
      $(call build-userimage-ext-target,$(TARGET_OUT),$(1),system,$(INTERNAL_USERIMAGES_EXT_VARIANT),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
    endef
  endif
 
完成後,可以直接
carl@carl-amd64:/work/gb$ export USE_SQUASHFS=0
carl@carl-amd64:/work/gb$ m -j3 iso_img
 
 
IAudioEffect.c的問題解決
out/target/product/vm/obj/SHARED_LIBRARIES/libOpenSLES_intermediates/IAndroidEffect.o:(.data.rel.ro._ZTIN7android12SortedVectorINS_16key_value_pair_tImPNS_11AudioEffectEEEEE[typeinfo for android::SortedVector<android::key_value_pair_t<unsigned long, android::AudioEffect*> >]+0x0): undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info'
out/target/product/vm/obj/SHARED_LIBRARIES/libOpenSLES_intermediates/IAndroidEffect.o:(.data.rel.ro._ZTIN7android12SortedVectorINS_16key_value_pair_tImPNS_11AudioEffectEEEEE[typeinfo for android::SortedVector<android::key_value_pair_t<unsigned long, android::AudioEffect*> >]+0x10): undefined reference to `typeinfo for android::SortedVectorImpl'
collect2: ld returned 1 exit status
將system/media/opensles/libopensles/IAndroidEffect.c換名IAndroidEffect.cpp並更新Android.mk文件
 
init.rc不執行拷貝的問題
在build/target/board/generic_x86/AndroidBoard.mk中指定的init.rc模塊,無論如何設置都不會執行拷貝,這是由於新版本的build system腳本調整導致的麻煩,需要強制在definitions.mk中指定安裝init.rc模塊。
ifeq ($(TARGET_PROVIDES_INIT_RC), true)
ALL_DEFAULT_INSTALLED_MODULES:=init.rc
else
ALL_DEFAULT_INSTALLED_MODULES:=
endif
 
SQUASHFS生成目標的支持問題
froyo-x86默認是生成SQUASHFS,如下修改bootable/newinstaller/Android.mk爲默認不生成SQUASHFS;如果需要設置生成SQUASHFS,只需要在make前export USE_SQUASHFS=1
 
# use squashfs for iso, unless explictly disabled
ifeq ($(USE_SQUASHFS),1)
MKSQUASHFS = $(shell which mksquashfs)
 
在Makefile中集成system.sfs目標
 
$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH) | $(ACP)
        @echo "Install system fs image: $@"
        $(copy-file-to-target)
        $(hide) $(call assert-max-image-size,$@ $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE),yaffs)
 
ifneq ($(MKSQUASHFS),)
$(PRODUCT_OUT)/system.sfs: $(BUILT_SYSTEMIMAGE)
        $(call build-squashfs-target,$^,$@)
endif
 
systemimage: $(INSTALLED_SYSTEMIMAGE)
 
 
init.rc的定製問題
 
Gingerbread修改了system/core/init模塊的代碼,init.rc的支持也變得更加強大。
init.rc需要根據不同平臺來進行定製,否則在chroot到android後會出現嚴重問題。
基本思路是基於Android原生的init.rc修改,添加文件系統mount的指令,添加eth0啓動時支持。
 
 
BOARD_KERNEL_CMDLINE的問題
由於沒有使用diskinstaller,所以build/target/board/generic-x86/BoardConfig.mk中KERNEL_CMDLINE如下修改
# For VirtualBox and likely other emulators
#BOARD_INSTALLER_CMDLINE := init=/init console=ttyS0 console=tty0 androidboot.hardware=generic_x86 vga=788 verbose
#BOARD_KERNEL_CMDLINE := init=/init console=tty0 console=ttyS0 androidboot.hardware=generic_x86 vga=788
BOARD_KERNEL_CMDLINE := init=/init console=tty0 androidboot.hardware=$(TARGET_PRODUCT) acpi_sleep=s3_bios,s3_mode vga=788
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章