diff options
author | Rafał Miłecki <rafal@milecki.pl> | 2016-11-19 22:42:50 +0100 |
---|---|---|
committer | Rafał Miłecki <rafal@milecki.pl> | 2016-11-20 17:17:48 +0100 |
commit | 0d3be662ce722011f000dfd4ddee2e8f45067980 (patch) | |
tree | 778bdb37f656409430ef6b4c009a36ae6f3cd177 /tools/firmware-utils | |
parent | 746e63201bef8fcbe8a333a8834976b2d7f3d82d (diff) | |
download | mtk-20170518-0d3be662ce722011f000dfd4ddee2e8f45067980.zip mtk-20170518-0d3be662ce722011f000dfd4ddee2e8f45067980.tar.gz mtk-20170518-0d3be662ce722011f000dfd4ddee2e8f45067980.tar.bz2 |
firmware-utils: tplink-safeloader: keep per-device info on trailing char
Recent refactoring introduced a regression. It ignored second argument
of make_support_list function which was originally true for C2600. The
new generic build_image function always passes false.
This patch allows specifying trailing char in a device specific info. It
also switches Archer C9 to the \0 char to make it compliant with vendor
images.
I verified generated images to be binary identical to the ones that
were created before whole refactoring.
Reported-by: Jo-Philipp Wich <jo@mein.io>
Fixes: fd924d2068f ("firmware-utils: tplink-safeloader: use one function for generating images")
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Diffstat (limited to 'tools/firmware-utils')
-rw-r--r-- | tools/firmware-utils/src/tplink-safeloader.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/tools/firmware-utils/src/tplink-safeloader.c b/tools/firmware-utils/src/tplink-safeloader.c index cefb071..2e8da8f 100644 --- a/tools/firmware-utils/src/tplink-safeloader.c +++ b/tools/firmware-utils/src/tplink-safeloader.c @@ -70,6 +70,7 @@ struct flash_partition_entry { struct device_info { const char *vendor; const char *support_list; + char support_trail; const struct flash_partition_entry *partitions; void *(*generate_sysupgrade_image)(const struct flash_partition_entry *flash_parts, const struct image_partition_entry *image_parts, size_t *len); }; @@ -347,14 +348,14 @@ static struct image_partition_entry make_soft_version(uint32_t rev) { } /** Generates the support-list partition */ -static struct image_partition_entry make_support_list(const char *support_list, bool trailzero) { - size_t len = strlen(support_list); +static struct image_partition_entry make_support_list(struct device_info *info) { + size_t len = strlen(info->support_list); struct image_partition_entry entry = alloc_image_partition("support-list", len + 9); put32(entry.data, len); memset(entry.data+4, 0, 4); - memcpy(entry.data+8, support_list, len); - entry.data[len+8] = trailzero ? '\x00' : '\xff'; + memcpy(entry.data+8, info->support_list, len); + entry.data[len+8] = info->support_trail; return entry; } @@ -609,6 +610,7 @@ static void *generate_sysupgrade_image_eap120(const struct flash_partition_entry struct device_info cpe210_info = { .vendor = cpe510_vendor, .support_list = cpe210_support_list, + .support_trail = '\xff', .partitions = cpe510_partitions, .generate_sysupgrade_image = &generate_sysupgrade_image, }; @@ -616,6 +618,7 @@ struct device_info cpe210_info = { struct device_info cpe510_info = { .vendor = cpe510_vendor, .support_list = cpe510_support_list, + .support_trail = '\xff', .partitions = cpe510_partitions, .generate_sysupgrade_image = &generate_sysupgrade_image, }; @@ -623,6 +626,7 @@ struct device_info cpe510_info = { struct device_info c2600_info = { .vendor = c2600_vendor, .support_list = c2600_support_list, + .support_trail = '\x00', .partitions = c2600_partitions, .generate_sysupgrade_image = &generate_sysupgrade_image_c2600, }; @@ -630,12 +634,14 @@ struct device_info c2600_info = { struct device_info e9_info = { .vendor = c2600_vendor, .support_list = c9_support_list, + .support_trail = '\x00', .partitions = c5_partitions, }; struct device_info eap120_info = { .vendor = eap120_vendor, .support_list = eap120_support_list, + .support_trail = '\xff', .partitions = eap120_partitions, .generate_sysupgrade_image = &generate_sysupgrade_image_eap120, }; @@ -651,7 +657,7 @@ static void build_image(const char *output, parts[0] = make_partition_table(info->partitions); parts[1] = make_soft_version(rev); - parts[2] = make_support_list(info->support_list, false); + parts[2] = make_support_list(info); parts[3] = read_file("os-image", kernel_image, false); parts[4] = read_file("file-system", rootfs_image, add_jffs2_eof); |