You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Thibaut VARÈNE 050fb3b55c tools/firmware-utils: mktplinkfw* fix rootfs offset
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>
7 years ago
..
add_header.c firmware-utils: when using open with O_CREAT and O_WRONLY, also use O_TRUNC to ensure that overwritten files have the right size (fixes #3505) 16 years ago
addpattern.c firmware-utils: honor env SOURCE_DATE_EPOCH 7 years ago
asustrx.c tools: firmware-utils: fix compiler warnings 9 years ago
bcm_tag.h firmware-utils: move bcm_tag.h here 12 years ago
bcmalgo.c tools: add Broadcom cable modem firmware image creator 11 years ago
bcmalgo.h tools: add Broadcom cable modem firmware image creator 11 years ago
buffalo-enc.c firmware-utils: improve tools for Buffalo DHP series 7 years ago
buffalo-lib.c firmware-utils/buffalo-enc: explicitly use signed char for checksum function 9 years ago
buffalo-lib.h firmware-utils: improve tools for Buffalo DHP series 7 years ago
buffalo-tag.c firmware-utils: improve tools for Buffalo DHP series 7 years ago
buffalo-tftp.c firmware-utils: fix compilation warnings. 10 years ago
csysimg.h adds support for Edimax BR-6524N 12 years ago
cyg_crc.h firmware-utils: add new tool for the wrt400n (based on a patch by Sandeep Mistry <sandeep.mistry at gmail.com>) 15 years ago
cyg_crc16.c firmware-utils: add new tool for the wrt400n (based on a patch by Sandeep Mistry <sandeep.mistry at gmail.com>) 15 years ago
cyg_crc32.c firmware-utils: add new tool for the wrt400n (based on a patch by Sandeep Mistry <sandeep.mistry at gmail.com>) 15 years ago
dgfirmware.c firmware-utils: fix various compiler warnings 9 years ago
dgn3500sum.c firmware-utils: fix dgn3500sum compiler warnings 7 years ago
edimax_fw_header.c tools: edimax_fw_header: fix suspicious memset usage 10 years ago
encode_crc.c remove 'svn:executable' property 14 years ago
fix-u-media-header.c firmware-utils: new tool for fixing U-Media firmware headers 12 years ago
fw.h buld images for the Ubiquiti LiteStation and NanoStation ported from http://atheros.openwrt.net. Tested on a Nanostation 2 with airos 3 16 years ago
hcsmakeimage.c firmware-utils: honor env SOURCE_DATE_EPOCH 7 years ago
imagetag.c firmware-utils: honor env SOURCE_DATE_EPOCH 7 years ago
imagetag.ggo brcm63xx: do not align squashfs rootfs start 9 years ago
imagetag_cmdline.c brcm63xx: do not align squashfs rootfs start 9 years ago
imagetag_cmdline.h brcm63xx: do not align squashfs rootfs start 9 years ago
jcgimage.c firmware-utils: honor env SOURCE_DATE_EPOCH 7 years ago
lzma2eva.c firmware-utils: fix various compiler warnings 9 years ago
makeamitbin.c Add makeamitbin to generate images for other RDC-based devices, thanks sn9 ! 16 years ago
md5.c firmware-utils: replace md5 code with Alexander Peslyak's implementation 8 years ago
md5.h firmware-utils: replace md5 code with Alexander Peslyak's implementation 8 years ago
mkbrncmdline.c Support booting the Speedport W502V using BRN-BOOT. 12 years ago
mkbrnimg.c tools: firmware-utils: fix compiler warnings 9 years ago
mkbuffaloimg.c ar71xx: add support for Buffalo BHR-4GRV2 8 years ago
mkcameofw.c firmware-utils/mkcameofw: allow to use combined kernel image 11 years ago
mkcasfw.c tools: firmware-utils: fix compiler warnings 9 years ago
mkchkimg.c tools/firmware-utils: document reserved fields in mkchkimg 7 years ago
mkcsysimg.c tools: firmware-utils: fix compiler warnings 9 years ago
mkdapimg.c Add Netgear WNCE2001 (OF version) 11 years ago
mkdcs932.c tools: add tool to generate dcs93xl images 11 years ago
mkdhpimg.c firmware-utils: improve tools for Buffalo DHP series 7 years ago
mkdniimg.c tools: firmware-utils: fix compiler warnings 9 years ago
mkedimaximg.c Add firmware tool for generating factory images for Edimax devices 13 years ago
mkfwimage.c firmware-utils: mkfwimage: fix firmware_max_length for XM layout 8 years ago
mkfwimage2.c tools/mkfwimage2: remove 256 length limit for partition images 8 years ago
mkheader_gemtek.c firmware-utils: add Gemtek header tool 10 years ago
mkhilinkfw.c firmware-utils: fix various compiler warnings 9 years ago
mkmerakifw-old.c tools/firmware-utils: fix portability issue in mkmerakifw-old 8 years ago
mkmerakifw.c firmware-utils: Fix build failure in mkmerakifw.c FS#298 8 years ago
mkmylofw.c ar71xx: Revert "added board support for compex wpj558" 9 years ago
mkplanexfw.c tools: firmware-utils: fix compiler warnings 9 years ago
mkporayfw.c ramips: generate factory images for Nexx devices 10 years ago
mkrtn56uimg.c firmware-utils: honor env SOURCE_DATE_EPOCH 7 years ago
mksenaofw.c firmware-utils: mksenaofw: rework option validation 8 years ago
mktitanimg.c fix mktitanimg segfault on 64-bits hosts (#7443) 14 years ago
mktitanimg.h add mktitanimg to create Titan (AR7-based) images (#6632) 14 years ago
mktplinkfw-lib.c tools/firmware-utils: mktplinkfw* fix rootfs offset 7 years ago
mktplinkfw-lib.h tools/firmware-utils: mktplinkfw move build_fw() to lib 7 years ago
mktplinkfw.c tools/firmware-utils: mktplinkfw* fix rootfs offset 7 years ago
mktplinkfw2.c tools/firmware-utils: mktplinkfw* fix rootfs offset 7 years ago
mkwrggimg.c firmware-utils: fix compilation on MacOS X 8 years ago
mkwrgimg.c firmware-utils: rename the devname variable in mkwrgimg to avoid a clash with a BSD stdlib function 13 years ago
mkzcfw.c tools: firmware-utils: fix compiler warnings 9 years ago
mkzynfw.c tools: firmware-utils: fix compiler warnings 9 years ago
motorola-bin.c get rid of $Id$ - it has never helped us and it has broken too many patches ;) 15 years ago
myloader.h ar71xx: Revert "added board support for compex wpj558" 9 years ago
nand_ecc.c treewide: replace nbd@openwrt.org with nbd@nbd.name 8 years ago
osbridge-crc.c tools: firmware-utils: fix compiler warnings 9 years ago
oseama.c firmware-utils: oseama: support extracting entity 8 years ago
pc1crypt.c tools: firmware-utils: fix compiler warnings 9 years ago
ptgen.c ptgen: work around gcc miscompilation 8 years ago
seama.c tools: firmware-utils: fix compiler warnings 9 years ago
seama.h tools/firmware-utils: add seama tool 12 years ago
sha1.c firmware-utils/mkplanexfw: new firmware generation tool for the Planex MZK-W04NU device 16 years ago
sha1.h firmware-utils/mkplanexfw: new firmware generation tool for the Planex MZK-W04NU device 16 years ago
spw303v.c firmware-utils: honor env SOURCE_DATE_EPOCH 7 years ago
srec2bin.c firmware-utils: fix various compiler warnings 9 years ago
tplink-safeloader.c ar71xx: add support for TP-LINK Archer C7 v4 7 years ago
trx.c firmware-utils: improve tools for Buffalo DHP series 7 years ago
trx2edips.c firmware-utils: fix build on big endian systems 13 years ago
trx2usr.c move target/utils to tools/firmware-utils 18 years ago
wrt400n.c Revert "tools: wrt400n: fix making factory images with kernel bigger than 1MB" 7 years ago
xorimage.c firmware-utils: honor env SOURCE_DATE_EPOCH 7 years ago
zyimage.c firmware-utils: add tool to create zyxel images 8 years ago
zynos.h firmware-utils/mkzynfw: add support for the NBG460N board 14 years ago
zyxbcm.c firmware-utils: honor env SOURCE_DATE_EPOCH 7 years ago