Guide: create a custom configuration and compile an Android-x86 kernel

6,514 views
Skip to first unread message

Paul Lutus

unread,
Mar 27, 2014, 2:49:41 PM3/27/14
to andro...@googlegroups.com
A number of posts have reported failure or difficulties in recompiling a kernel with a modified configuration, and the available documentation is pretty terrible. So here's a basic guide to editing the default configuration and recompiling. Some of the instructions assume a Ubuntu/Kubuntu environment.

I came to this because I couldn't get Android-x86 to boot on a desktop machine with the available kernel as configured. I knew I had to add some SATA drivers to the existing configuration. I tried reading http://www.android-x86.org/documents/customizekernel, unfortunately it couldn't be more confusingly written if someone had set out to be as confusing as possible to win a contest.

So, with the aim of allowing custom kernel configurations, here are the clearest instructions I can manage:

1. Acquire the Android-x86 source here: http://www.android-x86.org/getsourcecode . BTW it is huge, 12.8 gigabytes at the time of writing.

2. Put the source in a directory, let's call it "source", that is a subdirectory of a work directory, call that "work". So we have /work/source (use your own preferred names).

3. Create directory /work/config that will be used to contain the custom configuration, which must be segregated from the build tree and which you will want to retain if it's successful.

4. Now make a copy of the default Android-x86 configuration into your custom configuration directory:

    FROM: /work/source/kernel/arch/x86/configs/android-x86_defconfig
    TO: /work/config/.config
    
5. Remember this is a Ubuntu/Kubuntu example. To perform the configuration below in the least painful way, you will probably need to install some extra libraries/applications:

    python-lunch
    libqt4-core
    libqt4-gui
    qt4-default
    gcc-multilib
    distcc
    ccache
    
6. These libraries are easily gotten:

    # apt-get -y install python-lunch libqt4-core libqt4-gui qt4-default gcc-multilib distcc ccache
    
7. If you want the compilation to finish in any finite amount of time, set up distcc on every computer you can get your hands on and get networked -- separate topic, not covered here.

8. Now for the important part -- remember that we want to configure and compile a custom kernel, not a complete Android system, but we need the complete Android environment for this to be possible.

9. Enter the /work/source directory and issue these commands:

    . build/envsetup.sh
    export ARCH=x86
    lunch android_x86-eng
    make -C kernel O=/work/config/.config xconfig
    
10. The final command in the above list will launch a graphical configuration dialog that will look more or less like this: https://i.imgur.com/8ROkrEy.png .

11. Make any changes you require, remembering there are some settings essential to using the kernel with Android. In my case, I needed to add some statically linked SATA drivers to support a desktop environment.

12. Save your changes and close the dialog.

13. Now to actually compile the modified kernel:

    export ARCH=x86
    export TARGET_PRODUCT=android_x86
    export TARGET_KERNEL_CONFIG=/work/config/.config
    make clean (optional, first time)
    make kernel -j16 CC="distcc gcc" CXX="distcc g++"  (if using distcc on a populated network)
    make kernel -j4 (if not using distcc, very slow)

14. Now copy the compiled kernel, which of course will have compiled without error and in a finite amount of time:

    FROM: /work/source/out/target/product/x86/kernel
    TO: any chosen destination.
    
15. To deal with the issue of a system that the default Android-x86 installation code can't understand or install to:

    a. Install Android-x86 on any convenient device that the installer does recognize, like a USB stick.
    b. Create a suitable partition on the target drive.
    c. Copy the working installation from the source USB stick into the newly created partition.
    d. Overwrite the default kernel (located by default at (device)/android-4.4-RC1/kernel) with the modified kernel compiled above.
    
16. To get grub2 to recognize and list the new partition in its menus, create a configuration file named 45_android, containing:

    #!/bin/sh
    echo "$0: Android-4.4-RC1 (on /dev/sda4)" >&2 
    exec tail -n +4 $0

    menuentry "Android android-4.4-RC1 Normal (on /dev/sda4)" {
            set root=(hd0,4)
            linux /android-4.4-RC1/kernel root=/dev/ram0 androidboot.hardware=android_x86 acpi_sleep=s3_bios,s3_mode SRC=/android-4.4-RC1 DPI=160 UVESA_MODE=1280x1024
            initrd /android-4.4-RC1/initrd.img
    }
    
    menuentry "Android android-4.4-RC1 Debug (on /dev/sda4)" {
            set root=(hd0,4)
            linux /android-4.4-RC1/kernel pnp.debug=1 root=/dev/ram0 androidboot.hardware=android_x86 acpi_sleep=s3_bios,s3_mode SRC=/android-4.4-RC1 DEBUG=1 DPI=160 UVESA_MODE=1280x1024
            initrd /android-4.4-RC1/initrd.img
    }

