Jump to content

Q&A regarding gellmar's notes on E400 development


Guest crazybyte

Recommended Posts

Guest crazybyte

Do you think it's possible to join two consecutive partitions mmcblk0p20 and mmcblk0p21 in one mounted to /data? I think that i'd be a good idea to have 1GB for apps and leave the microsd slot for "external" /sdcard storage. I did it before myself without joining it (i did with dirty init.rc scripts) because i was scared of bricking my device if i change the number of partitions.

Link to comment
Share on other sites

Guest gellmar

I had such idea long ago, but I need to explore the bootloader code. Maybe we should leave number of partitions intact but the size of /data is to be adjusted to a bare possible minimum ext4 allows.

Link to comment
Share on other sites

Guest viking_kong

wow!new development is here.uhm,can i request something about cm9?what i hate about cm9 is the unstable battery percentage.when you reboot or turn it off,later when you turn it on again,the battery sometimes increases or decreases like hell.that's so annoying.the battery percentage is really unstable.unlike in stock.you reboot or turn it off and on,the battery level is stable.stays the same or only drops 1%.is there any fix for that issue?i'm starting to love cm9 especially now that the usb mass storage is now working.no need to go to cwm.hehe.thanks!

Link to comment
Share on other sites

Guest crazybyte

I had such idea long ago, but I need to explore the bootloader code. Maybe we should leave number of partitions intact but the size of /data is to be adjusted to a bare possible minimum ext4 allows.

You could format the 1GB partition as EXT4 and mount in init.rc. What i did was:

1. Format 1gb partition to EXT4.

2. Write code for mounting it in init.rc as /data (runs in linux before android core startup)

3. Swap the internal emmc and the external sdcard device in fstab.vold (that makes android core to recognise the 1GB ext partition as secondary external storage and sdcard as primary sdcard that it's what we want)

The third step it's here for avoiding mounting errors in the notification bar. If Android framework detects an error while mounting the primary external storage it will show a error message asking to format the sdcard, also some apps like Gallery, will crash as they're using getExternalStorage() method which returns null if not available, BUT if the mounting error happens on the external storage partition android just ignore it and even don't show anything.

If only we could disable in the kernel the external storage option this dirty fix could be enough to achieve 1 gb of internal storage for apps and sdcard for external.

If you know how to do this in the kernel, i will help you with the rest.

Link to comment
Share on other sites

Guest gellmar

Ygreck, try changing only framework-res but not boot.img

crazybyte, the issue is about vold rather and storage_info.xml inside the framework-res.apk, but let me check your scenario. Can you PM your init.rc?

Here's what I plan to check:

1. The hecatae's swap scenario: format /dev/block/mmcblk0p20 as ext2fs and /dev/block/mmcblk0p21 as vfat, change the mtd@ mapping, leave init.rc intact to get sdcard of 157 MB and /data of 1 GB. This can eliminate the need to patch the kernel / bootloader.

2. If it works (and I think it works), investigate bootloader parts for partition table. If nothing, fdisk /dev/block/mmcblk0 and delete /data/ and /sdcard partitions and make a new one of 1.157 MB ext2fs, then change vold.fstab and recovery.fstab and disable the sd-ext in storage_info.xml and anywhere else (this is your question whether it needs to be disabled inside kernel some way)

About getExternalStorage() mess, it relies on kernel's sdcard mapping - now the mapping shows ext-sd as external, but if there is no ext-sd, the code will return the only sdcard as external, emulating the sdcard-less devices...

I am inspecting kernel sources for mmcblk0 - found in devices documentation and in lge/factory/lge_emmc_direct_access.c

The very interesting file is that direct access stuff... there are some hardcoded offsets for MBR/EBR and the names of all partitions :) I should deep into it and update the /dev/block post first.

Edited by gellmar
Link to comment
Share on other sites

Guest crazybyte

Ygreck, try changing only framework-res but not boot.img

crazybyte, the issue is about vold rather and storage_info.xml inside the framework-res.apk, but let me check your scenario. Can you PM your init.rc?

Here's what I plan to check:

1. The hecatae's swap scenario: format /dev/block/mmcblk0p20 as ext2fs and /dev/block/mmcblk0p21 as vfat, change the mtd@ mapping, leave init.rc intact to get sdcard of 157 MB and /data of 1 GB. This can eliminate the need to patch the kernel / bootloader.

