OpenWrt Forum Archive

Topic: Chaning the MTD partition sizes

The content of this topic has been archived on 13 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hey all, I'm hoping someone can point me in the right direction.

I'm starting with a TP-LINK MR-3220.  I'm trying to change the size of the MTD partitions because I need more kernel space and less rootfs space for my particular build.  In the code below I'm trying to move 0x20000 from rootfs to the kernel.  So far I've...

1. Edited the mktplinkfw.c file and changed

 
{
    .id             = "TL-MR3220v1",
    .hw_id          = HWID_TL_MR3220_V1,
    .hw_rev         = 1,
    .fw_max_len     = 0x3c0000,
    .kernel_la      = 0x80060000,
    .kernel_ep      = 0x80060000,
    .rootfs_ofs     = 0x160000, // was 0x140000
}, {

2. edited target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-mr3x20.c and changed:

static struct mtd_partition tl_mr3x20_partitions[] = {
        {
                .name           = "u-boot",
                .offset         = 0,
                .size           = 0x020000,
                .mask_flags     = MTD_WRITEABLE,
        }, {
                .name           = "kernel",
                .offset         = 0x020000,
                .size           = 0x160000, //was 0x140000
        }, {
                .name           = "rootfs",
                .offset         = 0x180000, //was 0x160000
                .size           = 0x270000, //was 0x290000
        }, {
                .name           = "art",
                .offset         = 0x3f0000,
                .size           = 0x010000,
                .mask_flags     = MTD_WRITEABLE,
        }, {
                .name           = "firmware",
                .offset         = 0x020000,
                .size           = 0x3d0000,
        }
};

3. rebuild openwrt using make.

When load the factory.bin on to the router I see:

spi0.0: no WRT160NL signature found
Creating 5 MTD partitions on "spi0.0":
0x000000000000-0x000000020000 : "u-boot"
0x000000020000-0x000000160000 : "kernel" <<----- should be 0x20000 - 0x180000
0x000000160000-0x0000003f0000 : "rootfs"
mtd: partition "rootfs" set to be root filesystem
split_squashfs: no squashfs found in "spi0.0"  <<----- NOT GOOD
0x0000003f0000-0x000000400000 : "art"
0x000000020000-0x0000003f0000 : "firmware"
ag71xx_mdio: probed
eth0: Atheros AG71xx at 0xba000000, irq 5
eth0: Found an AR7240 built-in switch
eth1: Atheros AG71xx at 0xb9000000, irq 4
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
ar71xx-ehci ar71xx-ehci: Atheros AR91xx built-in EHCI controller
ar71xx-ehci ar71xx-ehci: new USB bus registered, assigned bus number 1
ar71xx-ehci ar71xx-ehci: irq 3, io mem 0x1b000000
ar71xx-ehci ar71xx-ehci: USB 2.0 started, EHCI 1.00
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
usbcore: registered new interface driver ums-freecom
usbcore: registered new interface driver ums-usbat
Atheros AR71xx hardware watchdog driver version 0.1.0
TCP westwood registered
NET: Registered protocol family 17
802.1Q VLAN Support v1.8 Ben Greear <greearb@candelatech.com>
All bugs added by David S. Miller <davem@redhat.com>
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000000: 0x8af1 instead <<---- NOT GOOD either
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000004: 0x13ff instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000008: 0xda37 instead

The MTD size of the kernel is 0x140000 not the 0x160000 I requested.  Because of that, I'm guessing the rootfs cannot be found, and things go downhill from there.  Is there another file i need to edit to get this to work?

Thanks for your help.
-pete

(Last edited by ClubPetey on 27 Apr 2011, 19:25)

Ok, I've made more progress!

Turns out that the mach-tl-mr3x20.c file in the build directory was not updated from the target directory.  I could fix that by doing "make clean" and rebuilding.  But, shouldn't a change to a file in the target path force a change to a similar file in the build_dir?  Is this a bug? or am I not understanding how the two directories interact?

BTW, I've seen several people ask how to change the MTD partition sizes.  The steps below do work, as long as you "make clean" before a "make"

-pete

I tried to do the samilar thing, but failed.

I saw an interesting thread to customize an extra mtd partition. Cause I also want to have a partition to store few persistent data, but not in the rootfs_data.

The board I am using it Compex WPJ344. There is no mtd_partition definition in mach-wpj344.c, there are some other boards having no mtd_partition definition neither. I add the custom partition in mach-wpj344.c, initialize it and compile a firmware. There came no error, however, the mtd partition is not changed. I think the definition may be in somewhere else, but can not find it.

If someone can help, I would be very thankful.

(Last edited by stone8936 on 4 Apr 2014, 14:18)

ClubPetey wrote:

BTW, I've seen several people ask how to change the MTD partition sizes.  The steps below do work, as long as you "make clean" before a "make"

-pete

Where are the steps?

stone8936 wrote:

I tried to do the samilar thing, but failed.

The board I am using it Compex WPJ344. There is no mtd_partition definition in mach-wpj344.c, there are some other boards having no mtd_partition definition neither. I add the custom partition in mach-wpj344.c, initialize it and compile a firmware. There came no error, however, the mtd partition is not changed. I think the definition may be in somewhere else, but can not find it.

If someone can help, I would be very thankful.

Hi, Stone,
Just a untested clue regarding generate the image to locate your modified partition. The file is located at "<BuildRoot\target\linux\ar71xx\image\Makefile>" with paramter BoardName_mtdlayout__FlashSize.
Hope it's useful.

Note: As ClubPetey's reminder, please make clean first or modify the file in "build_dir\target-mips_r2_eglibc-2.15\OpenWrt-ImageBuilder-ar71xx_generic-for-linux-i686\target\linux\ar71xx\image\Makefile"

Got it! Thanks.
BTW, even I didn't make clean, it still works.

xujie.paul wrote:
stone8936 wrote:

I tried to do the samilar thing, but failed.

The board I am using it Compex WPJ344. There is no mtd_partition definition in mach-wpj344.c, there are some other boards having no mtd_partition definition neither. I add the custom partition in mach-wpj344.c, initialize it and compile a firmware. There came no error, however, the mtd partition is not changed. I think the definition may be in somewhere else, but can not find it.

If someone can help, I would be very thankful.

Hi, Stone,
Just a untested clue regarding generate the image to locate your modified partition. The file is located at "<BuildRoot\target\linux\ar71xx\image\Makefile>" with paramter BoardName_mtdlayout__FlashSize.
Hope it's useful.

Note: As ClubPetey's reminder, please make clean first or modify the file in "build_dir\target-mips_r2_eglibc-2.15\OpenWrt-ImageBuilder-ar71xx_generic-for-linux-i686\target\linux\ar71xx\image\Makefile"

(Last edited by stone8936 on 14 Apr 2014, 12:11)

The discussion might have continued from here.