0% found this document useful (0 votes)
96 views5 pages

Blog Android x86 Build

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 5

Android-x86 OS build

With kernel customization

Here in this post we will be building Android x86 OS image with kernel customization
for specific purpose I needed to add network driver supports to the kernel so i am going to show how i did that .
If you need to build an image with kernel customization you can follow my approach

>> host machine info


ayx@ayx-ThinkPad:~$ uname -a
Linux ayx-ThinkPad 5.0.0-29-generic #31~18.04.1-Ubuntu SMP Thu Sep 12 18:29:21 UTC 2019 x86_64 x86_64
x86_64 GNU/Linux

>> install dependencies


ayx@ayx-ThinkPad:~$ sudo apt -y install git gcc curl make repo libxml2-utils flex m4
ayx@ayx-ThinkPad:~$ sudo apt -y install openjdk-8-jdk lib32stdc++6 libelf-dev
ayx@ayx-ThinkPad:~$ sudo apt -y install libssl-dev python-mako syslinux-utils
ayx@ayx-ThinkPad:~/android-src/android-x86$ sudo apt-get install ncurses-devel libncurses-dev

>> Download Source


ayx@ayx-ThinkPad:~/android-src/android-x86$ repo init -u http://scm.osdn.net/gitroot/android-x86/manifest -b pie-x86
ayx@ayx-ThinkPad:~/android-src/android-x86$ repo sync -j8

This will download all the source

>> environment setup


ayx@ayx-ThinkPad:~/android-src/android-x86$ make clean
ayx@ayx-ThinkPad:~/android-src/android-x86$ . build/envsetup.sh
ayx@ayx-ThinkPad:~/android-src/android-x86$ lunch

Choose : “android_x86_64-userdebug”

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=9
TARGET_PRODUCT=android_x86_64
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_ARCH=x86_64
TARGET_ARCH_VARIANT=x86_64
TARGET_2ND_ARCH=x86
TARGET_2ND_ARCH_VARIANT=x86_64
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.0.0-29-generic-x86_64-Ubuntu-18.04.3-LTS
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=PI
OUT_DIR=out
============================================

>> Obtaining Network card info


ayx@ayx-ThinkPad:~/android-src/android-x86$ lspci | awk '/[Nn]et/ {print $1}' | xargs -i% lspci -ks %
03:00.0 Network controller: Intel Corporation Centrino Wireless-N 2230 (rev c4)
Subsystem: Intel Corporation Centrino Wireless-N 2230 BGN
Kernel driver in use: iwlwifi
Kernel modules: iwlwifi
0c:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet
Controller (rev 07)
Subsystem: Lenovo RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
Kernel driver in use: r8169
Kernel modules: r8169

Take note of the network card’s kernel module names

>> Customization of the Kernel


ayx@ayx-ThinkPad:~/android-src/android-x86$ make -C kernel O=$OUT/obj/kernel ARCH=x86 menuconfig
Now the standard Linux kernel customization graphical interface in terminal will show up
[make sure your terminal is wide and long enough ]

Note: The configuration file is the default .config

Browse to >Device Drivers > Network device support


│ <*> Virtio network driver

Browse to >Device Drivers > Network Device Support > Ethernet Driver Support
│ <*> Realtek 8169 gigabit ethernet support

In a similar way you can change the kernel as you want

>> Now copy this config file to build systems’ actual config files’ location
ayx@ayx-ThinkPad:~/android-src/android-x86$ cp out/target/product/x86_64/obj/kernel/.config
kernel/arch/x86/configs/

>> Now rename the .config file


ayx@ayx-ThinkPad:~/android-src/android-x86/kernel/arch/x86/configs$ mv .config my_x86_64_conf_20190923

>> Now build the kernel only


ayx@ayx-ThinkPad:~/android-src/android-x86$ nproc
8
ayx@ayx-ThinkPad:~/android-src/android-x86$ make -j8 kernel

The build took around 25 minutes

The built kernel is at out/target/product/x86_64/


The kernel modules are at out/target/product/x86_64/system/lib/modules/

>> Now we will build the final image with the kernel we just built

ayx@ayx-ThinkPad:~/android-src/android-x86$ make iso_img -j8 TARGET_PRODUCT=android_x86_64


TARGET_PREBUILT_KERNEL=~/android-src/android-x86/out/target/product/x86_64/kernel

Total translation table size: 23151


Total rockridge attributes bytes: 10128
Total directory bytes: 24576
Path table size(bytes): 130
Done with: The File(s) Block(s) 342143
Writing: Ending Padblock Start Block 342197
Done with: Ending Padblock Block(s) 150
Max brk space used 23000
342347 extents written (668 MB)

out/target/product/x86_64/android_x86_64.iso is built successfully.

#### build completed successfully (08:51:29 (hh:mm:ss)) ####

>> Android-x86 installation on VM

Open Virtual Box >> Create new machine , choose linux type , create a virtual disk
From Settings -> storage -> Select the ISO you built

Now boot the machine , select installation of hard disk , Use GPT to write partition table
Create a partition out of the free space of the VDI , format by EXT4 , then GRUB will be asked but GRUB won’t work
on a GPT partitioned so MBR will be used

Enable 3D and 2D acceleration , after installation completed remove iso attachment , these are shown in the pictures
below

You might also like