Skip to content

Commit

Permalink
aw3som3: hax the partition table!
Browse files Browse the repository at this point in the history
Developers have long tried to sqeeze in ROMs into legacy
devices with low internal memory, and one of the ways to
do this was by using custom tailored mtd_parts, which
gave the kernel a partition table to use, with resized
partitions. This was widely used on many devices like
the HTC G1, MT3G, Hero, Evo4G, Desire, etc.

While that was a viable option for the HTC Pico, a small
"problem" that popped up was that different phones have
different NAND Devices, with different partition tables
and pagesizes. Incase the modified custom mtd_parts even
*accidentally* touched the boot partition, or has been
offset'ed out of the available space, a partition would
be *lost*.

As a solution, dynamically obtain 32 mB from userdata
partition, and 48 mB from the cache partition, and hax
the partition table as soon as the information is got
from ATAG. This should make this method work on *almost*
all Pico's out there, which have partition layouts as
misc:recovery:boot:system:cache:userdata:devlog and
partitions in the order misc:rec..cache:devlog:userdata.

Enable PICO_NAND_RESIZE_PART in defconfigs.

PS1: initial, add logging
PS2: add the hax
PS3: remove logging from mtdpart.c
PS4: remove notes for self
PS5: whitespace fix
PS6: unbloat code
PS7: unbloat code (again)
PS8: Add KConfig option

Change-Id: I2d1eefa72ded09cf48b8f649da812c4d4a5ffb15
Signed-off-by: Vineeth Raj <contact.twn@opmbx.org>
  • Loading branch information
Vineeth Raj committed Jun 30, 2014
1 parent a3756b2 commit f78b034
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
10 changes: 10 additions & 0 deletions arch/arm/mach-msm/Kconfig
Expand Up @@ -315,6 +315,16 @@ config MACH_PICO
help
Support for Pico (PDA phone).

config PICO_NAND_RESIZE_PART
depends on MACH_PICO
bool "Repartition NAND Devices on Pico"
default n
help
dynamically resize the system partiton by obtaining
32 mB from userdata partition, and 48 mB from the
cache partition, and hax the partition table as soon
as the information is got from ATAG.

config MACH_GOLFU
depends on ARCH_MSM7X27A
depends on !MSM_STACKED_MEMORY
Expand Down
13 changes: 13 additions & 0 deletions arch/arm/mach-msm/nand_partitions.c
Expand Up @@ -5,6 +5,7 @@
*
* Copyright (C) 2007 Google, Inc.
* Copyright (c) 2008-2009, Code Aurora Forum. All rights reserved.
* Copyright (c) 2014, Vineeth Raj <contact.twn@opmbx.org>.
* Author: Brian Swetland <swetland@google.com>
*
* This software is licensed under the terms of the GNU General Public
Expand Down Expand Up @@ -86,6 +87,18 @@ static int __init parse_tag_msm_partition(const struct tag *tag)
msm_nand_data.nr_parts = count;
msm_nand_data.parts = msm_nand_partitions;

#ifdef CONFIG_PICO_NAND_RESIZE_PART
#define PICO_PART_BOOT 2
unsigned one_mb = 0;
for (one_mb = 0, n = 0; n < msm_nand_partitions[PICO_PART_BOOT].size; one_mb++, n+=4) ;
msm_nand_partitions[PICO_PART_BOOT + 2].size -= (48 * one_mb);
msm_nand_partitions[PICO_PART_BOOT + 3].size -= (32 * one_mb);
msm_nand_partitions[PICO_PART_BOOT + 1].size += (80 * one_mb);
msm_nand_partitions[PICO_PART_BOOT + 2].offset = msm_nand_partitions[PICO_PART_BOOT + 1].offset + msm_nand_partitions[PICO_PART_BOOT + 1].size;
msm_nand_partitions[PICO_PART_BOOT + 4].offset = msm_nand_partitions[PICO_PART_BOOT + 2].offset + msm_nand_partitions[PICO_PART_BOOT + 2].size;
msm_nand_partitions[PICO_PART_BOOT + 3].offset = msm_nand_partitions[PICO_PART_BOOT + 4].offset + msm_nand_partitions[PICO_PART_BOOT + 4].size;
#endif

return 0;
}

Expand Down

0 comments on commit f78b034

Please sign in to comment.