Hi! We're discussing a clarification of the content license; please look over to Current events if you're interested in editing.

QuickDeveloperStartGuide

From Htc-linux

Jump to: navigation, search

This page will try to help you getting started with development and understand what the elements are.

This is still a draft. Any improvements are welcome. To find more general information on Linux development for embedded devices you can stop by at http://elinux.org

Contents

[edit] The Basics

The system on a pxa is not much different from a standard PC. In fact (beside cross compiling and if the kernel supports the hardware, you can even run some desktop distributions on it...)

To run Linux on a phone you'll need:

  • A boot loader that loads the kernel into memory and runs it.
  • A Kernel which is responsible to access the hardware and let applications communicate with it.
  • Daemons and utilities that make the system available to user space
  • And there is a GUI or commandline which is responsible for user interaction.

Once most of this works your phone could be used.


Source(s): QuickDeveloperStartGuide

[edit] Bootloader

The developers use mainly HaRET which is a bootloader and a tool used to analyse your phone hardware.

This tool runs from Windows Mobile. It won't replace the system or anything on the phone.

There is also Linload used on some htc phones. It is used to only start the kernel directly.

First thing the bootloader needs to know where to load the kernel and run it.


[edit] Kernel

[edit] Obtaining source code and building the kernel

Using htc vogue in this example. For HD2 aka leo use branch 'htc-msm-2.6.32' and config 'htcleo_defconfig'


Obtaining the source code

First chose a kernel repository and branch for your device.

get a local copy of the kernel repository

git clone git://git.linuxtogo.org/home/groups/mobile-linux/kernel.git


cd kernel


list branches

git branch -a


you will see that a branch named htc-vogue exists on the remote repository

'remotes/origin/htc-vogue'


check that branch out

git checkout -b htc-vogue origin/htc-vogue


optional: see below for how to check out a specific revision/commit of the source code


Configuring the kernel

There are default configurations for many devices included in the kernel sources. Show a list of available kernel configurations chose the one that suites your device best

make ARCH=arm help


Write the default kernel configuration for your device from arch/arm/configs/vogue_defconfig to .config

make ARCH=arm vogue_defconfig


optional: If you want to edit the default configuration run

make ARCH=arm menuconfig


Compiling the kernel

sometimes it is necessary to remove your already compiled files and build from scratch

make clean


let's start compiling. CROSS_COMPILE= env var is important. read more about it on toolchain page. zImage will give you a gzipped kernel image. to produce uncompressed one simply put 'Image' instead

make ARCH=arm CROSS_COMPILE=/path-to-toolchain/bin/arm-linux-gnueabi- zImage


The product will be written to arch/arm/boot/zImage

On most htc devices you will need HaRET to boot it.


Compile and installing the kernel modules

In many cases the Linux kernel is configured to use modules. Drivers that are not included in the Image / zImage and which must be installed into your rootfilesystem.

Compiling the kernel modules

make ARCH=arm CROSS_COMPILE=/path-to-toolchain/bin/arm-linux-gnueabi- modules


Install the modules into your rootfilesystem

make ARCH=arm INSTALL_MOD_PATH=/mountpoint/of/your/rootfilesystem modules_install


Staying up to date To obtain code updates run

git pull


To clean any local changes use

git reset --hard


Checking out a specific revision/commit of the source code

optionally, before builing you can checkout a specific source revision to view a commit overview of the current branch use

git log


to show the source revision at a specified date use this

git rev-list htc-vogue -n 1 --first-parent --before=2010-03-11


this will give you the hash for that commit

497da7f2f1a9040d3000eedd08d6caff4eaba4e8


move to the desired revision (removing any locally made changes)

git reset --hard 497da7f2f1a9040d3000eedd08d6caff4eaba4e8


Monitoring local changes

git status


Creating patches

git format-patch


For a more in-depth look at kernel development and collaboration in git, see AdvancedGitGuide.

[edit] Linux OS / Embedded distributions

This usually is included in the distribution. (Angstrom, Android, Openmoko, etc)

Usually they have an init system and basic utilities (libc, binutils, openssh, etc. or an equivalent embedded version uclibc, busybox, etc.)


[edit] OpenEmbedded (OE)

openembedded


[edit] Angstrom

building angstrom


[edit] Openmoko

http://www.openmoko.org


[edit] Android

http://www.android.com