Android 2.3.1 For 5-Series
This page will collect the information used to build Android 2.3.1 for 5-Series EK board.
Getting Started
In order to get familiar with the working environment of development on Android, it's highly recommended
Getting Started Page shall be read firstly.
AT91Bootstrap
AT91Bootstrap is the first step bootloader which provides a set of algorithms to manage hardware initialization (GPIO, Clock, SDRAM, etc), to download your main application from specified FLASH media to main memory and to start it.
In the Android4SAM pre-built demo it is used to configure the hardware and to load and start the standard
U-Boot bootloader, it can also be configured to start Linux kernel directly.
For more information, Please goto
the AT91Bootstrap application note.
Source code or patches
Load AT91Bootstrap on SAM9 Boards (NandFlash booting only)
Build AT91Bootstrap
For SD Card Booting
- Change to your working directory
$ cd YOUR_WORKING_DIR
- Get the source code of AT91Bootstrap
$ wget ftp://ftp.linux4sam.org/pub/Android4SAM/9x5/v1.2/Patches/SAM9x5_at91bootstrap.tar.gz
- Decompress the package
$ tar zxvf SAM9x5_at91bootstrap.tar.gz && cd at91bootstrap
- Setup environment variable
$ export ARCH=arm
$ export CROSS_COMPILE=/path/to/your/crosstoolchain/bin/arm-none-linux-gnueabi-
- Configure AT91Bootstrap
$ make mrproper && make at91sam9x5sd_defconfig
- Build AT91Bootstrap
$ make
- Format one SD Card to FAT32
- Copy binaries/at91sam9x5ek-sdcardboot-3.0.bin to SD card and rename it to boot.bin

In Linux environment, you may need to name the booting image as
BOOT.BIN

In order to boot from SD card, the MCU ROM code has two assumptions,
- The first partition of the SD Card is formated with FAT or FAT32
- The bootstrap file is named with "boot.bin" and is copied into the first partition
For NandFlash Booting
- Get the source code of AT91Bootstrap
$ wget ftp://ftp.linux4sam.org/pub/Android4SAM/9x5/v1.2/Patches/SAM9x5_at91bootstrap.tar.gz
- Decompress the package
$ tar zxvf SAM9x5_at91bootstrap.tar.gz && cd at91bootstrap
- Setup environment variable
$ export ARCH=arm
$ export CROSS_COMPILE=/path/to/your/crosstoolchain/bin/arm-none-linux-gnueabi-
- Configure AT91Bootstrap
$ make mrproper && make at91sam9x5nf_kernel_defconfig
- Build AT91Bootstrap
$ make
- Format one SD Card to FAT32
- The final image can be found as binaries/at91sam9x5ek-nandflashboot-3.0.bin
- Flash the final image to your EK board, as mentioned above
Linux Kernel 2.6.35
Introduction
Android4SAM kernel is based on Linux kernel 2.6.35, with AT91 patch and Android experimental patch applied orderly.
Official Linux 2.6.35
Source code or patches
Build Linux Kernel
- Export environment variables
$ export ARCH=arm
$ export CROSS_COMPILE=/path/to/your/crosstoolchain/bin/arm-none-linux-gnueabi-
- Download official 2.6.35 Linux Kernel
$ cd YOUR_WORKING_DIR
$ wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.35.tar.bz2
$ tar xvjf linux-2.6.35.tar.bz2
- Apply 5-Series patchset
$ wget ftp://ftp.linux4sam.org/pub/Android4SAM/9x5/v1.2/Patches/SAM9x5_linux-2.6.35.diff
$ cd linux-2.6.35 && cat ../SAM9x5_linux-2.6.35.diff | patch -p1
$ cd ..
- Apply Android4SAM patchset
$ wget ftp://ftp.linux4sam.org/pub/Android4SAM/9x5/v1.2/Patches/SAM9x5_linux-2.6.35_Android-2.3.1_r1.diff
$ cd linux-2.6.35 && cat ../SAM9x5_linux-2.6.35_Android-2.3.1_r1.diff | patch -p1
- Configure and Build Linux Kernel
- Booting from SDCard
$ make mrproper
$ make at91sam9x5_android_defconfig
$ make uImage
- Booting from Nandflash (UBIFS)
You need to build Android before this step
Build Android, see Here
$ make mrproper
$ cp -a YOUR_WORKING_DIR/Android-$ANDROID_VERSION/out/target/product/sam9x5/root ./
$ make ARCH=arm at91sam9x5_android_ubifs_defconfig
$ make uImage
- After successful building, you can find Linux image(U-Boot format) in: arch/arm/boot/uImage
Android Root File System
Setup Build Machine
Host System
- Google recommends recent versions of 64bits UBuntu (10.04 or newer)
Necessary Packages
- Python 2.4 -- 2.7, which you can download from python.org
- JDK 6 if you wish to build Gingerbread or newer
$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ sudo add-apt-repository "deb-src http://archive.canonical.com/ubuntu lucid partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk
- Git 1.5.4 or newer. You can find it at git-scm.com
- GNU Make - Google recommends make 3.81
GNU Make 3.82 will even prevent Android system from building
- (optional) Valgrind, a tool that will help you find memory leaks, stack corruption, array bounds overflows, etc. Download from valgrind.org
- Other packages
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \
x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \
libgl1-mesa-dev g++-multilib mingw32 tofrodos

