Android-x86 1.6-r2 Donut

This section explain how to create a bootable USB drive for Android-x86 1.6-r2. This Android x86
is developed at section is tested with single board computers, which are
equippwith Intel Atom Z500 series CPU. Since the single board computers do not have any
storage, the boards use USB drive as storage. The porting process is quite simple. Obtain and build
the source files, and write the built files into a bootable USB drive. The single board computers are
booted from the USB drive.

Obtaining and Building Source Files.

Ubuntu 8.04 is used as the building environment.

  • Obtain the source files. The source files are downloaded form At the preparation,
    create a directory will house the downloaded files. The first command line creates the new directly,
    then move down to the newly created directly. The third command lines identifies the location of
    the source files, and the the fourth command line downloads (syncs) these files form the depository.
    $ mkdir android-x86-1.6r2
    $ cd android-x86-1.6r2
    $ repo init -u git:// -b donut-x86
    $ repo sync 
  • Build First, identify the x86 machine. This targets an embedded system, which comes with Atom
    Z500 family, but the x86 machine is defined as eeepc for a practical reason. Then build.
    $ make usb_img TARGET_PRODUCT=eeepc
    After the build is completed, the directly android-x86-1.6r2/out/target/product/eeepc/usb_boot has
    been created, and in this directory, a holder android-system exists. If a kernel and three image files,
    such as, initrd.img, install.img, kernel, ramdisk.img, and system.img are in the android-system
    holder, it indicates that the build process has been successful.
    $ cd ~/android-x86-1.6r2/out/target/product/eeepc/usb_boot
    $ ls android-system
    initrd.img  install.img  kernel  ramdisk.img  system.img

Boot from USB derive

Format a USB device (2GB) in ext3. Then, copy android-system into the USB device. At this moment,
this device can be bootable as vfat is used. However, this section describes the case that the devoice
is mounted at /media/disk/.

$ sudo cp -fr android-system /media/disk/
  • Install grub Caution: Pay attention to the directory below /dev of USB device.
    $ sudo grub-install --root-directory=/media/disk --no-floppy /dev/sdb
  • Configure grub Edit menu.lst of grub
    $ sudo vi /media/disk/boot/grub 
    $ sudo vi menu.lst
    The contents of menue.lst in the bootable USB drive are almost identical to the contents of memu.lst,
    which is located at /android-x86-1.6r2/out/target/product/eeepc/usb_boot. Since the chipset of the
    targeted single board computer is US15W, the board is booted in VESA mode.
    root (hd0,0)
    title Live USB - VESA Mode
            kernel /android-system/kernel root=/dev/ram0 androidboot_hardware=eeepc acpi_sleep=s3_bios,s3_mode quiet vga=788 SRC=/android-system
            initrd /android-system/initrd.img
    title Live USB - Debug Mode
            kernel /android-system/kernel root=/dev/ram0 androidboot_hardware=eeepc acpi_sleep=s3_bios,s3_mode vga=788 SRC=/android-system DEBUG=1
            initrd /android-system/initrd.img

This is the end of creation of bootable USB drive. To boot the single board computer, insert the bootable
USB drive. After turning power on, check the boot order by BIOS, then select VESA mode in the menu
of grub. Android starts booting. (Once Android is in suspend mode, it cannot be released.)

AOSP for x86 (Installing android-2.6.29 kernel)

This explains how to build the kernel of Android Open Source Project (AOSP) for x86.
To follow the standard building procedure, two errors occur and interrupt the building
process. This identifies the causes of the errors and shows how to fix these errors.

Get kernel

To prepare for building the kernel for x86, obtain the 2.6.29 kernel from the repository.

$ mkdir kernel
$ cd kernel
$ git clone git:// android_kernel
$ cd android_kernel

The first two commands create an empty directory which is called kernel and move into
the directory, respectively. The third command makes the android_kernel folder under
the kernel directly, and the original repository is copied into the android_kernel directory.
Then, move into this directory.

$ git checkout --track -b android-2.6.29 origin/android-2.6.29

The command above creates a new branch for android-2.6.29 and switches to it in one command line.
The preparation is completed.


This section explains how to build the android-2.6.29 kernel for x86 as well as how to fix
errors which occur during its building process. To build android-2.6.29 for x86, there are two known
errors in two files. Overall three parts of the two files are needed to be fixed.

At the beginning, the kernel modules are needed to be configured. By the first two commands,
move down to the android_kernel directory in which the android-2.6.29 kernel is located.
The third command copies the configuration file, .config, from arch/x86/configs/i386_defconfig.

