@@ -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
@@ -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
new file mode 100644
@@ -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
@@ -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))
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