Pages

Get it free, Try now

Free Cell Phones

Friday, November 19, 2010

Android - Manual SD Card partions vfat and ext2

we will first check if there are any partitions on the sdcard,if there any we will set it to unpartitioned state...
below steps are command base you may use the GUI software Gparted to do the same.

Disclaimer: I AM NOT RESPONSIBLE FOR WHAT YOU DO WITH YOUR DEVICE


1. Read the sdcard partions(shows devices connected)
#cat /proc/partitions
major minor #blocks name


8 0 156290904 sda
8 1 102400 sda1
8 2 104985600 sda2
8 32 312571224 sdc
8 33 226298554 sdc1
8 34 1 sdc2
8 37 82715648 sdc5
8 38 3555328 sdc6
8 16 488386584 sdb
8 17 102398278 sdb1
8 18 1 sdb2
8 21 20482843 sdb5
8 48 1921024 sdd // see some hardware connected
8 49 1920000 sdd1 // ID of the HW

2. Very again, if they are mounted using mount command and we see that there is a Linux partition of type ext2
# mount
blah ...
....
/dev/sdd1 on /media/61de92d5-99ae-48e7-9c14-0fa3f86c2d93 type ext2 (rw,nosuid,nodev,uhelper=udisks)

3. unmount the drive
# umount /dev/sdd1
#

4.Now we will remove the already available partitions and create two new partition of type FAT32 and ext2. follow the warning from command to get rid any unknown issues



#fdisk /dev/sdd

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').

Command (m for help): c
DOS Compatibility flag is not set

Command (m for help): u
Changing display/entry units to sectors

Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help): p

Disk /dev/sdd: 1967 MB, 1967128576 bytes
54 heads, 32 sectors/track, 2223 cylinders, total 3842048 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00026cc2

Device Boot Start End Blocks Id System
/dev/sdd1 * 2048 3842047 1920000 83 Linux

Command (m for help): d // delete 1st partition
Selected partition 1

ommand (m for help): n // type n for new partition
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First sector (32-3842047, default 32):
Using default value 32 // 1st partition starts after 32 till 3842047
Last sector, +sectors or +size{K,M,G} (32-3842047, default 3842047): 2000000 // we use only half of the value

Command (m for help): p

Disk /dev/sdd: 1967 MB, 1967128576 bytes
54 heads, 32 sectors/track, 2223 cylinders, total 3842048 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00026cc2

Device Boot Start End Blocks Id System
/dev/sdd1 * 32 2000000 999984+ c W95 FAT32 (LBA)

Command (m for help): t // change type of partitions
Selected partition 1 // apply for 1st partition
Hex code (type L to list codes): 83 // 83 corresponds to Linux id
Changed system type of partition 1 to 83 (Linux)

Command (m for help): p // type p, shall results in partition of type Linux

Disk /dev/sdd: 1967 MB, 1967128576 bytes
54 heads, 32 sectors/track, 2223 cylinders, total 3842048 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00026cc2

Device Boot Start End Blocks Id System
/dev/sdd1 * 32 2000000 999984+ 83 Linux
//repeat steps to create new partions
//
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2 // 2nd partition
First sector (2000001-3842047, default 2000001):
Using default value 2000001 // allocation start here and ends at 3842047
Last sector, +sectors or +size{K,M,G} (2000001-3842047, default 3842047):
Using default value 3842047

Command (m for help): p

Disk /dev/sdd: 1967 MB, 1967128576 bytes
54 heads, 32 sectors/track, 2223 cylinders, total 3842048 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00026cc2

Device Boot Start End Blocks Id System
/dev/sdd1 * 32 2000000 999984+ 83 Linux
/dev/sdd2 2000001 3842047 921023+ 83 Linux

Command (m for help): t // type t to change 2nd partitio to windows type
Partition number (1-4): c // typeo err
Partition number (1-4): 2 //
Hex code (type L to list codes): c // ID for windows type
Changed system type of partition 2 to c (W95 FAT32 (LBA))

