android源代码编译和到s3c2440的移植

1,到官网www.android.com下载源代码的过程,就是按照官网的提示一步一步地做就可以了。http://source.android.com/source/initializing.html上面有详细的过程介绍,虽然不懂为什么这么配置和编译,但是先编译完再说。

2,编译的时候,由于我天生弱智,所以在开始make的时候,应该打make -j2,结果我打了个make j2,然后编译总是停下来,然后说找不到一些DOC目录,如find: `frameworks/base/frameworks/base/docs/html': 没有那个文件或目录
find: `out/target/common/docs/gen': 没有那个文件或目录
find: `frameworks/base/frameworks/base/docs/html': 没有那个文件或目录
find: `out/target/common/docs/gen': 没有那个文件或目录

我编译停止是因为找不到以上目录而停下的呢,所以找了很久解决这个问题的办法,其实,这个问题完全不用管,是因为我的make命令敲错了。大概2天以后我才意识到这个问题,不过已经相当焦头烂额了。然后这回make -j2敲正确了以后,虽然还是说找不到目录,但是已经顺利继续编译下去了。

 

3,后来编译再次出错,内容是:

 

host C: libneo_cgi <= external/clearsilver/cgi/cgi.c
external/clearsilver/cgi/cgi.c:22:18: error: zlib.h: No such file or directory

 

这个错误是因为我们缺少zlib1g-dev,需要使用apt-get命令从软件仓库中安装,如下:

 

sudo apt-get install zlib1g-dev

 

我在安装官网提示安装的一些库的时候,有些库安不上,说找不到,我想是add-apt-repository的时候有些地址没有加上的缘故。


安装完这个库,编译就正常运行下去了。

 

 

4,编译完成后,就希望能把代码移植到开发板中,但是毫无头绪,一是不知这套代码干嘛用的,二是找遍编译完的代码,连个像样的文档都没有,source.android.com里面也没什么文档,以至于我连我搞了半天在搞什么也都不清楚,太奇怪了。像什么pdk.android.com这种介绍文档,官网直接说移除了,移到别的地方去了,移到哪里也不说,所以就找傻我。到网上查半天,有一个研究生论文《基于ARM9+S3C2440的android操作系统移植》写的比较详细,让我初步知道了我下载和编译半天的代码究竟干嘛使得。文档连接:http://www.docin.com/p-126417136.html

然后到网上去查官网的文档到底在哪,有人说,You can still find the documentation in the source code here android-gingerbread/development/pdk it contains a README telling how to generate the documentation.

The kandroid site also has a copy
http://www.kandroid.org/android_pdk/index.html

 

一些官网的文档:http://code.google.com/android/intro/index.html

http://code.google.com/android/what-is-android.html

http://code.google.com/android/intro/index.html

API的介绍:http://developer.android.com/reference/packages.html

上不去可以用代理。

 

 5, 不知什么原因,还是找不到最新的PDK文档。以上提到的文档链接全都过时了,没有最新的。所以只好搜中文的资料,按照一些有经验的人的方法来继续做。

6,(20110528)哎呀妈呀,今天在我说放弃并且开始尝试做qtopia的时候,android的相关的官方文档似乎终于被我找到了。

有两个网址,看似很像官网:http://code.google.com/p/androidteam/  这个说可能又要转移了,转移到:

http://teampal.ustcsz.edu.cn/projects/android/wiki

 


7,(20110603)因为已经编译完成,因此在android根目录里面有一个out目录里会包含已经生成好的文件系统。我的输出在out/target/product/passion下面。里面生成了root,system,data等目录,以及这些目录的img文件。我具体的用法是,将system目录和data目录拷贝到root目录下,root目录里面本来就有system目录和data目录,但是都是空的,需要用上层的system目录和data目录来替换和覆盖。这样,就制作好了root目录了,这个目录就是android文件系统的根目录。可以用mkyaffs工具打包然后烧写flash,但是我是用的nfs来载入android文件系统的,因此,在挂载nfs以后,只要使用chroot来将根切换到我的android的root目录内就可以了。命令是:chroot /mnt/android/root/ /system/bin/sh然后回车,就可以了。回车以后,命令行提示“segmentation fault”错误,我理解是由于我的开发板是s3c2440的,cpu是armv4t的,因此不能运行android文件系统,必须找到支持armv4t的文件系统才可以。因此到网上查到了“android-on-freerunner”这个项目,这个项目是将android运行到armv4t上的一个项目,里面也有直接编译好的包可以下载,下面将里面的内容摘录一下。

