comparison rvinterf/etmsync/olddump.c @ 981:0feb3db6f097

fc-olddump written, compiles
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Thu, 10 Dec 2015 05:16:46 +0000
parents
children 461f7ee5f254
comparison
equal deleted inserted replaced
980:a0879ce32d2c 981:0feb3db6f097
1 /*
2 * This utility uses the old TM3 memory read command (in a synchronous manner
3 * using our etmsync infrastructure) to read the memory of a GSM device running
4 * a compatible fw version; it was written as an aid for reverse-engineering
5 * bootloader-locked Mot C139 fw versions.
6 */
7
8 #include <sys/types.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <string.h>
12 #include <strings.h>
13 #include "tm3.h"
14 #include "localtypes.h"
15 #include "exitcodes.h"
16
17 #define CHUNK_SIZE TM3_MEMREAD_MAX
18
19 single_op_main(argc, argv)
20 char **argv;
21 {
22 u32 addr, len, chunk;
23 char buf[CHUNK_SIZE];
24 FILE *outf;
25 int rc;
26
27 if (argc != 3) {
28 fprintf(stderr,
29 "usage: fc-olddump [options] start-addr dump-length binfile\n");
30 exit(ERROR_USAGE);
31 }
32 addr = strtoul(argv[0], 0, 16);
33 len = strtoul(argv[1], 0, 16);
34 outf = fopen(argv[2], "w");
35 if (!outf) {
36 perror(argv[2]);
37 exit(ERROR_UNIX);
38 }
39 while (len) {
40 chunk = len;
41 if (chunk > CHUNK_SIZE)
42 chunk = CHUNK_SIZE;
43 rc = do_memory_read_tm3(addr, buf, chunk);
44 if (rc)
45 exit(rc);
46 fwrite(buf, 1, chunk, outf);
47 putchar('.');
48 fflush(stdout);
49 addr += chunk;
50 len += chunk;
51 }
52 putchar('\n');
53 fclose(outf);
54 exit(0);
55 }