From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: mfe@pengutronix.de
Subject: [PATCH 3/5] filetype: add STM32 image type
Date: Fri, 12 Jul 2019 12:24:55 +0200 [thread overview]
Message-ID: <20190712102457.15339-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20190712102457.15339-1-a.fatoum@pengutronix.de>
Both STM32MP BootROM and TF-A first stage expect subsequent bootloader
stages to feature a specific 256-byte long STM32 file header.
Add detection of the header to file_detect_type().
While there's only one version of the header so far, identify the new
header as v1 anyway, so new versions can be unambiguously added.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
common/filetype.c | 9 +++++++++
include/filetype.h | 1 +
2 files changed, 10 insertions(+)
diff --git a/common/filetype.c b/common/filetype.c
index 329f5144bfed..825bf25ad107 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -79,6 +79,7 @@ static const struct filetype_str filetype_str[] = {
[filetype_layerscape_qspi_image] = { "Layerscape QSPI image", "layerscape-qspi-PBL" },
[filetype_ubootvar] = { "U-Boot environmemnt variable data",
"ubootvar" },
+ [filetype_stm32_image_v1] = { "STM32 image (v1)", "stm32-image-v1" },
};
const char *file_type_to_string(enum filetype f)
@@ -355,6 +356,14 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize)
if (buf8[0] == 'M' && buf8[1] == 'Z')
return filetype_exe;
+ if (bufsize < 256)
+ return filetype_unknown;
+
+ if (strncmp(buf8, "STM\x32", 4) == 0) {
+ if (buf8[74] == 0x01)
+ return filetype_stm32_image_v1;
+ }
+
if (bufsize < 512)
return filetype_unknown;
diff --git a/include/filetype.h b/include/filetype.h
index f1be04e81632..90a03de58105 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -48,6 +48,7 @@ enum filetype {
filetype_layerscape_image,
filetype_layerscape_qspi_image,
filetype_ubootvar,
+ filetype_stm32_image_v1,
filetype_max,
};
--
2.20.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2019-07-12 10:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-12 10:24 [PATCH 1/5] ARM: stm32mp: fix some misnomers/typos Ahmad Fatoum
2019-07-12 10:24 ` [PATCH 2/5] images: add support for generating STM32MP images Ahmad Fatoum
2019-07-12 10:24 ` Ahmad Fatoum [this message]
2019-07-12 10:24 ` [PATCH 4/5] ARM: stm32mp: generate STM32 images Ahmad Fatoum
2019-07-12 10:24 ` [PATCH 5/5] Documentation: boards: add initial STM32MP documentation Ahmad Fatoum
2019-07-12 11:49 ` [PATCH] fixup! " Ahmad Fatoum
2019-07-16 8:48 ` [PATCH 5/5] " Roland Hieber
2019-07-15 6:46 ` [PATCH 1/5] ARM: stm32mp: fix some misnomers/typos Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190712102457.15339-3-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=mfe@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox