顯示具有 android 標籤的文章。 顯示所有文章
顯示具有 android 標籤的文章。 顯示所有文章

2013年7月9日 星期二

Change system partition size of Android emulator


emulator -avd MyAndroid -partition-size 128 -no-snapshot-load

2012年11月23日 星期五

How "mtdparts=" Kernel Command Line Work in Nexus One

I am just wondering how it works.
And...source code is your answers.

I clone kernel source from cm-kernel
https://github.com/CyanogenMod/cm-kernel.git
branch: android-msm-2.6.37

  1. arch/arm/mach-msm/nand_partitions.c:
    Extract partition information from ATAG setup by boot loader.

    static int __init parse_tag_msm_partition(...)

    {
        ....
        msm_nand_data.nr_parts = count;
        msm_nand_data.parts = msm_nand_partitions;

        return 0;
    }


    This puts partition information into flash_platform_data

  2. drivers/mtd/devices/msm_nand.c  (msm nand flash controller driver)

    // request to use cmdlinepart parser
    static const char *part_probes[] = { "cmdlinepart", NULL,  };
    ...
    static int __devinit msm_nand_probe(struct platform_device *pdev)
    {
        ...
    #ifdef CONFIG_MTD_PARTITIONS
        err = parse_mtd_partitions(&info->mtd, part_probes,    
                                   &info->parts, 0);

        // if kernel command line has partition information, use it!
        if (err > 0)
            add_mtd_partitions(&info->mtd, info->parts, err);
        else if (err <= 0 && pdata && pdata->parts) {
            // else use partition information from boot loader
            for (i = 0; i < pdata->nr_parts; ++i) {
                pdata->parts[i].offset *= info->mtd.erasesize;
                pdata->parts[i].size *= info->mtd.erasesize;
            }
            add_mtd_partitions(&info->mtd,
                               pdata->parts, pdata->nr_parts);
        } else
    #endif
            err = add_mtd_device(&info->mtd);
    }

2012年7月18日 星期三

Android: modify partition layouts

Storage is never enough!
Fortunately, we can pass partition layouts via kernel command line without kernel modification.
lbcoder, Thanks for post this! Custom partition layouts, ZERO brick risk!

My Nexus One default partition layouts:

# cat /proc/mtd
dev:    size   erasesize  name          size
mtd0: 000e0000 00020000 "misc"          896K
mtd1: 00400000 00020000 "recovery"      4M
mtd2: 00380000 00020000 "boot"          3M
mtd3: 09100000 00020000 "system"        145M
mtd4: 05f00000 00020000 "cache"         95M
mtd5: 0c440000 00020000 "userdata"      196M

# msm_nand MTD info during kernel booting
[   13.353302] msm_nand: DEV_CMD1: f00f3000
[   13.357299] msm_nand: NAND_EBI2_ECC_BUF_CFG: 1ff
[   13.361724] Creating 6 MTD partitions on "msm_nand":
[   13.366790] 0x000003ee0000-0x000003fc0000 : "misc"
[   13.373260] 0x000004240000-0x000004640000 : "recovery"
[   13.381561] 0x000004640000-0x0000049c0000 : "boot"
[   13.386108] 0x0000049c0000-0x00000dac0000 : "system"
[   13.538635] 0x00000dac0000-0x0000139c0000 : "cache"
[   13.637023] 0x0000139c0000-0x00001fe00000 : "userdata"
 
cache partition is too large to me.
I would like to change partition layouts to

dev:    size   erasesize  name          size
mtd0: 000e0000 00020000 "misc"          896K
mtd1: 00400000 00020000 "recovery"      4M
mtd2: 00380000 00020000 "boot"          3M
mtd3: 09100000 00020000 "system"        145M
mtd4: 02800000 00020000 "cache"         95M->40M
mtd5: 0FB00000 00020000 "userdata"      196M->251M

userdata partition up to 251M!

So, I need add kernel command line like below
mtdparts=msm_nand:896k@0x3ee0000(misc),4M@0x4240000(recovery),3M@0x4640000(boot),145M@0x49c0000(system),40M@0xdac0000(cache),251M@0x102C0000(userdata)
But how?
I do it manually. We need to modify both recovery and boot images.
  1. Boot to recovery mode
  2. Extract recovery image from recovery partition and use hex editor to add kernel command line into recovery image
  3. Flash back modified recovery image then boot to recovery again
  4. Check MTD information, we are done.
    [    9.726074] msm_nand: DEV_CMD1: f00f3000
    [    9.726257] msm_nand: NAND_EBI2_ECC_BUF_CFG: 1ff
    [    9.726440] 6 cmdlinepart partitions found on MTD device msm_nand
    [    9.726684] Creating 6 MTD partitions on "msm_nand":
    [    9.726837] 0x000003ee0000-0x000003fc0000 : "misc"
    [    9.728668] 0x000004240000-0x000004640000 : "recovery"
    [    9.733581] 0x000004640000-0x000004940000 : "boot"
    [    9.737548] 0x0000049c0000-0x00000dac0000 : "system"
    [    9.893493] 0x00000dac0000-0x0000102c0000 : "cache"
    [    9.937652] 0x0000102c0000-0x00001fdc0000 : "userdata"
     
  5. Flash zip from SD (I use CM7.2)
  6. Extract boot image from boot partition and use hex editor to add kernel command line into boot image
  7. Flash back modified boot image then reboot
  8. Boot to CM, then check MTD information.

2011年4月4日 星期一

Build Cyanogenmod on Fedora 14 X86_64

Can build Cyanogenmod for N1 now!
Next step...understand android build system and how to customize.

ps:
Can also try to build for emulator~~
Compile CyanogenMod for Emulator