From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Joacim Zetterling <joacim.zetterling@westermo.com>,
barebox@lists.infradead.org
Subject: Re: [PATCH 2/3] scripts: arch: imx: Add QSPI boot support to IMX build image script
Date: Tue, 8 Mar 2022 17:21:04 +0100 [thread overview]
Message-ID: <694c28de-73e2-ff61-c32f-4e323989a822@pengutronix.de> (raw)
In-Reply-To: <20220308160801.782206-3-joacim.zetterling@westermo.com>
On 08.03.22 17:08, Joacim Zetterling wrote:
> This functionality extend the IMX image build script with a support
> for generating QSPI boot images.
>
> A QSPI boot image need device configuration parameters located at
> an offset of 0x400 in the IVT section. The configuration parameters
> are stored in a 512 byte bin file which will be included in the
> final boot image. The boot image parameters comes from the board
> flash header imxcfg file.
>
> The QSPI configuration parameters are described in the reference
> manual for the specific target.
>
> Signed-off-by: Joacim Zetterling <joacim.zetterling@westermo.com>
Does this mean we can't have the same barebox image for both SD/eMMC
and QSPI-NOR?
Does filetype correctly detect this format? If not, you should
add a check there to allow barebox update handlers to bail out
when installing an incompatible image.
Cheers,
Ahmad
> ---
> arch/arm/mach-imx/include/mach/imx-header.h | 2 +
> scripts/imx/imx-image.c | 25 ++++++++
> scripts/imx/imx.c | 67 ++++++++++++++++++++-
> 3 files changed, 93 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/mach-imx/include/mach/imx-header.h b/arch/arm/mach-imx/include/mach/imx-header.h
> index 8e968e6efba3..a58deb8d864e 100644
> --- a/arch/arm/mach-imx/include/mach/imx-header.h
> +++ b/arch/arm/mach-imx/include/mach/imx-header.h
> @@ -118,6 +118,8 @@ struct config_data {
> char *signed_hdmi_firmware_file;
> int encrypt_image;
> size_t dek_size;
> + uint32_t bb_cfg_ofs;
> + char *bb_cfg_file;
> };
>
> #define MAX_RECORDS_DCD_V2 1024
> diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c
> index 439912a805dc..b8ae63ad9400 100644
> --- a/scripts/imx/imx-image.c
> +++ b/scripts/imx/imx-image.c
> @@ -951,6 +951,31 @@ int main(int argc, char *argv[])
> exit(1);
> }
>
> + /*
> + * The boot ROM expects a 512-byte configuration parameters area for
> + * some devices (like the FlexSPI NOR flash) to be present an defined
> + * offset in the image ivt section (0x400 for the FlexSPI NOR).
> + */
> + if (data.bb_cfg_file) {
> + size_t bb_cfg_file_size = 512;
> + char *bb_cfg;
> +
> + bb_cfg = calloc(512, sizeof(char));
> + if (!bb_cfg)
> + exit(1);
> +
> + bb_cfg = read_file(data.bb_cfg_file, &bb_cfg_file_size);
> +
> + if (lseek(outfd, data.bb_cfg_ofs, SEEK_SET) < 0) {
> + perror("lseek");
> + exit(1);
> + }
> +
> + xwrite(outfd, bb_cfg, bb_cfg_file_size);
> +
> + free(bb_cfg);
> + }
> +
> if (lseek(outfd, data.header_gap, SEEK_SET) < 0) {
> perror("lseek");
> exit(1);
> diff --git a/scripts/imx/imx.c b/scripts/imx/imx.c
> index 87560ad27de1..a242e6d76a47 100644
> --- a/scripts/imx/imx.c
> +++ b/scripts/imx/imx.c
> @@ -215,6 +215,16 @@ static int do_dcdofs_error(struct config_data *data, int argc, char *argv[])
> return -EINVAL;
> }
>
> +static int do_header_gap(struct config_data *data, int argc, char *argv[])
> +{
> + if (argc < 2)
> + return -EINVAL;
> +
> + data->header_gap = strtoul(argv[1], NULL, 0);
> +
> + return 0;
> +}
> +
> struct soc_type {
> char *name;
> int header_version;
> @@ -223,6 +233,7 @@ struct soc_type {
> uint32_t first_opcode;
> };
>
> +#define SZ_4K (4 * 1024)
> #define SZ_32K (32 * 1024)
>
> static struct soc_type socs[] = {
> @@ -580,7 +591,6 @@ do_signed_hdmi_firmware(struct config_data *data, int argc, char *argv[])
> const char *file;
> int len;
>
> -
> if (argc != 2) {
> fprintf(stderr, "usage: signed_hdmi_firmware <file>\n");
> return -EINVAL;
> @@ -609,6 +619,52 @@ do_signed_hdmi_firmware(struct config_data *data, int argc, char *argv[])
> return 0;
> }
>
> +static int do_bb_cfg_ofs(struct config_data *data, int argc, char *argv[])
> +{
> + if (argc < 2)
> + return -EINVAL;
> +
> + data->bb_cfg_ofs = strtoul(argv[1], NULL, 0);
> +
> + return 0;
> +}
> +
> +static int do_bb_cfg_file(struct config_data *data, int argc, char *argv[])
> +{
> + const char *file;
> + int len;
> +
> + if (argc != 2) {
> + fprintf(stderr, "usage: bb_cfg_file <file>\n");
> + return -EINVAL;
> + }
> +
> + if ((data->cpu_type != IMX_CPU_IMX8MM) &&
> + (data->cpu_type != IMX_CPU_IMX8MN) &&
> + (data->cpu_type != IMX_CPU_IMX8MP) &&
> + (data->cpu_type != IMX_CPU_IMX8MQ)) {
> + fprintf(stderr,
> + "Warning: The configuration param command is "
> + "only supported i.MX8 SoCs\n");
> + return 0;
> + }
> +
> + file = argv[1];
> +
> + if (*file == '"')
> + file++;
> +
> + data->bb_cfg_file = strdup(file);
> + if (!data->bb_cfg_file)
> + return -ENOMEM;
> +
> + len = strlen(data->bb_cfg_file);
> + if (data->bb_cfg_file[len - 1] == '"')
> + data->bb_cfg_file[len - 1] = 0;
> +
> + return 0;
> +}
> +
> struct command cmds[] = {
> {
> .name = "wm",
> @@ -634,6 +690,9 @@ struct command cmds[] = {
> }, {
> .name = "dcdofs",
> .parse = do_dcdofs_error,
> + }, {
> + .name = "header_gap",
> + .parse = do_header_gap,
> }, {
> .name = "soc",
> .parse = do_soc,
> @@ -667,6 +726,12 @@ struct command cmds[] = {
> }, {
> .name = "signed_hdmi_firmware",
> .parse = do_signed_hdmi_firmware,
> + }, {
> + .name = "bb_cfg_ofs",
> + .parse = do_bb_cfg_ofs,
> + }, {
> + .name = "bb_cfg_file",
> + .parse = do_bb_cfg_file,
> },
> };
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2022-03-08 16:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-08 16:07 [PATCH 0/3] arch: arm: imx: spi: Add QSPI boot support to the IMX8 platforms Joacim Zetterling
2022-03-08 16:07 ` [PATCH 1/3] " Joacim Zetterling
2022-03-08 16:18 ` Ahmad Fatoum
2022-03-08 16:08 ` [PATCH 2/3] scripts: arch: imx: Add QSPI boot support to IMX build image script Joacim Zetterling
2022-03-08 16:21 ` Ahmad Fatoum [this message]
2022-03-09 8:43 ` Sascha Hauer
2022-03-08 16:08 ` [PATCH 3/3] arch: arm: imx: spi: Add QSPI boot option to the IMX8MN-EVK Joacim Zetterling
2022-03-09 8:53 ` 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=694c28de-73e2-ff61-c32f-4e323989a822@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=joacim.zetterling@westermo.com \
/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