17. Change the above references to "/dev/sda4" and "hd0,4" to the actual target partition on your system, examples: /dev/sda1 = hd0,1 , /dev/sdb3 = hd1,3
    
18. Change the above resolution (1280x1024) to your desired resolution. I have one laptop that supports Android-x86 at 1920x1080.

19. Copy the file 45_android into /etc/grub.d and make it executable.

20. Then, as root: update-grub

At this point you should be able to reboot into the modified Android-x86 on a desktop or laptop.

I hope this clears up the confusion surrounding the issue of custom kernel configurations.

midi jari

unread,
Mar 28, 2014, 7:24:16 PM3/28/14
to andro...@googlegroups.com
Thank you for the Guide, but I have some issues that I couldn't fix even w/ recompiling kernel from scratch : I can't connect to WiFi (even though it shouws me the hotspots and everything) and stuck in "Obtaining IP adresss" for ever! I have an UEFI system and GRUB 2, I recompiled it for the <efivar> problem (that seems to be corrected when removing the necessary files from the source https://groups.google.com/forum/#!topic/android-x86/GrPdnpa6XBM <-- See here on the latest posts) but WiFi does work if I boot a USB key from LegacyMode Instead of UEFI. What could that be?

(Can you send me the kernel you built? I want to test every single one available :) ) 

Paul Lutus

unread,
Mar 29, 2014, 6:21:14 PM3/29/14
to andro...@googlegroups.com
> I can't connect to WiFi (even though it shouws me the hotspots and everything) and stuck in "Obtaining IP adresss" for ever! 

Well, if the local hotspots are listed but you're never assigned an address, this might be a DHCP failure, or possibly a conflict between the kernel's WiFi device driver and the actual hardware device in the machine. Check to make sure that other local devices are assigned an address, and that you're using the right password. Also check to see if the kernel WiFi driver is really meant for the WiFi hardware on the host machine.

Another thing to check is to run the default OS for that machine, see if you get hooked up, and find out which driver is being used. Then make sure the same driver is made available to Android.

Another tactic is to run WireShark on a local machine and monitor the traffic going between the Android machine and the WiFi router.

> (Can you send me the kernel you built? I want to test every single one available :) ) 

I think it would be more efficient if I send you the configuration I'm using -- it weighs much less. :) It's attached. I have made very few changes over the default configuration, only enough to make the kernel work in a desktop machine with modern SATA drives.

Just position the attached configuration as explained in my first post, and run the configuration dialog to see what's up.

> WiFi does work if I boot a USB key from LegacyMode Instead of UEFI. 

I assume you mean the USB device is running the default Android-x86 configuration, yes? If that's true, maybe check to see what changes you've made and whether they might be interfering with the WiFi driver.

.config

Andrews Magnoni

unread,
Mar 30, 2014, 2:16:33 AM3/30/14
to andro...@googlegroups.com
did you try to compile these experimental kernel:

im getting errors.

Paul Lutus

unread,
Mar 30, 2014, 2:17:26 AM3/30/14
to andro...@googlegroups.com
Dear group: I have turned my prior post into an article with more detail and graphics: http://arachnoid.com/android/Android-x86

I hope it helps people create their own kernels.

Vaidotas

unread,
Apr 5, 2014, 5:08:11 PM4/5/14
to andro...@googlegroups.com
Thanks for detailed description. But what should I do if I want to compile a more recent kernel for Android-x86, like the one mentioned above, 3.14-experimental? I wasn't able to compile it due to errors. Is it possible to create a new device configuration with different kernel version?

Joan R. Serra

unread,
Apr 6, 2014, 3:55:40 AM4/6/14
to andro...@googlegroups.com
Thanks for the article Paul !!

Andy Percept

unread,
Apr 7, 2014, 2:10:55 AM4/7/14
to andro...@googlegroups.com
Paul can you guide me for the issues i am facing in building the kernel

Query Link :https://groups.google.com/d/msg/android-x86/Sv56Bu9WJu8/6f-l9YWj-DQJ

Andy Percept

