I saw this with many devices in mt7621, and it might be a good idea regarding the additional layer of bad blocks management this would put on top, but I feel too inexperienced to evaluate what would be the best solution to use here.
Also, can we just introduce this regardless of what the stock firmware previously did to that flash area? (It seems so, if it was previously used as raw flash only).
As far as I understand, only the squashfs + jffs2 would be contained within the ubi partition, while the kernel is placed directly into NAND flash, only using the FTL provided by Mediatek. This means during sysupgrade, the kernel is overwritten, assuming this would happen less frequently so no bad blocks would arise, though rootfs_data
would be more robust since having the additional UBI layer?
But it seems this would not work with any sort of dynamic mtd-split
, but rather requires using a fixed-size kernel partition, which may seem to be a regression.
Looking at other devices, it actually scares me to see this:
target/linux/ramips/image$ grep -rn "KERNEL_SIZE :=" mt7621.mk
205: KERNEL_SIZE := 4096k
295: KERNEL_SIZE := 4096k
312: KERNEL_SIZE := 4096k
341: KERNEL_SIZE := 4096k
356: KERNEL_SIZE := 4352k
402: KERNEL_SIZE := 4096k
552: KERNEL_SIZE := 4096k
907: KERNEL_SIZE := 8192k
941: KERNEL_SIZE := 4096k
975: KERNEL_SIZE := 4096k
1025: KERNEL_SIZE := 4096k
1133: KERNEL_SIZE := 4096k
1180: KERNEL_SIZE := 4096k
1200: KERNEL_SIZE := 4096k
1230: KERNEL_SIZE := 4096k
1272: KERNEL_SIZE := 4096k
1300: KERNEL_SIZE := 4096k
1474: KERNEL_SIZE := 4352k
1507: KERNEL_SIZE := 4096k
1673: KERNEL_SIZE := 4096k
1708: KERNEL_SIZE := 4096k
1761: KERNEL_SIZE := 4096k
1818: KERNEL_SIZE := 4096k
1832: KERNEL_SIZE := 4096k
2063: KERNEL_SIZE := 3145728
2230: KERNEL_SIZE := 4096k
2313: KERNEL_SIZE := 4096k
2576: KERNEL_SIZE := 8192k
2602: KERNEL_SIZE := 4096k
For the moment, the kernel is slightly above 2.6 MiB, but exceeding the 4 MiB limit could likely fall into the hardware lifespan of these device, which would require a lot more fiddling in the distant future (most probably involving the loss of UBI bad blocks information, which might be a bad thing for devices aged over so many years).
But again, I don't really want to make this decision here.
Regarding the ELX vs. padding: just adding 132 bytes of zero-padding after the DEADC0DE
marker before shoving this into elx-header
will only result in more garbage (i.e. exactly those 132 bytes of XOR'ed zeroes) to be appended, so the size of the payload must be somehow determined based on kernel and/or filesystem headers maybe?
// edit: the elx-header
recipe in include/image-commands.mk
would just stat
the input file and write that value into the header:
echo -ne "$$(printf '%08x' $$(stat -c%s $@) | fold -s2 | xargs -I {} echo \\x{} | tr -d '\n')" | \
dd bs=8 count=1 conv=sync; \
Maybe further experimentation should be towards messing with that value in the elx header; Unfortunately I won't find the time for this during the rest of this week.