From d06e88ce39dadb22c8c0adfcad8f788a6cc4f6fa Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Tue, 7 Aug 2012 21:52:16 +0200 Subject: image: image_type_from_data - added support for rx-51 images --- src/image.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src/image.c') diff --git a/src/image.c b/src/image.c index fb54d61..c1367b9 100644 --- a/src/image.c +++ b/src/image.c @@ -397,15 +397,10 @@ enum image_type image_type_from_data(struct image * image) { image_seek(image, 0); image_read(image, buf, sizeof(buf)); - // 2nd : +0x34 = 2NDAPE - // secondary: +0x04 = NOLOScnd - // x-loader : +0x14 = X-LOADER - // xloader8 : +0x0c = NOLOXldr - // kernel : +0x00 = 0000 a0e1 0000 a0e1 - // initfs : <2M...be sure with 3M 0x300000 - if ( memcmp(buf+0x34, "2NDAPE", 6) == 0 ) return IMAGE_2ND; + else if ( memcmp(buf+0x14, "2ND", 3) == 0 ) + return IMAGE_2ND; else if ( memcmp(buf+0x04, "NOLOScnd", 8) == 0 ) return IMAGE_SECONDARY; else if ( memcmp(buf+0x14, "X-LOADER", 8) == 0 ) @@ -413,22 +408,26 @@ enum image_type image_type_from_data(struct image * image) { else if ( memcmp(buf+0x0c, "NOLOXldr", 8) == 0 ) return IMAGE_XLOADER; else if ( memcmp(buf+4, "NOLOXldr", 8) == 0 ) - // TODO: this is xloader800, not valid on 770? return IMAGE_2ND; else if ( memcmp(buf, "\x00\x00\xa0\xe1\x00\x00\xa0\xe1", 8) == 0 ) return IMAGE_KERNEL; else if ( memcmp(buf, "\x21\x01\x01", 3) == 0 ) return IMAGE_KERNEL; - else if ( memcmp(buf, "\x85\x19", 2) == 0 ) { - // JFFS2 MAGIC + else if ( memcmp(buf, "UBI#", 4) == 0 ) /* UBI EC header */ + return IMAGE_ROOTFS; + else if ( memcmp(buf, "\xb0\x00\x01\x03\x9d\x00\x00\x00", 8) == 0 ) + return IMAGE_CMT_2ND; + else if ( memcmp(buf, "\xb1\x00\x00\x00\x82\x00\x00\x00", 8) == 0 ) + return IMAGE_CMT_ALGO; + else if ( memcmp(buf, "\xb2\x00\x00\x01\x44\x00\x00\x00", 8) == 0 ) + return IMAGE_CMT_MCUSW; + else if ( memcmp(buf, "\x85\x19\x01\xe0", 2) == 0 ) { /* JFFS2 MAGIC */ if ( image->size < 0x300000 ) return IMAGE_INITFS; else return IMAGE_ROOTFS; } - /* TODO: Add support for UBIFS rootfs and other types */ - return IMAGE_UNKNOWN; } -- cgit v1.2.3