Command (m for help): p // type p

Disk /dev/sdd: 1967 MB, 1967128576 bytes
54 heads, 32 sectors/track, 2223 cylinders, total 3842048 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00026cc2

Device Boot Start End Blocks Id System
/dev/sdd1 * 32 2000000 999984+ 83 Linux
/dev/sdd2 2000001 3842047 921023+ c W95 FAT32 (LBA)

// finally, we created two partions 1st linux and 2nd windows
// now we need to write the table to disk and exit
// type w
Command (m for help): w
The partition table has been altered!


Calling ioctl() to re-read partition table.

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.

~???#

now we need to format tables inthe disk, i;e make filesystem
#mkfs.vfat /dev/sdd2
mkfs.vfat /dev/sdd2
#
#root@br-desktop:/home/br# mkfs.ext2 /dev/sdd1
mke2fs 1.41.11 (14-Mar-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
62592 inodes, 249996 blocks
12499 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=260046848
8 block groups
32768 blocks per group, 32768 fragments per group
7824 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376


Writing inode tables: done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
// now unplug and plugin the sdcard and type Mount on the terminal, shall show you this
#
#
#mount
....
...
/dev/sdd1 on /media/2b3f5798-9c5f-4ce3-8275-c7c987b0764c type ext2 (rw,nosuid,nodev,uhelper=udisks)
/dev/sdd2 on /media/79BF-0782 type vfat (rw,nosuid,nodev,uhelper=udisks,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,flush)

Technicalities to build custom ROM for LG GT540

::First things first::

Thanks to XDA developer and Modaco forums to share their experience

Below are the steps taken by me to build a working Android kernel image and system image for the GT540 (a.k.a. LG SWIFT). This image is based on linux kernel 2.6.29 and relies on the Android 2.1 "Eclair".

This page is here as a reminder to me for when I come to do it again. This is what worked for me so far, your approach may vary.



1. Download required tools and software

-Download GT540 ROM sources from LG here.

I have used Eclair sources, the size should be 132MB after download. next unzip sources and follow the Readme.txt to ease I copy-paste below
1. How to download Android source.

refer to Android site - http://source.android.com/source/download.html

2. Check your build environment

whether it is successful in building downloaded Android source.

3. Untar open source package of GT540 into downloaded Android source

4. Kernel Build

dount$> source ./build/envsetup.sh

donut$> choosecombo 1 1 generic 1

donut$> cd kernel

donut/kernel$> make swift_defconfig

donut/kernel$> make

-> After build, you can find the built image at kernel/arch/arm/boot/

5. Android Source Build

donut$> source ./build/envsetup.sh

donut$> choosecombo 1 1 generic 1

donut$> make

-> After built, you can find the built image at out/target/product/generic

-Download Android source code for desired version like Eclair in this case, Details on how to download source code is here

2. Build kernel and system images

-Following the first steps in Readme.txt from LG sources will give you the kernel image i;e zImage at ~/eclair/kernel/arch/arm/boot/zImage

-Second step will build system.img, ramdisk.img, userdata.img which will be at ~home/br/eclair/out/target/product/generic/

you may run system.img to test on emulator(How to is here ) before NAND flashing

3. Unpack, Repack and Flashing

- Get the Boot image from existing target

 

# cat /proc/mtd

dev: size erasesize name

mtd0: 00500000 00020000 "boot"

mtd1: 04000000 00020000 "cache"

mtd2: 00500000 00020000 "recovery"

mtd3: 00060000 00020000 "splash"

mtd4: 0f500000 00020000 "system"

mtd5: 002c0000 00020000 "lgdrm"

mtd6: 08b80000 00020000 "userdata"

mtd7: 00080000 00020000 "usd"

mtd8: 005a0000 00020000 "pkg"

mtd9: 1cfc0000 00020000 ""

# cat /dev/mtd/mtd0 > /sdcard/boot.img pull the boot.img from sdcard and apply below scripts

- Download scripts from here (follow the instruction in the scripts) to add new kernel image with devicee ramdisk. I have a different set of scripts that I will share later.

- Used fastboot to flash images, fastboot usage is here

-First reboot may take while, or you may see weird behavior (stuck at boot screen or reboot loop.....)

Conclusion: Kernel up and running, but system image give a problem...

 

P.S : Dear readers, if you are able to run custom system image please do share your experiences.

Thursday, November 11, 2010

Android: make the system partitions on the device read-write

From the SDK's tools directory, run adb shell. In the
prompt run the following:

# su
# mount -o rw,remount -t yaffs2 /dev/block/mtdblock4 /system
# chmod 777 /system (Or any subdirectory you want to push to inside system)
# exit
adb push

and eventually you should restore the original directory permissions by:
# chmod 755 /system (Or any subdirectory you modified permissions to)

Make sure you knew the mount point for system by running #
# cat /proc/mtd
dev: size erasesize name
mtd0: 00500000 00020000 "boot"
mtd1: 04000000 00020000 "cache"
mtd2: 00500000 00020000 "recovery"
mtd3: 00060000 00020000 "splash"
mtd4: 0f500000 00020000 "system"
mtd5: 002c0000 00020000 "lgdrm"
mtd6: 08b80000 00020000 "userdata"
mtd7: 00080000 00020000 "usd"
mtd8: 005a0000 00020000 "pkg"
mtd9: 1cfc0000 00020000 ""

Wednesday, November 10, 2010

How to Build a single module in Android and include in System image

Go to build directory under Android sources
Execute source ./envsetup.sh
Go to corresponding application directory (~/eclair/hardware/msm7k/libaudio$)
Issue mm command to build the Module only in this case its libaudio.so

if you want to include in system.img in conjunction with ROM sources from vendor

run make from the root directory

~/eclair$ make
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.1-update1
TARGET_PRODUCT=generic
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=ECLAIR
============================================
build/core/copy_headers.mk:15: warning: overriding commands for target `out/target/product/generic/obj/include/libpv/getactualaacconfig.h'
build/core/copy_headers.mk:15: warning: ignoring old commands for target `out/target/product/generic/obj/include/libpv/getactualaacconfig.h'
Install: out/host/linux-x86/lib/libneo_util.so
...
...
...
Install system fs image: out/target/product/generic/system.img
~/eclair$

Running Android emulator up with custom system image

1.Run Terminal, and change to the 'tools' directory of the SDK
2.Type './android list target'
3.Note the 'id' number of the '2.1' target (in my case it's '7')
4.Type './android create avd -n eclair -t 7' (where 7 with the target number determined above if required)
5.You will be prompted to create a hardware profile. say YES and provide user defined values or leave as default.
6.Copy system.img to ~/.android/avd/eclair.avd/system.img
7.Type './emulator -avd eclair' command to run emulator with system.img! Note: initial boot may take a few minutes!

should you get any Java issues download the JDK for your system "jdk-6u14-windows-i586.exe"

how to use fastboot on Ubuntu

1.Download fastboot from here

OR you could the one from the android sources at location ~/eclair/out/host/linux-x86/obj/EXECUTABLES/fastboot_intermediates/fastboot
2.Move it sdk "tools" folder and enable root permissions
3.Make sure you add vendor id to the 51.android.rules file and set a+rx permissions and reboot(more details on setting vendor id is here )
4.Reboot in fastboot mode(each individual hardware has it own keyspress to boot into bootloader) then connect USB cable and issue below command

$./fastboot devices
??????? fastboot


quick usage


$./fastboot -w
$./fastboot erase system
$./fastboot flash system system.img
$./fastboot flash boot boot.img
$./fastboot reboot

Tested on LG GT540

Note: No idea why it shows ???? indeed vendorid is povided already.