From b99b2dd30fdc82800c9355a3d9e99d5edf7802dd Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Thu, 19 Oct 2017 13:41:55 +0200 Subject: [PATCH] FIX: stderr -> stdout --- client/flash.c | 30 +++++++++++++++--------------- client/flasher.c | 42 +++++++++++++++++++++--------------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/client/flash.c b/client/flash.c index fbe8081d7..730a740c2 100644 --- a/client/flash.c +++ b/client/flash.c @@ -54,7 +54,7 @@ static int build_segs_from_phdrs(flash_file_t *ctx, FILE *fd, Elf32_Phdr *phdrs, ctx->num_segs = 0; seg = ctx->segments; - fprintf(stderr, "Loading usable ELF segments:\n"); + fprintf(stdout, "Loading usable ELF segments:\n"); for (int i = 0; i < num_phdrs; i++) { if (le32(phdr->p_type) != PT_LOAD) { phdr++; @@ -70,7 +70,7 @@ static int build_segs_from_phdrs(flash_file_t *ctx, FILE *fd, Elf32_Phdr *phdrs, phdr++; continue; } - fprintf(stderr, "%d: V 0x%08x P 0x%08x (0x%08x->0x%08x) [%c%c%c] @0x%x\n", + fprintf(stdout, "%d: V 0x%08x P 0x%08x (0x%08x->0x%08x) [%c%c%c] @0x%x\n", i, vaddr, paddr, filesz, memsz, flags & PF_R ? 'R' : ' ', flags & PF_W ? 'W' : ' ', @@ -98,7 +98,7 @@ static int build_segs_from_phdrs(flash_file_t *ctx, FILE *fd, Elf32_Phdr *phdrs, // make extra space if we need to move the data forward data = malloc(filesz + BLOCK_SIZE); if (!data) { - fprintf(stderr, "Out of memory\n"); + fprintf(stderr, "Error: Out of memory\n"); return -1; } if (fseek(fd, offset, SEEK_SET) < 0 || fread(data, 1, filesz, fd) != filesz) { @@ -121,7 +121,7 @@ static int build_segs_from_phdrs(flash_file_t *ctx, FILE *fd, Elf32_Phdr *phdrs, uint32_t hole = this_offset - prev_seg->length; uint8_t *new_data = malloc(new_length); if (!new_data) { - fprintf(stderr, "Out of memory\n"); + fprintf(stderr, "Error: Out of memory\n"); free(data); return -1; } @@ -200,7 +200,7 @@ int flash_load(flash_file_t *ctx, const char *name, int can_write_bl) { goto fail; } - fprintf(stderr, "Loading ELF file '%s'...\n", name); + fprintf(stdout, "Loading ELF file '%s'...\n", name); if (fread(&ehdr, sizeof(ehdr), 1, fd) != 1) { fprintf(stderr, "Error while reading ELF file header\n"); @@ -308,7 +308,7 @@ static int enter_bootloader(char *serial_port_name) { return 0; if (state & DEVICE_INFO_FLAG_CURRENT_MODE_OS) { - fprintf(stderr, "Entering bootloader...\n"); + fprintf(stdout, "Entering bootloader...\n"); UsbCommand c; memset(&c, 0, sizeof (c)); @@ -318,22 +318,22 @@ static int enter_bootloader(char *serial_port_name) { // and enter the bootrom on the next boot. c.cmd = CMD_START_FLASH; SendCommand(&c); - fprintf(stderr, "(Press and release the button only to abort)\n"); + fprintf(stdout, "(Press and release the button only to abort)\n"); } else { // Old style handover: Ask the user to press the button, then reset the board c.cmd = CMD_HARDWARE_RESET; SendCommand(&c); - fprintf(stderr, "Press and hold down button NOW if your bootloader requires it.\n"); + fprintf(stdout, "Press and hold down button NOW if your bootloader requires it.\n"); } msleep(100); CloseProxmark(); - fprintf(stderr, "Waiting for Proxmark to reappear on %s", serial_port_name); + fprintf(stdout, "Waiting for Proxmark to reappear on %s", serial_port_name); do { msleep(1000); - fprintf(stderr, "."); + fprintf(stdout, "."); } while ( !OpenProxmark()); - fprintf(stderr, " Found.\n"); + fprintf(stdout, " Found.\n"); return 0; } @@ -407,7 +407,7 @@ static int write_block(uint32_t address, uint8_t *data, uint32_t length) { // Write a file's segments to Flash int flash_write(flash_file_t *ctx) { - fprintf(stderr, "Writing segments for file: %s\n", ctx->filename); + fprintf(stdout, "Writing segments for file: %s\n", ctx->filename); for (int i = 0; i < ctx->num_segs; i++) { flash_seg_t *seg = &ctx->segments[i]; @@ -415,7 +415,7 @@ int flash_write(flash_file_t *ctx) { uint32_t blocks = (length + BLOCK_SIZE - 1) / BLOCK_SIZE; uint32_t end = seg->start + length; - fprintf(stderr, " 0x%08x..0x%08x [0x%x / %d blocks]", seg->start, end - 1, length, blocks); + fprintf(stdout, " 0x%08x..0x%08x [0x%x / %d blocks]", seg->start, end - 1, length, blocks); int block = 0; uint8_t *data = seg->data; @@ -436,9 +436,9 @@ int flash_write(flash_file_t *ctx) { baddr += block_size; length -= block_size; block++; - fprintf(stderr, "."); + fprintf(stdout, "."); } - fprintf(stderr, " OK\n"); + fprintf(stdout, " OK\n"); } return 0; } diff --git a/client/flasher.c b/client/flasher.c index fffd28a52..13de42622 100644 --- a/client/flasher.c +++ b/client/flasher.c @@ -77,28 +77,28 @@ int OpenProxmark() { //poll once a second if (sp == INVALID_SERIAL_PORT) { - printf("ERROR: invalid serial port\n"); + //fprintf(stderr, "ERROR: invalid serial port\n"); return 0; } else if (sp == CLAIMED_SERIAL_PORT) { - printf("ERROR: serial port is claimed by another process\n"); + fprintf(stderr, "ERROR: serial port is claimed by another process\n"); return 0; } return 1; } static void usage(char *argv0) { - fprintf(stderr, "Usage: %s [-b] image.elf [image.elf...]\n\n", argv0); - fprintf(stderr, "\t-b\tEnable flashing of bootloader area (DANGEROUS)\n\n"); - fprintf(stderr, "\nExample (Linux):\n\n\t %s /dev/ttyACM0 armsrc/obj/fullimage.elf\n", argv0); - fprintf(stderr, "\nExample (OS) :\n\n\t %s /dev/cu.usbmodem1451 armsrc/obj/fullimage.elf\n", argv0); - fprintf(stderr, "\nExample (WIN) :\n\n\t %s com3 armsrc/obj/fullimage.elf\n", argv0); - fprintf(stderr, "\nNote (Linux): if the flasher gets stuck in 'Waiting for Proxmark to reappear on ',\n"); - fprintf(stderr, " you need to blacklist proxmark for modem-manager - see wiki for more details:\n"); - fprintf(stderr, " old ref --> http://code.google.com/p/proxmark3/wiki/Linux\n\n"); - fprintf(stderr, " new refs --> "); - fprintf(stderr, " https://github.com/Proxmark/proxmark3/wiki/Gentoo Linux\n\n"); - fprintf(stderr, " https://github.com/Proxmark/proxmark3/wiki/Ubuntu Linux\n\n"); - fprintf(stderr, " https://github.com/Proxmark/proxmark3/wiki/OSX\n\n"); + fprintf(stdout, "Usage: %s [-b] image.elf [image.elf...]\n\n", argv0); + fprintf(stdout, "\t-b\tEnable flashing of bootloader area (DANGEROUS)\n\n"); + fprintf(stdout, "\nExample (Linux):\n\n\t %s /dev/ttyACM0 armsrc/obj/fullimage.elf\n", argv0); + fprintf(stdout, "\nExample (OS) :\n\n\t %s /dev/cu.usbmodem1451 armsrc/obj/fullimage.elf\n", argv0); + fprintf(stdout, "\nExample (WIN) :\n\n\t %s com3 armsrc/obj/fullimage.elf\n", argv0); + fprintf(stdout, "\nNote (Linux): if the flasher gets stuck in 'Waiting for Proxmark to reappear on ',\n"); + fprintf(stdout, " you need to blacklist proxmark for modem-manager - see wiki for more details:\n"); + fprintf(stdout, " old ref --> http://code.google.com/p/proxmark3/wiki/Linux\n\n"); + fprintf(stdout, " new refs --> "); + fprintf(stdout, " https://github.com/Proxmark/proxmark3/wiki/Gentoo Linux\n\n"); + fprintf(stdout, " https://github.com/Proxmark/proxmark3/wiki/Ubuntu Linux\n\n"); + fprintf(stdout, " https://github.com/Proxmark/proxmark3/wiki/OSX\n\n"); } int main(int argc, char **argv) { @@ -135,29 +135,29 @@ int main(int argc, char **argv) { serial_port_name = argv[1]; - fprintf(stderr, "Waiting for Proxmark to appear on %s", serial_port_name); + fprintf(stdout, "Waiting for Proxmark to appear on %s", serial_port_name); do { msleep(500); fprintf(stderr, "."); } while (!OpenProxmark(0)); - fprintf(stderr, " Found.\n"); + fprintf(stdout, " Found.\n"); res = flash_start_flashing(can_write_bl, serial_port_name); if (res < 0) return -1; - fprintf(stderr, "\nFlashing...\n"); + fprintf(stdout, "\nFlashing...\n"); for (int i = 0; i < num_files; i++) { res = flash_write(&files[i]); if (res < 0) return -1; flash_free(&files[i]); - fprintf(stderr, "\n"); + fprintf(stdout, "\n"); } - fprintf(stderr, "Resetting hardware...\n"); + fprintf(stdout, "Resetting hardware...\n"); res = flash_stop_flashing(); if (res < 0) @@ -165,7 +165,7 @@ int main(int argc, char **argv) { CloseProxmark(); - fprintf(stderr, "All done.\n\n"); - fprintf(stderr, "Have a nice day!\n"); + fprintf(stdout, "All done.\n\n"); + fprintf(stdout, "Have a nice day!\n"); return 0; }