[PORT] Android to Touch Diamond/XDA Ignito - Windows Mobile Development and Hacking General

I am attempting to create my own port of android to my HTC touch diamond (rebranded as the XDA Ignito) and i've hit a slight problem, I'm using dd to create an image file:
Code:
dd if=/dev/zero of=~/system.img count=19000
(not sure if it was 19000 but it created an image of about 90mb.)
I then create an ext2 filesystem out of it:
Code:
mkfs.ext2 ~/system.img
and then mount it to /andsys:
Code:
mount ~/system.img /andsys -o loop
and put the cutomized system into this.
then I unmount it and copy the new system onto my phone,
when hariet runs it say that loop2 is an unvalid ext2 system and
cannot mount /sys. it works fine with the stock system.img that
comes in a zip. and idea's why my modified system isn't working?
thanks,
Sam Aldis

I hate to bump but has no one got any ideas?
am attempting to create a custom android system that
it specifically for other HTC phones rather than being
android for G1/G2 running on a HTC phone.

You may want to do a search. I believe that there are a number of threads which deal with Android porting to different devices.
Sorry I can't be of anymore help, but I wish you luck!

Related

Minimal UI for LUKS encryption on the Wildfire

This is a basic gui I wrote to unlock my encrypted partitions during boot.
I'm running my /data and /sdcard partitions encrypted, and the "luksunlock" binary is launched from init.rc to read the password and unlock the encrypted partitions.
I have included my somewhat modified init.rc for those interested.
For more information about LUKS on Android see this blogpost, written by shawn (Seems I'm not allowed to have urls in the post, but Google for 'android luks' , first hit)
This works good on Wildfire, altough it should work fine on other phones as well. Just remember that you need to set up your partitions as in the luksunlock.c (or change the defines).
Dont forget to backup before you start playing around!
Good luck!
Thanks! i'll give a try!
Hi,
I tried to use your cryptsetup binary from your blog, but I have some issues that you'll sure have an answer:
I run ./cryptsetup luksFormat -c aes-plain /dev/block/loop2 and after i put the luks password it says 'Command failed', no logs, no other output, even using the -v flag...
Any clue?
Thanks in advance!
PS: the module dm-crypt is necessary for cryptsetup? could be this the error? I don't have it installed on the system because I can't find it for 2.6.35.9-cyanogenmod
tusabe said:
Hi,
I tried to use your cryptsetup binary from your blog, but I have some issues that you'll sure have an answer:
I run ./cryptsetup luksFormat -c aes-plain /dev/block/loop2 and after i put the luks password it says 'Command failed', no logs, no other output, even using the -v flag...
Any clue?
Thanks in advance!
PS: the module dm-crypt is necessary for cryptsetup? could be this the error? I don't have it installed on the system because I can't find it for 2.6.35.9-cyanogenmod
Click to expand...
Click to collapse
CM6.1 for wildfire uses a 2.6.32 kernel (see HCDR.jacob's post about his custom kernel for more info)
tusabe said:
PS: the module dm-crypt is necessary for cryptsetup? could be this the error? I don't have it installed on the system because I can't find it for 2.6.35.9-cyanogenmod
Click to expand...
Click to collapse
Yeah you really need dm-crypt support, either compiled into the kernel or as a module. You also need the AES ciphers support.
sigkill1337 said:
Yeah you really need dm-crypt support, either compiled into the kernel or as a module. You also need the AES ciphers support.
Click to expand...
Click to collapse
Hi! Yeah, that's what I was afraid of.... ok, but the problem is that i'm running CM6.1 with 2.6.35.9 which has no dm-crypt module neither compiled in kernel... where can i find some kernel with this modules included? Is for an HTC Desire (@Sympnotic )
Thanks in advance!
Great work and thanks for sharing @Sigkill. Working on building it here for my NexusOne with CM6.1.
BTW, I’m the lead on a project working on general secure Android distro – we’ve ported Tor, have an OTR IM app, and have supported other projects along those lines. Would love to talk more about supporting anyone working on this specific capability.
wow! awesome work!!! Very exciting news. Gonna give this a go on my MyTouch Slide
NathanFreitas said:
Great work and thanks for sharing @Sigkill. Working on building it here for my NexusOne with CM6.1.
BTW, I’m the lead on a project working on general secure Android distro – we’ve ported Tor, have an OTR IM app, and have supported other projects along those lines. Would love to talk more about supporting anyone working on this specific capability.
Click to expand...
Click to collapse
Seems really nice. I like the secure phone concept.
New Makefile and wiki info up
_hc from the @guardianproject has a new build process up for Crypsetup/LUKS which includes a Makefile compatible with Android NDK r5.
We have new instructions up on our wiki, as well.
I cannot post links under this account, but you can find the info on github if you search "LUKS" or just under our guardianproject account.
How did you create the encrypted partitions? Could you give some pointers for that. I am familiar with using dmcrypt/cryptsetup on desktop linux, I guess this works similar. What are the relevant device names? Did you run into any problems?
Calavera1 said:
How did you create the encrypted partitions? Could you give some pointers for that. I am familiar with using dmcrypt/cryptsetup on desktop linux, I guess this works similar. What are the relevant device names? Did you run into any problems?
Click to expand...
Click to collapse
Hi, sorry for the late answer,
/dev/block/mtdblock5 is the "userdata" partition. I formatted it and mount it to /encrypted-data during init:
mount yaffs2 [email protected] /encrypted-data nosuid nodev
The only file on this partition is "data.encrypted" file, which gets created in init.rc as a loopback device:
exec /system/bin/losetup /dev/block/loop0 /encrypted-data/data.encrypted
I created the "data.encrypted" file on my computer with cryptsetup and losetup, and copied all files from my old unencrypted userdata partition to it and then copied it back as a file to the formated userdata partition.
The sdcard "/dev/block/mmcblk0p2" partition is formated with "cryptsetup luksFormat", I did this also on my computer, saves some time. And then copy everything from the old unencrypted sdcard.
I did run in to one problem recently, my phone hung during boot, about 4 months after I started encrypting my phone.
Had to copy my data.encrypted file to my computer, mount it as a loopback device and do a fsck, and then copy it back to my phone.
I suspect this has to do with the filesystem not being umounted properly. (I have had this on my to do list for a while hehe)
Probably should make a script run during shutdown to cleanly "luksClose" the encrypted partition and then umount them. Not doing this is probably very crazy
I also want to fix it so my "/dev/block/mmcblk0p2" partition gets presented to my computer when i attach my usb cable (as it should do), so i can unlock it in ubuntu and copy images and files. Right now i have to take my memorycard out and put it into the computer.
I hope this post makes sense, it was written in haste =) Good luck!
sigkill1337 said:
Hi, sorry for the late answer,
/dev/block/mtdblock5 is the "userdata" partition. I formatted it and mount it to /encrypted-data during init:
mount yaffs2 [email protected] /encrypted-data nosuid nodev
The only file on this partition is "data.encrypted" file, which gets created in init.rc as a loopback device:
exec /system/bin/losetup /dev/block/loop0 /encrypted-data/data.encrypted
I created the "data.encrypted" file on my computer with cryptsetup and losetup, and copied all files from my old unencrypted userdata partition to it and then copied it back as a file to the formated userdata partition.
The sdcard "/dev/block/mmcblk0p2" partition is formated with "cryptsetup luksFormat", I did this also on my computer, saves some time. And then copy everything from the old unencrypted sdcard.
I did run in to one problem recently, my phone hung during boot, about 4 months after I started encrypting my phone.
Had to copy my data.encrypted file to my computer, mount it as a loopback device and do a fsck, and then copy it back to my phone.
I suspect this has to do with the filesystem not being umounted properly. (I have had this on my to do list for a while hehe)
Probably should make a script run during shutdown to cleanly "luksClose" the encrypted partition and then umount them. Not doing this is probably very crazy
I also want to fix it so my "/dev/block/mmcblk0p2" partition gets presented to my computer when i attach my usb cable (as it should do), so i can unlock it in ubuntu and copy images and files. Right now i have to take my memorycard out and put it into the computer.
I hope this post makes sense, it was written in haste =) Good luck!
Click to expand...
Click to collapse
I figured most of that out without your post and tried it on my desire (I created the luks partitions with adb on the phone though, worked anyway ). Then I couldn't figure out where my regular init.rc is stored (I could only find the one used by Clockwork Recovery), and then I figured I already spent enough time, tried a reboot (which of course didn't work). Then I couldn't even get into recovery (probably because its init.rc tries to mount /data which doesn't work? I didn't investigate any further). Flashed my backup with fastboot and was stuck again with my un-encrypted pre-experiment state
Oddly enough, it was no problem to unlock my encrypted SD-card from my computer (running ubuntu) while in recovery (clockword has an option to present the sd card to a computer connected via usb). Maybe the booted system handles this differently than recovery though? I didn't get a chance to try, as I couldn't boot after my encryption attempt.
I will try again after my algorithm and data structure exam this friday and report back
Is anybody using the UI on another device than the Wildfire? Does it work?
How much is the performance drain when using an encrypted /data partition?
Amazing work!
Did anyone manage to make sigkill1337's luksunlock build from source ?
I would like to change the path of the data/sdcard partitions to match my device but I tried many ways using the NDK and I can't get it to compile properly.
Is there any way to do this ?
I have been trying for days, I am getting literaly insane !
@sigkill1337 : could you give me some pointers ? I would appreciate a lot.
mount manpage said:
The bind mounts.
Since Linux 2.4.0 it is possible to remount part of the file hierarchy somewhere else. The call is
mount --bind olddir newdir
or shortoption
mount -B olddir newdir
or fstab entry is:
/olddir /newdir none bind
After this call the same contents is accessible in two places. One can also remount a single file (on a single file).
This call attaches only (part of) a single filesystem, not possible submounts. The entire file hierarchy including submounts is attached a second place using
mount --rbind olddir newdir
or shortoption
mount -R olddir newdir
Note that the filesystem mount options will remain the same as those on the original mount point, and cannot be changed by passing the -o option along with --bind/--rbind. The mount options can be changed by a separate remount command, for example:
mount --bind olddir newdir
mount -o remount,ro newdir
Click to expand...
Click to collapse
If nothing helps, you should always be able to bindmount it
I'd rather get sigkill1337's UI to compile...
Lots of nice security tweaks and settings could be done with a pre-boot GUI
Anyway, concerning encryption, I'll use the bind option for now, thanks for the tip.
But if anyone here could give me some pointers about compiling this stuff it would be great.
I managed to compile it by integrating luksunlock in Android source externals and main.mk but when I push it to my phone and modify init.rc to call it, it just does not work...
Other modifications are working (mount, mkdir, etc.) but the GUI won't show up
Sorry for the late reply.. But you could try running it from a shell when the phone is booted, just to verify that the binary starts (thats how I tested it without having to reboot my phone all the time)
My environment for building the source was setup using one of the tutorials online, nothing out of the ordinary
Im still running this on my phone, for almost 8 months now, I havent noticed that much in performance problems, the Wildfire was slow before i started using luks.
When i get a new phone (maybe SE Arc) i will be easier to see if performance is affected
There is an Issue for getting CM support for encrypted filesystems during boot:
Issue 2736: support encrypted filesystem from boot
If you want to get that feature, just "star" it, so it may get more attention.

