lunes, 13 de agosto de 2012

Building AOKP for the Nexus S

Building any AOSP variant for a Nexus device is pretty straightforward, as the device tree is already included by Goole and they are well tested & supported devices. In order to build AOKP (AOSP variant with some tweaks):

The source code is here (check the README below):
https://github.com/AOKP/vendor_aokp

First of, clone the whole code from git


mkdir ~/bin
PATH=~/bin:$PATH
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
chmod a+x ~/bin/repo
repo init -u https://github.com/AOKP/platform_manifest.git -b jb

Then sync:

repo sync -j16

-jNN will speed up things for multicore - fast - connected build environments, BUT it may lock on Ubuntu because of its broken python impementation. To avoid this problem:



sudo sysctl -w net.ipv4.tcp_window_scaling=0
repo sync -j1

For building AOKP I prepare a handy script that set ups ccache (to speedup things) and builds for "crespo" that is Nexus S. This script might be on vendor/aokp/build.sh for instance:
export USER=alienmind
export USE_CCACHE=1
export CCACHE_DIR=/$HOME/.ccache
prebuilts/misc/linux-x86/ccache/ccache -M 40G
source build/envsetup.sh
lunch aokp_crespo-userdebug
make -j1 otapackage # bacon
#brunch $DEV
There are three build types:
BuildtypeUse
userlimited access; suited for production
userdebuglike "user" but with root access and debuggability; preferred for debugging
engdevelopment configuration with additional debugging tools

References:  http://source.android.com/source/building-devices.html

martes, 3 de enero de 2012

Android preferences

Reworking icetool preferences the proper way ...

Modding boot.img

Modding boot.img can be useful for changing kernel or init scripts on ramdisk.

The ramdisk itself contains - for instance - default.prop that can be edited to unsecure the image - that means having adb shell directly as root, or ability to use adb remount
Boot partition can be extracted with dd if=/dev/mtd/mtd2 (on Nexus S) or as generic way, from recovery using flash_dump boot boot.img

Needed steps are:
$ unpack-bootimg.pl boot.img 
kernel written to boot.img-kernel.gz
ramdisk written to boot.img-ramdisk.cpio.gz

removed old directory boot.img-ramdisk

gzip: ../boot.img-ramdisk.cpio.gz: decompression OK, trailing garbage ignored
529 blocks

extracted ramdisk contents to directory boot.img-ramdisk/

$ cd boot.img-ramdisk/
# ... do whatever edits you need ...

# Repack
$ find . | cpio -o  -H newc | gzip > ../boot.img-ramdisk-new.cpio.gz
$ cd ..
$ mkbootimg --kernel boot.img-kernel.gz --ramdisk boot.img-ramdisk-new.cpio.gz --base 0x30000000 --pagesize 4096 -o boot.img.new
Looks like base / pagesize parameters are device dependent. Above are for Nexus S only

Example 1 - Unsecuring boot.img

After unpacking the img, we can chdir to unpacked ramdisk folder and change in default.prop:
ro.secure=1
to
ro.secure=0
EDIT: This example is useless, as someone pointed me how to properly gain root access with just running "adb root" and nothing else

Example 2 - Adding init.d support

At the end of init.rc we may add (if we also add busybox to system.img of course):
# Execute files in /etc/init.d before booting
service userinit /system/xbin/busybox run-parts /system/etc/init.d
    oneshot
    class late_start
    user root
    group root

Attach: mkbootimg.zip containing all needed tools