网址:http://code.google.com/p/android-on-freerunner/

编译好的android文件系统下载和运行:http://code.google.com/p/android-on-freerunner/wiki/GetIt

android for armv4t原代码的获取和编译:http://code.google.com/p/android-on-freerunner/wiki/BuildIt

Neo Freerunner的硬件参数介绍:http://wiki.openmoko.org/wiki/Neo_FreeRunner_Hardware

 

//下面摘录网站内容。

http://code.google.com/p/android-on-freerunner/wiki/GetIt

  • Main page
  • Get it
    • Before you start
    • Download
    • Installing
  • Use it
    • Post install set-up
    • Applications
    • Support
    • ADB shell
    • Dropbear SSH
    • Busybox SSH
    • Features
  • Emulate it
  • Improve it
    • The basics
    • A working repository
    • Working with the source
  • Build it
  • AoF on SD
  • Art
  • FAQ
GetIt  
android-on-freerunner, Downloading & installing.
Updated Mar 16, 2011 by [email protected]

Before you start

You need:

  • A fully charged Openmoko Freerunner GTA02 telephone
  • An SD memory card supported on the Freerunner (non-exhaustive list available here )
  • Some way of connecting your SD card to your computer.
  • Root priveliges on your Linux system

If required, you can find very comprehensive additional information on most of the points covered below at the Openmoko Wiki site .

Update GSM firmware

Some of the issues with reading SIM card contacts, wakeup interrupts, etc. can be fixed by updating the GSM firmware on your phone to the latest version - currently Moko11. See the relevant OpenMoko wiki page for full instructions on checking your version and how to update.

Backup your data - Manually

Be warned! Loading a new build means clearing everything from your SD card and your telephone's memory, including the bootloader. Backup any personal files or modified config files you want to keep from your Freerunner now!

To back up your contacts and SMS data, create a local directory to store the data and pull the data from your Android phone using ADB.

$ mkdir backup
$ mkdir backup
/ data
$ adb pull
/ data / data / com . android . providers . contacts / databases / contacts . db backup / data / contacts . db
$ adb pull
/ data / data / com . android . providers . telephony / databases / mmssms . db backup / data / mmssms . db
$ adb pull
/ data / data / com . android . alarmclock / databases / alarms . db backup / data / alarms . db
$ adb pull
/ data / data / com . android . providers . settings / databases / settings . db backup / data / settings . db
$ adb pull
/ data / data / com . android . providers . calendar / databases / calendar . db backup / data / calendar . db
$ adb pull
/ data / data / com . android . settings / backup / data / com . android . settings /
$ adb pull
/ data / data / com . android . settings / shared_prefs / com . android . settings_preferences . xml backup / data / com . android . settings_preferences . xml
$ adb pull
/ data / data / org . andnav2 / backup / data / org . andnav2 /

Backup your data - Automated

We've adapted the script by Teodor Robas who created the initial script to automatically backup contacts, sms, preferences, wallpaper, calendar and so on. It creates a restore script for pushing these back to the Freerunner after flashing a new image. This restore script will also install busybox, a file explorer, and sets the date and time correctly.

You can check out the adapted script here.

Partition and format the SD card

For Android to work properly the Micro SD Card in your FreeRunner needs to have 2 primary partitions. The first needs to be a VFAT/MSDOS (16 or 32) partition which is used is mounted as '/sdcard', this is used as a storage area (for pictures, movies, music, etc). The second is an ext3 partition which Android mounts as '/data', this is where it stores settings, caches, etc.