[TOOL] MTD-Utils for Android (incl. nanddump/nandwrite)

I could not find any binaries of the MTD-Utils (a set of useful tools when dealing with flash devices; see http://www.linux-mtd.infradead.org/index.html) for Android so I compiled some Android binaries from the source (http://git.infradead.org/mtd-utils.git).
My main interest was to get the two programs 'nanddump' and 'nandwrite' running on Android which must be used instead of 'dd' when creating images of nand partitions and restoring partitions from these images, because dd does not handle the bad blocks on the nand correctly which could lead to corrupted data.
With these two tools more flexible backup/recovery tools can be implemented since a backup/recovery can be made for every partition available on the device, even those which do not have a readable filesystem, for example the bootloader. Also, for partitions which include a filesystem, but hide some extra data outside that filesystem, this hidden data will also be included in the backup. These raw nand partition images can be tar'd or zip'd to reduce the size of the backup files.
Download: http://www.multiupload.com/5GJLEJNR8M
I do not accept donations, however if you want to make my life easier and thank me for my efforts, please think about signing up for a free SpiderOak account using this refer-a-friend link https://spideroak.com/download/referral/b89974e492728fa6a246880f0b7cbcd5. It is just like Dropbox except you can get up to 50GB of free space and they have a true zero-knowledge policy.
Thanks. I am trying to dump the system partition and restore it to another Android Mobile. Any Hints ? Thanks.
kkkelvinkk said:
Thanks. I am trying to dump the system partition and restore it to another Android Mobile. Any Hints ? Thanks.
Click to expand...
Click to collapse
Dump from one device wont work on other, if they are very similar it has few chances of booting but else it'ld brick if you dont be safe!
Actually, I want to remove some system app and then install other app, and make all configuration. After that, I want to clone this configuration to other mobile device with same model. Do you have any suggestions ?
Thanks.
kkkelvinkk said:
Actually, I want to remove some system app and then install other app, and make all configuration. After that, I want to clone this configuration to other mobile device with same model. Do you have any suggestions ?
Thanks.
Click to expand...
Click to collapse
Ok so you got a phone (model a) and you wanna remove sumtin frm /system/app n add sumtin back n then let some user having the same model a use it
Get root
Install root explorer or any root file explorer
Allow su permissions
Navigate to /system/app and do what you wanted
Then you can dump the /system partition
Kindly give some more info of your device - will help more
And yes also paste the output of "mount" command
I think I can only give more information about the phone after I back to my office.
Actually, I am using System App Remover to remove the System App. It does the job.
Wow can I dump and restore the system partition ? I have tried to use dd command, but it fails. May be nanddump will help, but I cannot find the documentation how to use it. Please help. Thanks.
Is there any way to have nanddump directly send the image to a PC that is running recv_image? I'd like to use nanddump on my Galaxy Nexus, but since it is lacking an SD card, it would seem like writing the nanddump image to the nand would just destroy any possibility of obtaining a clean nand image.
I found a way using netcat...
From host machine in one console window:
Code:
adb.exe forward tcp:5555 tcp:5555
adb.exe shell
# nanddump [options] /dev/mtd/mtd0 | nc -l -p 5555
From host machine in a second console window
Code:
nc 127.0.0.1 5555 > flashdump.bin
So how does nanddump compare with Nandroid, which uses mkyaffs2image to create .img files?
So does n e one a mirror for this??? Multiupload is no good n e more...
Sent from my Hellfire Kindle using xda premium
da-pharoah said:
So does n e one a mirror for this??? Multiupload is no good n e more...
Sent from my Hellfire Kindle using xda premium
Click to expand...
Click to collapse
Per my request, stericson kindly built nanddump and nandwrite into his version of busybox. If you still want Ezekeels's pack, I might still have it around here somewhere.
Maximilian Mary said:
Per my request, stericson kindly built nanddump and nandwrite into his version of busybox. If you still want Ezekeels's pack, I might still have it around here somewhere.
Click to expand...
Click to collapse
Yes please and thank you..
Sent from my Hellfire Kindle using xda premium
da-pharoah said:
Yes please and thank you..
Sent from my Hellfire Kindle using xda premium
Click to expand...
Click to collapse
Nope. I dug through my sdcard and the backups on my computer, and I do not still have it. If you want to contact the OP directly, he is @ezekeel666 on twitter.
Maximilian Mary said:
Nope. I dug through my sdcard and the backups on my computer, and I do not still have it. If you want to contact the OP directly, he is @ezekeel666 on twitter.
Click to expand...
Click to collapse
dirty... and nope also.. I PM'd him and he informed me he deleted all his backups on this....
also try compile, but it hard for me.
all link dead. please, upload mtdutil again.
so I saw that you updated your github!! thanks! now lets see if I can get this sorted and btw if I end up using anything no worries I will give you full credit as usual! Thanks again!
mtd ultil for android
ok guys...
1st: sorry for reviving this topic ...
2nd:here ara the binaries for android: http://goo.gl/eJ8mX
3rd and most importanto to me:
If I do a nandread mtd7 > mtd7.img (in my case the /misc partition) I can do a nandwrite mtd7.img > /dev/mtd/mtd7 without any data corruption ?
I have a lot of backups of many partition except this /misc that in freaking me!
So. Is this a reliablbe backup/restore system ? can I do it with all mtd partition ?
* I tested nandread in qcom msm_7x27 device running android 2.3.6.
shaunco said:
I found a way using netcat...
From host machine in one console window:
Code:
adb.exe forward tcp:5555 tcp:5555
adb.exe shell
# nanddump [options] /dev/mtd/mtd0 | nc -l -p 5555
From host machine in a second console window
Code:
nc 127.0.0.1 5555 > flashdump.bin
Click to expand...
Click to collapse
Or just:
adb shell "nanddump -f - /dev/mtd/mtd0" > mtd0.img
-f - outputs to stdout
Excude the partial OT, but are there any similar tools for MMC flash storage?

[HOWTO] "Partitioning" your Nexus S using LVM

Always wanted a larger /data partition? Want to add a swap partition or an extra partition for your Debian/Ubuntu/Fedora chroot? Want your ROM to have the combined /data and /sdcard of Honeycomb and ICS devices? Then this guide is for you.
Table of contents
This post: background information
(Advanced) users: modifying your phone to use LVM
Developers: adding LVM support to a ROM
Building LVM for Android
The Linux [URL="http://sourceware.org/lvm2/]Logical Volume Manager[/URL] (LVM) is a set of tools which allows you to create virtual disks ("logical volumes", "LVs") backed by a set of real storage devices ("physical volumes", "PVs") organized into "volume groups" ("VGs"). Using LVM, you can:
Create logical volumes which are larger than any of the individual physical volumes available on your device's real storage.
Create an arbitrary number of logical volumes of arbitrary size, regardless of the number of physical volumes or partitions available on your real storage devices. You could, for example, add a dedicated swap partition, or create a separate /system and /data for a dual-boot setup.
Take a snapshot of a logical volume -- a copy of the LV which only stores differences between it and the original (requires additional kernel support). You could, for example, take a snapshot of the external storage LV and export it via USB mass storage to a computer, without needing to unmount the LV from your device.
Grow or shrink logical volumes without unmounting the file system ("online resize", requires filesystem support).
LVM was developed to manage storage on Linux servers and workstations, but was also used by Palm/HP in WebOS devices. It uses the Linux device-mapper technology used in Android for apps installed on the SD card, so any Android kernel will work with LVM.
This guide was developed with the Nexus S in mind, but the technique described should be applicable to many other Android devices as well.
Modifying your phone to use LVM
WARNING WARNING WARNING
While unlikely, you could brick your phone if you do this incorrectly!!!
Read this guide completely before attempting. If you don't understand the procedure, read it again until you do. If you still don't understand, wait for someone else to make this easier. If you're not sure you understand, you probably don't.
BACK UP EVERYTHING ON YOUR PHONE, INCLUDING THE CONTENTS OF /sdcard, BEFORE ATTEMPTING THIS PROCEDURE! This will erase everything on your phone.
The preassembled images attached to this post are for Nexus S GT-i9020T running stock Android 4.0.4 IMM76D ONLY. They may or may not work with other phones and ROMs. (See the next post for how to modify any ROM to use LVM.)
You will need:
A Nexus S with unlocked bootloader
A computer with fastboot and adb installed and working
A USB cable
Factory images for your phone, in case something goes wrong
Procedure:
Take a nandroid backup of your phone and copy it to your computer. We'll use it to restore the ROM later. You MUST copy the backup to your computer! This procedure will erase EVERYTHING on your phone, including the contents of /sdcard.
Download the boot and recovery images attached to this post. Reboot your phone into the bootloader, then flash the recovery to your phone using fastboot:
Code:
fastboot flash recovery recovery-lvm-clockwork-5.0.2.0-crespo.img
(GPL information: this is the stock kernel image from ClockworkMod 5.0.2.0. For LVM source, see this post.)
Boot into recovery.
Enter the shell on the device:
Code:
adb shell
In the shell on the device, do the following (# is your prompt):
Code:
# /lvm/sbin/lvm pvcreate /dev/block/mmcblk0p1 /dev/block/mmcblk0p2 /dev/block/mmcblk0p3
# /lvm/sbin/lvm vgcreate lvpool /dev/block/mmcblk0p1 /dev/block/mmcblk0p2 /dev/block/mmcblk0p3
This marks the partitions normally used for /system, /data, and /sdcard for use with LVM, and creates an LVM volume group named "lvpool" using those devices.
In the shell on the device, set up your desired logical volumes (partitions).
Code:
# /lvm/sbin/lvm lvcreate -L 320M -n system lvpool
# /lvm/sbin/lvm lvcreate -L 1G -n userdata lvpool
# /lvm/sbin/lvm lvcreate -L 10G -n media lvpool
[...]
This creates the mandatory logical volumes named "system", "userdata", and "media", which will be mounted on /system, /data, and /sdcard, respectively. Replace the argument to -L with the desired size of each partition. (/system needs to be at least 300 MB to fit the stock ROM.) You can create additional volumes similarly:
Code:
# /lvm/sbin/lvm lvcreate -L [size] -n [name] lvpool
replacing [size] with the desired size and [name] with the desired name. You have a little less than 15 GB space in the volume group to work with; depending on how many partitions you want to create, you can adjust the size of the "media" and "userdata" logical volumes as required.
Reboot back into recovery. Mount the USB storage on your computer. On your computer, format your phone's USB storage as you would a USB flash drive.
Copy your nandroid backup from your computer onto your phone.
Reboot back into recovery. Restore the nandroid backup.
Reboot into the bootloader. Flash the boot image to your phone via fastboot:
Code:
fastboot flash boot boot-lvm-crespo-IMM76D.img
(GPL information: this is the stock kernel image for IMM76D. Source is available from AOSP git. For LVM source, see this post.)
Reboot. You should have a working device running on LVM.
Additional tips and hints
To see the logical volumes you've created, use
Code:
# /lvm/sbin/lvm lvs
and to see how much free space you have remaining in the volume group, use
Code:
# /lvm/sbin/lvm vgs
If you want to delete a logical volume (for example, if you screwed up), use
Code:
# /lvm/sbin/lvm lvremove /dev/lvpool/name
(replacing "name" with the name of the LV you want to delete).
It's often useful to leave a bit of free space in the volume group (512 MB to 1 GB or so). This gives you a bit more flexibility to modify the layout or grow partitions in the future, and allows you to take snapshots of logical volumes.
Removing LVM from your phone
Flash a standard recovery such as the regular ClockworkMod recovery to your phone.
Do a full wipe/factory reset.
Restore your phone from a backup.
If things go really wrong, flash the factory image to your phone via fastboot.
Modifying an existing ROM to use LVM
(This is a condensed version of the full guide: https://raw.github.com/steven676/android-lvm-mod/master/HOWTO-MOD)
You will first want to grab a copy of the binaries and config files by cloning my git repository: https://github.com/steven676/android-lvm-mod.
Unpack the ramdisks from your boot and recovery images. Make the following changes:
Copy the contents of lvm-bin/ in the git repository to lvm/ in the ramdisks.
Copy devices/crespo/lvm.conf to lvm/etc/lvm.conf in the ramdisks.
For the boot image, integrate the changes in devices/crespo/boot/init.herring.rc-changes.diff into your init.herring.rc.
For the recovery image, integrate the changes in devices/crespo/recovery/init.rc-changes.diff into your init.rc.
For the recovery image, copy devices/crespo/recovery/recovery.fstab to etc/recovery.fstab.
Repack the ramdisks and create new boot and recovery images with them (the original kernels are fine to use).
If creating a flashable zip to install your ROM, you will also want to modify the installer script to set up the LVM volume group and logical volumes (see the previous post).
If you're building your own kernel, consider enabling CONFIG_DM_SNAPSHOT in your kernel's build configuration, to allow taking snapshots of logical volumes.
Remember that LVM is released under the terms of the GPL v2 (same as the Linux kernel), so you are required to comply with the GPL's source distribution requirements with respect to LVM.
More extensive modifications (such as changing the devices used to form the volume group) are possible; see the full HOWTO guide for details.
Building LVM from source for Android
The LVM source was written for standard glibc-based GNU/Linux systems, and doesn't build agains Android libc. We could invest time and effort into porting it to Android, but it's easier to just statically link the LVM binary against glibc (we already have to use a statically linked binary, since the boot image doesn't ship shared libraries).
To build LVM with glibc, you will need either an actual GNU/Linux ARM system with a development environment (gcc, make, and glibc header files) set up, or a GNU/Linux ARM cross-compiler toolchain (more difficult to set up). The binaries in lvm-bin/ were compiled with an Emdebian squeeze/armel toolchain running on a Debian squeeze/amd64 machine; this procedure has also been tested with a Nexus S running a Debian squeeze chroot (though any recent Linux distribution and any device should do). The Linaro prebuilt GCC toolchain and the CodeSourcery CodeBench Lite toolchain for ARM GNU/Linux should work; the Android NDK toolchain will not.
Getting the source
Clone the lvm-mod git repository. Then, in the newly cloned repository, do
Code:
git submodule init
git submodule update
You will have a copy of the LVM source (as used to build the binaries in lvm-bin/) in lvm-src/.
(Alternately, clone https://github.com/steven676/lvm2 and checkout branch android-lvm-mod. You can also use upstream's git repository or source tarballs; see their website for details.)
Building the source
(This is a condensed version of the full guide: https://raw.github.com/steven676/android-lvm-mod/master/HOWTO-BUILD)
These instructions are written for a native build (building in a Debian/Ubuntu/Fedora chroot on an actual ARM device).
Configure the LVM source:
Code:
$ ./configure --prefix=/lvm --enable-static_link --disable-readline \
--disable-selinux --with-pool=none --with-cluster=none \
--with-confdir=/lvm/etc --with-default-run-dir=/data/lvm/run \
--with-default-system-dir=/lvm/etc \
--with-default-locking-dir=/data/lvm/lock \
--with-optimisation="-Os -march=armv5te -mtune=cortex-a8 -mthumb"
For a cross build, you need to set up the system to run ARM binaries using QEMU (see the full HOWTO for details). (For extra credit, fix the build so that it works with the configuration produced by running configure without qemu-arm enabled.) Then configure the source with:
Code:
$ export CC=arm-linux-gnueabi-gcc # replace with your cross compiler
$ ./configure --host=arm-linux-gnueabi \
--prefix=/lvm --enable-static_link --disable-readline \
--disable-selinux --with-pool=none --with-cluster=none \
--with-confdir=/lvm/etc --with-default-run-dir=/data/lvm/run \
--with-default-system-dir=/lvm/etc \
--with-default-locking-dir=/data/lvm/lock \
--with-optimisation="-Os -march=armv5te -mtune=cortex-a8 -mthumb"
Build the source:
Code:
$ make
Grab the pieces you need: the statically linked, unstripped lvm binary is located in tools/lvm.static, and a sample configuration file is in doc/example.conf.
(reserved)
Hello steven676,
This post is helpful to me!
But I have some questions on LVM as I am new to it.
1. Is it possible to use LVM only on one pv, say /sdcard?
2. If 1. yes, will lv's on a pv be linear mapped, that is, lv's in a pv are placed one after one?
3. now that removing lvm is possible, is it also possible to backup lvm setting, and switching between non-lvm and lvm environment?
Thanks
solarispika said:
1. Is it possible to use LVM only on one pv, say /sdcard?
Click to expand...
Click to collapse
Sure. Just modify the arguments to pvcreate and vgcreate accordingly:
Code:
# /lvm/sbin/lvm pvcreate /dev/block/mmcblk0p3
# /lvm/sbin/lvm vgcreate lvpool /dev/block/mmcblk0p3
solarispika said:
2. If 1. yes, will lv's on a pv be linear mapped, that is, lv's in a pv are placed one after one?
Click to expand...
Click to collapse
Probably, but in general it is not safe to assume this. Imagine the following sequence of commands:
Code:
# /lvm/sbin/lvm lvcreate -L 1G -n vola lvpool
# /lvm/sbin/lvm lvcreate -L 1G -n volb lvpool
# /lvm/sbin/lvm lvresize -L +1G /dev/lvpool/vola
What's likely to happen here is that vola is going to be split into two segments on disk, like this:
Code:
[ 1GB vola ][ 1 GB volb ][ 1 GB vola ][ remaining free space ]
There are ways in which you can give LVM hints as to what on-disk layout you want, and the LVM tools will generate information about the current layout in /data/lvm/backup if that directory's available (and mounted read-write) at the time, but in general, it's best to treat the on-disk layout of a logical volume as unknown. In practice, unless you have physical volumes with widely varying characteristics in the same volume group (say, an SSD and some spinning-platter hard disks), you shouldn't need to worry about the actual layout.
solarispika said:
3. now that removing lvm is possible, is it also possible to backup lvm setting, and switching between non-lvm and lvm environment?
Click to expand...
Click to collapse
If /data is mounted read-write, running
Code:
# /lvm/sbin/lvm vgcfgbackup
will create a human-readable backup of the current LVM volume group metadata in /data/lvm/backup (if that directory is available and mounted read-write).
I'm not sure what you mean by "switching" between non-LVM and LVM environments. If you mean going between an unmodified stock boot image and an LVM boot image, the answer is yes, but you won't have access to any of the data in your LVM logical volumes while running an image not configured for LVM, and you need to be careful not to accidentally format the LVM physical volume.
If you're asking about having two or more ROMs on the phone, one installed to the normal /data and /system eMMC partitions, and another on LVM logical volumes, the answer is also yes, but both ROMs will need modified ramdisks. The one for the eMMC-installed ROM should only mount /sdcard from LVM, while the others should be set up to mount /data and /system from LVM as well.
Good write up;-)
wonder if lvm swap could be connected as extra memory .
Sent from my Nexus S using XDA
wizardslovak said:
wonder if lvm swap could be connected as extra memory .
Click to expand...
Click to collapse
Sure, of course. From my phone:
Code:
$ cat /proc/swaps
Filename Type Size Used Priority
/dev/mapper/lvpool-swap partition 65532 28196 -1
It works just fine, even if it's not a setup I'd use on a mission-critical server.
Hey Guys,
Thanks for this awesome guide.
I just have a quick question, what are the advantages of using LVM instead of the normal partitioning?
I just want to know cause i might added to my rom.
Thanks
mandaman2k said:
I just have a quick question, what are the advantages of using LVM instead of the normal partitioning?
Click to expand...
Click to collapse
Primarily flexibility in deciding the number and layout of partitions -- see the first post.
Sounds good . Ill try it once home ;-)
Sent from my Nexus S using XDA
I just pushed a couple of changes:
Updated prebuilt binaries and LVM source to 2.02.96.
Fixed the instructions for cross compiling LVM.
The boot and recovery images attached to the second post have been updated accordingly.
Is this the only way to make the device function like HC/ICS/JB devices that ship with combined storage?
Are the images from Google partitioned with internal/external storage or are the latest images partitioned with a layout similar to the Galaxy Nexus?
CocoCopernicus said:
Is this the only way to make the device function like HC/ICS/JB devices that ship with combined storage?
Click to expand...
Click to collapse
If you want a setup that's exactly as on a 3.0+ device with "SD card" data stored in /data, then yes, this is the only way I know of. If you just want MTP functionality, then no.
CocoCopernicus said:
Are the images from Google partitioned with internal/external storage or are the latest images partitioned with a layout similar to the Galaxy Nexus?
Click to expand...
Click to collapse
Official Google software builds use separate userdata and media partitions and continue to offer the 2.x-style USB mass storage access. I'm not sure the partition layout is adjustable in software -- the eMMC presents an EFI partition layout which no one seems to have figured out how to change.
Cool, thanks. Yea, I'm not too interested in the MTP functionality, I just don't want to deal with internal/external storage after using the Galaxy Nexus.
Swap partiton
Hi..
how i can to create a swap partition of 1G and added to system??
I had create a 1G partition "swap" but system no activated this partition.
xxmurdocxx said:
Hi..
how i can to create a swap partition of 1G and added to system??
I had create a 1G partition "swap" but system no activated this partition.
Click to expand...
Click to collapse
You'd need to format the swap partition:
Code:
# mkswap /dev/lvpool/swap
Also, you need to make sure that your kernel has swap support (CONFIG_SWAP=y -- the default kernel does not have this) and that your init scripts are enabling the swap partition (swapon /dev/lvpool/swap).
One other note: you might find lag to be somewhat severe with a 1 GB swap partition -- I'd suggest smaller.
I'm finally getting around to messing with my NS. From what I understand I can't just modify an existing rom(stock JB in this case) to use the larger partitions without compiling an entire new rom, right?
Which would mean I'd be at the mercy of whoever created the ROM to update when an OTA rolls around?
CocoCopernicus said:
I'm finally getting around to messing with my NS. From what I understand I can't just modify an existing rom(stock JB in this case) to use the larger partitions without compiling an entire new rom, right?
Which would mean I'd be at the mercy of whoever created the ROM to update when an OTA rolls around?
Click to expand...
Click to collapse
No, you can modify an existing ROM yourself. It's most definitely not the simplest process around, though -- see the documentation at the top of the thread for instructions. As I say there ... read thoroughly and understand before attempting.

[GUIDE] Compile CWM Recovery

Hi. I am creating this guide because i did not find any particular functional guide with details.
You must be running a 64 or 32 bit version of Ubuntu. Please note that i wont be going in the details on how to setup a build environment and sync sources as there are many guides for that.
Step 1 :
Install the required packages
Step 2 :
Setup the build environment and sync the sources for the required CWM. CWM source comes bundled with the CyanogenMod source.
Code:
CWM 5 - Gingerbread
CWM 6 - Jellybean
Step 3 :
Now we come to the actuall compiling part. Make sure you have synced the latest source using the "repo sync" command.
Change directory to your source.
Issue this command :
Code:
make -j4 otatools
Step 3.5 :
Do this step if your device is not officially supported by CM10.
Using terminal emulator on your device, issue the command
Code:
dump_image boot /sdcard/boot.img
This will dump the boot image to your sdcard. Transfer it to your home directory.
To build Android from source for a new device, you need to set up a board config and its makefiles. This is generally a long and tedious process. Luckily, if you are only building recovery, it is a lot easier. From the root of your Android source directory (assuming you've run envsetup.sh), run the following (substituting names appropriately):
Code:
build/tools/device/mkvendor.sh device_manufacturer_name device_name /your/path/to/the/boot.img
For example if you are having the Samsung Galaxy Ace device, the command will go as follows :
Code:
build/tools/device/mkvendor.sh Samsung cooper ~/boot.img
Please note that Cooper is the device name. Only use "~/boot.img" if you have the boot image in your home directory. Or else please specify the correct path.
You will receive the confirmation "Done!" if everything worked. The mkvendor.sh script will also have created the following directory in your Android source tree:
manufacturer_name/device_name
Step 3.5 ends here.
Step 4 :
Now that you have the device config ready, proceed.
Type the following code in your terminal in the source directory.
Code:
. build/envsetup.sh
This will setup the build environment for you to work.
Now launch the command
Code:
lunch full_device_name-eng
This will set the build system up to build for your new device. Open up the directory in a file explorer or IDE. You should have the following files: AndroidBoard.mk, AndroidProducts.mk, BoardConfig.mk, device_.mk, kernel, system.prop, recovery.fstab, and vendorsetup.sh.
The two files you are interested in are recovery.fstab and kernel. The kernel in that directory is the stock one that was extracted from the boot.img that was provided earlier. For the most part, recovery.fstab will work on most devices that have mtd, emmc, or otherwise named partitions. But if not, recovery.fstab will need to be tweaked to support mounts and their mount points. For example, if your /sdcard mount is /dev/block/mmcblk1p1, you would need the following lines in your BoardConfig.mk
/sdcard vfat /dev/block/mmcblk1p1
Once the recovery.fstab has been properly setup, you can proceed to the next step.
Step 5 :
Now we build the actual recovery.
Code:
make -j4 recoveryimage
This command builds the recovery image
You can use the command
Code:
make -j4 recoveryzip
to make a fakeflash recovery i.e. a temporary recovery to test out on the actual device.
Your recovery can then be found at "your_source_directory/OUT/target/product/device/recovery.img" and the temporary fakeflash zip in the utilities folder at the same location.
If everything works out well, you will have a working recovery.
Once you have working builds, notify "koush", on Github and he can build official releases and add ROM Manager support!
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Some tips :
If you want to compile CWM 6, sync the jellybean branch using the command :
Code:
repo init -u git://github.com/CyanogenMod/android.git -b jellybean
repo sync
If you want to compile CWM 6 on a 32 bit system, you need to sync THIS source too. Instructions are given in the readme.
Run "make clobber" between builds if you change the BoardConfig.mk, or the change will not get picked up.
Credits :
Koush for this guide.
Nice.
Will come in handy
Excellent guide!
Thanks!
I will try on my Motorola PRO+, wish me luck
any ideeas how i can make the recovery font smaller? i read somewhere that i have to edit ui.c file, but what syntax? thanks
thank you for this
i will try to compile this
i tried before using koush online builder but the cwm has bugs.
Okay, I'm problly stupid, but.
repo init -u git://github.com/CyanogenMod/android.git -b jellybean
seems to work fine, but
repo sync does this:
Code:
fatal: '../CyanogenMod/android_abi_cpp.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
error: Cannot fetch CyanogenMod/android_abi_cpp
What did I screw up, or not have prepared correctly?
I have built AOSP and currently build kernels on this box, so I know git and all that is setup correctly.
D
.
edited
Got it. Needed an updated repo script.
D
.
what's this ?
shaaan said:
Hey guys, i present to you a new updated version of CyanogenMod Recovery a.k.a CWM 6.0.1.3. The current version that we use is 5.0.2.6
Edit : As you guys know, i bricked my ace while trying to get CWM working. The bootloader is lost. So there is no way i can get it working back. This is the end of developing for me for now atleast. I will have to replace the motherboard or get a new device. Any dev wanting to take over the project, please feel free. Contact me for help and i will try my best. But if you use my sources, please give credits to me and TeamCooper.
My sources are here.
Edit : You can refer my guide on compiling a recovery here.
Click to expand...
Click to collapse
now afraid to do it on my own
So you copy pasted a guide (and linked it in the end), and then you say you can't find any other guide.
Orelly?
Can jou tell a bit more about run "envsetup.sh"thats what i mis in this guide and the original guide. and most other guides.
The file "dump_image" needs to be placed on the phone. Can be put on the sd of the phone and than place on a place you like.(Folder bin/xbin ore some other) Use terminal on the phone. (any from google store play) cd to the dir the dump_image is than run the command.
How do i find the device name for my phone/tablet. I know the name of the tablet i bought.. But still. samsung ace hase device name cooper? Where did you find it?
Thx by the way. This guide is a bit more clear than the original.
the device name is in build.prop
[email protected] said:
Can jou tell a bit more about run "envsetup.sh"thats what i mis in this guide and the original guide. and most other guides.
The file "dump_image" needs to be placed on the phone. Can be put on the sd of the phone and than place on a place you like.(Folder bin/xbin ore some other) Use terminal on the phone. (any from google store play) cd to the dir the dump_image is than run the command.
How do i find the device name for my phone/tablet. I know the name of the tablet i bought.. But still. samsung ace hase device name cooper? Where did you find it?
Thx by the way. This guide is a bit more clear than the original.
Click to expand...
Click to collapse
dump_image would be on the phone, it was for MTD devices now a days ytou want to use DD on mmcblk devices
i solved the font problem, you need to edit the Anndroid.mk from bootable/recovery, but now i got messed up Graphics in the recovery and i cannot boot back into the OS. ideeas? thanks
PS: i think that the graphics.c may be the problem. but for booting, i really have no clue.
This will give you a non touch version of CWM
Any idea if the touch modifications are also available opensource to modify code?
Not yet. But finding it. Once I get it working, will add it to the op.
Thx for the answar on my question.:good:
I have a nother question:silly: For example, my recovery.fstab hase: /sdcard mount is /dev/block/mmcblk1p1
What lines do i ad in my BoardConfig.mk:
? what is here? /sdcard vfat /dev/block/mmcblk1p1
just adding /sdcard vfat /dev/block/mmcblk1p0 does not seem to work..
my recovery.fstab:
# mount point fstype device [device2]
/boot mtd boot
/cache yaffs2 cache
/data yaffs2 userdata
/misc mtd misc
/recovery mtd recovery
/sdcard vfat /dev/block/mmcblk0p1 /dev/block/mmcblk0
/system yaffs2 system
/sd-ext ext4 /dev/block/mmcblk0p2
My vold.fstab hase:
# External NAND Storage
dev_mount sdcard /mnt/sdcard auto /devices/virtual/block/ndda
# External SD card
dev_mount ext_sd /mnt/ext_sd auto /devices/platform/tcc-sdhc
# External USB storage
dev_mount usb_sda /mnt/usb_sda1 all /devices/platform/dwc_otg /devices/platform/tcc-ohci /devices/platform/tcc-ehci
dev_mount usb_sdb /mnt/usb_sdb1 all /devices/platform/dwc_otg /devices/platform/tcc-ohci /devices/platform/tcc-ehci
Some other info i found..:
/dev/block/platform/tcc-sdhc0.0/mmcblk0
if i use mount in terminal i get this:
/dev/block/vold/179:0 /mnt/ext_sd vfat ...
/dev/block/vold/240:0 /mnt/sdcard vfat ...
cat /proc/mtd
geeft:
dev: size: erasersize: name:
mtd0 00a00000 00100000 ¨boot¨
mtd1 00500000 00100000 ¨kpanic¨
mtd2 12c00000 00100000 ¨system¨
mtd3 00400000 00100000 ¨plash¨
mtd4 09600000 00100000 ¨cache¨
mtd5 40000000 00100000 ¨userdata¨
mtd6 00a00000 00100000 ¨recovery¨
mtd7 00100000 00100000 ¨misc¨
mtd8 00100000 00100000 ¨tcc¨
partitions /proc/partitions:
major: minor: #blocks name:
7 0 16664 loop0
31 0 10240 mtdblock0
31 1 5120 mtdblock1
etc/ sow on
179 0 15339520 mmcblk0
240 0 2392064 ndda
240 1 2392064 ndda1
240 0 16663 dm-0
My boot.img files on github. + some adding ...(/device/YG/m805_892x) https://github.com/Frank77GLD/Telechip_tcc892x
(just testing a github for fun...)
Hope you could give me some advice?
can someone please make an english working cwm for samsung galaxy young cdma ich-509 please?
Porting to a new "unknown" device
Hi folks. I`m trying to start to develop some stuff to an chinese tablet and, of course, my first need is the cmw ...
Then. I only can have it using the fakeflash method(locked bootloader). My problem that it`s kinda new stuff to me.
I have some files built by utkanos to start the job. But now I dont know where to go to ...
Theere appears do be no documentation in what files in what folders I have to edit/add to get it fully functional.
When i flash the zip and the cwm load there`s no partition table. It loads a lot of errors on the screen saying no /dev/block* ...
I little help will be much appreciated here. Even just a start point .. anything that can help!

[vision][fried emmc] Booting CM 7.2 from SD card

Hi there,
I just found catherall's thread on [how to boot CM 7.1 from the external SD card][0] on a Desire Z/G2 with the infamously fried eMMC.
I used his instructions to boot CM 7.2 (the last stable version for the Vision); since the above thread ends with a dangling question on how to update the system to be booted, I thought I'd document my efforts.
anonymousthing said:
anybody know what system.img format he is using?
Click to expand...
Click to collapse
It's just an ext4 file system:
Code:
$ file system.img
system.img: Linux rev 1.0 ext4 filesystem data, UUID=b4db3ed8-7d52-46a0-85fb-46fb67c5e837 (needs journal recovery) (extents) (huge files)
$ adb shell
~ # mount | grep system
/dev/block/loop0 on /tmp/boot.img-ramdisk/system type ext4 (rw,nodev,noatime,nodiratime,nouser_xattr,commit=19,barrier=0,data=ordered)
Disclaimer: On the original image, `file` actually identifies the FS as a `mounted or unclean` ext2; it's definitely an ext4 with journaling, though. Accordingly a `mount -t ext2` will fail with a `wrong fs type`.
You can create a new one with
Code:
$ dd if=/dev/zero of=system.img bs=4k count=64000
$ /sbin/mkfs.ext4 system.img
# mount -o loop -t ext4 system.img /media/new_sys
anonymousthing said:
I have tried making my own system.img from the rom but it does not work
Click to expand...
Click to collapse
This is potentially due to missing binaries:
Code:
$ diff -r /media/orig_sys update-cm-7.1.0-vision-signed/system | head -n 5
Only in /media/orig_sys/bin: cat
Only in /media/orig_sys/bin: cmp
Only in /media/orig_sys/bin: date
Only in /media/orig_sys/bin: dd
Only in /media/orig_sys/bin: dmesg
If you download a version of CM, at least the `toolbox` and the `busybox` binaries will be missing from the `system/bin` and `system/xbin` directories respectively. I couldn't be bothered to check for up-to-date versions but just copied the ones provided by catherall before copying over the new CM version:
Code:
# cp -r /media/orig_sys/bin /media/orig_sys/xbin /media/new_sys
# cp -r cm-7.2.0-vision/system/* /media/new_sys
This will obviously update all the files that come with CM 7.2 and just keep what's not included in the box.
While you're at it, you might want to add up-to-date gapps:
Code:
# cp -r gapps-gb-20131214-signed/system/* /media/new_sys
This gives you a booting CM 7.2. Just replace the `system.img` that comes with catherall's `.zip` with the one you just created and off you go
Unpleasant issue: Booting from SD seems to require a specifically prepared kernel, so the `boot.img` that comes with a different ROM/CM version won't work. So until someone finds out how to prepare a kernel for booting from SD, you will have to continue to boot the one provided by catherall. However, the WIFI driver has not been compiled into the kernel but lives in a separate kernel module in `/system/lib/modules/bcm4329.ko`. Which we (by copying over the `/system` dir from the CM 7.2 build) replaced with a version incompatible with the old kernel we have to boot. So if you intend to boot through `fastboot` and use WIFI (and why wouldn't you? ;P), we will have to put the old kernel module back:
Code:
# cp /media/orig_sys/lib/modules/bcm4329.ko /media/new_sys/lib/modules/
Weirdly enough, in the CM 7.2 version I downloaded, the permissions for the `dhcpd-run-hooks` script were broken, so I at least needed to fix those too:
Code:
# chmod 550 /media/new_sys/etc/dhcpd/dhcpd-run-hooks
So, `umount` your pristine new `system.img`, move it to your SD card and boot into CM 7.2.
HTH
D.
PS I naively tried to create a larger 1 GB `data.img`, copying over the content from the existing one, but the phone didn't boot with that one. I might have made a mistake (was rather late at that point -.- and I didn't investigate any further), but it seems like the size of the partitions may be hardcoded somewhere. If someone has any additional information, please let me know Thx!
PPS If anyone ([MENTION]@catherall[/MENTION]? ;P) knows anything about the kernel issue, I'd be highly interested
PPPS After creating this account (to be fair, I've been profiting from this community since the old Windows Mobile days), I was informed that as an account noob, I obviously didn't have anything to contribute to this community and was ordered to place my undoubtedly profane question (which certainly had been answered may times before, I was only too lazy/dumb to search) outside the elite developer forums [/rage]. Maybe one of the Mods can stitch the [original thread][0] and this st0pid workaround back together again? :/ Thanks!
[0]: http://forum.xda-developers.com/showthread.php?t=1572924

Categories

Resources