Android on Freerunner/zh tw

From Openmoko

Revision as of 10:06, 12 December 2008 by Coolcat (Talk | contribs)

Jump to: navigation, search

Contents

在Freerunner上執行Android

Google 釋出了他們Android手機的開放源碼軟體套件。為了要讓它可以在Freerunner上使用,很多 patche需要在armv4 java exception上被套用、編譯。

編譯套件

Android對於gcc 的版本相當的挑剔。若沒有修改的狀況下,針對armv4它也需要一些 java exception支援。以下是我用來build Android的工具:


Binutils 2.18

曾經我有使用在 armv5t程式架構下編譯的 Android,它會導致連結器產生這些blx 指令,讓它無法在armv4下使用。我無法確定這是否仍然是必要的,但我仍然有下面的變更套用到binutils:

diff -urN binutils-2.18-orig/bfd/elf32-arm.c binutils-2.18/bfd/elf32-arm.c
--- binutils-2.18-orig/bfd/elf32-arm.c	2007-08-07 02:59:23.000000000 +0700
+++ binutils-2.18/bfd/elf32-arm.c	2008-03-15 11:30:17.000000000 +0700
@@ -3093,8 +3093,8 @@
 static void check_use_blx(struct elf32_arm_link_hash_table *globals)
 {
   if (bfd_elf_get_obj_attr_int (globals->obfd, OBJ_ATTR_PROC,
-				Tag_CPU_arch) > 2)
-    globals->use_blx = 1;
+				Tag_CPU_arch) >= TAG_CPU_ARCH_V5T)
+    globals->use_blx = 0;
 }
 
 bfd_boolean


configure --prefix={devel path}/android/cross --target=arm-eabi

gcc 4.2.4 with gcc41-java-arm4.patch

configure --prefix={devel path}/android/cross --target=arm-eabi --with-arch=armv4t --enable-shared --enable-threads --disable-nls --disable-libmudflap --enable-target-optspace --with-abi=aapcs --enable-multilib --disable-libssp --disable-libstdcxx --enable-languages=c,c++

java-6-sun

它是個給大部份套件使用的標準Linux package。

Patches

Coming soon. I've posted a number of them on the devel mailing list so far. Eventually, I expect to provide everything necessary for people to build Android for themselves.

Images

要使用Kernel,你必須調整你的 u-boot 環境,讓它可以支援超過 2 MB,或者是你必須修改 Qi Bootloader

我在下面的位置放了 使用2.6.26 版kernel 的Android :

   uImage-android

我已經在下列的網址放了 jffs2 image:

  androidfs.jffs2

Warning: 安裝Android必須要載入新的 kernel 及 rootfs image到手機當中。我並沒有時間製作一個完全不需要使用sd card的影像檔。

有人可以幫忙製作 HOWTO 'change u-boot environment' or a ready-to-download u-boot 的文件嗎?

Installation

就如上面所註明的,這個安裝需要你抺掉目前燒製在Freerunner NAND中的kernel及rootfs。 你也必須要製作出一個設定為二個主磁磁分割的SDCARD:第一個是 VFAT/MSDOS (16 or 32) ,做為 /sdcard 儲存圖片、影片、音樂...等檔案的分割區,另一個則切割為ext3 primary partition ,做為儲存 Android 設定,快取等儲存區。

我建議你進行的第一個工作是設定 SD CARD。 你可以先flash NAND,但你仍然必須要準備好包含二個分割區的SD CARD ,做為你BOOT進系統之前的前置準區。我使用的是 2GB card,我將它切割為以下的內容:

   /dev/mmcblk0p1               1        2454      996310    6  FAT16
/dev/mmcblk0p2 2455 4908 996324 83 Linux

格式化為以下的內容:

   sudo mkfs.vfat /dev/mmcblk0p1
sudo mkfs.ext3 /dev/mmcblk0p2

並不需要將資料放在 ext3 分割區, 若你希望的話,VFAT 分割區也可以放置資料。

在完全的設定好你的SDCARD後,可以準備燒製kernel及rootfs:

   sudo {path_to}/dfu-util -d 0x1d50:0x5119 -a kernel -D uImage-android
sudo {path_to}/dfu-util -d 0x1d50:0x5119 -a rootfs -D androidfs.jffs2

工具

要支援debugging 並且取得Android 手機的shell access,你可以使用:

  adb

你應該可以使用USB連接手機與主機。我不覺得在你將它插入主機後,它會正常運作。你可以使用下面的指令:

   ADBHOST=neo ./adb logcat           - like a tail -f of the android log
   ADBHOST=neo ./adb logcat -b radio  - same as above for the radio logs
   ADBHOST=neo ./adb shell            - bring up a command shell to the phone
   ADBHOST=neo ./adb kill-server      - kill the background server on the host

Note: ADBHOST=neo assumes you have neo in your hosts file to point to the ip of the phone (192.168.0.202). Otherwise prefix the commands with "ADBHOST=192.168.0.202 ./adb [...]" It seems that simply adding IP to /etc/hosts doesn't work on Ubuntu, using IP address (192.168.0.202) instead neo will save your time. If you cannot to the device run "adb kill-server" before trying other commands.

已知的問題

這一個版本的 linux kernel 並無法成功的自suspend mode被喚醒。你的電池壽命也較低,因為你必須要將螢幕的鎖. Your battery life will be significantly lowered because of this and the phone will lock up unless you setup the phones screen timeout to never.

這一個版本也用到了 keypad hack。按鈕的配置如下:

   Aux = "上一步" key.
   電源按鈕=:
       快速按下為選單按鈕,
       按住數秒快速放掉則為end
       按住十秒鐘,則為"關機"。
