aboutsummaryrefslogtreecommitdiff
path: root/external
diff options
context:
space:
mode:
authorAdriana Kobylak <anoo@linux.ibm.com>2018-10-23 13:47:29 -0500
committerStewart Smith <stewart@linux.ibm.com>2018-10-25 07:08:28 +1100
commitb6ebee077d915916989aa3057239a985981edb07 (patch)
tree6269e8d938f6a9c0410d09ba1f1fcff7bdb815a6 /external
parentae546e0b6d977b13ed93d63c365376af87f0fbb6 (diff)
downloadskiboot-b6ebee077d915916989aa3057239a985981edb07.zip
skiboot-b6ebee077d915916989aa3057239a985981edb07.tar.gz
skiboot-b6ebee077d915916989aa3057239a985981edb07.tar.bz2
pflash: Add --skip option for reading
Add a --skip=N option to pflash to skip N number of bytes when reading. This would allow users to print the VERSION partition without the STB header by specifying the --skip=4096 argument, and it's a more generic solution rather than making pflash depend on secure/trusted boot code. Signed-off-by: Adriana Kobylak <anoo@linux.ibm.com> Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> [stewart: fix up pflash test] Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
Diffstat (limited to 'external')
-rw-r--r--external/pflash/pflash.c26
-rw-r--r--external/pflash/test/results/00-usage.out3
-rw-r--r--external/pflash/test/results/05-bad-numbers.out3
3 files changed, 29 insertions, 3 deletions
diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c
index 72b90fc..c81520c 100644
--- a/external/pflash/pflash.c
+++ b/external/pflash/pflash.c
@@ -471,7 +471,7 @@ out:
}
static int do_read_file(struct blocklevel_device *bl, const char *file,
- uint32_t start, uint32_t size)
+ uint32_t start, uint32_t size, uint32_t skip_size)
{
int fd, rc = 0;
uint32_t done = 0;
@@ -481,6 +481,9 @@ static int do_read_file(struct blocklevel_device *bl, const char *file,
perror("Failed to open file");
return 1;
}
+ start += skip_size;
+ size -= skip_size;
+
printf("Reading to \"%s\" from 0x%08x..0x%08x !\n",
file, start, start + size);
@@ -644,6 +647,8 @@ static void print_help(const char *pname)
printf("\t\tTarget filename instead of actual flash.\n\n");
printf("\t-S, --side\n");
printf("\t\tSide of the flash on which to operate, 0 (default) or 1\n\n");
+ printf("\t--skip=N\n");
+ printf("\t\tSkip N number of bytes from the start when reading\n\n");
printf("\t-T, --toc\n");
printf("\t\tlibffs TOC on which to operate, defaults to 0.\n");
printf("\t\tleading 0x is required for interpretation of a hex value\n\n");
@@ -709,7 +714,7 @@ int main(int argc, char *argv[])
bool no_action = false, tune = false;
char *write_file = NULL, *read_file = NULL, *part_name = NULL;
bool ffs_toc_seen = false, direct = false, print_detail = false;
- int flash_side = 0;
+ int flash_side = 0, skip_size = 0;
int rc = 0;
while(1) {
@@ -735,6 +740,7 @@ int main(int argc, char *argv[])
{"version", no_argument, NULL, 'v'},
{"debug", no_argument, NULL, 'g'},
{"side", required_argument, NULL, 'S'},
+ {"skip", required_argument, NULL, 'k'},
{"toc", required_argument, NULL, 'T'},
{"clear", no_argument, NULL, 'c'},
{NULL, 0, NULL, 0 }
@@ -826,6 +832,13 @@ int main(int argc, char *argv[])
case 'S':
flash_side = atoi(optarg);
break;
+ case 'k':
+ skip_size = strtoul(optarg, &endptr, 0);
+ if (*endptr != '\0') {
+ rc = 1;
+ no_action = true;
+ }
+ break;
case 'T':
if (!optarg)
break;
@@ -935,6 +948,13 @@ int main(int argc, char *argv[])
goto out;
}
+ /* Skip only supported on read */
+ if (skip_size && !do_read) {
+ fprintf(stderr, "--skip requires a --read command !\n");
+ rc = 1;
+ goto out;
+ }
+
/* Program command should always come with a file */
if (program && !write_file) {
fprintf(stderr, "Program with no file specified !\n");
@@ -1142,7 +1162,7 @@ int main(int argc, char *argv[])
}
rc = 0;
if (do_read)
- rc = do_read_file(flash.bl, read_file, address, read_size);
+ rc = do_read_file(flash.bl, read_file, address, read_size, skip_size);
if (!rc && erase_all)
rc = erase_chip(&flash);
else if (!rc && erase)
diff --git a/external/pflash/test/results/00-usage.out b/external/pflash/test/results/00-usage.out
index 3b54f45..caf7b8d 100644
--- a/external/pflash/test/results/00-usage.out
+++ b/external/pflash/test/results/00-usage.out
@@ -43,6 +43,9 @@ Usage: ./pflash [options] commands...
-S, --side
Side of the flash on which to operate, 0 (default) or 1
+ --skip=N
+ Skip N number of bytes from the start when reading
+
-T, --toc
libffs TOC on which to operate, defaults to 0.
leading 0x is required for interpretation of a hex value
diff --git a/external/pflash/test/results/05-bad-numbers.out b/external/pflash/test/results/05-bad-numbers.out
index 211bd6a..17db665 100644
--- a/external/pflash/test/results/05-bad-numbers.out
+++ b/external/pflash/test/results/05-bad-numbers.out
@@ -43,6 +43,9 @@ Usage: ./pflash [options] commands...
-S, --side
Side of the flash on which to operate, 0 (default) or 1
+ --skip=N
+ Skip N number of bytes from the start when reading
+
-T, --toc
libffs TOC on which to operate, defaults to 0.
leading 0x is required for interpretation of a hex value