summaryrefslogtreecommitdiffstats
path: root/src/image.c
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2012-08-07 21:52:16 +0200
committerPali Rohár <pali.rohar@gmail.com>2012-08-07 21:52:16 +0200
commitd06e88ce39dadb22c8c0adfcad8f788a6cc4f6fa (patch)
treee98adf47463fc753706bd607e7082def67ad0333 /src/image.c
parentdf9fae0c0ee189519545a0d01488e98c9aac8836 (diff)
download0xFFFF-d06e88ce39dadb22c8c0adfcad8f788a6cc4f6fa.tar.bz2
image: image_type_from_data - added support for rx-51 images
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c23
1 files changed, 11 insertions, 12 deletions
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;
}