2013年2月18日 星期一

Start Build TI AM335X Android JB DevKit BSP in Fedora 16.

最近比較有空 (等PCB 回來驗證修改部份 ) , 所以在看看 TI 的 Android 吧 !!
發現 , TI release 的 Android JB for AM335x  的 BSP 了 .

一樣 在 FC16 上 build 看看吧 !! 我的 PC 還是 FC16 , 所以應該缺少的 東西不多 !
想說可以順利build 完畢 , 沒想到 .... 第一步就有問題 !!


Cross Compile 給我用 64 bit 的 ..... 我的 FC16 是 32bit 啦 !!!!
不想使用 VM machine (build 太慢) , 並且有舊的 project toolchain (32Bit ) .
好吧 , 試試看是否能 在 32 bit build .

PS. 這篇文章會陸續增加 修正的項目 .


A.先改 ./prebuilts/tools/gcc-sdk/gcc 吧.
  原始檔案使用 file -L "$SHELL" 的方式再次檢查是否 64 bit. 感覺有點多餘.
  每次都用同樣方式檢查不就可以了 ?? 修改後的 diff 如下:

--------------------------------- gcc-sdk/gcc ---------------------------------
index eac1c47..38f6317 100755
@@ -1,4 +1,5 @@
 #!/bin/bash
+# vi:set ts=4 :

 HOST_OS=`uname -s | tr '[:upper:]' '[:lower:]'`
 if [ "$HOST_OS" != "linux" ] ; then
@@ -14,27 +15,13 @@ PREFIX64=../../gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6/bin/x86_64-linux

 options=" ${@} "   # sentinel prefix/suffix space to simplify pattern match below

