diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rvinterf/etmsync/olddump.c	Thu Dec 10 05:16:46 2015 +0000
@@ -0,0 +1,55 @@
+/*
+ * 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);
+}