Commit 65412b14 authored by Andre Przywara's avatar Andre Przywara
Browse files

fel: Detect (and report) FIT image



In preparation for proper FIT image support, detect a FIT image by
checking its first four byte against the DTB magic.

Report this as not-yet-supported to the user, for now.
Signed-off-by: default avatarAndre Przywara <osp@andrep.de>
parent 5541673d
...@@ -46,6 +46,7 @@ static bool enter_in_aarch64 = false; ...@@ -46,6 +46,7 @@ static bool enter_in_aarch64 = false;
#define IH_TYPE_INVALID 0 /* Invalid Image */ #define IH_TYPE_INVALID 0 /* Invalid Image */
#define IH_TYPE_FIRMWARE 5 /* Firmware Image */ #define IH_TYPE_FIRMWARE 5 /* Firmware Image */
#define IH_TYPE_SCRIPT 6 /* Script file */ #define IH_TYPE_SCRIPT 6 /* Script file */
#define IH_TYPE_FLATDT 8 /* DTB or FIT image */
#define IH_NMLEN 32 /* Image Name Length */ #define IH_NMLEN 32 /* Image Name Length */
/* Additional error codes, newly introduced for get_image_type() */ /* Additional error codes, newly introduced for get_image_type() */
...@@ -91,6 +92,8 @@ int get_image_type(const uint8_t *buf, size_t len) ...@@ -91,6 +92,8 @@ int get_image_type(const uint8_t *buf, size_t len)
if (len <= HEADER_SIZE) /* insufficient length/size */ if (len <= HEADER_SIZE) /* insufficient length/size */
return IH_TYPE_INVALID; return IH_TYPE_INVALID;
if (be32toh(hdr->ih_magic) == 0xd00dfeed)
return IH_TYPE_FLATDT;
if (be32toh(hdr->ih_magic) != IH_MAGIC) /* signature mismatch */ if (be32toh(hdr->ih_magic) != IH_MAGIC) /* signature mismatch */
return IH_TYPE_INVALID; return IH_TYPE_INVALID;
/* For sunxi, we always expect ARM architecture here */ /* For sunxi, we always expect ARM architecture here */
...@@ -889,6 +892,11 @@ static void aw_fel_write_uboot_image(feldev_handle *dev, uint8_t *buf, ...@@ -889,6 +892,11 @@ static void aw_fel_write_uboot_image(feldev_handle *dev, uint8_t *buf,
} }
exit(1); exit(1);
} }
if (image_type == IH_TYPE_FLATDT) { /* FIT image */
pr_error("FIT image not yet supported.\n");
exit(1);
}
if (image_type != IH_TYPE_FIRMWARE) if (image_type != IH_TYPE_FIRMWARE)
pr_fatal("U-Boot image type mismatch: " pr_fatal("U-Boot image type mismatch: "
"expected IH_TYPE_FIRMWARE, got %02X\n", image_type); "expected IH_TYPE_FIRMWARE, got %02X\n", image_type);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment