FreeCalypso > hg > freecalypso-tools
changeset 153:9925fba699be
fc-olddump replaced with fc-memdump
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 06 Mar 2017 01:19:51 +0000 |
parents | 9a08c09a07c0 |
children | 3c446058b5a6 |
files | .hgignore CHANGES rvinterf/etmsync/Makefile rvinterf/etmsync/memdump.c rvinterf/etmsync/olddump.c |
diffstat | 5 files changed, 129 insertions(+), 62 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Sun Mar 05 18:55:43 2017 +0000 +++ b/.hgignore Mon Mar 06 01:19:51 2017 +0000 @@ -30,9 +30,7 @@ ^rvinterf/ctracedec/ctracedec$ ^rvinterf/etmsync/fc-dspapidump$ ^rvinterf/etmsync/fc-fsio$ -^rvinterf/etmsync/fc-getpirimei$ -^rvinterf/etmsync/fc-olddump$ -^rvinterf/etmsync/fc-pirhackinit$ +^rvinterf/etmsync/fc-memdump$ ^rvinterf/lowlevel/rvinterf$ ^rvinterf/lowlevel/rvtdump$ ^rvinterf/lowlevel/tfc139$
--- a/CHANGES Sun Mar 05 18:55:43 2017 +0000 +++ b/CHANGES Mon Mar 06 01:19:51 2017 +0000 @@ -29,6 +29,9 @@ * fc-tmsh now supports L1/RF test mode commands and other TM3 protocol commands (omr, omw, oabbr, oabbw, tm3ver). +* fc-olddump renamed to fc-memdump, can now use either TM3 or ETM memory read + commands. + * tiffs: added -O option to parse FFS images from the ancient 20020917 firmware on the D-Sample.
--- a/rvinterf/etmsync/Makefile Sun Mar 05 18:55:43 2017 +0000 +++ b/rvinterf/etmsync/Makefile Mon Mar 06 01:19:51 2017 +0000 @@ -1,6 +1,6 @@ CC= gcc CFLAGS= -O2 -I../include -PROGS= fc-dspapidump fc-fsio fc-olddump +PROGS= fc-dspapidump fc-fsio fc-memdump INSTBIN=/opt/freecalypso/bin INSTHELP=/opt/freecalypso/helpfiles @@ -12,7 +12,7 @@ fsupload.o fswrite.o help.o interf.o launchrvif.o memcmd.o \ memops.o pirimei.o pirmagnetite.o rfcap.o stddirs.o symlink.o -OLDDUMP_OBJS= connect.o interf.o launchrvif.o memops.o olddump.o simplemain.o +MEMDUMP_OBJS= connect.o interf.o launchrvif.o memdump.o memops.o all: ${PROGS} @@ -22,8 +22,8 @@ fc-fsio: ${FSIO_OBJS} ${CC} ${CFLAGS} -o $@ ${FSIO_OBJS} -fc-olddump: ${OLDDUMP_OBJS} - ${CC} ${CFLAGS} -o $@ ${OLDDUMP_OBJS} +fc-memdump: ${MEMDUMP_OBJS} + ${CC} ${CFLAGS} -o $@ ${MEMDUMP_OBJS} install: ${PROGS} mkdir -p ${INSTBIN}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rvinterf/etmsync/memdump.c Mon Mar 06 01:19:51 2017 +0000 @@ -0,0 +1,121 @@ +/* + * This utility uses one of TI's Test Mode memory read commands (either TM3 or + * ETM) in a synchronous manner (using our etmsync infrastructure) to read the + * memory of a GSM device running a compatible fw version. It supplants + * the former fc-olddump tool. + */ + +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> +#include <unistd.h> +#include "etm.h" +#include "tm3.h" +#include "localtypes.h" +#include "exitcodes.h" + +int use_etm; + +extern char *socket_pathname; +extern char *rvinterf_ttyport, *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt; + +single_op_main(argc, argv) + char **argv; +{ + u32 addr, len, chunk, maxchunk; + char buf[MAX_MEMREAD_BYTES]; + FILE *outf; + int rc; + + if (argc != 3) { + fprintf(stderr, + "usage: fc-memdump [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); + } + if (use_etm) + maxchunk = MAX_MEMREAD_BYTES; + else + maxchunk = TM3_MEMREAD_MAX; + while (len) { + chunk = len; + if (chunk > maxchunk) + chunk = maxchunk; + if (use_etm) + rc = do_memory_read(addr, buf, chunk); + else + 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); +} + +main(argc, argv) + char **argv; +{ + extern int optind; + extern char *optarg; + int c, sopt = 0; + + while ((c = getopt(argc, argv, "B:el:p:s:w:")) != EOF) + switch (c) { + case 'B': + rvinterf_Bopt = optarg; + continue; + case 'e': + use_etm++; + continue; + case 'l': + rvinterf_lopt = optarg; + continue; + case 'p': + rvinterf_ttyport = optarg; + continue; + case 's': + socket_pathname = optarg; + sopt++; + continue; + case 'w': + rvinterf_wopt = optarg; + continue; + case '?': + default: + /* error msg already printed */ + exit(ERROR_USAGE); + } + if (rvinterf_ttyport) { + if (sopt) { + fprintf(stderr, + "%s error: -p and -s options are mutually exclusive\n", + argv[0]); + exit(ERROR_USAGE); + } + launch_rvinterf(); + } else { + if (rvinterf_Bopt || rvinterf_lopt || rvinterf_wopt) { + fprintf(stderr, +"%s error: -B, -l and -w options are meaningful only when launching rvinterf\n", + argv[0]); + exit(ERROR_USAGE); + } + connect_local_socket(); + } + + return single_op_main(argc - optind, argv + optind); +}
--- a/rvinterf/etmsync/olddump.c Sun Mar 05 18:55:43 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* - * 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); -}