2. If it works (and I think it works), investigate bootloader parts for partition table. If nothing, fdisk /dev/block/mmcblk0 and delete /data/ and /sdcard partitions and make a new one of 1.157 MB ext2fs, then change vold.fstab and recovery.fstab and disable the sd-ext in storage_info.xml and anywhere else (this is your question whether it needs to be disabled inside kernel some way)

About getExternalStorage() mess, it relies on kernel's sdcard mapping - now the mapping shows ext-sd as external, but if there is no ext-sd, the code will return the only sdcard as external, emulating the sdcard-less devices...

I am inspecting kernel sources for mmcblk0 - found in devices documentation and in lge/factory/lge_emmc_direct_access.c

The very interesting file is that direct access stuff... there are some hardcoded offsets for MBR/EBR and the names of all partitions :) I should deep into it and update the /dev/block post first.

You're forgetting a step. If you change the partition layout you have to rebuild the recovery, otherwise when it will try to mount /data for installing a rom it will fail.

In the other hand what you says about getExternalStorage() it's true, that it's what i said that we have to "remove" the sd-ext option. I forgot a step my init.rc script relies on the previous format in the rom install script of the 1gb partition, saddly i removed the rom because it was unusable on my girlfriend phone because the charger and sudden reboot bugs... That was a pity because i never tought that somebody would fix it. :/

I can ask him to give me the phone leting me to "build" the modded rom again.

PS: Sorry about my English, i'm from Spain, i'm trying to do my best :)

Link to comment
Share on other sites

Guest gellmar

crazybyte, you are right about recovery. But I think I found the routine lge_mmc_scan_partitions with the list. Now trying to get a print from it

Link to comment
Share on other sites

Guest crazybyte

Watch out about changing the number of partitions(because if we mess the bootloader we will brick the device you already know!), we could do a first approach mounting only the bigger one and leaving the remaining intact.

Edited by crazybyte
Link to comment
Share on other sites

Guest gellmar

crazybyte, the hack works if make a correct combination of vold.fstab + storage_info.xml + build.prop. And of course recovery.fstab and init.rc. Let me show the screenshots.

But I need the dump of stock MBR because I was a dumb :(


su

dd if=/dev/block/mmcblk0 of=/mnt/sdcard/mbr.bin bs=1024 count=100

post-994615-0-77949400-1363211678.png

post-994615-0-74113600-1363211680.png

post-994615-0-84401000-1363211684.png

Edited by gellmar
Link to comment
Share on other sites

Guest crazybyte

That's cool, tomorrow at sunrise i will upload the mbr. Sorry about this but i my girlfriend now have the stock rom and i have to root it and i deleted the drivers from my pc hehe.

EDIT: Backup your MBR maybe it's easier to install in a script this patch. We can add to the install script some steps like 1. DD the new mbr, 2. Reload partition table 3. Format new partitions 4. Mount partitions and install. It should work because the start and the ends of the remaining partitions matches the original.

Edited by crazybyte
Link to comment
Share on other sites

Guest gellmar

crazybyte, thanks - but looks like mine and yours are identical. It means that MBR (the first part) is identical as expected and where is EBR - I need to reveal. Think we need an sfdisk command line tool to handle re-partitioning with partition lists from within script.

UPDATE: Grab file sfdisk from https://github.com/o...-arm/bin/sfdisk (it is a stripped static build for armv7l), place it to /system/bin/, assign 755 permissions and as root run:


/system/bin/sfdisk -d /dev/block/mmcblk0 > /sdcard/mmcblk0_stock.txt

and post a zipped file here. The best bet of sfdisk is that we can dump and restore the partition table in command-line with

sfdisk -d /dev/block/mmcblk0 > mmcblk0_merge.txt

and

cat mmcblk0_merge.txt > sfdisk /dev/block/mmcblk0

Edited by gellmar
Link to comment
Share on other sites

Guest gellmar

It works, but fdisk does not allow to set non cylinder-boundary layout... So I guess we need a rooted but stock phone or at least a phone with recovery installed.

UPDATE: Stock KDZ reflasher rewrites partition table back so we can revert the mod by KDZ or from recovery if we have a full dump.

Edited by gellmar
Link to comment
Share on other sites

Guest crazybyte

It works, but fdisk does not allow to set non cylinder-boundary layout... So I guess we need a rooted but stock phone or at least a phone with recovery installed.

Don't worry as i said this morning i rooted my girlfriend's phone and i gave you the mbr. Tomorrow you will have the stock partition layout. Using fdisk you could check in the install script if the device already has correct partition layout by counting the number of partitons. Maybe another user could do the same job if youre free to work now, if not we will have to wait until i see her.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.