unread,
Apr 11, 2014, 1:43:49 AM4/11/14
to andro...@googlegroups.com

Hi Paul,

I am tring to compile the source but i am getting following error

Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/lunch/runner.py", line 103, in run
    lunch_master = master.run_master(config_file, log_to_file=file_logging_enabled, log_dir=logging_dir, log_level=log_level)
  File "/usr/lib/pymodules/python2.7/lunch/master.py", line 730, in run_master
    execute_config_file(lunch_master, config_file, chmod_config_file=chmod_config_file)
  File "/usr/lib/pymodules/python2.7/lunch/master.py", line 689, in execute_config_file
    execfile(config_file) # config is plain python using the globals defined here. (the add_process function)
  File "./config/.config/android-x86_defconfig", line 6, in <module>
    CONFIG_X86_32=y
NameError: name 'y' is not defined


if i change the kernel =y to ='y' error is solved but
my terminal does not proceed forward it gets stuck in

root@ubuntu-desktop:/home/ubuntu/android/androidjb# lunch ./config/.config/andid-x86_defconfig

-- At this stage no error is fired, i kept if for more than 8 hours as it is...

Thanks & Regards
Arun

michael colvin

unread,
Apr 11, 2014, 3:42:09 PM4/11/14
to andro...@googlegroups.com
Thanks for the guide. I just had just posted looking for that.

michael colvin

unread,
Apr 14, 2014, 4:05:32 PM4/14/14
to andro...@googlegroups.com
Thanks for the info.
Got it to build and now it works on my target machine.
Just had a question though. On the line "make -C kernel O=/work/config/.config xconfig" I had to leave off the ".config". to make a new one. 
Also when I set the "export TARGET_KERNEL_CONFIG=/work/config/.config" it ended up looking for the kernel in "/home/michael/work/android-x86/kernel/arch/x86/configs/work/config/.config". So I just renamed the .config to mikeconfig and added it to configs directory.
Did I do something wrong so that it appended the directory instead of being a absolute path?

On Thursday, March 27, 2014 12:49:41 PM UTC-6, Paul Lutus wrote:

Mauro Rossi

unread,
May 3, 2014, 5:49:11 AM5/3/14
to andro...@googlegroups.com
Hi Paul,

could you be so kind to provide the kernel you compiled?
I would like to try installing Android-x86 on a SATA HDD

Thanks

Mauro

zoe vas

unread,
May 6, 2014, 7:57:59 AM5/6/14
to andro...@googlegroups.com
Hello,

I made an hierarchy of files as you mentioned  .
I do 

$ . build/envsetup.sh
$ export ARCH=x86
$ lunch android_x86-eng
$ make -C kernel O=/home/zoi/work/config/.config xconfig 

But i get the following error Makefile:121: *** output directory "/home/zoi/android-x86/config/.config" does not exist. 
I checked the path many times and it is right.
Do you have any tip?

Thanks in advance,
Zoi Vasiliou

Mauro Rossi

unread,
May 16, 2014, 7:45:03 AM5/16/14
to andro...@googlegroups.com
Hi, I have the same problem in Ubuntu 14.04; is the commando syntax correct or there is some space needed somewhere?
Message has been deleted
Message has been deleted
Message has been deleted

Mauro Rossi

unread,
Jul 20, 2014, 9:13:28 AM7/20/14
to andro...@googlegroups.com
Hi,

for people who may be interested,

the easiest way to modify kernel config after a stock kernel build is to follow CHih-Wei instructions "custom kernel" and using xconfig as per Paul  suggestion.

When you'll have built the stock 3.10.40 kernel, you'll have .config file in $OUT/obj/kernel folder, you can launch:

. build/envsetup.sh
export ARCH=x86
lunch android_x86-eng
make -C kernel O=$OUT/obj/kernel ARCH=x86 xconfig

[i.e. there is no need to specify the .config file, it is the default filename for kernel config]

[now you can modify kernel config, for example I removed nvidia, riva, radeon frame buffer modules due to incompatibility with nouveau drm and radeon drm, then saved ]

cp $OUT/obj/kernel/.config [kitkat-x86]kernel/arch/x86/configs/my_defconfig


at this point, delete iso and kernel from $OUT directory and you can build by simply issuing this command:

make iso_img TARGET_PRODUCT=android_x86 TARGET_KERNEL_CONFIG=my_defconfig

Thanks to Chih-Wei and Paul

Mauro
Reply all
Reply to author
Forward
0 new messages