Building Android Kernel & Modules with Automated Environment Setup

24 10938
Edited by mattrix at Mon Nov 10, 2014 23:06

This should work on Windows / MAC OS X / Linux

Download and install latest Vagrant from HERE
Download and install latest VirtualBox from HERE
Download my Vagrant files from HERE

Unzip and you will now have a "AndroidBuilder" folder with 2 files in it.

Open a command prompt / terminal and move into the "AndroidBuilder" folder and run the following commands

  1. vagrant plugin install vagrant-vbguest
  2. vagrant up
Copy the Code
The vagrant up command will download the correct VM image, start it up, setup the environment and do an inital build of the firmware.
There is no user input required during this process, so feel free to leave it running.
It shouldn't take more than an hour (depending on your internet speed of course)

You will find the new kernel files in the AndroidBuilder/OUTPUT folder.

Now you are ready to start modifying the kernel!
All future builds & vagrant up's will be a lot quicker than the first!

Once the initial build is done, you need to SSH into the Virtual Machine.
I use PUTTY on Windows.

  1. Host:
  2. Port: 2222
  3. User: root
  4. Password: root
Copy the Code
On your first login, it will bring you straight into the Android Config Menu where you can configure the kernel.
It uses a fully featured base config (from Banana Pi's normal Android builds) to get you started
Below are the basic commands. Run them all within the /BUILD directory (You are moved into this directory when you login via SSH.)


  1. ./config
Copy the Code
## DO BUILD ##

  1. ./build
Copy the Code

  1. ./update
Copy the Code
Once it's built, you will find the new kernel and modules under the "AndroidBuilder/OUTPUT" folder (The build script copies them out of the VM into your computer)

De-compile an Android image with Dragonface and copy
AndroidBuilder/OUTPUT/vmlinux file to DragonFace/CPFOP/bootfs/vmlinux  (OVERWRITE)
AndroidBuilder/OUTPUT/modules/* to DragonFace/fsop/system/vendor/modules/*  (OVERWRITE - Don't delete other files)

Build image and burn as usual with Phoenix Card.

Current known issues:
- None

Past issues:
- No ethernet (FIXED)

Huge thanks to zrox for all the information!
Give him some love!

I am now hosting a Git Repository of this code.
This allows for us to add new drivers and make fixes etc:

If you want to contribute / add new drivers -> simply make a pull request.

This is not the official Lemaker Android source code, which means you should have no expectations of it working 100%.
They haven't released their source code for their Android builds and this is just the outcome of us end users "making do".
For those who like me use HyperV on the Windows machine, you have to switch it off so that VT-x is available for VirtualBox.

To do that, run the command with admin privilege:
  1. bcdedit /set hypervisorlaunchtype off
Copy the Code
and reboot.
To reactivate Hyper-V support, run the command with admin privilege:

  1. bcdedit /set hypervisorlaunchtype on
Copy the Code
and reboot.

Edited by ChrisP at Sat Nov 8, 2014 12:37

Hi Mattrix, could it be that a step is missing ? I striclty followed the steps, but once doing the make menuconfig, I have the following errors:

  1. root@builder:/BUILD/linux-3.4# make menuconfig arch=arm
  2.   HOSTCC  scripts/basic/fixdep
  3.   HOSTCC  scripts/kconfig/conf.o
  4.   HOSTCC  scripts/kconfig/lxdialog/checklist.o
  5.   HOSTCC  scripts/kconfig/lxdialog/inputbox.o
  6.   HOSTCC  scripts/kconfig/lxdialog/menubox.o
  7.   HOSTCC  scripts/kconfig/lxdialog/textbox.o
  8.   HOSTCC  scripts/kconfig/lxdialog/util.o
  9.   HOSTCC  scripts/kconfig/lxdialog/yesno.o
  10.   HOSTCC  scripts/kconfig/mconf.o
  11.   SHIPPED scripts/kconfig/
  12.   SHIPPED scripts/kconfig/zconf.lex.c
  13.   SHIPPED scripts/kconfig/zconf.hash.c
  14.   HOSTCC  scripts/kconfig/
  15.   HOSTLD  scripts/kconfig/mconf
  16. scripts/kconfig/mconf.o: In function `show_help':
  17. mconf.c:(.text+0x744): undefined reference to `stdscr'
  18. scripts/kconfig/mconf.o: In function `main':
  19. mconf.c:(.text.startup+0x6c): undefined reference to `initscr'

  20. ...
  21. [lots of undefined references]
  22. ...

  23. scripts/kconfig/lxdialog/menubox.o: In function `print_buttons':
  24. menubox.c:(.text+0x4b1): undefined reference to `wrefresh'
  25. collect2: ld returned 1 exit status
  26. make[1]: *** [scripts/kconfig/mconf] Error 1
  27. make: *** [menuconfig] Error 2
  28. root@builder:/BUILD/linux-3.4#
Copy the Code
the vagrant folder seems to be fine on the VM:
  1. root@builder:/BUILD/linux-3.4# ll /vagrant
  2. total 1073486
  3. drwxrwxrwx  1 vagrant vagrant       4096 Nov  8 11:21 ./
  4. drwxr-xr-x 25 root    root          4096 Nov  8 11:27 ../
  5. -rwxrwxrwx  1 vagrant vagrant        202 Nov  8 03:12*
  6. -rwxrwxrwx  1 vagrant vagrant      74566 Nov  7 23:15 .config*
  7. -rwxrwxrwx  1 vagrant vagrant        957 Nov  8 03:22*
  8. drwxrwxrwx  1 vagrant vagrant          0 Nov  8 11:21 OUTPUT/
  9. -rwxrwxrwx  1 vagrant vagrant 1099164022 Nov  7 22:24 v2.0_A20-Kernel-only.tar.bz2*
  10. drwxrwxrwx  1 vagrant vagrant          0 Nov  8 09:29 .vagrant/
  11. -rwxrwxrwx  1 vagrant vagrant        341 Nov  8 01:54 Vagrantfile*
Copy the Code

Edited by mattrix at Sat Nov 8, 2014 05:56

Yes. I hadn't actually tried the menu config.

I'm cleaning it up a lot now, and it should become a lot smaller and only the bits we need.
I also will create a GIT repository so we can all contribute to a nice Android kernel

for now, run these commands to get it working
  1. cd /BUILD/linux-3.4
  2. ARCH=arm make clean
  3. cp /vagrant/.config /BUILD/linux-3.4/.config
  4. ARCH=arm make oldconfig

  5. ARCH=arm make menuconfig

  6. cd /BUILD/
  7. ./
Copy the Code

Edited by mattrix at Sat Nov 8, 2014 09:18

Just did a big update! (first post has been updated)

First, have got the Android code down from that 1GB file into a nice 100MB Git Repo.

The Vagrant script has been update to pull the source from this git repo.
Also added a "update" utility script so can easily update the source.

Should hopefully have the Ethernet fixed tomorrow.

Edited by ChrisP at Sun Nov 9, 2014 00:08

it works ! (but the initial build is not done on the initial vagrant up command. Not an real issue anyway, the build command are just fine).

I even made my K400 recognized now, but only the touchpas is working. A lots of progress , thanks guys

And Virtual boxing is offering a better way than HyperV to virtualize Seven for DragonFace and now for Phoenix card, thanks to USB passthrough.

To make Phoenixcard to works, on a clean Seven 32bits VM, this is what I had to do:
I can now access my sdcard reader directly from my Seven VM. But to make it work, it's a bit painfull, you have to install VirtualBox 4.2.16 first, Copy and rename the driver subfolder from ProgramFiles\Oracle\VirtualBox, uninstall VirtualBox, reinstall the last version 4.3.18, then force the 4.2.16 USB filter driver. This way , the USB bug is workarounded and working fine. Thanks to this, I am now finally able to burn SD without error anytime !! Damned win 8.1 !!

And for DragonFace:
And to get rid of the DragonFace side by side error while saving, at 30%, install the Visual C++ 2008 Runtime (x86).

Edited by mattrix at Sun Nov 9, 2014 03:12

Just got Ethernet working. Mission!
Will be updating git repo soon with changes.

It's now got the latest GMAC driver from the Sunxi GIT.
Also, it now shows MAC address!! (YAH!)

Hi matrix,
I need driver for my k230 keyboard and m210 mouse. All connected on my USB dongle unifying. (Work on lubuntu)
Thanks a lot

Edited by ChrisP at Sun Nov 9, 2014 20:55

Mmmmh, just tried after a ./ then ./ but ethernet card is still show as disconnected. [Edit: my bad, wrong cable, it's working fine)

And if I tried to do a ./ just after a ./, the following build is giving errors and failing :/ If I do in order clean/build/config/build, it's working without errors.

Regarding the unifying receiver driver, it's working if you config it in the kernel, but still don't get how to make the keyboard work, only the touchpad of k400 for now.

"And if I tried to do a ./ just after a ./, the following build is giving errors and failing :/ If I do in order clean/build/config/build, it's working without errors."

Can you post the errors?
You shouldn't actually need to clean (I personally never use it)
Without the clean - it will compile a lot quicker subsequent times (only compiles changes)

You have to log in before you can reply Login | Sign Up

Points Rules