From 91099dacc6c9402b305d40e7bc4068a8cd65da79 Mon Sep 17 00:00:00 2001 From: Cyril Bur Date: Thu, 15 Mar 2018 16:58:18 +1100 Subject: external/ffspart: Remove side, order and backup options These options are currently flakey in libflash/libffs so there isn't much point to being able to use them in ffspart. Future reworks planned for libflash/libffs will render these options redundant anyway. Signed-off-by: Cyril Bur Signed-off-by: Stewart Smith --- external/ffspart/ffspart.c | 87 ++-------------------- external/ffspart/test/results/00-usage.out | 5 -- external/ffspart/test/tests/01-param-sanity | 6 +- external/ffspart/test/tests/02-param-sides | 6 +- external/ffspart/test/tests/03.1-tiny-pnor-backup | 4 + .../ffspart/test/tests/05.1-hdr-overlap-backup | 6 +- 6 files changed, 24 insertions(+), 90 deletions(-) (limited to 'external') diff --git a/external/ffspart/ffspart.c b/external/ffspart/ffspart.c index 350d78b..f8ea8d6 100644 --- a/external/ffspart/ffspart.c +++ b/external/ffspart/ffspart.c @@ -52,11 +52,6 @@ #define MAX_LINE 100 #define SEPARATOR ',' -enum order { - ORDER_ADB, - ORDER_ABD -}; - /* Full version number (possibly includes gitid). */ extern const char version[]; @@ -76,23 +71,16 @@ static void print_help(const char *pname) printf("\t\tNumber of blocks on the flash\n\n"); printf("\t-i, --input=file\n"); printf("\t\tFile containing the required partition data\n\n"); - printf("\t-o, --order=( ADB | ABD )\n"); - printf("\t\tOrdering of the TOC, Data and Backup TOC. Currently only ADB (default)\n"); - printf("\t\tis supported\n"); printf("\t-p, --pnor=file\n"); printf("\t\tOutput file to write data\n\n"); - printf("\t-t, --sides=( 1 | 2 )\n"); - printf("\t\tNumber of sides to the flash (Default: 1)\n"); } int main(int argc, char *argv[]) { const char *pname = argv[0]; struct blocklevel_device *bl = NULL; - unsigned int sides = 1; uint32_t block_size = 0, block_count = 0; - enum order order = ORDER_ADB; - bool bad_input = false, backup_part = false; + bool bad_input = false; char *pnor = NULL, *input = NULL; struct ffs_hdr *new_hdr; FILE *in_file; @@ -101,25 +89,19 @@ int main(int argc, char *argv[]) while(1) { struct option long_opts[] = { - {"backup", no_argument, NULL, 'b'}, {"block_size", required_argument, NULL, 's'}, {"block_count", required_argument, NULL, 'c'}, {"debug", no_argument, NULL, 'g'}, {"input", required_argument, NULL, 'i'}, - {"order", required_argument, NULL, 'o'}, {"pnor", required_argument, NULL, 'p'}, - {"tocs", required_argument, NULL, 't'}, {NULL, 0, 0, 0} }; int c, oidx = 0; - c = getopt_long(argc, argv, "bc:gi:o:p:s:t:", long_opts, &oidx); + c = getopt_long(argc, argv, "c:gi:p:s:", long_opts, &oidx); if (c == EOF) break; switch(c) { - case 'b': - backup_part = true; - break; case 'c': block_count = strtoul(optarg, NULL, 0); break; @@ -129,52 +111,27 @@ int main(int argc, char *argv[]) case 'i': input = strdup(optarg); break; - case 'o': - if (strncmp(optarg, "ABD", 3) == 0) - order = ORDER_ABD; - else if (strncmp(optarg, "ADB", 3) == 0) - order = ORDER_ADB; - else - bad_input = true; - break; case 'p': pnor = strdup(optarg); break; case 's': block_size = strtoul(optarg, NULL, 0); break; - case 't': - sides = strtoul(optarg, NULL, 0); - break; default: exit(1); } } - if (sides == 0) - sides = 1; - - if (sides > 2) { - fprintf(stderr, "Greater than two sides is not supported\n"); - bad_input = true; - } - if (!block_size || !block_count || !input || !pnor) bad_input = true; - /* TODO Check assumption that sides divide the flash in half. */ - if (block_count % sides) { - fprintf(stderr, "Invalid block_count %u for sides %u\n", block_count, sides); - bad_input = true; - } - - if (bad_input || order == ORDER_ABD) { + if (bad_input) { print_help(pname); rc = 1; goto out; } - rc = ffs_hdr_new(block_size, block_count / sides, &new_hdr); + rc = ffs_hdr_new(block_size, block_count, &new_hdr); if (rc) { if (rc == FFS_ERR_BAD_SIZE) { /* Well this check is a tad redudant now */ @@ -185,14 +142,6 @@ int main(int argc, char *argv[]) goto out; } - if (sides == 2) { - rc = ffs_hdr_add_side(new_hdr); - if (rc) { - fprintf(stderr, "Couldn't add side to header\n"); - goto out_free_hdr; - } - } - in_file = fopen(input, "r"); if (!in_file) { rc = errno; @@ -221,7 +170,6 @@ int main(int argc, char *argv[]) struct ffs_entry_user user = { 0 }; char *pos, *old_pos; char *name, *endptr; - int side = -1; uint32_t pbase, psize, pactual = 0; /* Inline comments in input file */ @@ -309,20 +257,6 @@ int main(int argc, char *argv[]) case 'B': user.miscflags |= FFS_MISCFLAGS_BACKUP; break; - case '0': - case '1': - case '2': - /* - * There should only be one side specified, fail if - * we've already seen a side - */ - if (side != -1) { - rc = -1; - goto out_close_bl; - } else { - side = *pos - '0'; - } - break; default: fprintf(stderr, "Unknown flag '%c'\n", *pos); rc = -1; @@ -331,9 +265,6 @@ int main(int argc, char *argv[]) pos++; } - if (side == -1) /* Default to 0 */ - side = 0; - printf("Adding '%s' 0x%08x, 0x%08x\n", name, pbase, psize); rc = ffs_entry_new(name, pbase, psize, &new_entry); if (rc) { @@ -348,7 +279,7 @@ int main(int argc, char *argv[]) goto out_while; } - rc = ffs_entry_add(new_hdr, new_entry, side); + rc = ffs_entry_add(new_hdr, new_entry, 0); if (rc) { fprintf(stderr, "Couldn't add entry '%s' 0x%08x for 0x%08x\n", name, pbase, psize); @@ -417,14 +348,6 @@ out_while: goto out_close_bl; } - if (backup_part) { - rc = ffs_hdr_create_backup(new_hdr); - if (rc) { - fprintf(stderr, "Failed to create backup part\n"); - goto out_close_bl; - } - } - rc = ffs_hdr_finalise(bl, new_hdr); if (rc) fprintf(stderr, "Failed to write out TOC values\n"); diff --git a/external/ffspart/test/results/00-usage.out b/external/ffspart/test/results/00-usage.out index 19eedc7..3ad0441 100644 --- a/external/ffspart/test/results/00-usage.out +++ b/external/ffspart/test/results/00-usage.out @@ -11,11 +11,6 @@ Usage: ./ffspart [options] -s size -c num -i layout_file -p pnor_file ... -i, --input=file File containing the required partition data - -o, --order=( ADB | ABD ) - Ordering of the TOC, Data and Backup TOC. Currently only ADB (default) - is supported -p, --pnor=file Output file to write data - -t, --sides=( 1 | 2 ) - Number of sides to the flash (Default: 1) diff --git a/external/ffspart/test/tests/01-param-sanity b/external/ffspart/test/tests/01-param-sanity index 9e28c45..28acf51 100644 --- a/external/ffspart/test/tests/01-param-sanity +++ b/external/ffspart/test/tests/01-param-sanity @@ -1,6 +1,10 @@ #! /bin/sh -run_binary "./ffspart" "-t 3 -s 1 -c 3 -i /dev/null -p /dev/null" +#This test has become a little redundant now. +#TODO Do more sanity checking +return 0 + +run_binary "./ffspart" "-s 1 -c 3 -i /dev/null -p /dev/null" if [ "$?" -ne 1 ] ; then fail_test fi diff --git a/external/ffspart/test/tests/02-param-sides b/external/ffspart/test/tests/02-param-sides index cd7984b..17a2461 100644 --- a/external/ffspart/test/tests/02-param-sides +++ b/external/ffspart/test/tests/02-param-sides @@ -1,6 +1,10 @@ #! /bin/sh -run_binary "./ffspart" "-t 2 -s 1 -c 1 -i /dev/null -p /dev/null" +#The parameter has been removed +#TODO Something clever with this test +return 0 + +run_binary "./ffspart" "-s 1 -c 1 -i /dev/null -p /dev/null" if [ "$?" -ne 1 ] ; then fail_test fi diff --git a/external/ffspart/test/tests/03.1-tiny-pnor-backup b/external/ffspart/test/tests/03.1-tiny-pnor-backup index 3065c86..8fa8d4e 100644 --- a/external/ffspart/test/tests/03.1-tiny-pnor-backup +++ b/external/ffspart/test/tests/03.1-tiny-pnor-backup @@ -1,5 +1,9 @@ #! /bin/sh +#The backup partition flag is gone +#disable this test temporarily +return 0 + touch $DATA_DIR/$CUR_TEST.gen run_binary "./ffspart" "-b -s 0x100 -c 15 -i $DATA_DIR/$CUR_TEST.in -p $DATA_DIR/$CUR_TEST.gen" diff --git a/external/ffspart/test/tests/05.1-hdr-overlap-backup b/external/ffspart/test/tests/05.1-hdr-overlap-backup index 5814fff..0cbd9fa 100644 --- a/external/ffspart/test/tests/05.1-hdr-overlap-backup +++ b/external/ffspart/test/tests/05.1-hdr-overlap-backup @@ -1,8 +1,12 @@ #! /bin/sh +#The backup partition flag is gone +#disable this test temporarily +return 0 + touch $DATA_DIR/$CUR_TEST.gen -run_binary "./ffspart" "-b -s 0x100 -c 10 -i $DATA_DIR/$CUR_TEST.in -p $DATA_DIR/$CUR_TEST.gen" +run_binary "./ffspart" "-s 0x100 -c 10 -i $DATA_DIR/$CUR_TEST.in -p $DATA_DIR/$CUR_TEST.gen" #expect this error code, which is FFS_ERR_BAD_PART_BASE becase we're #going to have too many partitions for header to fit before the first #partition -- cgit v1.1