-suffix_m32=${options##* -m32 }    # suffix after the last -m32
-suffix_m64=${options##* -m64 }    # suffix after the last -m64
-
-len_m32=${#suffix_m32}            # length of suffix after the last -m32
-len_m64=${#suffix_m64}            # length of suffix after the last -m64
-
-if [ $len_m32 -ge $len_m64 ] ; then
-  # Choose 64-bit if -m64 only, -m64 appears after -m32, or neither exist (-eq)
-  MY_TOOL=`dirname $0`/${PREFIX64}-${PROGNAME}
-  # Make sure host is running 64-bit OS.
-  # Note that "uname -m" only show host CPU is capable of.  Use the following technique
-  # from ndk/build/core/ndk-common.sh instead
-  file -L "$SHELL" | grep -q "x86[_-]64"
-  if [ $? != 0 ]; then
-    # $SHELL is not a 64-bit executable, so assume our userland is too.
-    echo "ERROR: $MY_TOOL only run on 64-bit linux"
-    exit 1
-  fi
+
+file -L "$SHELL" | grep -q "x86[_-]64"
+
+if [ $? != 0 ]; then
+    MY_TOOL=`dirname $0`/${PREFIX32}-${PROGNAME}
 else
-  # Otherwise, choose 32-bit
-  MY_TOOL=`dirname $0`/${PREFIX32}-${PROGNAME}
+    MY_TOOL=`dirname $0`/${PREFIX64}-${PROGNAME}
 fi

 $MY_TOOL "$@"


這一版本沒有 32bit 的 target toolchain , 所以由 ICS 的 版本內將的 toolchain
arm-linux-androideabi-4.4.x 複製到
./prebuild/linux-x86/toolchain/ 目錄下!!
原本應該在 ./prebuilds 下 , 不過擔心 ICS 的 toolchain 會有內部指定位置 , 所以放在和
ICS 一樣的 ./prebuild/ 目錄下.
本篇最後會有一個 env.sh 的 file , 內容會說明如何將 toolchain 指定到這邊 !!



B.Java VM 沒有辦法開啟 .
只細看一下 error message , 好像 jave 的 heap memory 太大 , 修正 下面這個檔案
./build/core/definitions.mk , diff 內容如下:

Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
make: *** [out/host/common/obj/JAVA_LIBRARIES/core-hostdex_intermediates/classes.dex] Error 1
make: *** Waiting for unfinished jobs....



index 9fe0a11..2750bed 100644
@@ -1547,7 +1547,7 @@ define transform-classes.jar-to-dex
 @echo "target Dex: $(PRIVATE_MODULE)"
 @mkdir -p $(dir $@)
 $(hide) $(DX) \
-    $(if $(findstring windows,$(HOST_OS)),,-JXms16M -JXmx2048M) \
+    $(if $(findstring windows,$(HOST_OS)),,-JXms16M -JXmx1024M) \
     --dex --output=$@ \
     $(incremental_dex) \
     $(if $(NO_OPTIMIZE_DX), \



C.修正 TOOLCHAIN 的位置.
   這版本內部使用 64bit 的 complier , 雖然可以由環境參數設定 TARGET_TOOLS_PREFIX 的方式來解決 , 不過我的系統都是 32bit , 所以就用固定的方式吧 !
修改後的 diff 內容如下:

------------------------ core/combo/TARGET_linux-arm.mk ------------------------
index 4a461f8..569001a 100644
@@ -43,8 +43,10 @@ include $(TARGET_ARCH_SPECIFIC_MAKEFILE)

 # You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
 ifeq ($(strip $(TARGET_TOOLS_PREFIX)),)
-TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-4.6
-TARGET_TOOLS_PREFIX := $(TARGET_TOOLCHAIN_ROOT)/bin/arm-linux-androideabi-
+## TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-4.6
+## TARGET_TOOLS_PREFIX := $(TARGET_TOOLCHAIN_ROOT)/bin/arm-linux-androideabi-
+TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-eabi-4.6
+TARGET_TOOLS_PREFIX := $(TARGET_TOOLCHAIN_ROOT)/bin/arm-eabi-
 endif

 # Only define these if there's actually a gcc in there.



D.因為我的 uname -m 是 i686 , Compile 的時候會尋找 system/core/include/arch/linux-i686 和 system/core/include/arch/target_linux-i686 的內容 , 所以
就將 linux-x86 和 target_linux-x86 個別複製一份為 linux-i686 & target_linux-i686

C.修正 ./external/webkit/Source/WebCore/make-hash-tools.pl file.
    請參考前一版 ICS 的修正方式.主要是 Fedora 16  的版本比較新 , 沒有 switch 功能.


E.Make 過程如果發現 libbfd 的問題 , 就需要更改./external/oprofile/common.mk ,
   因為我們使用 i686 的 toolchain , 所以沒有 libbfd , HAVE_LIBBFD需要為 false.
   更改後的 diff 如下:


---------------------------------- common.mk ----------------------------------
index f5578b1..cc79eef 100644
@@ -45,9 +45,13 @@ HAVE_LIBBFD := true
 common_host_cflags += -DMISSING_MREMAP
 common_host_ldlibs_libiconv := -liconv
 else
+ifeq ($(shell uname -m),i686)
+HAVE_LIBBFD := false
+else
 ifeq ($(HOST_OS)-$(HOST_ARCH),linux-x86)
 HAVE_LIBBFD := true
 endif
 endif
+endif

 endif


D.build 到 qemu 的時候會出錯
  主要是 非 standalone 的時候會去 build 64bit 的 library , 這時候就出錯 !!
  參考一下 Makefile.common 發現設定BUILD_STANDALONE_EMULATOR 會排除
  64 bit 的 library 部份 , 先設定吧 , 到時候 qemu 要用的時候再來修正.
  diff 後的 內容如下:

---------------------------------- Android.mk ----------------------------------
index 0b02fdb..abbab01 100644
@@ -2,8 +2,11 @@
 # through the 'm' or 'mm' build commands. if not, we use the
 # standard QEMU Makefile
 #
+# vi: set ts =4 :
+
 ifeq ($(DEFAULT_GOAL),droid)
     LOCAL_PATH:= $(call my-dir)
+    BUILD_STANDALONE_EMULATOR=true
     include $(LOCAL_PATH)/Makefile.android
 else
     include Makefile.qemu



E.編譯到一半 會發現沒有 LIBBFD 
 LIBBFD 我不知道是啥東西 , 不過確定32bit 的 toolchain 沒有 , 所以修改./external/oprofile/common.mk , 這個 mk file中有指定toolchain 目錄 , 所以順便一起更改 . 只要 uname -m 是i686 就關閉 LIBBFD 和設定 32 bit 的 toolchain 位置 , diff 內容如下:

---------------------------------- common.mk ----------------------------------
index f5578b1..4b1ff6c 100644
@@ -35,7 +35,12 @@ common_target_cflags := $(common_cflags)
 HAVE_LIBBFD := false

 ifeq ($(TARGET_ARCH),arm)
+ifneq ($(shell uname -m),i686)
 toolchain := prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-4.6
+else
+toolchain := prebuilts/gcc/$(HOST_PREBUILT_TAG)/toolchain/arm-linux-androideabi-4.4.x
+endif
+
 common_host_c_includes := $(common_c_includes) $(toolchain)/include
 common_host_cflags := $(common_cflags) -fexceptions -DANDROID_HOST -DHAVE_XCALLOC
 common_host_ldlibs_libiconv :=
@@ -46,8 +51,10 @@ common_host_cflags += -DMISSING_MREMAP
 common_host_ldlibs_libiconv := -liconv
 else
 ifeq ($(HOST_OS)-$(HOST_ARCH),linux-x86)
+ifneq ($(shell uname -m),i686)
 HAVE_LIBBFD := true
 endif
 endif
+endif

 endif


F. 編譯到 frameworks/native/libs/utils  目錄的時後會出錯
   原因是會去編譯 64 bit 的 static library.
   檢查一下 Android.mk file 發現 , default 會編譯 64 bit static library ,
   修改成不要編譯 (使用 uname -m 區別).
    Diff 的內容如下:

---------------------------- libs/utils/Android.mk ----------------------------
index ddfb83e..503126a 100644
@@ -81,6 +81,7 @@ include $(BUILD_HOST_STATIC_LIBRARY)

 # For the host, 64-bit
 # =====================================================
+ifneq ($(shell uname -m),i686)
 include $(CLEAR_VARS)
 LOCAL_SRC_FILES:= $(commonSources)
 ifeq ($(HOST_OS), linux)
@@ -93,7 +94,7 @@ LOCAL_C_INCLUDES := \
 LOCAL_CFLAGS += $(host_commonCflags) -m64
 LOCAL_LDLIBS += $(host_commonLdlibs)
 include $(BUILD_HOST_STATIC_LIBRARY)
-
+endif

 # For the device
 # =====================================================


G.編譯到 system/core/libcutils 和 system/core/liblog 的時候會有相同錯誤
   一樣發現要 編譯 64 bit 的 static lib , 分別修正 Android.mk (使用 uname -m) .
   diff  內容分別如下:

----------------------------- libcutils/Android.mk -----------------------------
index 5c227b6..22b86bf 100644
@@ -97,6 +97,7 @@ include $(BUILD_HOST_STATIC_LIBRARY)

 # Static library for host, 64-bit
 # ========================================================
+ifneq ($(shell uname -m),i686)
 include $(CLEAR_VARS)
 LOCAL_MODULE := lib64cutils
 LOCAL_SRC_FILES := $(commonSources) $(commonHostSources) dlmalloc_stubs.c
@@ -104,7 +105,7 @@ LOCAL_LDLIBS := -lpthread
 LOCAL_STATIC_LIBRARIES := lib64log
 LOCAL_CFLAGS += $(hostSmpFlag) -m64
 include $(BUILD_HOST_STATIC_LIBRARY)
-
+endif

 # Shared and static library for target
 # ========================================================

------------------------------ liblog/Android.mk ------------------------------
index be5cec2..7fcc6bf 100644
@@ -57,6 +57,7 @@ include $(BUILD_HOST_SHARED_LIBRARY)

 # Static library for host, 64-bit
 # ========================================================
+ifneq ($(shell uname -m),i686)
 include $(CLEAR_VARS)
 LOCAL_MODULE := lib64log
 LOCAL_SRC_FILES := $(liblog_host_sources)
@@ -64,6 +65,7 @@ LOCAL_LDLIBS := -lpthread
 LOCAL_CFLAGS := -DFAKE_LOG_DEVICE=1 -m64
 include $(BUILD_HOST_STATIC_LIBRARY)

+endif

 # Shared and static library for target
 # ========================================================



H.增加環境參數設定
為了容易設定環境參數 ,增加了一個 ./env.sh file 來協助整個環境的設定.
內容如下:

#!/bin/sh
# vi: set ts=4 :

## ==== Setting PATH.
JDK_BIN_DIR=${HOME}/bin/jdk1.6.0_34/bin

TOOLCHAIN_BIN_DIR=${PWD}/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin

PATH1=`echo ${PATH} | sed "s|[:]${JDK_BIN_DIR}||g"`
PATH2=`echo ${PATH1} | sed "s|${JDK_BIN_DIR}[:]||g"`

PATH3=`echo ${PATH2} | sed "s|[:]${TOOLCHAIN_BIN_DIR}||g"`
PATH4=`echo ${PATH3} | sed "s|${TOOLCHAIN_BIN_DIR}[:]||g"`

PATH_E=${PATH4}

export PATH=${TOOLCHAIN_BIN_DIR}:${JDK_BIN_DIR}:${PATH_E}

export TARGET_TOOLS_PREFIX=${PWD}/prebuilt/linux-x86/toolchain/arm-linux-androideabi-4.4.x/bin/arm-linux-androideabi-
## ====

export TARGET_PRODUCT=am335xevm_sk
export OMAPES=4.x
export USE_CCACHE=1

## ==== for u-boot or kernel used.

export ARCH=arm
export CROSS_COMPILE=arm-eabi-

source ${PWD}/build/envsetup.sh

## ==================================



Some Reference Web Address:
    https://groups.google.com/forum/?fromgroups=#!topic/android-building/Rq6bS2C47S8 

    http://forum.xda-developers.com/showthread.php?p=37568464&postcount=54


目前已經可以build 完畢 , 接著要試試看有沒有問題.......

沒有想像的那樣容易  , 不能 working .
後來發現 64 bit 的系統可以跑32bit 的程式,只要安裝 所需要的 32bit library即可 !!
舊的 Project 因為 code 的關係(int 大小不, 整個 struct 也會不對 ) 不能編譯成為 64 bit !!
不過可以在 CFLAGS & LDFLAGS 額外加上 -m32 就可以編譯成為
32 bit 的程式 , 當然對應的 32bit library 也要安裝 (ex zlib-devel.i686.....等)

乖乖的轉換 64 bit system , 並且不需要修改很多東西就可以了!!

2012年9月18日 星期二

加入自己的 執行程式...

開發階段可能需要一些簡單的測試程式(執行檔) , 來進行一些小功能測試 , 所以下一個階段 , 移植一個小執行檔進入 TI BSP 吧 !!

之前我們有一個 lcd-test 的程式 , 由 console press "Enter" key , 會使用 mmap 方式填寫固定 pattern 到 fb0 內. 就先移植這個吧 !!

同樣的使用自己的 makefile 方式 .

首先開一的資料夾 ( android 的 main.mk 會自己尋找 ) , 可以有兩層 , 我的方式如下:
rowboat-android/test_apps/test/lcd-test & rowboat-android/test_apps/test/lcd-test/lcd-test-0.0.1

在 lcd-test 資料夾下放入 Android.mk file , 內容如下:
#  Android.mk
#
#  Copyright 2012 Jeff Hsieh <jeff@instant-jeff.instant>
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#  MA 02110-1301, USA.
#
#


LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

CROSS_TC_PREFIX        := $(shell basename $(TARGET_TOOLS_PREFIX))
CROSS_TC_DIR        := $(realpath $(shell dirname $(TARGET_TOOLS_PREFIX)))
export TARGET_CC    := $(CROSS_TC_DIR)/$(CROSS_TC_PREFIX)gcc


export PRODUCT_OUT    := $(PRODUCT_OUT)
PACKAGE_PATH        := $(LOCAL_PATH)

LOCAL_GLOBAL_CFLAGS        := $(subst -I ,-I $(shell pwd)/,$(subst -include ,-include $(shell pwd)/,$(TARGET_GLOBAL_CFLAGS))) \
                        $(foreach f,$(TARGET_C_INCLUDES), $(addprefix -I$(shell pwd)/,$f)) \
                        $(foreach f,$(TARGET_PROJECT_INCLUDES), $(addprefix -I$(shell pwd)/,$f)) \
                        $(foreach f,$(JNI_H_INCLUDE), $(addprefix -I$(shell pwd)/,$f))


LOCAL_GLOBAL_LDFLAGS    := -L$(shell pwd)/$(TARGET_OUT_STATIC_LIBRARIES)


##=======================================
## Setting source file.
##=======================================

#~ ifeq ($(CONFIG_),y)
export VERNUM        = 0.0.1
export TARGET_EXE    = lcd-test

#~ endif

VERSION     = lcd-test-$(VERNUM)
PACKAGE     = $(PACKAGE_PATH)/$(VERSION)

##=======================================
## Setting Compiler FLAGS.
##=======================================

export EXE_CFLAGS    = $(LOCAL_GLOBAL_CFLAGS)

export EXE_LDFLAGS    = $(LOCAL_GLOBAL_LDFLAGS)

export EXE_EXT_FILE =  $(shell pwd)/$(TARGET_CRTBEGIN_DYNAMIC_O) \
                        $(shell pwd)/$(TARGET_CRTEND_O)


##=======================================

.PHONY: distclean install_lcd_test distclean_lcd_test

droid: install_lcd_test


install_lcd_test: $(TARGET_CRTBEGIN_DYNAMIC_O) $(TARGET_CRTEND_O) $(TARGET_OUT_STATIC_LIBRARIES)/libm.so \
                $(TARGET_OUT_STATIC_LIBRARIES)/libc.so $(TARGET_OUT_STATIC_LIBRARIES)/libdl.so \
                $(TARGET_OUT_STATIC_LIBRARIES)/liblog.so
    $(MAKE) -C $(PACKAGE) -f Makefile all


distclean: distclean_lcd_test

distclean_lcd_test:
    @$(MAKE) -C $(PACKAGE) -f Makefile distclean



##################################################


主要將一些 ldflags , cflags export 到 下一層 Makefile 使用 , 其中 EXE_EXT_FILES 是因為執行檔 , 會需要這兩個 .o file , 並且很奇怪需要放在 同一個目錄下 , 我試過使用 --sysroot=<path> 的方式 , 也是不行 , 所以只好 copy 過去 make 完畢後 delete 掉.

接著在 ./lcd-test-0.0.1/ 下建立 Makefile , 這個 makefile 就是自己的方式.內容如下:

# ./test_apps/test/lcd-test/lcd-test-0.0.1/Makefile
#
# vi: set ts=4 :

##==========================================


TARGET_OUT        := $(PWD)/$(PRODUCT_OUT)/system/bin/$(TARGET_EXE)

TARGET            = $(TARGET_EXE)
CFLAGS            = $(EXE_CFLAGS)
LDFLAGS            = $(EXE_LDFLAGS)

##==========================================
## Setting target & source file.
##==========================================

CPP_SRCS        = $(wildcard *.cpp)
C_SRCS          = $(wildcard *.c)

CPP_OBJS        = $(CPP_SRCS:.cpp=.opp)
C_OBJS          = $(C_SRCS:.c=.o)

DEPEND_FILE        = .depend


##==========================================
## Make Rules.
##==========================================


.PHONY: all distclean


all: $(DEPEND_FILE) $(TARGET_OUT)

$(TARGET_OUT): $(TARGET) Makefile
    @echo "  Install $(TARGET) ==> $(PRODUCT_OUT)/system/bin/"
    @cp $(TARGET) $(PWD)/$(PRODUCT_OUT)/system/bin/


$(TARGET): $(C_OBJS) $(CPP_OBJS)
    @echo "  Building '$@' ... "
    @cp $(foreach f,$(EXE_EXT_FILE), $(shell echo $f)) ./
    @$(TARGET_CC) -o $@ $(C_OBJS) $(CPP_OBJS) $(LDFLAGS)
    @rm $(foreach f,$(EXE_EXT_FILE), $(shell echo $f | sed 's/.*\///g'))


%.opp: %.cpp
    @echo "  Compiling '$<' ..."
    @$(TARGET_CC) $(CFLAGS) -o $@ -c $<

%.o: %.c
    @echo "  Compiling '$<' ..."
    @$(TARGET_CC) $(CFLAGS) -o $@ -c $<


distclean:
    @echo " Distcleaning '$(TARGET)'  ..."
    @rm -f $(TARGET) $(C_OBJS) $(CPP_OBJS) $(DEPEND_FILE)


$(DEPEND_FILE):
    @if [ -n "$(C_SRCS)" ] || [ -n "$(CPP_SRCS)" ] ; then \
        echo "  Generating '$@' ..." ;\
        for i in  $(C_SRCS) $(CPP_SRCS) ; do  \
            j=`echo $$i | sed 's/\.c/.o/g' ` ;\
            $(TARGET_CC) $(CFLAGS) -M $$i -MT"$$j" >> $@ ;\
        done ; \
    fi


ifeq ($(DEPEND_FILE),$(wildcard $(DEPEND_FILE)))
    include $(DEPEND_FILE)
endif

##==========================================

build 完畢後 ,利用 lrz 傳到 EVB 上的 /system/bin/ 下 . 執行看看 !!
成功....... ^^ , 不過會被原本 的畫面 re-flash 掉 , 所以建議找畫面更新率最低的頁面測試 , 或是使用 stop command 讓 java machine 暫停 , 在利用 console 執行測試程式.

Android 的 fb0 位置和一般linux 不同 , 移動到 /dev/graphics/fb0 位置.








2012年9月17日 星期一

Add Busybox into TI Android BSP

開發階段 , 很多東西都在 console 下進行一些 debug 的動作 , 有些小修改  , 卻沒有 vim 可以用 , 加上有些常用的 busybox command 都沒有 , 真的有點不方便 !!

之前有  lrz/lsz 的經驗 , 這次一樣如法泡製 , 將 busybox 移植到 TI 的 BSP 中 !!
一樣借用 linaro 這個組織的東西 網址 :

http://www.linaro.org/linux-on-arm

一樣修改一下 Android.mk file (格式和 debug message 修改 ) .

include $(CLEAR_VARS)

BUSYBOX_TOOLS := \
    ar \
    arp \
    ash \
    awk \
    base64 \
    basename \
    beep \
    blkid \
    blockdev \
    bunzip2 \
    bzcat \
    cal \
    catv \
    chat \
    chattr \
    chgrp \
    chpst \
    chroot \
    chrt \
    chvt \
    cksum \
    clear \
    comm \
    cp \
    cpio \
    cttyhack \
    cut \
    dc \
    deallocvt \
    depmod \
    devmem \
    diff \
    dirname \
    dnsd \
    dos2unix \
    dpkg \
    dpkg-deb \
    du \
    dumpkmap \
    echo \
    ed \
    egrep \
    envdir \
    envuidgid \
    expand \
    fakeidentd \
    false \
    fbset \
    fbsplash \
    fdflush \
    fdformat \
    fdisk \
    fgconsole \
    fgrep \
    find \
    findfs \
    flash_lock \
    flash_unlock \
    flashcp \
    flock \
    fold \
    freeramdisk \
    ftpd \
    ftpget \
    ftpput \
    fuser \
    getopt \
    grep \
    gunzip \
    halt \
    hdparm \
    head \
    hexdump \
    httpd \
    ifdown \
    ifup \
    inotifyd \
    install \
    iostat \
    ipaddr \
    ipcalc \
    iplink \
    iproute \
    iprule \
    iptunnel \
    klogd \
    linuxrc \
    loadkmap \
    losetup \
    lpd \
    lpq \
    lpr \
    lsattr \
    lspci \
    lsusb \
    lzcat \
    lzma \
    lzop \
    lzopcat \
    makedevs \
    makemime \
    man \
    md5sum \
    mesg \
    mkfifo \
    mknod \
    mkswap \
    mktemp \
    modinfo \
    modprobe \
    more \
    mpstat \
    nbd-client \
    nc \
    nice \
    nmeter \
    nohup \
    od \
    openvt \
    patch \
    pidof \
    pipe_progress \
    pmap \
    popmaildir \
    poweroff \
    printf \
    pscan \
    pstree \
    pwd \
    pwdx \
    raidautorun \
    rdev \
    readlink \
    readprofile \
    realpath \
    reformime \
    reset \
    resize \
    rev \
    rpm \
    rpm2cpio \
    rtcwake \
    run-parts \
    runsv \
    runsvdir \
    rx \
    script \
    scriptreplay \
    sed \
    sendmail \
    seq \
    setkeycodes \
    setlogcons \
    setserial \
    setsid \
    setuidgid \
    sha1sum \
    sha256sum \
    sha512sum \
    showkey \
    smemcap \
    softlimit \
    sort \
    split \
    start-stop-daemon \
    strings \
    stty \
    sum \
    sv \
    svlogd \
    sysctl \
    tac \
    tail \
    tar \
    tcpsvd \
    tee \
    telnet \
    telnetd \
    test \
    time \
    timeout \
    tr \
    traceroute \
    true \
    ttysize \
    tunctl \
    tune2fs \
    udhcpc \
    uname \
    uncompress \
    unexpand \
    uniq \
    unix2dos \
    unlzma \
    unlzop \
    unxz \
    unzip \
    uudecode \
    uuencode \
    vi \
    volname \
    watch \
    wc \
    wget \
    which \
    whoami \
    whois \
    xargs \
    xz \
    xzcat \
    yes \
    zcat

BB_TC_DIR := $(realpath $(shell dirname $(TARGET_TOOLS_PREFIX)))
BB_TC_PREFIX := $(shell basename $(TARGET_TOOLS_PREFIX))
BB_LDFLAGS := -nostdlib -Bdynamic -Wl,-z,muldefs$(shell if test $(PLATFORM_SDK_VERSION) -lt 16; then echo -ne ',-T../../$(BUILD_SYSTEM)/armelf.x'; fi),-dynamic-linker,/system/bin/linker,-z,nocopyreloc,--no-undefined ../../$(TARGET_CRTBEGIN_DYNAMIC_O) ../../$(TARGET_CRTEND_O) -L../../$(TARGET_OUT_STATIC_LIBRARIES)
# FIXME remove -fno-strict-aliasing once all aliasing violations are fixed
BB_COMPILER_FLAGS := $(subst -I ,-I../../,$(subst -include ,-include ../../,$(TARGET_GLOBAL_CFLAGS))) -I../../bionic/libc/include -I../../bionic/libc/kernel/common -I../../bionic/libc/arch-arm/include -I../../bionic/libc/kernel/arch-arm -I../../bionic/libm/include -fno-stack-protector -Wno-error=format-security -fno-strict-aliasing
BB_LDLIBS := dl m c gcc
ifneq ($(strip $(SHOW_COMMANDS)),)
BB_VERBOSE="V=1"
endif


.PHONY: build_busybox


FILE_BUSYBOX = $(PRODUCT_OUT)/system/bin/busybox

droid: build_busybox

systemtarball: symlinks
    @echo "==================== systemtarball done ...... "

build_busybox: $(TARGET_CRTBEGIN_DYNAMIC_O) $(TARGET_CRTEND_O) $(TARGET_OUT_STATIC_LIBRARIES)/libm.so $(TARGET_OUT_STATIC_LIBRARIES)/libc.so $(TARGET_OUT_STATIC_LIBRARIES)/libdl.so
    @if [ ! -e $(FILE_BUSYBOX) ];then  \
    echo "==================== Building Busybox ...... " ; \
        cd external/busybox && \
        sed -e "s|^CONFIG_CROSS_COMPILER_PREFIX=.*|CONFIG_CROSS_COMPILER_PREFIX=\"$(BB_TC_PREFIX)\"|;s|^CONFIG_EXTRA_CFLAGS=.*|CONFIG_EXTRA_CFLAGS=\"$(BB_COMPILER_FLAGS)\"|" configs/android_defconfig >.config && \
        export PATH=$(BB_TC_DIR):$(PATH) && \
        $(MAKE) -j1 oldconfig && \
        $(MAKE) -j1 $(BB_VERBOSE) EXTRA_LDFLAGS="$(BB_LDFLAGS)" LDLIBS="$(BB_LDLIBS)" && \
        mkdir -p ../../$(PRODUCT_OUT)/system/bin && \
        cp busybox ../../$(PRODUCT_OUT)/system/bin/ ; \
        cd - ; \
        for link in $(BUSYBOX_TOOLS); do\
        ln -sf busybox $(PRODUCT_OUT)/system/bin/$$link; done ; \
    fi

symlinks: build_busybox
    @echo "==================== Create busybox tools linking ...... " ;\
    for link in $(BUSYBOX_TOOLS); do\
        ln -sf busybox $(PRODUCT_OUT)/system/bin/$$link; done
  


最後可以在 out/target/product/am335xevm/system/bin/ 下看到 busybox 和一些 command 的 link .... 大功告成 ..
 

2012年9月13日 星期四

Add JNI demo code ( java + C )

Pure Java 完成了 , 改換 JNI 方式吧 !! 將 a + b 的動作 用 C library 來完成 .
一樣使用之前 pure java 的 code , 如下列修改方式.

    private OnClickListener mAddListener = new OnClickListener()
    {
        @Override
        public void onClick(View view)
        {
            int a = Integer.parseInt(mEditText1.getText().toString());
            int b = Integer.parseInt(mEditText2.getText().toString());
-    int result = a+b;
+ int result = addJNI(a, b);

            mButton.setText(String.valueOf("A+B=" + result));
        }
    };

並且在 .java 中加入 :

    public native int addJNI(int a, int b);
    static
    {
        System.loadLibrary("androint-jni");
    }

## 注意 library 的名稱為 libandroint-jni.so , java 會自動將 lib prefix 補上去 , 所以JNI 產生的 so file , 要注意 , 也需要 lib 這個 perfix.

接著先 產生 .class file , 在由 .class file 產生 .h , 然後 .c file include 這個 .h 並且完成 function 的功能.

產生 .class 的方式可以用下列的command :

javac -d ./ -cp /${HOME}/android-sdk-linux/platforms/android-15/android.jar src/com/eps/william/androint/AndroIntActivity.java <source top>/out/target/common/R/com/eps/william/androint/R.java

接著用 javah 來產生 .h file , command 如下: 
javah -jni -classpath ../bin com.eps.william.androint.AndroIntActivity
 



經過測試 ,沒有問題 , 只是..... 一切都不自動 , 需要手動產生, 並且還要先編譯 java 程式 , 然後手動產生 .h file , 然後 修正 .c file ,  最後在 Android.mk 中加入 .so 的 make 部份 . 一點都不優...... 

經過幾天的  study , 修改了一下 Android.mk  內容 , 讓整個 make 過程中自動產生 .h 然後接著 compile .c file 產生 .so ...... , 修改後的 Android.mk 如下: 

#  Android.mk
#
#  Copyright 2012 Jeff Hsieh <jeff@instant-jeff.instant>
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#  MA 02110-1301, USA.
#
#


LOCAL_PATH:= $(call my-dir)

############################################
#### Jave APK
############################################

$(warning DEBUG **** BUILD_APK)

include $(CLEAR_VARS)

LOCAL_MODULE_TAGS     := optional
LOCAL_SRC_FILES     := $(call all-subdir-java-files)
LOCAL_PACKAGE_NAME     := Sample_4

include $(BUILD_PACKAGE)


############################################
#### Jni Library.
############################################

#~ $(warning DEBUG **** BUILD_JNI)
#~
#~ include $(CLEAR_VARS)
#~
#~ LOCAL_MODULE_TAGS     := optional
#~ LOCAL_SRC_FILES     := $(call all-subdir-c-files)
#~ LOCAL_MODULE        := libandroint-jni
#~
#~ LOCAL_LDLIBS         := -llog
#~
#~ LOCAL_SHARED_LIBRARIES := libcutils
#~
#~ LOCAL_CHECKED_MODULE := build_jni_h
#~ LOCAL_REQUIRED_MODULES := build_jni_h
#~
#~ include $(BUILD_SHARED_LIBRARY)


.PHONY: distclean install_jni_so build_jni_hearder

droid: install_jni_so


############################################
#### create jni h file .
############################################

$(warning DEBUG **** Create JNI heard files.)

include $(CLEAR_VARS)

JNI_LOCAL_PKG_NAME    := $(shell cat $(LOCAL_PATH)/AndroidManifest.xml | grep package | sed 's/.*=//g')
JNI_LOCAL_PKG_DIR     := $(shell echo $(JNI_LOCAL_PKG_NAME) | sed 's/\./\//g' )

JNI_LOCAL_JAVA_SRC     :=
JNI_LOCAL_JAVA_SRC     += $(foreach f,$(call all-subdir-java-files), $(addprefix $(LOCAL_PATH)/,$f))

JNI_LOCAL_PATH         := $(LOCAL_PATH)

JNI_JAVA_LIB        := /home/jeff/Mydroid/android-sdk-linux/platforms/android-15/android.jar
JNI_R_JAVA            := $(TARGET_COMMON_OUT_ROOT)/R/$(JNI_LOCAL_PKG_DIR)/R.java

build_jni_hearder: Sample_4
    @if [ ! -e $(JNI_LOCAL_PATH)/bin ];then \
        mkdir -p $(JNI_LOCAL_PATH)/bin ; \
    fi
    @if [ ! -e $(JNI_LOCAL_PATH)/bin/.jni_header ];then \
        javac -d $(JNI_LOCAL_PATH)/bin  -cp $(JNI_JAVA_LIB) $(JNI_R_JAVA) $(JNI_LOCAL_JAVA_SRC) ; \
        javah -jni -classpath $(JNI_LOCAL_PATH)/bin -d $(JNI_LOCAL_PATH)/jni/jni_include $(JNI_LOCAL_PKG_NAME).AndroIntActivity ;\
    fi


## javac -d ./ -cp /home/jeff/Mydroid/android-sdk-linux/platforms/android-15/android.jar \
##            src/com/eps/william/androint/AndroIntActivity.java \
##            /home/jeff/Mydroid/TI_Android/rowboat-android/out/target/common/R/com/eps/william/androint/R.java

## javah -jni -classpath ../bin com.eps.william.androint.AndroIntActivity


############################################
#### Jni Library.
############################################

include $(CLEAR_VARS)

export JNI_TC_DIR             := $(realpath $(shell dirname $(TARGET_TOOLS_PREFIX)))
export JNI_TC_PREFIX         := $(shell basename $(TARGET_TOOLS_PREFIX))
export TARGET_CC            := $(JNI_TC_DIR)/$(JNI_TC_PREFIX)gcc

export JNI_COMPILER_FLAGS    := $(subst -I ,-I $(shell pwd)/,$(subst -include ,-include $(shell pwd)/,$(TARGET_GLOBAL_CFLAGS))) \
                        $(foreach f,$(TARGET_C_INCLUDES), $(addprefix -I$(shell pwd)/,$f)) \
                        $(foreach f,$(TARGET_PROJECT_INCLUDES), $(addprefix -I$(shell pwd)/,$f)) \
                        $(foreach f,$(JNI_H_INCLUDE), $(addprefix -I$(shell pwd)/,$f)) \

export JNI_LDFLAGS             := -L$(shell pwd)/$(TARGET_OUT_STATIC_LIBRARIES) -llog
export JNI_LOCAL_C_FILES    := $(call all-subdir-c-files)


export PRODUCT_OUT            := $(PRODUCT_OUT)

###################################


install_jni_so: build_jni_hearder \
                $(TARGET_CRTBEGIN_DYNAMIC_O) $(TARGET_CRTEND_O) $(TARGET_OUT_STATIC_LIBRARIES)/libm.so \
                $(TARGET_OUT_STATIC_LIBRARIES)/libc.so $(TARGET_OUT_STATIC_LIBRARIES)/libdl.so \
                $(TARGET_OUT_STATIC_LIBRARIES)/liblog.so
    @$(MAKE) -C $(JNI_LOCAL_PATH) -f Makefile.jni local_jni

############################################
#### Clean rules.
############################################

distclean:
    @if [ -e $(JNI_LOCAL_PATH)/jni/jni_include ];then \
        rm -rf $(JNI_LOCAL_PATH)/jni/jni_include ; \
    fi
    @echo "Remove temp file \"$(JNI_LOCAL_PATH)/bin/ \" .... "
    @if [ -e $(JNI_LOCAL_PATH)/bin ];then \
        rm -rf $(JNI_LOCAL_PATH)/bin ;\
    fi
    @$(MAKE) -C $(JNI_LOCAL_PATH) -f Makefile.jni $@


############################################



因為 Android 的 make rules 太複雜 ,並且支援 make -jN , 所以乾脆獨立出來 build so file . 所以會看到 "@$(MAKE) -C $(JNI_LOCAL_PATH) -f Makefile.jni local_jni " 的字串 , 其中 Makefile.jni 如下:

#  Makefile.jni
#
#  Copyright 2012 Jeff Hsieh <jeff@instant-jeff.instant>
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#  MA 02110-1301, USA.
#
#


DEPEND_FILE                := .jni_depend
JNI_SO_NAME                := libandroint-jni.so
JNI_LOCAL_OBJ_FILES        := $(JNI_LOCAL_C_FILES:.c=.o)
JNI_SO_TARGET           := $(addprefix $(shell pwd)/,$(JNI_SO_NAME))

JNI_TARGET_OUT            := $(PWD)/$(PRODUCT_OUT)/system/lib/$(JNI_SO_NAME)


.PHONY: local_jni distclean


local_jni: $(DEPEND_FILE) $(JNI_TARGET_OUT)

$(JNI_TARGET_OUT): $(JNI_SO_TARGET)
    @echo "  Install $(JNI_SO_NAME) ==> $(PRODUCT_OUT)/system/lib"
    @cp $(JNI_SO_TARGET) $(PWD)/$(PRODUCT_OUT)/system/lib/

$(JNI_SO_TARGET):  $(JNI_LOCAL_OBJ_FILES)
    @echo "  Building '$@' ... "
    @$(TARGET_CC) -shared -Wl,-soname,$(JNI_SO_NAME) -o $@ $(JNI_LOCAL_OBJ_FILES) $(JNI_LDFLAGS)

%.o: %.c
    @echo "  Compiling '$<' ..."
    @$(TARGET_CC) $(JNI_COMPILER_FLAGS) -o $@ -c $<


$(DEPEND_FILE):
    @if [ -n "$(JNI_LOCAL_C_FILES)" ]; then \
        echo "  Generating '$@' ..." ;\
        for i in  $(JNI_LOCAL_C_FILES) ; do  \
            j=`echo $$i | sed 's/\.c/.o/g' ` ;\
            $(TARGET_CC) $(JNI_COMPILER_FLAGS) -M $$i -MT"./$$j" >> $@  ;\
        done ; \
    fi


ifeq ($(DEPEND_FILE),$(wildcard $(DEPEND_FILE)))
    include $(DEPEND_FILE)
endif


distclean:
    @rm -f $(DEPEND_FILE) $(JNI_SO_TARGET) $(JNI_LOCAL_OBJ_FILES)

############################################

2012年8月31日 星期五

Add lrz/lsz into Android source tree.

開發過程中 , 只因為修改一個小檔案 ( jni 的 .so file ) , 卻需要將 SD 從EVB 移除 , 然後放到 Fedora 上 去複製檔案 , 真的有點 "煩" !! 如果有 lrz/lsz 就好了  !!

好吧 , 移植 lrz/lsz 吧 !! Android 使用 binoic library , 和一般 cross toolchain 的 library 不同 , 並且沒有辦法執行 .configure 去產生 Makefile , Makefile 也不被Andriod Source tree 接受 , 真是大工程........ !!

找找看 , 有沒有人已經將 lrz/lsz 放到 Android 上了 !! 找了兩天..... 發現 linaro 這個組織 , 專門優化 ARM 系統的東西 , 並且在 ICS 4.0.4 上有 lrz/lsz 的 source .....嘿嘿...借來用一下吧 !! 不過也公佈一下 這個組織網頁 ... 如下:

http://www.linaro.org/linux-on-arm

按照 linaro 網頁上說明 , 將整個 source tree repo 下來 , 並將 ./externel/lrzsz 資料夾 移到 TI BSP 的相對應位置上 . 並修改 ./externel/lrzsz/Android.mk , 主要是 style  修改 , 並沒有其它改動 ,修改後如下:

LOCAL_PATH:= $(call my-dir)

lrzsz_local_comm_file := timing.c zperr.c zreadline.c crctab.c \
                                rbsb.c zm.c protname.c tcp.c lsyslog.c \
                                canit.c long-options.c xstrtol.c xstrtoul.c error.c

include $(CLEAR_VARS)

LOCAL_SRC_FILES := lrz.c $(lrzsz_local_comm_file)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := lrz
LOCAL_CFLAGS := -DNFGVMIN -DHAVE_CONFIG_H=1
LOCAL_SHARED_LIBRARIES := libc

include $(BUILD_EXECUTABLE)

include $(CLEAR_VARS)

LOCAL_SRC_FILES := lsz.c $(lrzsz_local_comm_file)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := lsz
LOCAL_CFLAGS := -DNFGVMIN -DHAVE_CONFIG_H=1
LOCAL_SHARED_LIBRARIES := libc

include $(BUILD_EXECUTABLE)


一樣的 make 過程中會編譯但是沒有安裝 , 所以修改 ./build/target/product/core.mk檔案 , 加入 lrz , lsz 兩個 packages name , 修改項目如下:

    libwilhelm \
    libz \
    screencap \
    sensorservice \
    lrz\
    lsz \

# host-only dependencies
ifeq ($(WITH_HOST_DALVIK),true)
    PRODUCT_PACKAGES += \


OK 啦 , 可以 lrz  / lsz 操作了 !! 這樣開發過程會 "爽" 一點  !!

PS. 115200 bsp 遇到大的檔案還是要花很久 , 不過至少一些 .so 或是 testing program 就可以方便多了 !!

2012年8月30日 星期四

加入自己的 demo 程式 (Pure Java )

目前 Android ICS 可以運作了 , 自己放個 Demo Code 上去跑跑看吧 ! 順便看看要怎樣加 Code 到 這個 Source Tree 上 .

本人不會 Java 語言 , 所以先找別人的 code 了 !!  剛好 .... 2010年7月有去 "仕XXX科技" ( 避免廣告用 X 代替部份名稱) 上課 , 課程內容有 java 的 demo code ,  借來用一下吧 (著作權問題 , 尊重原作 , 公佈一下講師名稱: 梁文耀 ) ,這個 demo code 很簡單 , 輸入兩個數字 , 一個 button 會顯示結果. 

首先 , 我不想 "污染" 原來的 Source Tree 太多 , 所以另外建立一個目錄 "Instant_apps" , 並且在這資料夾內建立一個 Instant_app.mk 檔案 , 這檔案內容只有註明增加哪些 PACKAGES, 內容如下:

PRODUCT_PACKAGES := \
    Sample_1  \


在 Instant_apps 目錄下放入 sample code 資料夾 "AndroInt-ex1-activity"
在 Instant_apps/AndroInt-ex1-activity/ 建立 Android.mk file , 內容如下:

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_PACKAGE_NAME := Sample_1
include $(BUILD_PACKAGE)


## 注意 , Instant_app.mk 內的Samele_1 要和這個 Android.mk 中的 LOCAL_PACKAGES_NAME 相同 , 這樣 make 過程才會正確.

這樣就可以 make 了 , 不過 最後不會安裝到 out/target/product/am335xevm/ 下 , 需要在修改一個地方.主要是說明 am335xevm target 有包含這個 demo code (如果不想預載 ,可以找到 輸出的 .apk 然後用手動的方式在 target EVB 上安裝) , 所以修改 device/ti/am335xevm/am335xevm.mk 的內容 , 如下列紅色部份

# Inherit from those products. Most specific first.
$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base.mk)
$(call inherit-product, device/ti/am335xevm/device.mk)

$(call inherit-product, Instant_apps/Instant_app.mk)

PRODUCT_NAME := am335xevm
PRODUCT_DEVICE := am335xevm


大功告成 , 最後 .apk 會放在 out/target/product/am335xevm/system/app/Sample_1.apk , target EVB 開機後就可以看到 預載的 Sample code 了.



2012年8月17日 星期五

Do some modify .....

A. 修正 ./build/core/main.mk file.
Java 版本一直沒有辦法通過 main.mk file 的檢查 , 不過我確認我的 FC 16 已經是 java 6 了, 所以使用 "偷吃步 " 將 check java version 的 段落移除 , 讓 make 可以繼續 .

# Check for the correct version of java
java_version := $(shell java -version 2>&1 | head -n 1 | grep '^java .*[ "]1\.6[\. "$]')
ifneq ($(shell java -version 2>&1 | grep -i openjdk),"")

## Jeff >>>>
#java_version :=
## <<<<

endif


A. 不要使用 openJDK , 會有一些詭異的錯誤.
   先到 Java 官方網頁下載 jdk-6u34-linux-i586.bin file (可能會有新版本 6uxx  ),
   我的系統是 Fedora i686 並非 x64 , 所以選擇這個 , 更該為可執行 , 然後執行它.

   [jeff@localhost Downloads]$  chmod +x jdk-6u34-linux-i586.bin
   [jeff@localhost Downloads]$  ./jdk-6u34-linux-i586.bin 

    然後會產生一個目錄 "jdk1.6.0_34" !! 
   在開始 build Android source code 時候將 PATH 改為
   export PATH=/${HOME}/Downloads/jdk1.6.0_34/bin/:$PATH

   這樣就可以了 !!

B.修改 ./frameworks/compile/slang/Android.mk file .
整個 make 過程會發現下列的 error , 主要是 complier 將沒有使用的變數當作 error 來輸出 , 所以修改一下 Android.mk file , 將這個改為 warning 即可.

frameworks/compile/slang/slang_rs_export_foreach.cpp: In static member function ‘static slang::RSExportForEach* slang::RSExportForEach::Create(slang::RSContext*, const clang::FunctionDecl*)’: frameworks/compile/slang/slang_rs_export_foreach.cpp:249:23: error: variable ‘ParamName’ set but not used [-Werror=unused-but-set-variable] cc1plus: all warnings being treated as errors

# The prebuilt tools should be used when we are doing app-only build.
ifeq ($(TARGET_BUILD_APPS),)

LOCAL_PATH := $(call my-dir)

## Jeff >>>
local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter
##local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter -Werror
## <<<

ifneq ($(TARGET_BUILD_VARIANT),eng)
local_cflags_for_slang += -D__DISABLE_ASSERTS
endif
local_cflags_for_slang += -DTARGET_BUILD_VARIANT=$(TARGET_BUILD_VARIANT)


C. 修正 ./external/webkit/Source/WebCore/make-hash-tools.pl file.
Build 過程 看到下列的 error message ,
Can't locate Switch.pm in @INC (@INC contains: /usr/lib/perl5/site_perl /usr/share/perl5/site_perl /usr/lib/perl5/vendor_perl
/usr/share/perl5/vendor_perl /usr/lib/perl5/core_perl /usr/share/perl5/core_perl .)
at external/webkit/Source/WebCore/make-hash-tools.pl line 23. BEGIN failed--compilation aborted at external/webkit/Source/WebCore/make-hash-tools.pl line 23.
原來是 prel 版本的問題 , 需要修改 make-hash-tools.pl file , 修改方式請參考 下列網址說明.

http://code.google.com/p/android/issues/detail?id=22231

D. 修正 ./external/gtest/include/gtest/internal/gtest-param-util.h
如果有看到下列這樣的 error message :
external/gtest/src/../include/gtest/internal/gtest-param-util.h:122:11: error: ‘ptrdiff_t’ does not name a type
請參考 下列網址中的說明 ,修改

http://code.google.com/p/android/issues/detail?id=22005

external/gtest/include/gtest/internal/gtest-param-util.h
 #include <vector> 
+#include <cstddef> 
 #include <gtest/internal/gtest-port.h> 

  D. 修正 ./build/env.sh

In file included from external/oprofile/libpp/arrange_profiles.cpp:24:0:
external/oprofile/libpp/format_output.h:94:22: error: reference ‘counts’ cannot be declared ‘mutable’ [-fpermissive]
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/liboprofile_pp_intermediates/arrange_profiles.o] Error 1




E. 修正 hardware/ti/sgx/Makefile.KM.Android File.
依照 User guide 要傳OMAPES=4.x 給 kernel , 但是在這個 makefile 中卻重新設定為INVALIDVAL . 這樣會導致 make 不過.

 --- a/Makefile.KM.Android
+++ b/Makefile.KM.Android
@@ -1,6 +1,6 @@
 include Rules.make

-OMAPES:=INVALIDVAL
+##OMAPES:=INVALIDVAL

 .PHONY: all_km buildkernel
 .PHONY: clean_km cleankernelmodule
@@ -76,6 +76,7 @@ else ifeq ($(OMAPES),7.x)
        @cp -rf $(GFX_KERNMOD_SRCPATH)/eurasiacon/binary2_omap4430_android_release/target/pvrsrvkm.ko $(GFX_REL_ES7_LIB_SRCPATH_AN
        @cp -rf $(GFX_KERNMOD_SRCPATH)/eurasiacon/binary2_omap4430_android_release/target/omaplfb.ko $(GFX_REL_ES7_LIB_SRCPATH_AND
 else
+       @echo "OMAPES:$(OMAPES)"
        @echo "OMAPES value not specified (Mandatory value)"
        exit 1
 endif


F. 為了增加make 過程的順利 , 我增加了一個 env.sh file .
內容如下 , 在 make之前先執行 source build/env.sh , 就會設定好一些環境參數.

#!/bin/sh

export PATH=${PWD}/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin:${HOME}/bin/jdk1.6.0_34/bin:$PATH
export PATH=${PWD}/build:$PATH

export TARGET_PRODUCT=am335xevm
export OMAPES=4.x

export USE_CCACHE=1


## ==== for u-boot or kernel used.

export ARCH=arm
export CROSS_COMPILE=arm-eabi-


#!/bin/sh


JDK_BIN_DIR=${HOME}/bin/jdk1.6.0_34/bin
TOOLCHAIN_BIN_DIR=${PWD}/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin

PATH1=`echo ${PATH} | sed "s|[:]${JDK_BIN_DIR}||g"`
PATH2=`echo ${PATH1} | sed "s|${JDK_BIN_DIR}[:]||g"`
PATH3=`echo ${PATH2} | sed "s|[:]${TOOLCHAIN_BIN_DIR}||g"`
PATHX=`echo ${PATH3} | sed "s|${TOOLCHAIN_BIN_DIR}[:]||g"`

export PATH=${TOOLCHAIN_BIN_DIR}:${JDK_BIN_DIR}:${PATHX}

export TARGET_PRODUCT=am335xevm
export OMAPES=4.x

export USE_CCACHE=1


## ==== for u-boot or kernel used.

export ARCH=arm
export CROSS_COMPILE=arm-eabi-





G. 為了自動產生 rootfs.tar.bz file . 我增加了一個 shell file.
依照 User Guide , 要執行5 個指令才能製作出 rootfs.tar.bz file .我將這接指令用一個 shell file 包裝起來 , 使用上就會方便多了, 只要在 top 目錄執行這個  shell 即可.


#!/bin/sh

#  $ cd out/target/product/<product-name>
#  $ mkdir android_rootfs
#  $ cp -r root/* android_rootfs
#  $ cp -r system android_rootfs
#  $ ../../../../build/tools/mktarball.sh ../../../host/linux-x86/bin/fs_get_stats android_rootfs . rootfs rootfs.tar.bz2

## ===== defind echo color
COLOR_ECHO="echo -e"        ## in Fedora the color echo need have -e argument.
COLOR_NORMAL="\033[0m"
COLOR_BOLD="\033[1m"
COLOR_RED="\033[31m"
COLOR_GREEN="\033[32m"
COLOR_YELLOW="\033[33m"


## ==== check doing env.sh .
if [ -z ${TARGET_PRODUCT} ];then
    ${COLOR_ECHO} "${COLOR_BOLD}${COLOR_RED}## Android Target Product type not defined. "
    ${COLOR_ECHO} "${COLOR_NORMAL}"
    exit
fi


_target_dir=${PWD}/out/target/product/${TARGET_PRODUCT}
_out_root=${_target_dir}/root
_out_system=${_target_dir}/system
_rootfs_dir=${_target_dir}/android_rootfs

MKTARBALL=${PWD}/build/tools/mktarball.sh
FS_GET_DATAS=${PWD}/out/host/linux-x86/bin/fs_get_stats


## ==== Check utility .
if [ ! -e ${MKTARBALL} ] || [ ! -e ${FS_GET_DATAS} ];then
    ${COLOR_ECHO} "${COLOR_BOLD}${COLOR_RED}## Some utility tools not exist. "
    ${COLOR_ECHO} "${COLOR_NORMAL}"
    exit
fi

## ==== check output data exist.

if [ -e ${_out_root} ] && [ -e ${_out_system} ] ;then
    #~ echo "DEBUG >>>> _target_dir=:${_target_dir}"
    #~ echo "DEBUG >>>> _out_root=:${_out_root}"
    #~ echo "DEBUG >>>> _out_system=:${_out_system}"
    #~ echo "DEBUG >>>> _rootfs_dir=:${_rootfs_dir}"

    ## ==== creat rootfs dir.
    if [ -e ${_rootfs_dir} ];then
        ${COLOR_ECHO} "${COLOR_BOLD}${COLOR_YELLOW}## Clean up old data in \"${_rootfs_dir}\" ....  "
        ${COLOR_ECHO} "${COLOR_NORMAL}"
        rm -rf ${_rootfs_dir}
    else
        ${COLOR_ECHO} "${COLOR_BOLD}${COLOR_GREEN}## Create rootfs dir \"${_rootfs_dir}\" "
        ${COLOR_ECHO} "${COLOR_NORMAL}"
    fi
    mkdir -p ${_rootfs_dir}

    cp -r ${_out_root}/* ${_rootfs_dir}
    cp -r ${_out_system} ${_rootfs_dir}

    ${COLOR_ECHO} "${COLOR_BOLD}${COLOR_GREEN}## Createing rootfs tarball .... "
    ${COLOR_ECHO} "${COLOR_NORMAL}"

    cd  ${_target_dir}
    ${MKTARBALL} ${FS_GET_DATAS} ${_rootfs_dir} . rootfs rootfs.tar.bz2
    cd - > /dev/null


else
    ${COLOR_ECHO} "${COLOR_BOLD}${COLOR_RED}## Android Target output data not exist "
    ${COLOR_ECHO} "${COLOR_NORMAL}"
    exit
fi

 


### 終於.... 可以執行 TI AM335x 的 ICS 了. 

裝個 "憤怒鳥" 來玩玩看吧 !!
http://www.youtube.com/watch?v=JURiyybtT4w&feature=g-upl