mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Marco Felsch <m.felsch@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] ARM: i.MX8M: bootrom: fix load image size
Date: Wed, 15 Nov 2023 14:14:31 +0100	[thread overview]
Message-ID: <20231115131431.GC3359458@pengutronix.de> (raw)
In-Reply-To: <20231113090438.1890680-1-m.felsch@pengutronix.de>

On Mon, Nov 13, 2023 at 10:04:38AM +0100, Marco Felsch wrote:
> Without the proper aligned image size we may encounter host load errors
> like:
> 
> | found i.MX8MP USB device [1fc9:0146]
> | No dcd table in this ivt
> | dl_command err=-1, last_trans=-1
> | 4 in err=-4, last_trans=0  00 00 00 00
> 
> The reason for this is that we asked only for the required bytes while
> the host tries to send the complete image which may contain alignment
> bytes at the end.
> 
> Fix this by request always 4K aligned sizes.

As discussed in mumble: This fix is not correct. It works with HABv4
enabled images, but not on images without HAB support.

Sascha

> 
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
>  arch/arm/mach-imx/romapi.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/arch/arm/mach-imx/romapi.c b/arch/arm/mach-imx/romapi.c
> index 1b1800f1e000..b4c63e4d7274 100644
> --- a/arch/arm/mach-imx/romapi.c
> +++ b/arch/arm/mach-imx/romapi.c
> @@ -6,6 +6,7 @@
>  #include <linux/bitfield.h>
>  #include <soc/imx9/flash_header.h>
>  #include <asm/sections.h>
> +#include <linux/sizes.h>
>  #include <mach/imx/romapi.h>
>  #include <mach/imx/atf.h>
>  #include <mach/imx/imx8m-regs.h>
> @@ -50,6 +51,12 @@ static int imx_bootrom_query(struct rom_api *rom_api, uint32_t type, uint32_t *_
>  
>  static int imx_romapi_load_stream(struct rom_api *rom_api, void *adr, size_t size)
>  {
> +	/*
> +	 * The imx-image tool align the final image size to 4K so we need to
> +	 * take this into account.
> +	 */
> +	size = ALIGN(size, SZ_4K);
> +
>  	while (size) {
>  		size_t chunksize = min(size, (size_t)1024);
>  		int ret;
> -- 
> 2.39.2
> 
> 
> 

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



  reply	other threads:[~2023-11-15 13:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-13  9:04 Marco Felsch
2023-11-15 13:14 ` Sascha Hauer [this message]
2023-11-15 15:22   ` Marco Felsch

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=20231115131431.GC3359458@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=m.felsch@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