Experience has shown that sizing these at a ratio of 3 to 1 works best. So if you have a 4GB card make a 3GB vfat partition and a 1GB ext3 partion.

Experience has also shown that it is best to delete all existing partitions and create new when installing a new build. (This greatly helps the testing and bug fixing process). Comprehensive information on partitioning and formatting your SD card can be found on the Openmoko Wiki.

Note Users have reported that it is also possible to install Android by making a single partition formatted as VFAT/MSDOS.

Choose your build

First step is to decide which version of Android you want to install.

One of the big plus points with Android is that Google push regular updates. The downside is that this project doesn't have the capacity to maintain several branches.

The current maintained options are Cupcake (Android 1.5) - as stable as it gets on the Freerunner with most functions working or Froyo (Android 2.2) - so bleeding edge as it hurts.

There is also a Master branch which is following the "Android Open Source Project" and will form the basis for future development. Allowing us to piggy-back on code releases from Google without going back to the start every time.

Next decide if you will create your own build: See detailed instructions here

or if you want to use one of the prepared builds available:

  • Download the latest "stable" Cupcake build version featured on the Downloads tab on this site.
  • Download the current Froyo build from the Downloads tab on this site. Be aware that these include the latest commits and are experimental.

NB: To install the SD builds on the Download tab see here for details.

We are grateful to Ran and Cley Faye for providing the prepared builds.

Installing

Start by opening a terminal and change to the directory you downloaded the build file to. Next you need to attach your squeaky clean, newly formatted SD card to your system.

To mount it you need to know what device name your system has allocated to it. This can vary due to your distribution's rules and your hardware setup. If you are not sure then plug in your card then try running -

$ dmesg 
|
 tail

You should see something like -

scsi 
5
:
0
:
0
:
0
:
 
Direct
-
Access
     
Multi
    
Flash
 
Reader
     
1.00
 PQ
:
 
0
 ANSI
:
 
0

sd
5 : 0 : 0 : 0 : Attached scsi generic sg2 type 0
usb
- storage : device scan complete
sd
5 : 0 : 0 : 0 : [ sdb ] Attached SCSI removable disk
sd
5 : 0 : 0 : 0 : [ sdb ] 3862528 512 - byte logical blocks : ( 1.97 GB / 1.84 GiB )
sd
5 : 0 : 0 : 0 : [ sdb ] Assuming drive cache : write through
sd
5 : 0 : 0 : 0 : [ sdb ] Assuming drive cache : write through
 sdb
: sdb1 sdb2

If your system doesn't automatically mount the new partitions then you need to mount the vfat (first) partition as root. Create a directory under /mnt or use an existing one there. In this case /tmp1 -

# mount /dev/sdb1 /mnt/tmp1

Now you need to unpack the files from the build tar that you downloaded. First change to the directory you just mounted -

$ cd 
/
mnt
/
tmp1

Now run the unpack commend as root -

# tar -xvzf /path/to/build/file/build.tar.gz

Don't worry if you see some messages about not being able to change the ownership of files.

First move out of the mounted directory -

$ cd 
~

Now unmount the SD card as root -

# umount /mnt/tmp1

Note: Failing to unmount or sync the SD card before using it can lead to problems with the boot process below.

Remove the SD card from your system and insert it into the Micro SD card in the Freerunner. This is located below the SIM card.

Go!

When you have reassembled your Freerunner, hold the 'Aux button' (top left) in while you push the 'Power button' (bottom right). You should now see a menu with several choices, keep pushing the Aux button until you highlight the Option to "Boot from microSD card (FAT+ext2)". While this option is highlighted push the 'Power button' again.

