diff options
author | Vincent Palatin <vpalatin@chromium.org> | 2014-10-01 11:41:09 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-10-02 07:02:54 +0000 |
commit | 1ec56e8546c9563a83f86e6db35f78e98739cb20 (patch) | |
tree | b9801bc9bc79d895afb8259d830ac14a529e8b77 /util/stm32mon.c | |
parent | d3ebcb18caabe9eb96383fa33edd501061bae7e0 (diff) | |
download | chrome-ec-1ec56e8546c9563a83f86e6db35f78e98739cb20.tar.gz |
stm32mon: add option to read firmware image from stdin
Add a command-line option to ask stm32mon to read the EC firmware image
to flash from the standard input when the filename is replaced by a "-".
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BRANCH=none
BUG=chromium:398165 chromium:396233
TEST=use the following flashing commands:
cat build/fruitpie/ec.bin | ./util/flash_ec --board=fruitpie --image=-
./util/flash_ec --board=fruitpie
./util/flash_ec --board=fruitpie --image=build/fruitpie/ec.RO.flat
and check the content of the flash.
Change-Id: I8039ecb6910f912161a7f59c5f5e2fc80447ce7b
Reviewed-on: https://chromium-review.googlesource.com/220842
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'util/stm32mon.c')
-rw-r--r-- | util/stm32mon.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/util/stm32mon.c b/util/stm32mon.c index 10dc495855..85246cefcd 100644 --- a/util/stm32mon.c +++ b/util/stm32mon.c @@ -734,7 +734,10 @@ int write_flash(int fd, struct stm32_def *chip, const char *filename, return -ENOMEM; } - hnd = fopen(filename, "r"); + if (!strncmp(filename, "-", sizeof("-"))) + hnd = fdopen(STDIN_FILENO, "r"); + else + hnd = fopen(filename, "r"); if (!hnd) { fprintf(stderr, "Cannot open file %s for reading\n", filename); free(buffer); @@ -792,8 +795,8 @@ void display_usage(char *program) fprintf(stderr, "--e[rase] : erase all the flash content\n"); fprintf(stderr, "--r[ead] <file> : read the flash content and " "write it into <file>\n"); - fprintf(stderr, "--w[rite] <file> : read <file> and " - "write it to flash\n"); + fprintf(stderr, "--w[rite] <file|-> : read <file> or\n\t" + "standard input and write it to flash\n"); fprintf(stderr, "--g[o] : jump to execute flash entrypoint\n"); exit(2); |