diff options
author | Mychaela Falconia <mychaela.falconia@gmail.com> | 2019-02-12 15:21:33 +0700 |
---|---|---|
committer | Vadim Yanitskiy <axilirator@gmail.com> | 2019-02-19 15:18:56 +0700 |
commit | 947369922990195bccb59cae88cccbd7eefac9c8 (patch) | |
tree | 12ae3f62f0c22adc90d9a69a89e8ba3b7e8e5dea /src/target/firmware/include | |
parent | edabc799edcc893fcdef707ee861de9807dc78e7 (diff) |
firmware/lib: introduce TIFFS filesystem support
All known TI GSM firmwares implement some kind of flash file system, or FFS.
We call it TIFFS (Texas Instruments FFS) because it is TI's invention.
TIFFS is a file system with a hierarchical directory tree structure, and
with Unixy forward-slash-separated, case-sensitive pathnames; the semantics
of "what is a file" and "what is a directory" are exactly the same as in
UNIX; and TIFFS even supports symlinks, although that support is a little
under-developed, and apparently no FFS symlinks were ever used in any
production GSM device. Thus the FFS implemented in TI-based GSM devices
(modems and "dumbphone" handsets) is really no different from, for example,
JFFS2 in embedded Linux systems.
The FFS in a GSM device typically stores two kinds of content:
- Factory data: IMEI, RF calibration values, device make/model/revision
ID strings etc. These files are expected to be programmed on the
factory production line and not changed afterward.
- Dynamic data written into the FFS in normal device operation: contacts,
settings / preferences, call history, received SMS, etc.
It should be noted that both Compal (Mot C1xx) and Foxconn (Pirelli DP-L10)
vendors moved their vital per-unit factory data out of the FFS into their
own ad hoc flash data structures, leaving their FFS only for less
critical data. However, we do enable TIFFS access for them anyway.
The location of TIFFS within the flash memory of a given GSM device is
defined by the firmware design of that device, but is always some integral
number of contiguous flash sectors.
- On Motorola/Compal C139/140 phones, the FFS used by the original
proprietary firmware occupies 5 sectors of 64 KiB each (320 KiB
in total), starting at 0x370000. C11x/123 use smaller FFS
configurations, whereas C155/156 seem to have switched to some
other FFS format, different from our familiar TIFFS.
- On the Pirelli DP-L10, the FFS used by the original proprietary
firmware occupies 18 sectors of 256 KiB each (for 4.5 MiB in total),
starting at the beginning of the 2nd flash chip select (0x02000000
in the ARM7 address space).
- On FCDEV3B (FreeCalypso hardware), the FFS is located in the first
8 sectors (of 256 KiB each) in the 2nd flash chip select bank,
which appears at 0x01800000 in the ARM7 address space.
- On the GTA01/02 GSM modem, FFS occupies 7 sectors of 64 KiB each,
starting at flash offset 0x380000.
For more information, please refer to the FreeCalypso project
documentation, from where this great contribution comes from.
Please note that existing MediaTek targets most likely use different
storage format as they have nothing from TI Calypso. Also, we don't
(yet) know the location of TIFFS on SE J100i and Compal E99 targets.
The TIFFS support is needed for the follow-up change, that
implements reading of the factory RF calibration values.
Tweaked (coding style changes) by Vadim Yanitskiy <axilirator@gmail.com>
Change-Id: If6e212baeb10953129fb0d5253d263567f5e12d6
Related: OS#3582
Diffstat (limited to 'src/target/firmware/include')
-rw-r--r-- | src/target/firmware/include/string.h | 3 | ||||
-rw-r--r-- | src/target/firmware/include/tiffs.h | 33 |
2 files changed, 36 insertions, 0 deletions
diff --git a/src/target/firmware/include/string.h b/src/target/firmware/include/string.h index f060659a..ecef13d0 100644 --- a/src/target/firmware/include/string.h +++ b/src/target/firmware/include/string.h @@ -9,4 +9,7 @@ size_t strlen(const char *s); void *memset(void *s, int c, size_t n); void *memcpy(void *dest, const void *src, size_t n); +int memcmp(const void *s1, const void *s2, size_t n); +int strcmp(const char *s1, const char *s2); + #endif diff --git a/src/target/firmware/include/tiffs.h b/src/target/firmware/include/tiffs.h new file mode 100644 index 00000000..4713c4e1 --- /dev/null +++ b/src/target/firmware/include/tiffs.h @@ -0,0 +1,33 @@ +/* + * The external API for the TIFFS reader library (libtiffs). + * + * For the file reading functions, the return code is 0 if the file wasn't + * found or there is no valid FFS (no error msg printed), 1 if the file was + * found and read successfully, or negative if some other error(s) occurred + * (error msg printed internally). + */ + +#define INODE_TO_DATAPTR(i) \ + ((uint8_t *)tiffs_base_addr + ((i)->dataptr << 4)) + +#define TIFFS_OBJTYPE_FILE 0xF1 +#define TIFFS_OBJTYPE_DIR 0xF2 +#define TIFFS_OBJTYPE_SEGMENT 0xF4 + +struct tiffs_inode { + uint16_t len; + uint8_t reserved1; + uint8_t type; + uint16_t descend; + uint16_t sibling; + uint32_t dataptr; + uint16_t sequence; + uint16_t updates; +}; + +int tiffs_init(uint32_t base_addr, uint32_t sector_size, unsigned nsectors); + +int tiffs_read_file_maxlen(const char *pathname, uint8_t *buf, + size_t maxlen, size_t *lenrtn); +int tiffs_read_file_fixedlen(const char *pathname, uint8_t *buf, + size_t expect_len); |