diff mbox series

[3/5] lpc32xx: Build firmware files using binman instead a rule in Makefile

Message ID 20240126092533.20709-3-piotr.wojtaszczyk@timesys.com
State New
Delegated to: Marek Vasut
Headers show
Series [1/5] usb: ohci-generic: ignore ENOSYS and ENOTSUPP errors from clk and reset | expand

Commit Message

Piotr Wojtaszczyk Jan. 26, 2024, 9:25 a.m. UTC
Also fixed rounding up in the header verification function. Previously
Makefile was showing the header verification error but it was ignored.

Signed-off-by: Piotr Wojtaszczyk <piotr.wojtaszczyk@timesys.com>
---

 Makefile                         |   2 +-
 arch/arm/Kconfig                 |   1 +
 arch/arm/dts/lpc32xx-u-boot.dtsi | 127 +++++++++++++++++++++++++++++++
 tools/lpc32xximage.c             |   3 +-
 4 files changed, 131 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/dts/lpc32xx-u-boot.dtsi
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 7a3209bd9e..9bc6fe41e0 100644
--- a/Makefile
+++ b/Makefile
@@ -1481,7 +1481,7 @@  OBJCOPYFLAGS_u-boot-with-spl.bin = -I binary -O binary \
 u-boot-with-spl.bin: $(SPL_IMAGE) $(SPL_PAYLOAD) FORCE
 	$(call if_changed,pad_cat)
 
-ifeq ($(CONFIG_ARCH_LPC32XX)$(CONFIG_SPL),yy)
+ifeq ($(CONFIG_ARCH_LPC32XX)_$(CONFIG_SPL)_$(CONFIG_BINMAN),y_y_)
 MKIMAGEFLAGS_lpc32xx-spl.img = -T lpc32xximage -a $(CONFIG_SPL_TEXT_BASE)
 
 lpc32xx-spl.img: spl/u-boot-spl.bin FORCE
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index abd7c6c79a..95d8952e09 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -848,6 +848,7 @@  config ARCH_LPC32XX
 	select GPIO_EXTRA_HEADER
 	select SPL_DM if SPL
 	select SUPPORT_SPL
+	select BINMAN if SPL && OF_CONTROL
 	imply CMD_DM
 
 config ARCH_IMX8
diff --git a/arch/arm/dts/lpc32xx-u-boot.dtsi b/arch/arm/dts/lpc32xx-u-boot.dtsi
new file mode 100644
index 0000000000..1df71d16a3
--- /dev/null
+++ b/arch/arm/dts/lpc32xx-u-boot.dtsi
@@ -0,0 +1,127 @@ 
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright 2023 Timesys
+ * Author: Piotr Wojtaszczyk <piotr.wojtaszczyk@timesys.com>
+ */
+
+#include <config.h>
+
+#ifdef CONFIG_SPL
+/ {
+	binman: binman {
+		multiple-images;
+
+		/* SPL U-boot format for SPI NOR flash */
+		lpc32xx-spl-spi {
+			filename = "lpc32xx-spl-spi.bin";
+			pad-byte = <0xff>;
+			int32 {
+				value = <0x13579BDF>;
+			};
+			file_size {
+				filename = "spl/u-boot-spl.bin";
+			};
+			blob {
+				filename = "spl/u-boot-spl.bin";
+			};
+		};
+
+		/* Full U-boot format for SPI NOR flash */
+		lpc32xx-full-spi {
+			filename = "lpc32xx-full-spi.bin";
+			pad-byte = <0xff>;
+			int32 {
+				value = <0x13579BDF>;
+			};
+			file_size {
+				filename = "spl/u-boot-spl.bin";
+			};
+			blob@0 {
+				filename = "spl/u-boot-spl.bin";
+				size = <CONFIG_SPL_PAD_TO>;
+			};
+			blob@1 {
+				filename = "u-boot.img";
+			};
+		};
+
+		/* U-boot format for external, 32bit wide, static memory */
+		lpc32xx-full-emc-32b {
+			filename = "lpc32xx-full-emc-32b.bin";
+			pad-byte = <0xff>;
+			int32 {
+				value = <0x13579BD2>;
+			};
+			blob@0 {
+				filename = "spl/u-boot-spl.bin";
+				size = <CONFIG_SPL_PAD_TO>;
+			};
+			blob@1 {
+				filename = "u-boot.img";
+			};
+		};
+
+		/* U-boot format for external, 16bit wide, static memory */
+		lpc32xx-full-emc-16b {
+			filename = "lpc32xx-full-emc-16b.bin";
+			pad-byte = <0xff>;
+			int32 {
+				value = <0x13579BD1>;
+			};
+			blob@0 {
+				filename = "spl/u-boot-spl.bin";
+				size = <CONFIG_SPL_PAD_TO>;
+			};
+			blob@1 {
+				filename = "u-boot.img";
+			};
+		};
+
+		/* U-boot format for external, 8bit wide, static memory */
+		lpc32xx-full-emc-8b {
+			filename = "lpc32xx-full-emc-8b.bin";
+			pad-byte = <0xff>;
+			int32 {
+				value = <0x13579BD0>;
+			};
+			blob@0 {
+				filename = "spl/u-boot-spl.bin";
+				size = <CONFIG_SPL_PAD_TO>;
+			};
+			blob@1 {
+				filename = "u-boot.img";
+			};
+		};
+
+		/* SPL U-boot format for NAND flash */
+		lpc32xx-spl {
+			filename = "lpc32xx-spl.img";
+			mkimage {
+				args = "-T lpc32xximage -a 0x0";
+				blob {
+					filename = "spl/u-boot-spl.bin";
+				};
+			};
+		};
+
+		/* Full U-boot format for NAND flash */
+		/* CONFIG_SPL_PAD_TO should be set to NAND block size */
+		lpc32xx-full {
+			filename = "lpc32xx-full.bin";
+			pad-byte = <0xff>;
+			blob@0 {
+				filename = "lpc32xx-spl.img";
+				size = <CONFIG_SPL_PAD_TO>;
+			};
+			blob@1 {
+				filename = "lpc32xx-spl.img";
+				size = <CONFIG_SPL_PAD_TO>;
+			};
+			blob@2 {
+				filename = "u-boot.img";
+			};
+		};
+
+	};
+};
+#endif
diff --git a/tools/lpc32xximage.c b/tools/lpc32xximage.c
index 715a55a5b5..33f1a39174 100644
--- a/tools/lpc32xximage.c
+++ b/tools/lpc32xximage.c
@@ -86,7 +86,8 @@  static int lpc32xximage_verify_header(unsigned char *ptr, int image_size,
 		(struct nand_page_0_boot_header *)ptr;
 
 	/* turn image size from bytes to NAND pages, page 0 included */
-	int image_size_in_pages = ((image_size - 1)
+	int image_size_in_pages = ((image_size
+				  + LPC32XX_BOOT_NAND_PAGESIZE - 1)
 				  / LPC32XX_BOOT_NAND_PAGESIZE);
 
 	if (hdr->data[0] != (0xff & LPC32XX_BOOT_ICR))