Resize partitions to accomodate 6.1 kernel

A few Kirkwood devices have kernel partitions too small for kernel 6.1, even though they have 32MB or more flash. Am I wrong in assuming the kernel partition can be resized?

I'm trying to build an image with a changed partition table in the .dts to verify.

Original:

partition@0 {
	label = "u-boot";
	reg = <0x0000000 0x100000>;
	read-only;
};

partition@a0000 {
	label = "u-boot environment";
	reg = <0xa0000 0x20000>;
	read-only;
};

partition@100000 {
	label = "kernel";
	reg = <0x100000 0x300000>;
};

partition@400000 {
	label = "ubi";
	reg = <0x400000 0x1C00000>;
};

What I'm trying:

partition@0 {
	label = "u-boot";
	reg = <0x0000000 0x100000>;
	read-only;
};

partition@a0000 {
	label = "u-boot environment";
	reg = <0xa0000 0x20000>;
	read-only;
};

partition@100000 {
	label = "kernel";
	reg = <0x100000 0x600000>;
};

partition@700000 {
	label = "ubi";
	reg = <0x700000 0x1800000>;
};

Before I'm trying to flash this, should this be safe? I'm planning to boot an initramfs image first before flashing, but that's of course no full guarantee it will work from flash.

Also, the ubi partition isn't fully aligned with the end of the flash chip. I'm having a hard time determining the exact sizes in hex, can anyone confirm what this should be?

There is no way to tell without trying (carefully)…

First check the bootloader environment (fw_printenv) for any hints about the kernel's load command and potential size limits in there, if there is nothing, you may want to check the OEM bootloader source. Then it appears that your device is NAND based, which makes this a bit harder - as any issue is going to be more risky (NAND can't be easily reflashed, but at least kirkwood/ mvebu should have kwboot based recovery) and then you have to 'break' the split between kernel & ubi during the upgrade, as that is determined by the old sysupgrade binary.

Possible, yes (probably…), but the DTS changes above are only part of the story - and with NAND, you have to tread (even more) carefully.

The partition layout is not based on the OEM layout. Installing OpenWrt on this device requires this step to create a new layout:

setenv mtdparts 'mtdparts=orion_nand:0x100000@0x000000(u-boot)ro,0x20000@0xA0000(u-boot environment)ro,0x300000@0x100000(kernel),0x1C00000@0x400000(ubi)'

The kernel log also shows this layout:

[0.000000] Kernel command line: console=ttyS0,115200n8 mtdparts=orion_nand:0x100000@0x000000(u-boot)ro,0x20000@0xA0000(u-boot environment)ro,0x300000@0x100000(kernel),0x1C00000@0x400000(ubi) root=

[0.988825] 4 fixed-partitions partitions found on MTD device orion_nand
[0.995563] Creating 4 MTD partitions on "orion_nand":
[1.000738] 0x000000000000-0x000000100000 : "u-boot"
[1.008431] 0x0000000a0000-0x0000000c0000 : "u-boot environment"
[1.015141] 0x000000100000-0x000000400000 : "kernel"
[1.022158] 0x000000400000-0x000002000000 : "ubi"

I can boot the device with the 6.1-based initramfs image I've created, which I assume works because the mount-point of the kernel partition is still the same (?). So question is then, will flashing the image repartition the NAND, or is a modified setenv mtdparts command required?