FreeCalypso > hg > freecalypso-sw
view rvinterf/etmsync/olddump.c @ 992:a7b0b426f9ca
target-utils: boot ROM UART autodetection revamped
The new implementation should work with both the familiar Calypso C035
boot ROM version found in our regular targets as well as the older
Calypso F741979B version found on the vintage D-Sample board.
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Wed, 30 Dec 2015 21:28:41 +0000 |
parents | 461f7ee5f254 |
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); }