Showing posts with label Kernel. Show all posts
Showing posts with label Kernel. Show all posts

Tuesday, November 20, 2012

Compile Kernel on Ubuntu 12.04



1. Downloading latest stable source code from http://www.kernel.org/.



2. While downloading, we install necessary packages required to compile the kernel.
# apt-get install kernel-package libncurses5-dev fakeroot wget bzip2


3. Untar the source code.

# mv ~/Downloads/linux-3.6.7.tar.bz2  /usr/src/
# cd /usr/src
# tar -jxvf linux-3.6.7.tar.bz2
# ln -s linux-3.6.7 linux
# cd linux




4. Configure the kernel
# cp /boot/config-3.2.0-33-generic ./.config
# make menuconfig

Screen below should show up, pick 'Loan an Alternate Configuration File' as '.config', then pick 'OK' follow by 'EXIT'





5. Start building....
# make-kpkg clean
# fakeroot make-kpkg  --initrd --append-to-version=-mykernel kernel_image kernel_header  -j4

'mykernel' can change to anything you like, option -j4 is to tell make use up to 4 threads.
Now walk away from your PC go enjoy coffee.



Finally completed. 


6. Installing...
# cd ..
$ sudo dpkg -i linux-image-3.6.7-mykernel_3.6.7-mykernel-10.00.Custom_amd64.deb
$ sudo dpkg -i linux-headers-3.6.7-mykernel_3.6.7-mykernel-10.00.Custom_amd64.deb 




# sudo shutdown -r 0


Friday, October 19, 2012

Android profiling with ARM Streamline

Configs :



1. Getting kernel source for Nexus S.
$mkdir ~/android
$cd android
$ git clone https://android.googlesource.com/kernel/samsung.git

2. Checkout the source.

$ git branch -r
  origin/HEAD -> origin/master
  origin/android-samsung-2.6.35-gingerbread
  origin/android-samsung-3.0-ics-mr1
  origin/android-samsung-3.0-jb
  origin/master

$git checkout android-samsung-2.6.35-gingerbread origin/android-samsung-2.6.35-gingerbread



3. Export prebuild toolchanin & build vars...
$export PATH=<SDK_PATH>/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin:$PATH

$export ARCH=arm
$export SUBARCH=arm
$export CROSS_COMPILE=arm-eabi-




4. Compile kernel and gator module.

$ make herring_defconfig

arch/arm/configs/herring_defconfig:323:warning: override: reassigning to symbol LOCALVERSION_AUTO
arch/arm/configs/herring_defconfig:333:warning: override: reassigning to symbol NET_ACTIVITY_STATS
#
# configuration written to .config
#
#herring_defconfig is config for NEXUS S, use 'make help' to find out your device config

$nano .config
Ensure the parameters below is set.
  • CONFIG_PROFILING=y
  • CONFIG_FTRACE=y 
  • CONFIG_ENABLE_DEFAULT_TRACERS=y


$ make -j4 CROSS_COMPILT=arm-eabi- uImage
  CHK     include/linux/version.h
  CHK     include/generated/utsrelease.h