Personal tools

在Freerunner上執行Android

Google 釋出了他們Android手機的開放源碼軟體套件。為了要讓它可以在Freerunner上使用,很多 patche需要在armv4 java exception上被套用、編譯。

編譯套件

Android對於gcc 的版本相當的挑剔。若沒有修改的狀況下,針對armv4它也需要一些 java exception支援。以下是我用來build Android的工具:


Binutils 2.18

曾經我有使用在 armv5t程式架構下編譯的 Android,它會導致連結器產生這些blx 指令,讓它無法在armv4下使用。我無法確定這是否仍然是必要的,但我仍然有下面的變更套用到binutils:

diff -urN binutils-2.18-orig/bfd/elf32-arm.c binutils-2.18/bfd/elf32-arm.c
--- binutils-2.18-orig/bfd/elf32-arm.c	2007-08-07 02:59:23.000000000 +0700
+++ binutils-2.18/bfd/elf32-arm.c	2008-03-15 11:30:17.000000000 +0700
@@ -3093,8 +3093,8 @@
 static void check_use_blx(struct elf32_arm_link_hash_table *globals)
 {
   if (bfd_elf_get_obj_attr_int (globals->obfd, OBJ_ATTR_PROC,
-				Tag_CPU_arch) > 2)
-    globals->use_blx = 1;
+				Tag_CPU_arch) >= TAG_CPU_ARCH_V5T)
+    globals->use_blx = 0;
 }
 
 bfd_boolean


configure --prefix={devel path}/android/cross --target=arm-eabi

gcc 4.2.4 with gcc41-java-arm4.patch

configure --prefix={devel path}/android/cross --target=arm-eabi --with-arch=armv4t --enable-shared --enable-threads --disable-nls --disable-libmudflap --enable-target-optspace --with-abi=aapcs --enable-multilib --disable-libssp --disable-libstdcxx --enable-languages=c,c++

java-6-sun

它是個給大部份套件使用的標準Linux package。

Patches

Coming soon. I've posted a number of them on the devel mailing list so far. Eventually, I expect to provide everything necessary for people to build Android for themselves.

Images

要使用Kernel,你必須調整你的 u-boot 環境,讓它可以支援超過 2 MB,或者是你必須修改 Qi Bootloader

我在下面的位置放了 使用2.6.26 版kernel 的Android :

   uImage-android

我已經在下列的網址放了 jffs2 image:

  androidfs.jffs2

Warning: 安裝Android必須要載入新的 kernel 及 rootfs image到手機當中。我並沒有時間製作一個完全不需要使用sd card的影像檔。

有人可以幫忙製作 HOWTO 'change u-boot environment' or a ready-to-download u-boot 的文件嗎?

Installation

就如上面所註明的,這個安裝需要你抺掉目前燒製在Freerunner NAND中的kernel及rootfs。 你也必須要製作出一個設定為二個主磁磁分割的SDCARD:第一個是 VFAT/MSDOS (16 or 32) ,做為 /sdcard 儲存圖片、影片、音樂...等檔案的分割區,另一個則切割為ext3 primary partition ,做為儲存 Android 設定,快取等儲存區。

我建議你進行的第一個工作是設定 SD CARD。 你可以先flash NAND,但你仍然必須要準備好包含二個分割區的SD CARD ,做為你BOOT進系統之前的前置準區。我使用的是 2GB card,我將它切割為以下的內容:

   /dev/mmcblk0p1               1        2454      996310    6  FAT16
/dev/mmcblk0p2 2455 4908 996324 83 Linux

格式化為以下的內容:

   sudo mkfs.vfat /dev/mmcblk0p1
sudo mkfs.ext3 /dev/mmcblk0p2

並不需要將資料放在 ext3 分割區, 若你希望的話,VFAT 分割區也可以放置資料。

在完全的設定好你的SDCARD後,可以準備燒製kernel及rootfs:

   sudo {path_to}/dfu-util -d 0x1d50:0x5119 -a kernel -D uImage-android
sudo {path_to}/dfu-util -d 0x1d50:0x5119 -a rootfs -D androidfs.jffs2

工具

要支援debugging 並且取得Android 手機的shell access,你可以使用:

  adb

你應該可以使用USB連接手機與主機。我不覺得在你將它插入主機後,它會正常運作。你可以使用下面的指令:

   ADBHOST=neo ./adb logcat           - like a tail -f of the android log
   ADBHOST=neo ./adb logcat -b radio  - same as above for the radio logs
   ADBHOST=neo ./adb shell            - bring up a command shell to the phone
   ADBHOST=neo ./adb kill-server      - kill the background server on the host

Note: ADBHOST=neo assumes you have neo in your hosts file to point to the ip of the phone (192.168.0.202). Otherwise prefix the commands with "ADBHOST=192.168.0.202 ./adb [...]" It seems that simply adding IP to /etc/hosts doesn't work on Ubuntu, using IP address (192.168.0.202) instead neo will save your time. If you cannot to the device run "adb kill-server" before trying other commands.

已知的問題

這一個版本的 linux kernel 並無法成功的自suspend mode被喚醒。你的電池壽命也較低,因為你必須要將螢幕的鎖. Your battery life will be significantly lowered because of this and the phone will lock up unless you setup the phones screen timeout to never.

這一個版本也用到了 keypad hack。按鈕的配置如下:

   Aux = "上一步" key.
   電源按鈕=:
       快速按下為選單按鈕,
       按住數秒快速放掉則為end
       按住十秒鐘,則為"關機"。