summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2014-10-01 11:41:09 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-10-02 07:02:54 +0000
commit1ec56e8546c9563a83f86e6db35f78e98739cb20 (patch)
treeb9801bc9bc79d895afb8259d830ac14a529e8b77
parentd3ebcb18caabe9eb96383fa33edd501061bae7e0 (diff)
downloadchrome-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>
-rwxr-xr-xutil/flash_ec3
-rw-r--r--util/stm32mon.c9
2 files changed, 8 insertions, 4 deletions
diff --git a/util/flash_ec b/util/flash_ec
index 6a38176b1b..7282381eb9 100755
--- a/util/flash_ec
+++ b/util/flash_ec
@@ -210,7 +210,8 @@ fi
function ec_image() {
# No image specified on the command line, try default ones
if [[ -n "${FLAGS_image}" ]] ; then
- if [ -f "${FLAGS_image}" ]; then
+ if [ -f "${FLAGS_image}" ] || \
+ [ "${FLAGS_image}" == "-" ]; then
echo "${FLAGS_image}"
return
fi
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);