FreeCalypso > hg > freecalypso-sw
changeset 225:c04aa85559ed
TIFFS in vitro reader started
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Mon, 13 Jan 2014 09:05:01 +0000 |
parents | 2900fe603f8a |
children | 4d706a4134b0 |
files | .hgignore ffstools/tiffs-rd/Makefile ffstools/tiffs-rd/README ffstools/tiffs-rd/main.c |
diffstat | 4 files changed, 139 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Sun Jan 12 07:59:00 2014 +0000 +++ b/.hgignore Mon Jan 13 09:05:01 2014 +0000 @@ -5,6 +5,8 @@ \.bin$ \.srec$ +^ffstools/tiffs-rd/tiffs$ + ^gsm-fw/build\.conf$ ^gsm-fw/config\.stamp$ ^gsm-fw/finlink/.*\.ld$
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ffstools/tiffs-rd/Makefile Mon Jan 13 09:05:01 2014 +0000 @@ -0,0 +1,12 @@ +CC= gcc +CFLAGS= -O2 +PROG= tiffs +OBJS= main.o + +all: ${PROG} + +${PROG}: ${OBJS} + ${CC} -o $@ ${OBJS} + +clean: + rm -f ${PROG} *.o *.out *errs
--- a/ffstools/tiffs-rd/README Sun Jan 12 07:59:00 2014 +0000 +++ b/ffstools/tiffs-rd/README Mon Jan 13 09:05:01 2014 +0000 @@ -1,33 +1,11 @@ The utility being developed in this source directory will allow one to examine -("in vitro") flash file system (FFS) images read out of TI GSM devices - or -more precisely, out of GSM devices using a TI chipset and running TI's GSM -firmware versions from the late Calypso era. The FFS version in question is -implemented in our own FreeCalypso GSM fw, also happens to be used by the -original proprietary firmware on the Pirelli DP-L10, and on some devices like -Openmoko GTA0x the use of this FFS format is required in order to make use of -the factory IMEI and RF calibration data. +("in vitro") flash file system (FFS) images read out of TI GSM devices; see +doc/TIFFS at the top level of the freecalypso-sw source tree for more info. This new tiffs utility is intended to replace the earlier mpffs-* utilities released in the summer of SE52 (A.D. 2013), and will also incorporate the additional examination functionality that was developed as part of the "pirollback" utilities. -Naming -====== - -I have previously referred to the FFS format in question as Mokopir-FFS or -MPFFS, from "Moko" and "Pirelli". I was originally hesitant to call it TIFFS, -as lacking the source code, I had no way of knowing whether the FFS format and -implementation were of TI's own invention, or something that TI licensed as a -black box from one of their many proprietary software partners. (I was unable -to identify it as any well-known, industry-standard FFS format, but absence of -evidence is not evidence of absence.) But now that we have TI's original source -code which implements this FFS (first the MV100-0.1.rar source, then the full -Leonardo one), complete with comments and a HISTORY file, we know that our FFS -was invented and implemented by someone named Mads Meisner-Jensen at TI - I'm -guessing in the SSA group in Nice, France. - -I am now making a naming transition from MPFFS to TIFFS: there is really no -link between this FFS format and the Openmoko+Pirelli duo, other than the -happenstance of me having first encountered this FFS on these two GSM device -brands, and the name TIFFS is more neutrally-descriptive. +See the abovementioned doc/TIFFS blurb for an explanation of the name change +from MPFFS to TIFFS.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ffstools/tiffs-rd/main.c Mon Jan 13 09:05:01 2014 +0000 @@ -0,0 +1,121 @@ +/* + * This C module contains the main() function for the tiffs utility, + * dispatching control to different operation commands. + */ + +#include <sys/types.h> +#include <ctype.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> +#include "types.h" + +u8 tiffs_header[6] = {'F', 'f', 's', '#', 0x10, 0x02}; +u8 blank_flash_line[16] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; + +char *imgfile; +u32 eraseblk_size; +int total_blocks; +u32 total_ffs_size; +int index_blk_num = -1, root_node_no; +int offset_blocks; +int verbose; + +parse_org_arg(arg) + char *arg; +{ + char *cp; + + cp = index(arg, 'x'); + if (!cp || !isdigit(cp[1]) || !isdigit(arg[0])) { + fprintf(stderr, + "error: TIFFS organization argument \"%s\" is invalid\n", arg); + exit(1); + } + *cp++ = '\0'; + if (!strcmp(arg, "16")) + eraseblk_size = 0x4000; + else if (!strcmp(arg, "32")) + eraseblk_size = 0x8000; + else if (!strcmp(arg, "64")) + eraseblk_size = 0x10000; + else if (!strcmp(arg, "128")) + eraseblk_size = 0x20000; + else if (!strcmp(arg, "256")) + eraseblk_size = 0x40000; + else { + fprintf(stderr, + "error: \"%s\" is not a recognized flash sector size\n", + arg); + exit(1); + } + total_blocks = atoi(cp); + if (total_blocks < 1 || total_blocks > 128) { + fprintf(stderr, + "error: \"%s\" is not a reasonable number of FFS sectors\n", + cp); + exit(1); + } + total_ffs_size = eraseblk_size * total_blocks; +} + +static struct cmdtab { + char *cmd; + int (*func)(); +} cmdtab[] = { + {"cat", NULL}, + {"fsck", NULL}, + {"ls", NULL}, + {"xtr", NULL}, + {NULL, NULL} +}; + +main(argc, argv) + char **argv; +{ + extern int optind; + extern char *optarg; + int c; + char *cmd; + struct cmdtab *tp; + + while ((c = getopt(argc, argv, "+a:o:r:v")) != EOF) + switch (c) { + case 'a': + index_blk_num = atoi(optarg); + continue; + case 'o': + offset_blocks = atoi(optarg); + continue; + case 'r': + root_node_no = atoi(optarg); + continue; + case 'v': + verbose++; + continue; + default: +usage: fprintf(stderr, + "usage: %s [global-options] <imgfile> <org> <op> ...\n", + argv[0]); + exit(1); + } + if (argc - optind < 3) + goto usage; + imgfile = argv[optind]; + parse_org_arg(argv[optind+1]); + cmd = argv[optind+2]; + + for (tp = cmdtab; tp->cmd; tp++) + if (!strcmp(tp->cmd, cmd)) + break; + if (!tp->func) { + fprintf(stderr, + "%s: operation \"%s\" is unknown or unimplemented\n", + argv[0], cmd); + exit(1); + } + optind += 2; + return tp->func(argc - optind, argv + optind); +}