Modifying Partition Table for Sercom NA502 (MT7621)

I'd like to modify the partition table for the Sercom NA502 device (defined in mt7621_sercom_na502.dts) in order to increase the space allocated to the UBI partition. Specifically, my plan is to:

Keep the following partitions:

  • u-boot
  • config
  • factory

Remove:

  • kernel1
  • kernel
  • ubi
  • user_storage
  • data
  • storage
  • backup

Create new:

  • kernel from 0x140000 to 0x1539999 (20 MiB)
  • ubi from 0x1540000 to 0x7FFFFFF (~106 MiB)

While analyzing the original partition layout, I noticed that the last address used by the backup partition is 0x6c40000 + 0x1340000 = 0x7F80000, which corresponds to about 127.5 MiB. Is there a specific reason for this? Was this partition layout directly inherited from the stock firmware?

Also, if anyone has experience with the following, I'd appreciate insights: Can the installed u-boot version load the kernel directly from a UBI volume? If so, would that allow me to drop the separate kernel partition altogether?

I have direct access to the USART.

DTS: https://git.infobricfleet.com/gtu/openwrt/-/blob/v24.10.0-rc3/target/linux/ramips/dts/mt7621_sercomm_na502.dts?ref_type=tags

this is the default, to make it possible to revert back to stock.

But i dont want to revert back to stock. (even if i wanted to, it would be possible anyway to flash the original firmware if it was available)

I guess the Openwrt devs weren't thinking about what you want, when the decision was made...

The point for me is: can i do that changes (for me) without any issues?

(Btw. I don't trust answers generated by any LLM that much, because they often contradict themselves in this specific topic.)

If the boot loader will let you...

For (for instance) the filogic target the boot loader have to be replaced, to make it happen (aka ubootmod).

There are no ubootmod images in https://downloads.openwrt.org/snapshots/targets/ramips/mt7621/.

So I had a look at my notes from the initial porting effort.

The boot loader verifies Image Header Checksums and Image Data Checksums. I don't know exactly what ranges are checked and if you can relocate the kernel/rootfs, that would be something to verify. Keep in mind that this is a NAND device, so recovery isn't exactly easy if the boot loader is messed up.

Yes. I always try to keep as much from stock as possible to allow flashing back to stock. This is the original layout (boot log):

[    3.204000] Creating 10 MTD partitions on "MT7621-NAND":
[    3.212000] 0x000000000000-0x000007f80000 : "ALL"
[    3.224000] 0x000000000000-0x000000080000 : "Bootloader"
[    3.236000] 0x000000080000-0x000000100000 : "Config"
[    3.248000] 0x000000100000-0x000000140000 : "Factory"
[    3.260000] 0x000000140000-0x000001540000 : "Firmware1"
[    3.272000] 0x000001540000-0x000002940000 : "Firmware2"
[    3.284000] 0x0000016a3e39-0x000002940000 : "rootfs"
[    3.292000] mtd: partition "rootfs" must either start or end on erase block boundary or be smaller than an erase block -- forcing read-only
[    3.332000] mtd: partition "rootfs_data" created automatically, ofs=0x2280000, len=0x6c0000
[    3.348000] 0x000002280000-0x000002940000 : "rootfs_data"
[    3.360000] 0x000002940000-0x000002a40000 : "user_storage"
[    3.372000] 0x000002a40000-0x000003a40000 : "data"
[    3.384000] 0x000003a40000-0x000006c40000 : "storage"
[    3.392000] 0x000006c40000-0x000007f80000 : "backup"

I wouldn't mess around with this. You get a custom OpenWrt build without easy upgrade options. If you need more space, you can easily use extroot on the USB port or format and use one of the unused partitions. IIRC, I even did this once for an experiment with a Z-Wave stack on the device.

I doubt that it supports UBI, but why don't you just try it if you have serial available?

That said: This device is not very powerful by today's means. Why do you need more space?