mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Roland Hieber <rhi@pengutronix.de>
To: ptxdist@pengutronix.de
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>,
	Roland Hieber <rhi@pengutronix.de>
Subject: [ptxdist] [PATCH v2] ptxd_make_fit_image: pad FIT image to block size of 4096 bytes
Date: Wed, 23 Aug 2023 12:49:59 +0200	[thread overview]
Message-ID: <20230823104959.2870164-1-rhi@pengutronix.de> (raw)
In-Reply-To: <20230823103409.2840820-1-rhi@pengutronix.de>

Trying to flash a FIT image over fastboot often results in errors like
this:

    Invalid sparse file format at header magic
    error: write_sparse_skip_chunk: don't care size 18394488 is not a multiple of the block size 4096
    error: write_sparse_skip_chunk: don't care size 10009976 is not a multiple of the block size 4096
    error: write_sparse_skip_chunk: don't care size 1625464 is not a multiple of the block size 4096
    [...]
    FAILED (remote: 'writing sparse image: Invalid argument')

The FIT image knows about its own size anyway, so to get around this
issue, we can simply pad the image to a multiple of 4 kiB to make it
work with the fastboot sparse magic.

Suggested-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Roland Hieber <rhi@pengutronix.de>
---
v2: clean up the temp image too
---
 scripts/lib/ptxd_make_fit_image.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/lib/ptxd_make_fit_image.sh b/scripts/lib/ptxd_make_fit_image.sh
index dd0f63b7b72d..8162195fdfa3 100644
--- a/scripts/lib/ptxd_make_fit_image.sh
+++ b/scripts/lib/ptxd_make_fit_image.sh
@@ -139,6 +139,8 @@ ptxd_make_image_fit() {
 	echo "Generated device-tree for the fit image:"
 	cat "${its}"
     fi &&
-    ptxd_exec mkimage -N pkcs11 -f "${its}" "${image_image}" -r "${sign_args[@]}"
+    ptxd_exec mkimage -N pkcs11 -f "${its}" "${image_image}.tmp" -r "${sign_args[@]}" &&
+    ptxd_exec dd if="${image_image}.tmp" of="${image_image}" conv=sync bs=4k &&
+    ptxd_exec rm "${image_image}.tmp"
 }
 export -f ptxd_make_image_fit
-- 
2.39.2




  reply	other threads:[~2023-08-23 10:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-23 10:34 [ptxdist] [PATCH] " Roland Hieber
2023-08-23 10:49 ` Roland Hieber [this message]
2023-08-31 21:16   ` [ptxdist] [PATCH v2] " Roland Hieber
2023-09-01  6:31   ` Michael Olbrich
2023-09-12 16:43     ` Roland Hieber

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=20230823104959.2870164-1-rhi@pengutronix.de \
    --to=rhi@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=ptxdist@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