The official
Android Page shall always be taken as a reference
Get Android Source Code
* Downaload Android source code from official web server
-
- Make sure you have a bin/ directory in your home directory, and that it is included in your path:
$ mkdir ~/bin
$ export PATH=~/bin:$PATH
- Download the Repo script and ensure it is executable:
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
- Initializing a Repo client
$ mkdir ANDROID_DIR
$ cd ANDROID_DIR
- Run repo init to get latest version of repo
repo init -u https://android.googlesource.com/platform/manifest
- Checkout Android 2.3.1-r1
$ repo init -u https://android.googlesource.com/platform/manifest.git -b android-2.3.1_r1
- Download all files
$ repo sync

The official
Android Page shall always be taken as a reference
Apply Patches
| Description |
Resource URL |
Size |
Features |
| Android source code patch |
SAM9x5_Android-2.3.1_r1.tar.gz |
(~ 2.6 MB) |
- Add the touchscreen calibration application to Android
- Add IP configure application to Android
- Make music work well under Android
- Modify code to use Android's own screen-lock
- Add configuration files for Android system initialization and ALSA system
- Add customized apk for Android system
|
Configure and Build Android
Generate Android Root Filesystem (UBIFS)
- Download helper script
$ wget ftp://ftp.linux4sam.org/pub/Android4SAM/9x5/v1.2/Tools/Generate_ubifs_image.tar.gz
$ cp Generate_ubifs_image.tar.gz ANDROID_DIR/
$ cd ANDROID_DIR/
$ tar zxvf Generate_ubifs_image.tar.gz
- Run script
# cd Generate_ubifs_image
$ ./ubifs.sh -b sam9x5
- After successful building, you'll get system_ubifs-at91sam9x5ek–ANDROID -2.3.1_r1.img and userdata_ubifs-at91sam9x5ek-ANDROID-2.3.1_r1.img
Generate Android Root Filesystem (SDCard Booting)
- Download helper script
$ wget ftp://ftp.linux4sam.org/pub/Android4SAM/9x5/v1.2/Tools/Generate_sdcard_image.tar.gz
$ cp Generate_sdcard_image.tar.gz ANDROID_DIR/
$ cd ANDROID_DIR/
$ tar zxvf Generate_sdcard_image.tar.gz
- Insert one SDCard to your Linux workstation (Size recommended, >= 2G)
- Run script
$ cd Generate_sdcard_image
# Note, you should specify correct device file for your SDCard
$ ./sdimage.sh -b sam9x5 -s /dev/sdc

Caution!! The SD card device node depends on your Linux host, here we take
/dev/sdc as an example.
Use UBIFS image files
Pre-Built demo images
- Replace system_ubifs-at91sam9x5ek–ANDROID -2.3.1_r1.img and userdata_ubifs-at91sam9x5ek-ANDROID-2.3.1_r1.img in the demo package
- Run flashing script to flash all image files to Evaluation Board. For details, see here
- Reboot the Evaluation Board, your new Android Root Filesystem will take effect
Use SDCard image files
Pre-Built demo images
- In order to program SDCard using the prebuilt image, please have a look at here
--
EricXu - 2011-09-28