summaryrefslogtreecommitdiffstats
path: root/common/filetype.c
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2018-08-23 19:52:22 -0700
committerSascha Hauer <s.hauer@pengutronix.de>2018-08-31 08:30:07 +0200
commit489157938a25285ee96f6fff19a957259d0f51a8 (patch)
tree71370e61b63f73b8c686dc5f7ee9010b5871f22a /common/filetype.c
parent91b7a171bcafd3bc738fe2e50500da765b793983 (diff)
downloadbarebox-489157938a25285ee96f6fff19a957259d0f51a8.tar.gz
barebox-489157938a25285ee96f6fff19a957259d0f51a8.tar.xz
filetype: Add code to detect i.MX image v1
Modify file_detect_type() and add code needed to be able to detect i.MX boot images with v1 header. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/filetype.c')
-rw-r--r--common/filetype.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/common/filetype.c b/common/filetype.c
index c5f2384a6c..8f2be27736 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -29,6 +29,8 @@
#include <image-sparse.h>
#include <elf.h>
+#include <arm/mach-imx/include/mach/imx-header.h>
+
struct filetype_str {
const char *name; /* human readable filetype */
const char *shortname; /* short string without spaces for shell scripts */
@@ -71,6 +73,7 @@ static const struct filetype_str filetype_str[] = {
[filetype_android_sparse] = { "Android sparse image", "sparse" },
[filetype_arm64_linux_image] = { "ARM aarch64 Linux image", "aarch64-linux" },
[filetype_elf] = { "ELF", "elf" },
+ [filetype_imx_image_v1] = { "i.MX image (v1)", "imx-image-v1" },
};
const char *file_type_to_string(enum filetype f)
@@ -250,6 +253,7 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize)
const u64 *buf64 = _buf;
const u8 *buf8 = _buf;
const u16 *buf16 = _buf;
+ const struct imx_flash_header *imx_flash_header = _buf;
enum filetype type;
if (bufsize < 9)
@@ -361,6 +365,9 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize)
if (strncmp(buf8, ELFMAG, 4) == 0)
return filetype_elf;
+ if (imx_flash_header->dcd_barker == DCD_BARKER)
+ return filetype_imx_image_v1;
+
return filetype_unknown;
}