mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Joacim Zetterling <joacim.zetterling@westermo.com>
Cc: barebox@lists.infradead.org, a.fatoum@pengutronix.de
Subject: Re: [PATCH 2/3] scripts: arch: imx: Add QSPI boot support to IMX build image script
Date: Wed, 9 Mar 2022 09:43:24 +0100	[thread overview]
Message-ID: <20220309084324.GI405@pengutronix.de> (raw)
In-Reply-To: <20220308160801.782206-3-joacim.zetterling@westermo.com>

Hi Joacim,

On Tue, Mar 08, 2022 at 05:08:00PM +0100, 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>
> ---
>  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);

The buffer you are allocating here is not used...
> +
> +			bb_cfg = read_file(data.bb_cfg_file, &bb_cfg_file_size);

...the pointer is directly overwritten with the buffer that read_file returns.

You should check the return value of read_file.

Anyway, specifying filenames in config files doesn't work properly. When
you are building out of tree then imx-image will look for the file
relative to $(objtree), but the file really is relative to $(srctree).

In other tools we usually pass filenames via a command line option, see
for example:

images/Makefile.mvebu:43:BINHDR_start_lenovo_ix4_300d.pblb.mvebu1img = $(board)/lenovo-ix4-300d/binary.0

Sascha

-- 
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


  parent reply	other threads:[~2022-03-09  8:45 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
2022-03-09  8:43   ` Sascha Hauer [this message]
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=20220309084324.GI405@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=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