Compiling a Kernel

From iDroidWiki

Revision as of 16:12, 17 October 2021 by Zaxtron (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Open-Source Licenses

The iDroid Project is an Open-Source Project. The kernel is licensed under GPLv2. As such, changes to the source code must be made public.

If you plan to compile the kernel with your own changes to the source code, please make your changes public. What you have changed may be helpful for the iDroid Project and for helping in troubleshooting.

If you don't have a git repo to put you changes, that's ok. You can always create a pastie of the diffs you've created, especially if only 1 line was changed.

Warning

Requirements

  1. Linux
  2. Android NDK R4 for Linux. You can download it here only if did not build android yourself. If you have followed the Compiling Android guide to build android, then the NDK is already in your PC and there is no need to download this.

Getting Started

  1. After you download the Android NDK R4, extract it to your home folder. It should look like /home/ubuntu/android-ndk-r4
 sudo apt-get install git-core
git clone url

Official:

git clone http://github.com/iDroid-Project/kernel_common.git

Compiling the kernel

Setting CROSS-COMPILE

  1. First of all, go into kernel_common and look for Makefile. Open it with gedit
  2. Look for CROSS_COMPILE ?=/path to somewhere, this is usually somewhere near line 185.
  3. The value after CROSS_COMPILE ?= is usually the path to arm-eabi- in the Android NDK folder. If you extracted the Android NDK R4 to your home folder, this line should be set to something like this:
CROSS_COMPILE	?= /home/username/android-ndk-r4/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/arm-eabi-

If you have compiled Android using the Compiling Android guide then the path is:

CROSS_COMPILE	?= /home/username/froyo/prebuilt/linux-x86/arm-eabi-4.4.0/bin/arm-eabi-

Configuring the Kernel

  1. Open Terminal (Applications > Accessories > Terminal):
cd kernel_common
sudo make menuconfig
sudo apt-get install libncurses5-dev
sudo make menuconfig

Making the Kernel

  1. Still in Terminal (and in kernel_common directory):
sudo make

What to do with zImage

  1. The zImage file is the kernel and should be found in /home/ubuntu/kernel_common/arch/arm/boot.
  2. In iPhone OS, SSH, FTP, upload the zImage to your iDevice's /private/var directory, replacing the previous zImage (Back-it up first before replacing).
  3. Boot into Android/iDroid and see if your newly compiled kernel works.

Errors

... 
CC kernel/cpuset.o
kernel/cpuset.c: In function 'cpuset_can_attach':
kernel/cpuset.c:1333: error: 'task' undeclared (first use in this function)
kernel/cpuset.c:1333: error: (Each undeclared identifier is reported only once
kernel/cpuset.c:1333: error: for each function it appears in.)
make[1]: *** [kernel/cpuset.o] Error 1
make: *** [kernel] Error 2

Turns out this is a typo in the kernel/cpuset.c file, find the word "task" in the file, and make it "tsk", so line 1333 of cpuset.c will now look like

if ((current != tsk) && (!capable(CAP_SYS_ADMIN))) {

instead of

if ((current != task) && (!capable(CAP_SYS_ADMIN))) {

However disable cpuset will be better.

..
CC [M]  fs/coda/psdev.o
In file included from fs/coda/psdev.c:44:
include/linux/coda.h:247: error: expected specifier-qualifier-list before 'u_quad_t'

It seems that it is because of that the arm-embi-gcc in Android is using "Thread model: single"

This solution may help : http://blog.csdn.net/stevenliyong/archive/2009/10/11/4654990.aspx

...
drivers/video/console/vgacon.c:508: error

Suggested solution: Disable VGA Console in configmenu

In file included from arch/arm/mach-apple_iphone/iphone.c:50:
arch/arm/mach-apple_iphone/include/mach/system.h: In function 'arch_idle':
arch/arm/mach-apple_iphone/include/mach/system.h:33: error: implicit declaration of function 'cpu_do_idle'
make[1]: *** [arch/arm/mach-apple_iphone/iphone.o] Error 1
make: *** [arch/arm/mach-apple_iphone] Error 2

Edit the file:

arch/arm/mach-apple_iphone/iphone.c

and add:

#include <asm/cpu-single.h>

after line 50, right after #include <asm/system.h>:

#include <asm/system.h>
#include <asm/cpu-single.h>
#include <mach/system.h>

Credits

Personal tools
Namespaces
Variants
Actions
Wiki
Community
Toolbox