`
mmdev
  • 浏览: 12929975 次
  • 性别: Icon_minigender_1
  • 来自: 大连
文章分类
社区版块
存档分类
最新评论

Building Kernel from source

 
阅读更多


Contents

[hide]

Install CyanogenMod on the device

First, you will need to get a working install on the device: Installing CyanogenMod on the device.

Install development support packages

Install the following packages using your favorite package manager:

Debian based Linux distributions

32bit and 64bit systems:

git-core gnupg sun-java6-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev

64bit only:

ia32-libs lib32z1-dev lib32ncurses5-dev gcc-multilib g++-multilib

Red Hat based Linux distributions

32bit and 64bit systems:

git gnupg java-1.6.0-openjdk-devel flex bison gperf SDL-devel esound-devel wxGTK-devel zip curl ncurses-devel zlib-devel gcc-c++

64bit only:

glibc-devel.i686 libstdc++.i686 zlib-devel.i686 ncurses-devel.i686

Setup Repo

Make sure you have a ~/bin directory, and setup repo.

mkdir -p ~/bin
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
chmod a+x ~/bin/repo
echo $PATH|grep ~/bin>/dev/null||export PATH="${PATH}":~/bin

To validate the repo command is in your path, type 'which repo'.

To add ~/bin to your $PATH edit ~/.bashrc and add:

export PATH = ~/bin:$PATH

Download ROM Source Code

mkdir -p ~/android/system
cd ~/android/system
For CyanogenMod 7 (Gingerbread):
repo init -u git://github.com/CyanogenMod/android.git -b gingerbread
For CyanogenMod 9 (Ice Cream Sandwich):
repo init -u git://github.com/CyanogenMod/android.git -b ics
repo sync -j16
This may take 1.5 hours, more or less, depending on your connection.

Create an environment variable denoting the location of the android toolchain as follows:

export CCOMPILER=${HOME}/android/system/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-

Download ARM EABI Toolchain (Optional)

If you're just building the kernel and don't need the whole ROM source try using the Code Sourcery ARM EABI Toolchain.

Download and extract then, create an environment variable denoting the location of the toolchain as follows:

export CCOMPILER=[extraction directory]/bin/arm-eabi-

Download Kernel Source Code

mkdir -p ~/android/kernel
cd ~/android/kernel
git clone git://github.com/CyanogenMod/cm-kernel.git
cd cm-kernel

Configure the Build

Retrieve a working kernel config from the device, and unzip it:

adb pull /proc/config.gz ~/android/kernel/cm-kernel/config.gz
cat config.gz | gunzip > .config

Alternatively, you can pull the .config from the newest boot.img

scripts/extract-ikconfig boot.img > .config

Configure the build. Just enter to accept defaults, or customize as needed:

make ARCH=arm CROSS_COMPILE=$CCOMPILER oldconfig
make ARCH=arm CROSS_COMPILE=$CCOMPILER menuconfig

Make the build

make ARCH=arm CROSS_COMPILE=$CCOMPILER -j`grep 'processor' /proc/cpuinfo | wc -l`
This step may take a while, depending on your computer.

At this point you should have a kernel stored in ~/android/kernel/cm-kernel/arch/arm/boot/zImageand kernel modules, if any were built, in the module sub-directories.

Merge the build

You will need to merge this file with a working cyanogen ramdisk in order to create a boot image suitable for flashing. Follow these instructions here.

If all goes well, you should now be running your own custom CyanogenMod kernel on the device.

Note: If you are building for Nexus One, you should use --base 0x20000000 when running mkbootimg.

An alternate method is to use an existing kernel update zip for your device. Unzip the update, replace the kernel zImage and kernel modules with your new ones, rezip, and flash on your device.

Compiling wifi kernel module

After installing a custom kernel, the wifi module may be unstable or unusable. The solution is to recompile the module, linking it to the new kernel build.

cd ~/android/system/system/wlan/ti/sta_dk_4_0_4_32
KERNEL_DIR=~/android/kernel/cm-kernel CROSS_COMPILE=$CCOMPILER ARCH=arm make -j`grep 'processor' /proc/cpuinfo | wc -l`

A file named wlan.ko will be produced in the current directory. You must install the new module to the device.

adb shell mount -o remount,rw /system
adb shell cp /system/lib/modules/wlan.ko /system/lib/modules/wlan.ko.backup
adb push wlan.ko /system/lib/modules/wlan.ko

Reboot the device. If all goes well, you should be using the newly compiled 'wlan.ko'.

For devices which may be utilizing wifi module from vendors other than TI, you may choose other appropriate drivers.

Installing kernel modules for debian chroot installation

If you have a debian chroot install on the device, you will want to add to it the loadable modules that were built along with the kernel. This is necessary to use things like fuse, cifs, etc.

First tar up and transfer over the modules

cd ~/android/kernel
tar -czf modules.tgz `find . | grep ko$`
adb push modules.tgz /sdcard/

Then, Copy the modules to your debian install (Replace <debian_root> with the root of your debian installation)

adb shell
mkdir <debian_root>/lib/modules/`uname -r`
cd <debian_root/lib/modules/`uname -r`
tar -zxf /sdcard/modules.tgz

Last, Install the modules from debian (must be done as root). Log in to your debian installation using your method of choice, then:

depmod -a

If all goes well, depmod should produce no output. At this point you may load a kernel module from within debian by typing (as root):

modprobe <module_name>

where <module_name> is the name of the kernel module without the .ko extension.

You may remove a module by typing:

modprobe -r <module_name>
分享到:
评论

相关推荐

    Linux+Kernel+In+A+Nutshell.pdf

    5. Installing and Booting from a Kernel . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Using a Distribution’s Installation Scripts 30 Installing by Hand 31 Modifying the Bootloader for the ...

    Building Embedded Linux Systems, 2nd

    Updated for the latest version of the Linux kernel, this new edition gives you the basics of building embedded Linux systems, along with the configuration, setup, and use of more than 40 different ...

    Building Embedded Linux Systems 2nd

    Updated for the latest version of the Linux kernel, this new edition gives you the basics of building embedded Linux systems, along with the configuration, setup, and use of more than 40 different ...

    vxworks_kernel_programmers_guide_6.9

    1.2 Kernel Architecture ......................................................................................................... 3 1.3 Related Documentation Resources ...................................

    开源FreeRTOS V10.1.0 最新版本

    + FreeRTOS/source contains the FreeRTOS real time kernel source code. + FreeRTOS/demo contains a pre-configured demo project for every official FreeRTOS port. + FreeRTOS-Plus contains additional ...

    Embedded Programming with Android: Bringing Up an Android System from Scratch

    The First Practical, Hands-On Guide to Embedded System Programming ...Integrate U-Boot and a Linux kernel into an AOSP and CyanogenMod source tree Create your own Android ROM on a virtual Android device

    The Linux Programmer’s Toolbox

    You'll start by learning the basics of downloading, building, and installing open source projects. You'll then learn how open source tools are distributed, and what to look for to avoid wasting time ...

    英文原版-The Linux Programmers Toolbox 1st Edition

    building, and installing open source projects. You’ll then learn how open source tools are distributed, and what to look for to avoid wasting time on projects that aren’t ready for you. Next, you’...

    romfs.2.0.x.gz

    When building from source, create a file in the top directory called ".gdbinit" that contains: target sim load to save some typing ;-) Then link the romfs.img to boot.rom with: ln -s images/...

    Embedded.Operating.Systems.A.Practical.Approach.2nd.Edition

    This easy-to- follow textbook/reference guides the reader through the creation of a fully functional embedded operating system, from its source code, in order to develop a deeper understanding of each...

    Embedded Linux System Design and Development

    detail the features of various open source and commercial embedded Linux distributions available. The chapter concludes by presenting a transition roadmap from a traditional RTOS to embedded Linux. ...

    Embedded.Linux.Systems.with.the.Yocto.Project.0133443248

    Building a Custom Linux Distribution Chapter 8. Software Package Recipes Chapter 9. Kernel Recipes Chapter 10. Board Support Packages Chapter 11. Application Development Chapter 12. Licensing and ...

    Apress.Pro.Linux.Embedded.Systems.Dec.2009

    associated projects are open source, you learn how to build everything you need for an embedded project from scratch. The entire Linux environment has advanced to the point that this undertaking is no...

    Professional Ubuntu Mobile Development

    Essential reading for open source software developersAs the most popular open source operating system in use today, Ubuntu Linux has recently released versions that are aimed at device manufacturers ...

    BeagleBone.Black.Cookbook.1783982926

    Following these recipes, more advanced examples take you through scripting, debugging, and working with software source files, eventually working with the Linux kernel. Subsequently, you will learn ...

    DTrace Dynamic Tracing In Oracle Solaris, Mac OS X & FreeBSD PDF

    Now, for the first time, there's a comprehensive, authoritative guide to making the most of DTrace in any supported UNIX environment--from Oracle Solaris to OpenSolaris, Mac OS X, and FreeBSD. ...

    a project model for the FreeBSD Project.7z

    The kernel is the main building block of FreeBSD. While the userland applications are protected against faults in other userland applications, the entire system is vulnerable to errors in the kernel. ...

    ethminer-0.16.0.dev3

    - [Building from source](#building-from-source) - [CMake configuration options](#cmake-configuration-options) - [Maintainer](#maintainer) - [Contribute](#contribute) - [F.A.Q.](#faq) ## Install ...

Global site tag (gtag.js) - Google Analytics