make[1]: `include/generated/mach-types.h' is up to date.
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  Kernel: arch/arm/boot/Image is ready
  SHIPPED arch/arm/boot/compressed/lib1funcs.S
  AS      arch/arm/boot/compressed/lib1funcs.o
  LD      arch/arm/boot/compressed/vmlinux
  OBJCOPY arch/arm/boot/zImage
  Kernel: arch/arm/boot/zImage is ready
  UIMAGE  arch/arm/boot/uImage
Image Name:   Linux-2.6.35.7-gf5f63ef
Created:      Thu Sep 27 13:36:20 2012
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    3017840 Bytes = 2947.11 kB = 2.88 MB
Load Address: 30008000
Entry Point:  30008000
  Image arch/arm/boot/uImage is ready


5. Build Gator module

Install DS-5 module for Eclipse, detail please refer to HERE.

or

Download DS-5 from http://www.arm.com/products/tools/software-tools/ds-5/index.php



6. After install.....go Eclipse Help-> ARM Extras, explore pop out.....
navigate to 'driver-src', extract 'gator-driver.tar.gz'.. to kernel dir.

$ cd gator-driver/
$ make -C path/to/kernel  M=`pwd`  modules
$ cd ..
$ adb pull /sdcard/init.rc /path/to/sdk/tools/

7. go Eclipse Help-> ARM Extras, explore pop out.....
navigate to 'daemon-src'.

$ mkdir /path/to/arm/gator/android
$ cp /path/to/arm/gator/daemon-src/gator-daemon/gator-daemon.tar.gz /path/to/arm/gator/android/
$ tar -zxvf gator-daemon.tar.gz
$ mv gator-daemon jni

$ ndk-build
Compile++ thumb  : gatord <= CapturedXML.cpp
Compile++ thumb  : gatord <= Child.cpp
Compile++ thumb  : gatord <= Collector.cpp
Compile++ thumb  : gatord <= ConfigurationXML.cpp
Compile++ thumb  : gatord <= Fifo.cpp
Compile++ thumb  : gatord <= LocalCapture.cpp
Compile++ thumb  : gatord <= Logging.cpp
Compile++ thumb  : gatord <= main.cpp
Compile++ thumb  : gatord <= OlySocket.cpp
Compile++ thumb  : gatord <= OlyUtility.cpp
Compile++ thumb  : gatord <= Sender.cpp
Compile++ thumb  : gatord <= SessionData.cpp
Compile++ thumb  : gatord <= SessionXML.cpp
Compile++ thumb  : gatord <= StreamlineSetup.cpp
Compile thumb  : gatord <= mxml-attr.c
Compile thumb  : gatord <= mxml-entity.c
Compile thumb  : gatord <= mxml-file.c
Compile thumb  : gatord <= mxml-get.c
Compile thumb  : gatord <= mxml-index.c
Compile thumb  : gatord <= mxml-node.c
Compile thumb  : gatord <= mxml-private.c
Compile thumb  : gatord <= mxml-search.c
Compile thumb  : gatord <= mxml-set.c
Compile thumb  : gatord <= mxml-string.c
StaticLibrary  : libstdc++.a
Executable     : gatord
Install        : gatord => libs/armeabi/gatord

8.  Copy gatord to device.
# adb push gatord /sdcard/
# adb push gator.ko /sdcard/
# adb shell

# su
# mount -o remount,rw -t yaffs2 /dev/block/mtdblock4 /system
# mv /sdcard/gatord /system/xbin/
# mv /sdcard/gator.ko /system/xbin/


# mount -o ro,remount -t yaffs2 /dev/block/mtdblock4 /system
# sync
# reboot


9. After device boot up.

# adb shell 
# su
# gatord &

10.  Profiling Android phone with Streamline
Streamline supports connection to your target using Ethernet. Using the Android Debug Bridge (ADB) utility, it is possible to forward a TCP port from the target to your PC localhost over a USB connection. ADB can also be configured to work over Ethernet or Wi-Fi. For more information about the Android SDK and ADB setup, see the Android website. Once ADB is set up, forward the Streamline port to your localhost using the following command:

# adb forward tcp:8080 tcp:8080

Now run DS-5 on your PC and open the Streamline Data View. If it is not visible from the Window->Show View menu, select Window->Show View->Other; find “ARM Streamline” in the dialog box and open “ARM Streamline Data”. Enter the device’s Ethernet address in the Capture Options dialog box of the ARM Streamline Data view in Eclipse or DS-5. If you use the Android Debug Bridge (ADB) over USB to forward the port, enter localhost in the Address field.


[src] :
1. http://blogs.arm.com/software-enablement/682-setting-up-android-mobile-phone-to-use-arm-streamline-for-profiling/
2. http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0482d/BABECIDJ.html
3. http://source.android.com/source/building-kernels.html

Compile Android Kernel

1. First thing is find out kernel version used for your device, assume you already downloaded the source from AOSP.

$ cd /android/android-2.3.6_r0.9/device/samsung/crespo

$ git log kernel
commit c85d206feeedd1ee1c69d0e0fe9e529897a5288b
Author: JP Abgrall <jpa@google.com>
Date:   Tue Aug 2 13:47:09 2011 -0700

    kernel + wifi update: gpu only
   
      21fb4cb gpu: pvr: Update to DDK 1.6.16.4131.1.1
   
    Change-Id: I9d728a27256486ba0d2e39211d06ef7f2ebeab6b
    Signed-off-by: JP Abgrall <jpa@google.com>

commit 7af59186753f2c08ed4123e0d2693d0e11f48410
Author: Simon Wilson <simonwilson@google.com>
Date:   Wed Jun 8 19:15:05 2011 -0700

    update kernel
   
    3cc95e3 net: Reorder incoming packets in PPPoLAC and PPPoPNS.
    3128bc4 jbd2: fix fsync() tid wraparound bug
   
    Change-Id: If6a22a320491d52ccbe6abb97acf5e97886fe144

commit 7643328cd8f7eabbf2fed86899b1758308bb747a
Author: JP Abgrall <jpa@google.com>
Date:   Thu May 26 19:50:48 2011 -0700

    Revert "Custom kernel with data-usage support and persistence."
   
    This reverts commit 6a0bcab7b1eb1ca53dd26127ed623e23eeff70a9.

commit 6a0bcab7b1eb1ca53dd26127ed623e23eeff70a9
Author: JP Abgrall <jpa@google.com>
Date:   Thu May 26 19:50:27 2011 -0700

    Custom kernel with data-usage support and persistence.
   
    This is for a one-time build of Gingerbread MR3.
    Not for release.
   
    This kernel is based on
      https://partner.source.android.com/g/gitweb?p=kernel%2Fprivate%2Fsamsung.git;a=shortlog;h=refs%2Fheads%2Fandroid-samsung-2.6.35-gingerbread
       at commit 807fb588280ee28833ea7838e6fa79b9b14f66c1
   
     with the needed iface_stat, udp, ... changes on top:
       https://review.source.android.com/#change,21605
       https://review.source.android.com/#change,21093
   
   
    Change-Id: I558a7f14258c3d6c497995880356bc5a4106de62
    Signed-off-by: JP Abgrall <jpa@google.com>

commit 830fe0120276f51fc9bf5872ff190bae6839eb4b
Author: Simon Wilson <simonwilson@google.com>
Date:   Thu May 26 16:28:34 2011 -0700

    update kernel
   
    807fb58 net: wimax: wimax_status mismatch fixed.
   
    Change-Id: Ide8950f3f5db57e25e4b0682e181c8cb95717cd4

commit 794ceba05495001fe2bf495b23a76acb5263da17
Author: Simon Wilson <simonwilson@google.com>
Date:   Wed May 25 14:47:58 2011 -0700

    update kernel


The log should contain notes of the commit SHA1 for the appropriate kernel project. Keep this value at hand so that you can use it in a later step.


2. Downloading sources

$ git clone https://android.googlesource.com/kernel/samsung.git
$ cd samsung/

Display the branch

$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/android-samsung-2.6.35-gingerbread
  remotes/origin/android-samsung-3.0-ics-mr1
  remotes/origin/android-samsung-3.0-jb
  remotes/origin/master
$ git checkout -b android-samsung-2.6.35-gingerbread origin/android-samsung-2.6.35-gingerbread


Checking out files: 100% (33879/33879), done.
Branch android-samsung-2.6.35-gingerbread set up to track remote branch android-samsung-2.6.35-gingerbread from origin.
Switched to a new branch 'android-samsung-2.6.35-gingerbread'


3. Assume Android-NDK is installed , if not please refer to NDK install page.

4. Setup Env

$export PATH=<android source>/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin:$PATH
$export ARCH=arm
$export SUBARCH=arm
$export CROSS_COMPILE=arm-eabi-


4. Setup default config

$ make herring_defconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/basic/docproc
  HOSTCC  scripts/basic/hash
  HOSTCC  scripts/kconfig/conf.o
scripts/kconfig/conf.c: In function ‘conf_sym’:
scripts/kconfig/conf.c:159:6: warning: variable ‘type’ set but not used [-Wunused-but-set-variable]
scripts/kconfig/conf.c: In function ‘conf_choice’:
scripts/kconfig/conf.c:231:6: warning: variable ‘type’ set but not used [-Wunused-but-set-variable]
scripts/kconfig/conf.c:307:9: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
scripts/kconfig/conf.c: In function ‘conf_askvalue’:
scripts/kconfig/conf.c:105:8: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
  HOSTCC  scripts/kconfig/kxgettext.o
  SHIPPED scripts/kconfig/zconf.tab.c
  SHIPPED scripts/kconfig/lex.zconf.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
arch/arm/configs/herring_defconfig:323:warning: override: reassigning to symbol LOCALVERSION_AUTO
arch/arm/configs/herring_defconfig:333:warning: override: reassigning to symbol NET_ACTIVITY_STATS
#
# configuration written to .config
#





5. Compile
$ make -j4
.........

  CC      arch/arm/boot/compressed/decompress.o
  SHIPPED arch/arm/boot/compressed/lib1funcs.S
  AS      arch/arm/boot/compressed/lib1funcs.o
  CC      crypto/ansi_cprng.mod.o
  CC      drivers/net/wireless/bcm4329/bcm4329.mod.o
  CC      drivers/scsi/scsi_wait_scan.mod.o
  LD [M]  crypto/ansi_cprng.ko
  LD [M]  drivers/net/wireless/bcm4329/bcm4329.ko
  LD [M]  drivers/scsi/scsi_wait_scan.ko
  AS      arch/arm/boot/compressed/piggy.gzip.o
  LD      arch/arm/boot/compressed/vmlinux
  OBJCOPY arch/arm/boot/zImage
  Kernel: arch/arm/boot/zImage is ready

 $ cp arch/arm/boot/zImage ../../../android/android-2.3.6_r0.9/device/samsung/crespo/kernel

6. Flash to device....
$ cd <android src>
$ make -j4
$ fastboot flash -w