0037-firmware-utils-tplink-safeloader-add-TP-Link-Archer-C25-v1.patch 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. From: Ludwig Thomeczek <ledesrc@wxorx.net>
  2. Date: Sat, 13 May 2017 11:40:48 +0200
  3. Subject: firmware-utils: tplink-safeloader: add TP-Link Archer C25 v1
  4. This adds the necessary firmware layout definitions for the Archer C25.
  5. It has an addtional partition containing some static data ("extra-para")
  6. without which no factory flash is possible, therefore put_data() has been
  7. added.
  8. Signed-off-by: Ludwig Thomeczek <ledesrc@wxorx.net>
  9. diff --git a/tools/firmware-utils/src/tplink-safeloader.c b/tools/firmware-utils/src/tplink-safeloader.c
  10. index 4e3d2058b286fb7220e5a8308dcdfb25626a1b59..7617566829e159ae9fec00d5de95919a0fb234c6 100644
  11. --- a/tools/firmware-utils/src/tplink-safeloader.c
  12. +++ b/tools/firmware-utils/src/tplink-safeloader.c
  13. @@ -293,6 +293,48 @@ static struct device_info boards[] = {
  14. .last_sysupgrade_partition = "file-system"
  15. },
  16. + /** Firmware layout for the C25v1 */
  17. + {
  18. + .id = "ARCHER-C25-V1",
  19. + .support_list =
  20. + "SupportList:\n"
  21. + "{product_name:ArcherC25,product_ver:1.0.0,special_id:00000000}\n"
  22. + "{product_name:ArcherC25,product_ver:1.0.0,special_id:55530000}\n"
  23. + "{product_name:ArcherC25,product_ver:1.0.0,special_id:45550000}\n",
  24. + .support_trail = '\x00',
  25. + .soft_ver = "soft_ver:1.0.0\n",
  26. +
  27. + /**
  28. + We use a bigger os-image partition than the stock images (and thus
  29. + smaller file-system), as our kernel doesn't fit in the stock firmware's
  30. + 1MB os-image.
  31. + */
  32. + .partitions = {
  33. + {"factory-boot", 0x00000, 0x20000},
  34. + {"fs-uboot", 0x20000, 0x10000},
  35. + {"os-image", 0x30000, 0x180000}, /* Stock: base 0x30000 size 0x100000 */
  36. + {"file-system", 0x1b0000, 0x620000}, /* Stock: base 0x130000 size 0x6a0000 */
  37. + {"user-config", 0x7d0000, 0x04000},
  38. + {"default-mac", 0x7e0000, 0x00100},
  39. + {"device-id", 0x7e0100, 0x00100},
  40. + {"extra-para", 0x7e0200, 0x00100},
  41. + {"pin", 0x7e0300, 0x00100},
  42. + {"support-list", 0x7e0400, 0x00400},
  43. + {"soft-version", 0x7e0800, 0x00400},
  44. + {"product-info", 0x7e0c00, 0x01400},
  45. + {"partition-table", 0x7e2000, 0x01000},
  46. + {"profile", 0x7e3000, 0x01000},
  47. + {"default-config", 0x7e4000, 0x04000},
  48. + {"merge-config", 0x7ec000, 0x02000},
  49. + {"qos-db", 0x7ee000, 0x02000},
  50. + {"radio", 0x7f0000, 0x10000},
  51. + {NULL, 0, 0}
  52. + },
  53. +
  54. + .first_sysupgrade_partition = "os-image",
  55. + .last_sysupgrade_partition = "file-system",
  56. + },
  57. +
  58. /** Firmware layout for the C5 */
  59. {
  60. .id = "ARCHER-C5-V2",
  61. @@ -615,6 +657,15 @@ static struct image_partition_entry read_file(const char *part_name, const char
  62. return entry;
  63. }
  64. +/** Creates a new image partition from arbitrary data */
  65. +static struct image_partition_entry put_data(const char *part_name, const char *datain, size_t len) {
  66. +
  67. + struct image_partition_entry entry = alloc_image_partition(part_name, len);
  68. +
  69. + memcpy(entry.data, datain, len);
  70. +
  71. + return entry;
  72. +}
  73. /**
  74. Copies a list of image partitions into an image buffer and generates the image partition table while doing so
  75. @@ -796,7 +847,8 @@ static void build_image(const char *output,
  76. bool add_jffs2_eof,
  77. bool sysupgrade,
  78. const struct device_info *info) {
  79. - struct image_partition_entry parts[6] = {};
  80. +
  81. + struct image_partition_entry parts[7] = {};
  82. parts[0] = make_partition_table(info->partitions);
  83. parts[1] = make_soft_version(rev);
  84. @@ -804,6 +856,11 @@ static void build_image(const char *output,
  85. parts[3] = read_file("os-image", kernel_image, false);
  86. parts[4] = read_file("file-system", rootfs_image, add_jffs2_eof);
  87. + if (strcasecmp(info->id, "ARCHER-C25-V1") == 0) {
  88. + const char mdat[11] = {0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00};
  89. + parts[5] = put_data("extra-para", mdat, 11);
  90. + }
  91. +
  92. size_t len;
  93. void *image;
  94. if (sysupgrade)