$ cd ~/
$ cd kernel/android_kernel
$ cp arch/x86/configs/i386_defconfig .config
$ make menuconfig

The fourth command displays a curses-based terminal configuration menu and helps the configuration of
the kernel modules. The modules are need to be selected and deselected. For the minimum requirements,
the configurations of the modules are listed below.

Enable the Anonymous Shared Memory Subsystemx
Wake lockx
Android pmem allocatorx
Android alarm driverx
Android Driversx
Android Binder IPC Driverx
Android log driverx
Android RAM buffer consolex
Android Low Memory Killerx


After start building the kernel, the first error is detected in cpuset.c.

kernel/cpuset.c: In function ‘cpuset_can_attach’:
kernel/cpuset.c:1360: error: ‘task’ undeclared (first use in this function)
kernel/cpuset.c:1360: error: (Each undeclared identifier is reported only once
kernel/cpuset.c:1360: error: for each function it appears in.)

This error is caused by a simple typo. At the line of 1354 in cpuset.c, task is supposed to be tsk.

static int cpuset_can_attach(struct cgroup_subsys *ss,
                             struct cgroup *cont, struct task_struct *tsk)
        struct cpuset *cs = cgroup_cs(cont);
        int ret = 0;
+ // change task->tsk
+ //      if ((current != task) && (!capable(CAP_SYS_ADMIN))) {
+       if ((current != tsk) && (!capable(CAP_SYS_ADMIN))) {
               const struct cred *cred = current_cred(), *tcred;

                if (cred->euid != tcred->uid && cred->euid != tcred->suid)
                        return -EPERM;

        if (cpumask_empty(cs->cpus_allowed) || nodes_empty(cs->mems_allowed))
                return -ENOSPC; 
        if (tsk->flags & PF_THREAD_BOUND) {

After task is changed to tsk, making process should be continued.


The second error occurs in the alarm.c file. The error message suggests that time.h cannot be found
under the asm directly.

  CC      drivers/rtc/alarm.o
drivers/rtc/alarm.c:16:27: error: asm/mach/time.h: No such file or directory
drivers/rtc/alarm.c: In function ‘alarm_suspend’:

First, examine contents of the asm directly.

$ ls include/asm

time.h is not detected. Only asm-offsets.h is recognized under the directly. This means that
the missing directly or file causes this error.

To fix this error, #include <asm/mach/time.h> is needed to be defined appropriately.
This preprocessor command is treated as a part of a set of conditional compilation.
Three preprocessor commands are added around the line 12 of #include <asm/mach/time.h>.
The changes are shown below.

 * GNU General Public License for more details.
+ #ifdef __i386__
+ #else
#include <asm/mach/time.h>
+ #endif

#include <linux/android_alarm.h>
#include <linux/device.h>

To respond to the changes described above, a set of conditional compilation and a function are
needed to be added. This set of conditional compilation is coordinated with the previously added
conditional compilation above and contains the newly added function. The newly added function is
ported from arch/arm/kernel/time.c.

The conditional compilations and ported function are inserted after alarm_triggered_function, which
ends at the line 325. The details are shown below.

static void alarm_triggered_func(void *p)
        struct rtc_device *rtc = alarm_rtc_dev;
        if (!(rtc->irq_data & RTC_AF))
         ANDROID_ALARM_DPRINTF(ANDROID_ALARM_PRINT_INT, "rtcalarm triggered\n");
         wake_lock_timeout(&alarm_rtc_wake_lock, 1 * HZ);
+ #ifdef __i386__
+ // Port this function from arch/arm/kernel/time.c
+ /**
+ * save_time_delta - Save the offset between system time and RTC time
+ * @delta: pointer to timespec to store delta
+ * @rtc: pointer to timespec for current RTC time
+ *
+ * Return a delta between the system time and the RTC time, such
+ * that system time can be restored later with restore_time_delta()
+ */
+ static void save_time_delta(struct timespec *delta, struct timespec *rtc)
+ {
+         set_normalized_timespec(delta,
+         xtime.tv_sec - rtc->tv_sec,
+         xtime.tv_nsec - rtc->tv_nsec);
+ }
+ #endif
int alarm_suspend(struct platform_device *pdev, pm_message_t state)
       int                 err = 0;

The two errors are fixed. The building process of the android-2.6.29 kernel should be completed.


Front page   Edit Freeze Diff Backup Upload Copy Rename Reload   New List of pages Search Recent changes   RSS of recent changes
Last-modified: 2010-08-17 (Tue) 13:37:19 (1339d)