aboutsummaryrefslogtreecommitdiffstats
path: root/tools/firmware-utils/src/mktplinkfw-lib.c
Commit message (Collapse)AuthorAgeFilesLines
* firmware-utils: mktplinkfw: fix JFFS2 EOF markersSergey Ryazanov2017-12-141-1/+1
| | | | | | | | | | | | | | | | | | | | | mktplinkfw/mktplinkfw2 utilities put JFFS2 EOF market only at 64KB boundary, this could lead to current device configuration lost during the sysupgrade on a device, which is equpped with flash with the 4KB erase block size (e.g. TP-Link Archer C20). This happens when 64KB and 4KB alignments do not match, so the JFFS2 data is written not exactly at the partition beginnig and startup scripts can not find the JFFS2 during the first boot just after the sysupgrade. Fix this by placing additional JFFS2 EOF marker at a 4KB boundary. Also keep the marker at 64KB intact, so the utilities will produce images suitable for devices with both 4KB and 64KB erase blocks. Fixes: 29a2c2ea80441895a2ffe100d854d2b26d5fa606 (add ability to put jffs2 eof marker into the image) Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
* tools/firmware-utils: mktplinkfw* fix rootfs offsetThibaut VARÈNE2017-11-081-8/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With '-a' specified on the command line, the current code: - computes an aligned _kernel length_ instead of an aligned _rootfs offset_. - does not update the rootfs offset after computing the new kernel length, and instead retains the layout default. When the kernel length exceeds the available space left with this fixed offset, the resulting image header contains invalid data, with the recorded rootfs offset overlapping the kernel area. This patch ensures that rootfs offset is correctly computed and reflected in the final image. Furthermore, the build_fw() function special cases the rootfs_align option because of the above invalid logic. This is also fixed and the computed (or command-line provided, or layout-provided) rootfs_ofs value is used in all cases. There seems to be no valid reason to extend the kernel length beyond the actual length of the kernel itself (OFW images don't do it) so this part of the existing behavior is dropped. Example image before the patch: Kernel data offset : 0x00000200 / 512 bytes Kernel data length : 0x00158438 / 1410104 bytes Kernel load address : 0x00000080 Kernel entry point : 0x00000080 Rootfs data offset : 0x00140000 / 1310720 bytes Rootfs data length : 0x001e4f7e / 1986430 bytes Example image after the patch: Kernel data offset : 0x00000200 / 512 bytes Kernel data length : 0x001583fe / 1410046 bytes Kernel load address : 0x00000080 Kernel entry point : 0x00000080 Rootfs data offset : 0x00158600 / 1410560 bytes Rootfs data length : 0x001e4e22 / 1986082 bytes Tested-by: Mathias Kresin <dev@kresin.me> Tested-by: Stefan Lippers-Hollmann <s.l-h@gmx.de> Tested-by: Daniel Engberg <daniel.engberg.lists@pyret.net> Tested-by: Henryk Heisig <hyniu@o2.pl> Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
* tools/firmware-utils: mktplinkfw move build_fw() to libThibaut VARÈNE2017-10-061-1/+77
| | | | | | | | | | | | | | This patch moves build_fw() to mktplinkfw-lib.c The versions of mktplinkfw.c and mktplinkfw2.c had slight differences in code flow, the version from mktplinkfw.c has been preferred. While it's expected that this change will not affect mktplinkfw2, all use cases could not be tested and so this particular change is committed separately. Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
* tools/firmware-utils: mktplinkfw regroup duplicate codeThibaut VARÈNE2017-10-061-0/+195
This patch carves out the duplicated code of mktplinfw.c and mktplinkfw2.c and moves it to mktplinkfw-lib.c This change is a semantic NOP (the code is unchanged). To ensure compatibility with gcc-5.x and newer without changing the code, -fgnu89-inline is added to the build flags for these two binaries. Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>