summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiago De Franco <hiago.franco@toradex.com>2023-10-16 16:16:37 -0300
committerMax Krummenacher <max.krummenacher@toradex.com>2023-11-29 17:06:09 +0100
commitd3f053a9cb3b5e23922dfb8767ae043483ef33a0 (patch)
treeb87b3718ef441c126fbe27e4cfb00c579a4ef8d1
parent85d0917d23aceba64bbda5022d80de9bca08938d (diff)
u-boot-toradex: Backport mainline patches for nand padding
This commit backports two patches submitted to the U-Boot mainline, both of which relocate the 'nand_padding' function to the Makefile of 'mach-imx.' The first patch introduces the 'u-boot-nand.imx' target to the Makefile, producing a binary file with 1024 leading zeros. The second patch adds a 'dd' command to the Makefile, appending 10k zeros to the end of the binary. These changes will eliminate the need of the 'nand_padding' function. Signed-off-by: Hiago De Franco <hiago.franco@toradex.com> (cherry picked from commit 678579d8783e2d24666ca1b6af58544f67579aa0)
-rw-r--r--recipes-bsp/u-boot/u-boot-toradex/0001-arm-imx-add-u-boot-nand.imx-to-boot-from-NAND-withou.patch61
-rw-r--r--recipes-bsp/u-boot/u-boot-toradex/0001-arm-mach-imx-Makefile-Extend-u-boot-nand.imx-padding.patch43
-rw-r--r--recipes-bsp/u-boot/u-boot-toradex_2022.07.bb2
3 files changed, 106 insertions, 0 deletions
diff --git a/recipes-bsp/u-boot/u-boot-toradex/0001-arm-imx-add-u-boot-nand.imx-to-boot-from-NAND-withou.patch b/recipes-bsp/u-boot/u-boot-toradex/0001-arm-imx-add-u-boot-nand.imx-to-boot-from-NAND-withou.patch
new file mode 100644
index 0000000..6dd2d99
--- /dev/null
+++ b/recipes-bsp/u-boot/u-boot-toradex/0001-arm-imx-add-u-boot-nand.imx-to-boot-from-NAND-withou.patch
@@ -0,0 +1,61 @@
+From 444331b1b1c8a94e5cdcfaddb447f8e718793ec4 Mon Sep 17 00:00:00 2001
+From: Luca Ceresoli <luca.ceresoli@bootlin.com>
+Date: Fri, 10 Mar 2023 11:07:52 +0100
+Subject: [PATCH] arm: imx: add u-boot-nand.imx to boot from NAND without SPL
+
+U-Boot can be booted from NAND without SPL by prepending the DCD header to
+the actual U-Boot binary. However this requires prepending 1024 bytes to
+u-boot.imx (DCD + u-boot.bin).
+
+There is already a similar target to build spl/u-boot-nand-spl.imx, add the
+same option for no-SPL boot.
+
+Tested on i.MX6ULL.
+
+The resulting layout of u-boot-nand.imx is:
+
+ - Offset 0x0000 (0 KiB): padding
+ - Offset 0x0400 (1 KiB): DCD header
+ - Offset 0x1000 (4 KiB): u-boot.bin
+
+Upstream-Status: Backport [95942f99a7057359c07bf383214d57154e2466fe]
+Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
+---
+ Makefile | 3 +++
+ arch/arm/mach-imx/Makefile | 6 ++++++
+ 2 files changed, 9 insertions(+)
+
+diff --git a/Makefile b/Makefile
+index 98867fbe06..402adbe26c 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1562,6 +1562,9 @@ endif
+ u-boot.uim: u-boot.bin FORCE
+ $(Q)$(MAKE) $(build)=arch/arm/mach-imx $@
+
++u-boot-nand.imx: u-boot.imx FORCE
++ $(Q)$(MAKE) $(build)=arch/arm/mach-imx $@
++
+ u-boot-with-spl.imx u-boot-with-nand-spl.imx: SPL $(if $(CONFIG_OF_SEPARATE),u-boot.img,u-boot.uim) FORCE
+ $(Q)$(MAKE) $(build)=arch/arm/mach-imx $@
+
+diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
+index aa0b6447f1..e9b484fa9b 100644
+--- a/arch/arm/mach-imx/Makefile
++++ b/arch/arm/mach-imx/Makefile
+@@ -132,6 +132,12 @@ u-boot.imx: MKIMAGEOUTPUT = u-boot.imx.log
+ u-boot.imx: u-boot.bin u-boot.cfgout $(PLUGIN).bin FORCE
+ $(call if_changed,mkimage)
+
++quiet_cmd_u-boot-nand_imx = GEN $@
++cmd_u-boot-nand_imx = (dd bs=1024 count=1 if=/dev/zero 2>/dev/null) | cat - $< > $@
++
++u-boot-nand.imx: u-boot.imx FORCE
++ $(call if_changed,u-boot-nand_imx)
++
+ ifeq ($(CONFIG_MULTI_DTB_FIT),y)
+ MKIMAGEFLAGS_u-boot-dtb.imx = -n $(filter-out $(PLUGIN).bin $< $(PHONY),$^) \
+ -T $(IMAGE_TYPE) -e $(CONFIG_SYS_TEXT_BASE)
+--
+2.42.0
+
diff --git a/recipes-bsp/u-boot/u-boot-toradex/0001-arm-mach-imx-Makefile-Extend-u-boot-nand.imx-padding.patch b/recipes-bsp/u-boot/u-boot-toradex/0001-arm-mach-imx-Makefile-Extend-u-boot-nand.imx-padding.patch
new file mode 100644
index 0000000..95878a2
--- /dev/null
+++ b/recipes-bsp/u-boot/u-boot-toradex/0001-arm-mach-imx-Makefile-Extend-u-boot-nand.imx-padding.patch
@@ -0,0 +1,43 @@
+From 7dede4033bd0391d240914b3e54ec49a984d39b2 Mon Sep 17 00:00:00 2001
+From: Hiago De Franco <hiago.franco@toradex.com>
+Date: Tue, 3 Oct 2023 18:26:54 -0300
+Subject: [PATCH] arm: mach-imx: Makefile: Extend u-boot-nand.imx padding
+
+Extend the padding process of u-boot-nand.imx target by adding 10k bytes
+of zeros to the end of the binary using the 'dd' command.
+
+The existing padding method did not generate a functional binary,
+as discussed in more detail in this thread [1]. Instead, we adopt the
+end-padding calculation method documented in 'board/doc/colibri_imx7.rst'
+as a reference, which is relevant for iMX7 with NAND storage.
+
+Adding 10k bytes of zeros provides an approximate value that makes the
+proper padding for these NAND devices.
+
+[1] https://lore.kernel.org/all/CAC4tdFUqffQzRQFv5AGe_xtbFy1agr2SEpn_FzEdexhwjdryyw@mail.gmail.com/
+
+Upstream-Status: Backport [7dede4033bd0391d240914b3e54ec49a984d39b2]
+Signed-off-by: Hiago De Franco <hiago.franco@toradex.com>
+Reviewed-by: Fabio Estevam <festevam@gmail.com>
+---
+ arch/arm/mach-imx/Makefile | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
+index aebfa6517b..6904cf3880 100644
+--- a/arch/arm/mach-imx/Makefile
++++ b/arch/arm/mach-imx/Makefile
+@@ -142,7 +142,9 @@ u-boot.imx: u-boot.bin u-boot.cfgout $(PLUGIN).bin FORCE
+ $(call if_changed,mkimage)
+
+ quiet_cmd_u-boot-nand_imx = GEN $@
+-cmd_u-boot-nand_imx = (dd bs=1024 count=1 if=/dev/zero 2>/dev/null) | cat - $< > $@
++cmd_u-boot-nand_imx = (dd bs=1024 count=1 if=/dev/zero 2>/dev/null) | cat - $< > $@.zero-padded ; \
++ (dd bs=10k count=1 if=/dev/zero 2>/dev/null) | cat $@.zero-padded - > $@ ; \
++ rm -f $@.zero-padded
+
+ u-boot-nand.imx: u-boot.imx FORCE
+ $(call if_changed,u-boot-nand_imx)
+--
+2.42.0
+
diff --git a/recipes-bsp/u-boot/u-boot-toradex_2022.07.bb b/recipes-bsp/u-boot/u-boot-toradex_2022.07.bb
index af07340..cdfd767 100644
--- a/recipes-bsp/u-boot/u-boot-toradex_2022.07.bb
+++ b/recipes-bsp/u-boot/u-boot-toradex_2022.07.bb
@@ -22,4 +22,6 @@ TDX_PATCHES = " \
file://0001-configs-colibri-imx7-Fix-bad-block-table-in-flash-co.patch \
file://0001-colibri_imx6-fix-RALAT-and-WALAT-values.patch \
file://0001-toradex-colibri_imx7-Enable-nand-emmc-detection-and-.patch \
+ file://0001-arm-imx-add-u-boot-nand.imx-to-boot-from-NAND-withou.patch \
+ file://0001-arm-mach-imx-Makefile-Extend-u-boot-nand.imx-padding.patch \
"