FreeCalypso > hg > freecalypso-tools
view rvinterf/etmsync/olddump.c @ 108:2b041d57de1f
target-utils/libcommon/cmd_baud_switch.c: const compiler warning fix
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 01 Nov 2016 01:12:00 +0000 |
parents | e7502631a0f9 |
children |
line wrap: on
line source
/* * This utility uses the old TM3 memory read command (in a synchronous manner * using our etmsync infrastructure) to read the memory of a GSM device running * a compatible fw version; it was written as an aid for reverse-engineering * bootloader-locked Mot C139 fw versions. */ #include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include "tm3.h" #include "localtypes.h" #include "exitcodes.h" #define CHUNK_SIZE TM3_MEMREAD_MAX single_op_main(argc, argv) char **argv; { u32 addr, len, chunk; char buf[CHUNK_SIZE]; FILE *outf; int rc; if (argc != 3) { fprintf(stderr, "usage: fc-olddump [options] start-addr dump-length binfile\n"); exit(ERROR_USAGE); } addr = strtoul(argv[0], 0, 16); len = strtoul(argv[1], 0, 16); outf = fopen(argv[2], "w"); if (!outf) { perror(argv[2]); exit(ERROR_UNIX); } while (len) { chunk = len; if (chunk > CHUNK_SIZE) chunk = CHUNK_SIZE; rc = do_memory_read_tm3(addr, buf, chunk); if (rc) exit(rc); fwrite(buf, 1, chunk, outf); putchar('.'); fflush(stdout); addr += chunk; len -= chunk; } putchar('\n'); fclose(outf); exit(0); }