Now sit back and watch the fun! Here's a short listing of what you should see during a normal installation:

  • Several boot messages
  • A message that the kernel is starting
  • A scary white screen for what seems forever but is only a few seconds
  • Lots of scrolling text
  • That white screen again (don't panic)
  • An andorid-on-freerunner splash screen! (exactly what depends on how creative Damir's been lately). This will be there for quite a while on the first boot. NB: "quite a while" = several minutes, if it's still there after 10 minutes something has gone wrong. Go back to the start and double check all the preparation steps!
  • Very fancy Android letters with rippling light effect.
  • Android start screen - locked!

Now you can use it! Go to Use it page to find out how.

Note The first boot takes much longer than subsequent ones, so don't worry.

Restore your data - Manually

To restore your contacts and SMS data, push your backup to your Android phone using ADB.

$ cd backup
$ adb push backup
/ data / contacts . db / data / data / com . android . providers . contacts / databases / contacts . db
$ adb push backup
/ data / mmssms . db / data / data / com . android . providers . telephony / databases / mmssms . db
$ adb push backup
/ data / alarms . db / data / data / com . android . alarmclock / databases / alarms . db
$ adb push backup
/ data / settings . db / data / data / com . android . providers . settings / databases / settings . db
$ adb push backup
/ data / calendar . db / data / data / com . android . providers . calendar / databases / calendar . db
$ adb push backup
/ data / com . android . settings / / data / data / com . android . settings /
$ adb push backup
/ data / com . android . settings_preferences . xml / data / data / com . android . settings / shared_prefs / com . android . settings_preferences . xml
$ adb push backup
/ data / org . andnav2 / / data / data / org . andnav2 /
$ adb shell sync
$ adb shell reboot

Restore your data - Automated

To restore your data, run the restore script generated by the backup script. This restore script will also install busybox, a file explorer, and sets the date and time correctly.

 

Send your comments to the mailing list

 

 

http://code.google.com/p/android-on-freerunner/wiki/BuildIt

  • Main page
  • Get it
    • Before you start
    • Download
    • Installing
  • Use it
    • Post install set-up
    • Applications
    • Support
    • ADB shell
    • Dropbear SSH
    • Busybox SSH
    • Features
  • Emulate it
  • Improve it
    • The basics
    • A working repository
    • Working with the source
  • Build it
  • AoF on SD
  • Art
  • FAQ
BuildIt  
Build your own system and test out your changes.
Updated Oct 5, 2010 by [email protected]

In general the setup necessary to build Android-on-Freerunner is the same as for the main Android project. See the Get Android Source page there for instructions on downloading source code and setting up your machine's build environment. One important difference: The AoF-specific source code is hosted at our Gitorious repository, so to checkout AoF code use the following command (not the one on the source.android.com page):

 $ repo init 
-
u git
:
//gitorious.org/android-on-freerunner/freerunner_platform_manifest.git -b froyo

The -b parameter on the repo command specifies the branch to check out, currently either cupcake or froyo .

Setting up your system

In general, for either Mac OS/X or Linux build machines, follow the instructions at the source.android.com page . Notes on specific situations are below.

To build, do:

    $ make 
-
j 
4
 TARGET_PRODUCT
=
freerunner

The -j parameter will try to optimise the compilation process. The number should represent the double the number of cores on your system. In this example, the source is compiled on a dual core system. If you are trying to diagnose a build error, not using the -j parameter may make the diagnostics easier to read.

NOTE: If you are building the Cupcake branch then you need to specify 'freerunner' as the TARGET_PRODUCT, if you are using a newer branch then use 'fr'

Ubuntu Linux

Install the packages recommended on the Android page for Ubuntu (32 or 64 bit). Ubuntu 9.10 (Karmic Koala) and later no longer have Java 5 (which is required) in the repositories. You can either manually download and install it from the Oracle page , or you can add the old repository lines to your sources.list. See this page for instructions on the two approaches.

Also in 9.10 and later, the default GCC version has changed, so gcc-4.3, g++-4.3, liblzo2-dev and uboot-mkimage must be installed:

    
# sudo aptitude install gcc-4.3 g++-4.3 liblzo2-dev uboot-mkimage sun-java5-jdk

Whichever of the methods above you've used to install Java 5, you need to point the Android Java variables to the correct location. Something like:

    $ 
export
 JAVA_HOME
=<
path
-
to
-
jdk1
.
5.0
_22 
>

    $
export ANDROID_JAVA_HOME = $JAVA_HOME

Additionally you must set the proper GCC version with environment variables:

    $ 
export
 CC
=
gcc
-
4.3
 
    $
export CXX = g ++- 4.3

In case you have multiple JREs installed, make sure to set the default to the version required for your build. To find out what JREs you have installed run the following:

    $ sudo java
-
update
-
alternatives 
--
list

To set the corect JRE, type:

    $ sudo java
-
update
-
alternatives 
--
set
 
[
the correct 
1.5
 JRE
]

Building with 64-bit OS seems to be more problematic. See the list of packages at the Android site, keeping in mind that you need GCC 4.3 versions of some of the listed packages (cc-4.3-multilib and g++-4.3-multilib). If you come up with a configuration that works, please post it to the mailing list. On the other hand, if you are having problems fell free to ask for help!

The Installer branch

The installer branch is important in case you want to build your own installer package like the daily builds or releases. The installer branch includes the qi bootloader and a kernel with busybox and mtd-utils.

Prepare your system by downloading and installing the OpenMoko toolchain as described in this paragraph . This you will need for compiling Buysybox.

Install the xutils-dev package since you will be needing lndir as part of the make process

    $ sudo apt
-
get
 install xutils
-
dev

Create a separate dir and get the source code on your system:

    $ repo init 
-
u git
:
//gitorious.org/android-on-freerunner/freerunner_platform_manifest.git -b installer

Compile the source by simply typing:

    $ make

Now look for the files called qi.img and uImage.img.

Installation Package

For those who wish to build their own AoF installation package from the local repository, we have created a little script that will do this for you. Pre-requisite is that you've successfully compiled your AoF branch (e.g. Cupcake or Froyo) and the installer branch.

The script, called PackageInstaller.sh, is part of the installer branch and can be found in the installer directory.

The script requires two parameters: the path to your local installer branch and the path to your AoF branch.

An example of how to use the script:

    $ 
./
aof_installer
/
installer
/
PackageInstaller
.
sh 
./
aof_installer 
./
aof_cupcake

The script will create the a file called aof-installpackage-YYYYMMDD.tar.gz in your current directory.

Copy your tar.gz to your SD card and you're ready to install your own AoF distro ;-)

Send your comments to the mailing list

 

http://code.google.com/p/android-on-freerunner/downloads/list

  
  Filename Summary + Labels Uploaded Size DownloadCount AndroidVersion BuildVersion ...
android-on-freerunner-froyo-sd-201104.tar.gz Froyo developers SD build from Apr 2011   Featured Apr 17 57.2 MB 327 Froyo ----  
android-on-freerunner-froyo-201104.tar.gz Froyo developers build from Apr 2011   Featured Apr 17 66.8 MB 272 Froyo ----  
backup-android.sh AoF backup script   Featured Mar 15 6.5 KB 144 ---- ----  
android-on-freerunner-cupcake-sd-stable-201101.tar.gz Cupcake stable SD build from Jan 2011   Featured Feb 1 38.5 MB 454 Cupcake ----  
android-on-freerunner-cupcake-stable-201101.tar.gz Cupcake stable build from Jan 2011   Featured Feb 1 46.5 MB 514 Cupcake ----  
FOSDEM2010 Openmoko Devroom Android on Freerunner 2010-02-07.pdf FOSDEM 2010 AoF Presentation   Featured Feb 2010 988 KB 2541 ---- ----  
freerunner_emulator_theme2.zip Theme for Freerunner emulation in SDK Nov 2009 703 KB 713 ---- ----  
Android-on-Feerunner Test List 20091020 v0.2.xls Android-on-Freerunner Test List   Featured Oct 2009 43.5 KB 2392 ---- ----  

 

 

你可能感兴趣的:(c,android,Build,download,branch,installer)