* [PATCH v2] mx8m: csf.sh: pad csf blob for u-boot.itb to CSF_SIZE minus IVT header
@ 2023-09-20 10:33 Rasmus Villemoes
2023-09-20 11:14 ` Fabio Estevam
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Rasmus Villemoes @ 2023-09-20 10:33 UTC (permalink / raw)
To: u-boot; +Cc: Fabio Estevam, Tim Harvey, Marek Vasut, uboot-imx,
Rasmus Villemoes
When built with CONFIG_IMX_HAB, the full FIT image, including stuff
tacked on beyond the end of the fdt structure, is expected to be (fdt
size rounded up to 0x1000 boundary)+CONFIG_CSF_SIZE.
Now, when the FIT image is loaded from a storage device, it doesn't
really matter that the flash.bin that gets written to target isn't
quite that big - we will just load some garbage bytes that are never
read or used for anything. But when flash.bin is uploaded via uuu,
it's important that we actually serve at least as many bytes as the
target expects, or we will hang in rom_api_download_image().
Extend the logic in the csf.sh script so that the csf blob is padded
to CONFIG_CSF_SIZE minus the size of the IVT header.
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
v2: use dd instead of truncate.
doc/imx/habv4/csf_examples/mx8m/csf.sh | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/doc/imx/habv4/csf_examples/mx8m/csf.sh b/doc/imx/habv4/csf_examples/mx8m/csf.sh
index 65c143073c..cd3b2614a2 100644
--- a/doc/imx/habv4/csf_examples/mx8m/csf.sh
+++ b/doc/imx/habv4/csf_examples/mx8m/csf.sh
@@ -75,5 +75,18 @@ dd if=ivt.bin of=flash.bin bs=1 seek=${ivt_block_offset} conv=notrunc
# Generate CSF blob
cst -i csf_fit.tmp -o csf_fit.bin
+
+# When loading flash.bin via USB, we must ensure that the file being
+# served is as large as the target expects (see
+# board_spl_fit_size_align()), otherwise the target will hang in
+# rom_api_download_image() waiting for the remaining bytes.
+#
+# Note that in order for dd to actually extend the file, one must not
+# pass conv=notrunc here. With a non-zero seek= argument, dd is
+# documented to preserve the contents of the file seeked past; in
+# particular, dd does not open the file with O_TRUNC.
+CSF_SIZE=$(sed -n "/CONFIG_CSF_SIZE=/ s@.*=@@p" .config)
+dd if=/dev/null of=csf_fit.bin bs=1 seek=$((CSF_SIZE - 0x20)) count=0
+
# Patch CSF blob into flash.bin
dd if=csf_fit.bin of=flash.bin bs=1 seek=${csf_block_offset} conv=notrunc
--
2.37.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] mx8m: csf.sh: pad csf blob for u-boot.itb to CSF_SIZE minus IVT header
2023-09-20 10:33 [PATCH v2] mx8m: csf.sh: pad csf blob for u-boot.itb to CSF_SIZE minus IVT header Rasmus Villemoes
@ 2023-09-20 11:14 ` Fabio Estevam
2023-09-20 11:22 ` Marek Vasut
2023-10-16 9:22 ` sbabic
2 siblings, 0 replies; 4+ messages in thread
From: Fabio Estevam @ 2023-09-20 11:14 UTC (permalink / raw)
To: Rasmus Villemoes
Cc: u-boot, Fabio Estevam, Tim Harvey, Marek Vasut, uboot-imx
On Wed, Sep 20, 2023 at 7:34 AM Rasmus Villemoes
<rasmus.villemoes@prevas.dk> wrote:
>
> When built with CONFIG_IMX_HAB, the full FIT image, including stuff
> tacked on beyond the end of the fdt structure, is expected to be (fdt
> size rounded up to 0x1000 boundary)+CONFIG_CSF_SIZE.
>
> Now, when the FIT image is loaded from a storage device, it doesn't
> really matter that the flash.bin that gets written to target isn't
> quite that big - we will just load some garbage bytes that are never
> read or used for anything. But when flash.bin is uploaded via uuu,
> it's important that we actually serve at least as many bytes as the
> target expects, or we will hang in rom_api_download_image().
>
> Extend the logic in the csf.sh script so that the csf blob is padded
> to CONFIG_CSF_SIZE minus the size of the IVT header.
>
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
> ---
> v2: use dd instead of truncate.
Reviewed-by: Fabio Estevam <festevam@denx.de>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] mx8m: csf.sh: pad csf blob for u-boot.itb to CSF_SIZE minus IVT header
2023-09-20 10:33 [PATCH v2] mx8m: csf.sh: pad csf blob for u-boot.itb to CSF_SIZE minus IVT header Rasmus Villemoes
2023-09-20 11:14 ` Fabio Estevam
@ 2023-09-20 11:22 ` Marek Vasut
2023-10-16 9:22 ` sbabic
2 siblings, 0 replies; 4+ messages in thread
From: Marek Vasut @ 2023-09-20 11:22 UTC (permalink / raw)
To: Rasmus Villemoes, u-boot; +Cc: Fabio Estevam, Tim Harvey, uboot-imx
On 9/20/23 12:33, Rasmus Villemoes wrote:
> When built with CONFIG_IMX_HAB, the full FIT image, including stuff
> tacked on beyond the end of the fdt structure, is expected to be (fdt
> size rounded up to 0x1000 boundary)+CONFIG_CSF_SIZE.
>
> Now, when the FIT image is loaded from a storage device, it doesn't
> really matter that the flash.bin that gets written to target isn't
> quite that big - we will just load some garbage bytes that are never
> read or used for anything. But when flash.bin is uploaded via uuu,
> it's important that we actually serve at least as many bytes as the
> target expects, or we will hang in rom_api_download_image().
>
> Extend the logic in the csf.sh script so that the csf blob is padded
> to CONFIG_CSF_SIZE minus the size of the IVT header.
>
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
> ---
> v2: use dd instead of truncate.
Reviewed-by: Marek Vasut <marex@denx.de>
Thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] mx8m: csf.sh: pad csf blob for u-boot.itb to CSF_SIZE minus IVT header
2023-09-20 10:33 [PATCH v2] mx8m: csf.sh: pad csf blob for u-boot.itb to CSF_SIZE minus IVT header Rasmus Villemoes
2023-09-20 11:14 ` Fabio Estevam
2023-09-20 11:22 ` Marek Vasut
@ 2023-10-16 9:22 ` sbabic
2 siblings, 0 replies; 4+ messages in thread
From: sbabic @ 2023-10-16 9:22 UTC (permalink / raw)
To: Rasmus Villemoes, u-boot
> When built with CONFIG_IMX_HAB, the full FIT image, including stuff
> tacked on beyond the end of the fdt structure, is expected to be (fdt
> size rounded up to 0x1000 boundary)+CONFIG_CSF_SIZE.
> Now, when the FIT image is loaded from a storage device, it doesn't
> really matter that the flash.bin that gets written to target isn't
> quite that big - we will just load some garbage bytes that are never
> read or used for anything. But when flash.bin is uploaded via uuu,
> it's important that we actually serve at least as many bytes as the
> target expects, or we will hang in rom_api_download_image().
> Extend the logic in the csf.sh script so that the csf blob is padded
> to CONFIG_CSF_SIZE minus the size of the IVT header.
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
> Reviewed-by: Fabio Estevam <festevam@denx.de>
> Reviewed-by: Marek Vasut <marex@denx.de>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
--
=====================================================================
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-16 9:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-20 10:33 [PATCH v2] mx8m: csf.sh: pad csf blob for u-boot.itb to CSF_SIZE minus IVT header Rasmus Villemoes
2023-09-20 11:14 ` Fabio Estevam
2023-09-20 11:22 ` Marek Vasut
2023-10-16 9:22 ` sbabic
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox