aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2019-02-15 17:02:14 +0100
committerChristian Lamparter <chunkeey@gmail.com>2019-02-20 18:51:31 +0100
commit6cdf08f02625975de32cce5ceab2e5d84a0134f0 (patch)
treed50774eb3fed9eb212654bdae7f44698cf3a8830
parenta69e101ed1169f562fc030a783cd997d3f066b16 (diff)
downloadupstream-6cdf08f02625975de32cce5ceab2e5d84a0134f0.tar.gz
upstream-6cdf08f02625975de32cce5ceab2e5d84a0134f0.tar.bz2
upstream-6cdf08f02625975de32cce5ceab2e5d84a0134f0.zip
firmware-tools/ptgen: Allow generation 0 size partitions
The firmware on the D-Link DNS-313 NAS require two blank partitions before the boot partition. Support this if explicitly requested with a "-n" flag. Tested on the D-Link DNS-313. Signed-off-by: Christian Lamparter <chunkeey@gmail.com> [Broken out from original patch] Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--tools/firmware-utils/src/ptgen.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/firmware-utils/src/ptgen.c b/tools/firmware-utils/src/ptgen.c
index 13e0eda622..0192bb65e5 100644
--- a/tools/firmware-utils/src/ptgen.c
+++ b/tools/firmware-utils/src/ptgen.c
@@ -27,6 +27,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
+#include <stdbool.h>
#include <ctype.h>
#include <fcntl.h>
#include <stdint.h>
@@ -59,6 +60,7 @@ int active = 1;
int heads = -1;
int sectors = -1;
int kb_align = 0;
+bool ignore_null_sized_partition = false;
struct partinfo parts[4];
char *filename = NULL;
@@ -140,6 +142,8 @@ static int gen_ptable(uint32_t signature, int nr)
memset(pte, 0, sizeof(struct pte) * 4);
for (i = 0; i < nr; i++) {
if (!parts[i].size) {
+ if (ignore_null_sized_partition)
+ continue;
fprintf(stderr, "Invalid size in partition %d!\n", i);
return -1;
}
@@ -196,7 +200,7 @@ fail:
static void usage(char *prog)
{
- fprintf(stderr, "Usage: %s [-v] -h <heads> -s <sectors> -o <outputfile> [-a 0..4] [-l <align kB>] [[-t <type>] -p <size>...] \n", prog);
+ fprintf(stderr, "Usage: %s [-v] [-n] -h <heads> -s <sectors> -o <outputfile> [-a 0..4] [-l <align kB>] [[-t <type>] -p <size>...] \n", prog);
exit(EXIT_FAILURE);
}
@@ -207,7 +211,7 @@ int main (int argc, char **argv)
int part = 0;
uint32_t signature = 0x5452574F; /* 'OWRT' */
- while ((ch = getopt(argc, argv, "h:s:p:a:t:o:vl:S:")) != -1) {
+ while ((ch = getopt(argc, argv, "h:s:p:a:t:o:vnl:S:")) != -1) {
switch (ch) {
case 'o':
filename = optarg;
@@ -215,6 +219,9 @@ int main (int argc, char **argv)
case 'v':
verbose++;
break;
+ case 'n':
+ ignore_null_sized_partition = true;
+ break;
case 'h':
heads = (int)strtoul(optarg, NULL, 0);
break;