aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAlex Maclean <monkeh@monkeh.net>2018-06-20 14:56:19 +0100
committerJohn Crispin <john@phrozen.org>2018-06-26 07:03:57 +0200
commit0a2f21fa715bcf2e2975e32a1843a13fa088c640 (patch)
tree45e9b015944a47a5d57d419d32480ded468ae099 /tools
parent34e22653ac18b6ac7fd368ca47625f665808067f (diff)
downloadupstream-0a2f21fa715bcf2e2975e32a1843a13fa088c640.tar.gz
upstream-0a2f21fa715bcf2e2975e32a1843a13fa088c640.tar.bz2
upstream-0a2f21fa715bcf2e2975e32a1843a13fa088c640.zip
firmware-utils: mktplinkfw: add rootfs offset for combined images
Add an option (-O) to calculate rootfs offset for combined images. This is needed for the TP-Link mtdsplit driver to locate the rootfs when the start is not aligned to an erase block. This will be the case for sysupgrade images produced by tplink-safeloader with upcoming dynamic partition splitting. Signed-off-by: Alex Maclean <monkeh@monkeh.net>
Diffstat (limited to 'tools')
-rw-r--r--tools/firmware-utils/src/mktplinkfw.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/tools/firmware-utils/src/mktplinkfw.c b/tools/firmware-utils/src/mktplinkfw.c
index ab5fd6d58b..ce2acc20c9 100644
--- a/tools/firmware-utils/src/mktplinkfw.c
+++ b/tools/firmware-utils/src/mktplinkfw.c
@@ -107,6 +107,7 @@ static uint32_t reserved_space;
static struct file_info inspect_info;
static int extract = 0;
static bool endian_swap = false;
+static bool rootfs_ofs_calc = false;
static const char md5salt_normal[MD5SUM_LEN] = {
0xdc, 0xd7, 0x3a, 0xa5, 0xc3, 0x95, 0x98, 0xfb,
@@ -202,6 +203,7 @@ static void usage(int status)
" -r <file> read rootfs image from the file <file>\n"
" -a <align> align the rootfs start on an <align> bytes boundary\n"
" -R <offset> overwrite rootfs offset with <offset> (hexval prefixed with 0x)\n"
+" -O calculate rootfs offset for combined images\n"
" -o <file> write output to the file <file>\n"
" -s strip padding from the end of the image\n"
" -j add jffs2 end-of-filesystem markers\n"
@@ -384,6 +386,10 @@ void fill_header(char *buf, int len)
hdr->rootfs_len = htonl(rootfs_info.file_size);
}
+ if (combined && rootfs_ofs_calc) {
+ hdr->rootfs_ofs = htonl(sizeof(struct fw_header) + kernel_len);
+ }
+
hdr->ver_hi = htons(fw_ver_hi);
hdr->ver_mid = htons(fw_ver_mid);
hdr->ver_lo = htons(fw_ver_lo);
@@ -539,7 +545,7 @@ int main(int argc, char *argv[])
while ( 1 ) {
int c;
- c = getopt(argc, argv, "a:H:E:F:L:m:V:N:W:C:ci:k:r:R:o:xX:ehsjv:");
+ c = getopt(argc, argv, "a:H:E:F:L:m:V:N:W:C:ci:k:r:R:o:OxX:ehsjv:");
if (c == -1)
break;
@@ -592,6 +598,9 @@ int main(int argc, char *argv[])
case 'o':
ofname = optarg;
break;
+ case 'O':
+ rootfs_ofs_calc = 1;
+ break;
case 's':
strip_padding = 1;
break;