mirror of
https://github.com/openwrt/openwrt.git
synced 2026-10-14 19:38:37 +04:00
Two fixes to the RouterBoot partition handling, both found on a MikroTik Chateau 5G R17 ax but neither device specific. hard_config is not guaranteed to fit within RB_BLOCK_SIZE. On this board the tag list spans 5576 bytes, because the WLAN calibration tag alone carries 5100 bytes of LZ77 compressed data, so truncating the partition makes that tag unreadable. Walk the tag list to its terminating null node and size the partition accordingly. The result never shrinks below RB_BLOCK_SIZE, so devices whose tag list already fits are unaffected. soft_config carries the boot settings and is the one RouterBoot segment meant to be written, but at RB_BLOCK_SIZE (4 KiB) on a flash with 64 KiB erase blocks MTD always forces it read-only. Grow it to a full erase block where the space is free, checked against the following partition so that erasing it cannot destroy a neighbour. That growth alone would break the checksum, because rb_softconfig derives everything from the partition size while RouterBoot validates the CRC32 over its own 4 KiB. Introduce RB_SC_CFG_SIZE and keep reads, CRC and write back within it; the erase still covers the whole partition. With both in place, writing boot_device followed by commit persists across a reboot and "ethonce" triggers a real etherboot. Signed-off-by: André Valentin <avalentin@marcant.net> Link: https://github.com/openwrt/openwrt/pull/24335 Signed-off-by: Robert Marko <robimarko@gmail.com>