Kernel 101 Prashant Somashekar Kernel 101 What will

  • Slides: 15
Download presentation
Kernel 101 Prashant Somashekar

Kernel 101 Prashant Somashekar

Kernel 101 • What will we discuss? -Brief overview of a kernel -How a

Kernel 101 • What will we discuss? -Brief overview of a kernel -How a kernel fits into the hierarchy -Android versus Linux kernel -Building an Android kernel from source -Flashing a kernel to bare metal (mobile) -Practical experience; pitfalls; methodology

Kernel 101 • What is a kernel? -Heart of the system -Hardware initialization •

Kernel 101 • What is a kernel? -Heart of the system -Hardware initialization • Hierarchy of a mobile system -Bootloader -> Kernel -> OS -Kernel provides low level abstraction layer

Kernel 101 • What is a kernel’s function? -Provide a layer for OS/App to

Kernel 101 • What is a kernel’s function? -Provide a layer for OS/App to speak with hardware -CPU/Memory management -Resource allocation -Input/Output from/to device’s components

Kernel 101 • Difference between Android and Linux kernel? -Based off Linux -Wakelock/Power management

Kernel 101 • Difference between Android and Linux kernel? -Based off Linux -Wakelock/Power management implementation -No paging to disk for virtual memory -Lightweight libc standard library (Bionic) -Video framebuffer instead of X 11 -Low memory killer

Kernel 101 • How can I acquire kernel source code? -Use of github as

Kernel 101 • How can I acquire kernel source code? -Use of github as a source code repository -Provides timeline of changes -Eases kernel development -Facilitates code sharing and dissemination

Kernel 101 • Will be using ubuntu (linux) -Install git: apt-get install git-core •

Kernel 101 • Will be using ubuntu (linux) -Install git: apt-get install git-core • Pulling source code from a github repo:

Kernel 101 • Use Codesourcery’s toolchain -ARM-EABI 2010. 09 (GCC 4. 5) • Use

Kernel 101 • Use Codesourcery’s toolchain -ARM-EABI 2010. 09 (GCC 4. 5) • Use and setup Codesourcery’s toolchain: -Unpack to a folder (ex: toolchain in home) -export CCOMPILER=~/toolchain/arm 2010. 09/bin/arm-none-eabi-export PATH=$PATH: ~/toolchain/arm 2010. 09/bin

Kernel 101 • Go to kernel directory and generate a defconfig -cd mykernel -make

Kernel 101 • Go to kernel directory and generate a defconfig -cd mykernel -make –j 2 ARCH=arm CROSS_COMPILE=$CCOMPILER pershoot_mahi_defconfig -sample configurations in arch/arm/configs • Compile a kernel: -make –j 2 ARCH=arm CROSS_COMPILE=$CCOMPILER

Kernel 101 • Put device in bootloader; fastboot mode • Boot device with new

Kernel 101 • Put device in bootloader; fastboot mode • Boot device with new kernel -fastboot z. Image -kernel image will be in arch/arm/boot -z. Image is a compressed kernel image • Copy wireless driver to device -adb remount -adb push drivers/net/wireless/bcm 4329. ko /system/lib/modules • Make more configuration changes -make –j 2 ARCH=arm CROSS_COMPILE=$CCOMPILER menuconfig (must have lib -ncurses installed) • Clean and rebuild: -make –j 2 ARCH=arm CROSS_COMPILE=$CCOMPILER clean && make –j 2 ARCH=arm CROSS_COMPILE=$CCOMPILER

Kernel 101 • Not all devices will have fastboot -Pull existing boot. img from

Kernel 101 • Not all devices will have fastboot -Pull existing boot. img from device -Use split_bootimg. pl to separate ramdisk and kernel -Use mkbootimg to merge your new kernel with existing ramdisk -mkbootimg --cmdline 'no_console_suspend=1 console=null' --kernel z. Image --ramdisk. gz --base 0 x 20000000 -o boot. img -Base listed is specific to Nexus One (Passion) • Ramdisk (initrd) is a temporary root file system -Bare minimum needed for boot until the real system’s filesystem is available -May contain utilities, drivers, folder layout, etc. • Flash boot. img to device via updater-script -write_raw_image("/tmp/boot. img", "boot") • Alternative method -use Any. Kernel (koush) -Only need to supply a z. Image and modules (optional) -Resign update. zip (with a test key) or toggle signature checking off (Clockwork Mod), prior to flashing

Kernel 101 • Feel free to play with the source! -Adjust frequency clocks (overclock)

Kernel 101 • Feel free to play with the source! -Adjust frequency clocks (overclock) -Under volt some frequency ranges to save some power -Implement GCC optimizations -Enable further functionality via loadable kernel modules

Kernel 101 • Not all devices are created equal -Hardware variances makes a ‘one

Kernel 101 • Not all devices are created equal -Hardware variances makes a ‘one size fits all’ mantra difficult to maintain at times -Different ROM bases may interact poorly -Remote troubleshooting can make resolution times lengthy • It is important to adhere to the GPL -Keeping things open -Engineering for the sake of making things faster and more fine-tuned -Contribute to Social Coding -Fit to a specific environment’s form -Fix bugs -Add and enhance functionality

Kernel 101 • Cyanogen. Mod -Distribution based off AOSP/Code. Aurora/Nvidia/Omapzoom -Aims to provide a

Kernel 101 • Cyanogen. Mod -Distribution based off AOSP/Code. Aurora/Nvidia/Omapzoom -Aims to provide a unified experience across multiple devices -Custom ROM and Kernel development -Open Platform which encourages social coding and development

Kernel 101 • Q&A

Kernel 101 • Q&A