All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/6] spl: mmc: introduce spl_mmc_get_uboot_raw_sector
@ 2019-09-20  3:27 Peng Fan
  2019-09-20  3:27 ` [U-Boot] [PATCH 2/6] spl: spi: introduce spl_spi_get_uboot_raw_sector Peng Fan
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Peng Fan @ 2019-09-20  3:27 UTC (permalink / raw)
  To: u-boot

Introduce a weak function spl_mmc_get_uboot_raw_sector, then platform
could have their own implementation.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Cc: Tien Fong Chee <tien.fong.chee@intel.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Andreas Dannenberg <dannenberg@ti.com>
Cc: Alex Kiernan <alex.kiernan@gmail.com>
Cc: Stefan Roese <sr@denx.de>
Cc: Patrick Delaunay <patrick.delaunay@st.com>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Michal Simek <michal.simek@xilinx.com>
---
 common/spl/spl_mmc.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index 6c6eaf4ec8..ebc566081a 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -313,6 +313,15 @@ int spl_boot_partition(const u32 boot_device)
 }
 #endif
 
+unsigned long __weak spl_mmc_get_uboot_raw_sector(struct mmc *mmc)
+{
+#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR
+	return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR;
+#else
+	return 0;
+#endif
+}
+
 int spl_mmc_load(struct spl_image_info *spl_image,
 		 struct spl_boot_device *bootdev,
 		 const char *filename,
@@ -340,6 +349,8 @@ int spl_mmc_load(struct spl_image_info *spl_image,
 		}
 	}
 
+	raw_sect = spl_mmc_get_uboot_raw_sector(mmc);
+
 	boot_mode = spl_boot_mode(bootdev->boot_device);
 	err = -EINVAL;
 	switch (boot_mode) {
-- 
2.16.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/6] spl: spi: introduce spl_spi_get_uboot_raw_sector
  2019-09-20  3:27 [U-Boot] [PATCH 1/6] spl: mmc: introduce spl_mmc_get_uboot_raw_sector Peng Fan
@ 2019-09-20  3:27 ` Peng Fan
  2019-09-20  9:11   ` Stefan Roese
  2019-09-20  3:27 ` [U-Boot] [PATCH 3/6] spl: nor: introduce spl_nor_get_uboot_base Peng Fan
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Peng Fan @ 2019-09-20  3:27 UTC (permalink / raw)
  To: u-boot

Introduce a weak function spl_spi_get_uboot_raw_sector, then
platform could have their own implementation.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Cc: Tien Fong Chee <tien.fong.chee@intel.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Andreas Dannenberg <dannenberg@ti.com>
Cc: Alex Kiernan <alex.kiernan@gmail.com>
Cc: Stefan Roese <sr@denx.de>
Cc: Patrick Delaunay <patrick.delaunay@st.com>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Michal Simek <michal.simek@xilinx.com>
---
 common/spl/spl_spi.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
index 9b74473377..1ba0e497d2 100644
--- a/common/spl/spl_spi.c
+++ b/common/spl/spl_spi.c
@@ -62,6 +62,12 @@ static ulong spl_spi_fit_read(struct spl_load_info *load, ulong sector,
 	else
 		return 0;
 }
+
+unsigned int __weak spl_spi_get_uboot_raw_sector(struct spi_flash *flash)
+{
+	return CONFIG_SYS_SPI_U_BOOT_OFFS;
+}
+
 /*
  * The main entry for SPI booting. It's necessary that SDRAM is already
  * configured and available since this code loads the main U-Boot image
@@ -71,7 +77,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
 			      struct spl_boot_device *bootdev)
 {
 	int err = 0;
-	unsigned payload_offs = CONFIG_SYS_SPI_U_BOOT_OFFS;
+	unsigned int payload_offs;
 	struct spi_flash *flash;
 	struct image_header *header;
 
@@ -90,6 +96,8 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
 		return -ENODEV;
 	}
 
+	payload_offs = spl_spi_get_uboot_raw_sector(flash);
+
 	header = spl_get_load_buffer(-sizeof(*header), sizeof(*header));
 
 #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
-- 
2.16.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 3/6] spl: nor: introduce spl_nor_get_uboot_base
  2019-09-20  3:27 [U-Boot] [PATCH 1/6] spl: mmc: introduce spl_mmc_get_uboot_raw_sector Peng Fan
  2019-09-20  3:27 ` [U-Boot] [PATCH 2/6] spl: spi: introduce spl_spi_get_uboot_raw_sector Peng Fan
@ 2019-09-20  3:27 ` Peng Fan
  2019-09-20  3:27 ` [U-Boot] [PATCH 4/6] spl: nand: Introduce spl_nand_get_uboot_raw_page Peng Fan
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Peng Fan @ 2019-09-20  3:27 UTC (permalink / raw)
  To: u-boot

Introduce weak spl_nor_get_uboot_base, then platform have their own
implementation.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Cc: Tien Fong Chee <tien.fong.chee@intel.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Andreas Dannenberg <dannenberg@ti.com>
Cc: Alex Kiernan <alex.kiernan@gmail.com>
Cc: Stefan Roese <sr@denx.de>
Cc: Patrick Delaunay <patrick.delaunay@st.com>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Michal Simek <michal.simek@xilinx.com>
---
 common/spl/spl_nor.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/common/spl/spl_nor.c b/common/spl/spl_nor.c
index 969e319de0..cb5d12d53d 100644
--- a/common/spl/spl_nor.c
+++ b/common/spl/spl_nor.c
@@ -18,6 +18,11 @@ static ulong spl_nor_load_read(struct spl_load_info *load, ulong sector,
 }
 #endif
 
+unsigned long  __weak spl_nor_get_uboot_base(void)
+{
+	return CONFIG_SYS_UBOOT_BASE;
+}
+
 static int spl_nor_load_image(struct spl_image_info *spl_image,
 			      struct spl_boot_device *bootdev)
 {
@@ -80,25 +85,25 @@ static int spl_nor_load_image(struct spl_image_info *spl_image,
 	 * defined location in SDRAM
 	 */
 #ifdef CONFIG_SPL_LOAD_FIT
-	header = (const struct image_header *)CONFIG_SYS_UBOOT_BASE;
+	header = (const struct image_header *)spl_nor_get_uboot_base();
 	if (image_get_magic(header) == FDT_MAGIC) {
 		debug("Found FIT format U-Boot\n");
 		load.bl_len = 1;
 		load.read = spl_nor_load_read;
 		ret = spl_load_simple_fit(spl_image, &load,
-					  CONFIG_SYS_UBOOT_BASE,
+					  spl_nor_get_uboot_base(),
 					  (void *)header);
 
 		return ret;
 	}
 #endif
 	ret = spl_parse_image_header(spl_image,
-			(const struct image_header *)CONFIG_SYS_UBOOT_BASE);
+			(const struct image_header *)spl_nor_get_uboot_base());
 	if (ret)
 		return ret;
 
 	memcpy((void *)(unsigned long)spl_image->load_addr,
-	       (void *)(CONFIG_SYS_UBOOT_BASE + sizeof(struct image_header)),
+	       (void *)(spl_nor_get_uboot_base() + sizeof(struct image_header)),
 	       spl_image->size);
 
 	return 0;
-- 
2.16.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 4/6] spl: nand: Introduce spl_nand_get_uboot_raw_page
  2019-09-20  3:27 [U-Boot] [PATCH 1/6] spl: mmc: introduce spl_mmc_get_uboot_raw_sector Peng Fan
  2019-09-20  3:27 ` [U-Boot] [PATCH 2/6] spl: spi: introduce spl_spi_get_uboot_raw_sector Peng Fan
  2019-09-20  3:27 ` [U-Boot] [PATCH 3/6] spl: nor: introduce spl_nor_get_uboot_base Peng Fan
@ 2019-09-20  3:27 ` Peng Fan
  2019-09-20  3:27 ` [U-Boot] [PATCH 5/6] imx8: Add support to get container image set size Peng Fan
  2019-09-20  3:27 ` [U-Boot] [PATCH 6/6] imx8: update README Peng Fan
  4 siblings, 0 replies; 8+ messages in thread
From: Peng Fan @ 2019-09-20  3:27 UTC (permalink / raw)
  To: u-boot

Introduce weak spl_nand_get_uboot_raw_page, then platform could
have their own implementation.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Cc: Tien Fong Chee <tien.fong.chee@intel.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Andreas Dannenberg <dannenberg@ti.com>
Cc: Alex Kiernan <alex.kiernan@gmail.com>
Cc: Stefan Roese <sr@denx.de>
Cc: Patrick Delaunay <patrick.delaunay@st.com>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Michal Simek <michal.simek@xilinx.com>
---
 common/spl/spl_nand.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
index e2bcefb111..d3185dc017 100644
--- a/common/spl/spl_nand.c
+++ b/common/spl/spl_nand.c
@@ -11,6 +11,11 @@
 #include <linux/libfdt_env.h>
 #include <fdt.h>
 
+uint32_t __weak spl_nand_get_uboot_raw_page(void)
+{
+	return CONFIG_SYS_NAND_U_BOOT_OFFS;
+}
+
 #if defined(CONFIG_SPL_NAND_RAW_ONLY)
 static int spl_nand_load_image(struct spl_image_info *spl_image,
 			struct spl_boot_device *bootdev)
@@ -21,7 +26,7 @@ static int spl_nand_load_image(struct spl_image_info *spl_image,
 	       CONFIG_SYS_NAND_U_BOOT_OFFS, CONFIG_SYS_NAND_U_BOOT_SIZE,
 	       CONFIG_SYS_NAND_U_BOOT_DST);
 
-	nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
+	nand_spl_load_image(spl_nand_get_uboot_raw_page(),
 			    CONFIG_SYS_NAND_U_BOOT_SIZE,
 			    (void *)CONFIG_SYS_NAND_U_BOOT_DST);
 	spl_set_header_raw_uboot(spl_image);
@@ -139,7 +144,7 @@ static int spl_nand_load_image(struct spl_image_info *spl_image,
 #endif
 #endif
 	/* Load u-boot */
-	err = spl_nand_load_element(spl_image, CONFIG_SYS_NAND_U_BOOT_OFFS,
+	err = spl_nand_load_element(spl_image, spl_nand_get_uboot_raw_page(),
 				    header);
 #ifdef CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND
 #if CONFIG_SYS_NAND_U_BOOT_OFFS != CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND
-- 
2.16.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 5/6] imx8: Add support to get container image set size
  2019-09-20  3:27 [U-Boot] [PATCH 1/6] spl: mmc: introduce spl_mmc_get_uboot_raw_sector Peng Fan
                   ` (2 preceding siblings ...)
  2019-09-20  3:27 ` [U-Boot] [PATCH 4/6] spl: nand: Introduce spl_nand_get_uboot_raw_page Peng Fan
@ 2019-09-20  3:27 ` Peng Fan
  2019-09-20  3:27 ` [U-Boot] [PATCH 6/6] imx8: update README Peng Fan
  4 siblings, 0 replies; 8+ messages in thread
From: Peng Fan @ 2019-09-20  3:27 UTC (permalink / raw)
  To: u-boot

To avoid hardcoded offset when adding u-boot.cnt to flash.bin, we use
flexible offset which is calculated based on the size of the container
image generated int the first stage. And pad u-boot.cnt at 1KB
alignment.

So add code to get the offset when SPL loading u-boot.cnt.

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 arch/arm/mach-imx/Makefile      |   9 +-
 arch/arm/mach-imx/imx8/Makefile |   2 +-
 arch/arm/mach-imx/imx8/image.c  | 246 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 255 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/mach-imx/imx8/image.c

diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 199b2df22b..46bc2a21e2 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -169,9 +169,16 @@ u-boot.cnt: MKIMAGEOUTPUT = u-boot.cnt.log
 ifeq ($(CONFIG_SPL_LOAD_IMX_CONTAINER), y)
 u-boot.cnt: u-boot.bin container.cfg FORCE
 	$(call if_changed,mkimage)
-endif
 flash.bin: spl/u-boot-spl.bin FORCE
 	$(call if_changed,mkimage)
+	@flashbin_size=`wc -c flash.bin | awk '{print $$1}'`; \
+                   pad_cnt=$$(((flashbin_size + 0x400 - 1) / 0x400)); \
+                   echo "append u-boot.cnt at $$pad_cnt KB"; \
+                   dd if=u-boot.cnt of=flash.bin bs=1K seek=$$pad_cnt;
+else
+flash.bin: spl/u-boot-spl.bin FORCE
+	$(call if_changed,mkimage)
+endif
 endif
 
 else
diff --git a/arch/arm/mach-imx/imx8/Makefile b/arch/arm/mach-imx/imx8/Makefile
index 97f9d22945..39e384d5c7 100644
--- a/arch/arm/mach-imx/imx8/Makefile
+++ b/arch/arm/mach-imx/imx8/Makefile
@@ -8,5 +8,5 @@ obj-y += cpu.o iomux.o misc.o lowlevel_init.o
 obj-$(CONFIG_OF_SYSTEM_SETUP) += fdt.o
 
 ifdef CONFIG_SPL_BUILD
-obj-$(CONFIG_SPL_LOAD_IMX_CONTAINER) += parse-container.o
+obj-$(CONFIG_SPL_LOAD_IMX_CONTAINER) += image.o parse-container.o
 endif
diff --git a/arch/arm/mach-imx/imx8/image.c b/arch/arm/mach-imx/imx8/image.c
new file mode 100644
index 0000000000..55cac4c979
--- /dev/null
+++ b/arch/arm/mach-imx/imx8/image.c
@@ -0,0 +1,246 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2019 NXP
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <asm/io.h>
+#include <mmc.h>
+#include <spi_flash.h>
+#include <nand.h>
+#include <asm/arch/image.h>
+#include <asm/arch/sys_proto.h>
+#include <asm/mach-imx/boot_mode.h>
+
+#define MMC_DEV		0
+#define QSPI_DEV	1
+#define NAND_DEV	2
+#define QSPI_NOR_DEV	3
+
+static int __get_container_size(ulong addr)
+{
+	struct container_hdr *phdr;
+	struct boot_img_t *img_entry;
+	struct signature_block_hdr *sign_hdr;
+	u8 i = 0;
+	u32 max_offset = 0, img_end;
+
+	phdr = (struct container_hdr *)addr;
+	if (phdr->tag != 0x87 && phdr->version != 0x0) {
+		debug("Wrong container header\n");
+		return -EFAULT;
+	}
+
+	max_offset = sizeof(struct container_hdr);
+
+	img_entry = (struct boot_img_t *)(addr + sizeof(struct container_hdr));
+	for (i = 0; i < phdr->num_images; i++) {
+		img_end = img_entry->offset + img_entry->size;
+		if (img_end > max_offset)
+			max_offset = img_end;
+
+		debug("img[%u], end = 0x%x\n", i, img_end);
+
+		img_entry++;
+	}
+
+	if (phdr->sig_blk_offset != 0) {
+		sign_hdr = (struct signature_block_hdr *)(addr + phdr->sig_blk_offset);
+		u16 len = sign_hdr->length_lsb + (sign_hdr->length_msb << 8);
+
+		if (phdr->sig_blk_offset + len > max_offset)
+			max_offset = phdr->sig_blk_offset + len;
+
+		debug("sigblk, end = 0x%x\n", phdr->sig_blk_offset + len);
+	}
+
+	return max_offset;
+}
+
+static int get_container_size(void *dev, int dev_type, unsigned long offset)
+{
+	u8 *buf = malloc(CONTAINER_HDR_ALIGNMENT);
+	int ret = 0;
+
+	if (!buf) {
+		printf("Malloc buffer failed\n");
+		return -ENOMEM;
+	}
+
+#ifdef CONFIG_SPL_MMC_SUPPORT
+	if (dev_type == MMC_DEV) {
+		unsigned long count = 0;
+		struct mmc *mmc = (struct mmc *)dev;
+
+		count = blk_dread(mmc_get_blk_desc(mmc),
+				  offset / mmc->read_bl_len,
+				  CONTAINER_HDR_ALIGNMENT / mmc->read_bl_len,
+				  buf);
+		if (count == 0) {
+			printf("Read container image from MMC/SD failed\n");
+			return -EIO;
+		}
+	}
+#endif
+
+#ifdef CONFIG_SPL_SPI_LOAD
+	if (dev_type == QSPI_DEV) {
+		struct spi_flash *flash = (struct spi_flash *)dev;
+
+		ret = spi_flash_read(flash, offset,
+				     CONTAINER_HDR_ALIGNMENT, buf);
+		if (ret != 0) {
+			printf("Read container image from QSPI failed\n");
+			return -EIO;
+		}
+	}
+#endif
+
+#ifdef CONFIG_SPL_NAND_SUPPORT
+	if (dev_type == NAND_DEV) {
+		ret = nand_spl_load_image(offset, CONTAINER_HDR_ALIGNMENT,
+					  buf);
+		if (ret != 0) {
+			printf("Read container image from NAND failed\n");
+			return -EIO;
+		}
+	}
+#endif
+
+#ifdef CONFIG_SPL_NOR_SUPPORT
+	if (dev_type == QSPI_NOR_DEV)
+		memcpy(buf, (const void *)offset, CONTAINER_HDR_ALIGNMENT);
+#endif
+
+	ret = __get_container_size((ulong)buf);
+
+	free(buf);
+
+	return ret;
+}
+
+static unsigned long get_boot_device_offset(void *dev, int dev_type)
+{
+	unsigned long offset = 0;
+
+	if (dev_type == MMC_DEV) {
+		struct mmc *mmc = (struct mmc *)dev;
+
+		if (IS_SD(mmc) || mmc->part_config == MMCPART_NOAVAILABLE) {
+			offset = CONTAINER_HDR_MMCSD_OFFSET;
+		} else {
+			u8 part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config);
+
+			if (part == 1 || part == 2) {
+				if (is_imx8qxp() && is_soc_rev(CHIP_REV_B))
+					offset = CONTAINER_HDR_MMCSD_OFFSET;
+				else
+					offset = CONTAINER_HDR_EMMC_OFFSET;
+			} else {
+				offset = CONTAINER_HDR_MMCSD_OFFSET;
+			}
+		}
+	} else if (dev_type == QSPI_DEV) {
+		offset = CONTAINER_HDR_QSPI_OFFSET;
+	} else if (dev_type == NAND_DEV) {
+		offset = CONTAINER_HDR_NAND_OFFSET;
+	} else if (dev_type == QSPI_NOR_DEV) {
+		offset = CONTAINER_HDR_QSPI_OFFSET + 0x08000000;
+	}
+
+	return offset;
+}
+
+static int get_imageset_end(void *dev, int dev_type)
+{
+	unsigned long offset1 = 0, offset2 = 0;
+	int value_container[2];
+
+	offset1 = get_boot_device_offset(dev, dev_type);
+	offset2 = CONTAINER_HDR_ALIGNMENT + offset1;
+
+	value_container[0] = get_container_size(dev, dev_type, offset1);
+	if (value_container[0] < 0) {
+		printf("Parse seco container failed %d\n", value_container[0]);
+		return value_container[0];
+	}
+
+	debug("seco container size 0x%x\n", value_container[0]);
+
+	value_container[1] = get_container_size(dev, dev_type, offset2);
+	if (value_container[1] < 0) {
+		debug("Parse scu container failed %d, only seco container\n",
+		      value_container[1]);
+		/* return seco container total size */
+		return value_container[0] + offset1;
+	}
+
+	debug("scu container size 0x%x\n", value_container[1]);
+
+	return value_container[1] + offset2;
+}
+
+#ifdef CONFIG_SPL_SPI_LOAD
+unsigned long spl_spi_get_uboot_raw_sector(struct spi_flash *flash)
+{
+	int end;
+
+	end = get_imageset_end(flash, QSPI_DEV);
+	end = ROUND(end, SZ_1K);
+
+	printf("Load image from QSPI 0x%x\n", end);
+
+	return end;
+}
+#endif
+
+#ifdef CONFIG_SPL_MMC_SUPPORT
+unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc)
+{
+	int end;
+
+	end = get_imageset_end(mmc, MMC_DEV);
+	end = ROUND(end, SZ_1K);
+
+	printf("Load image from MMC/SD 0x%x\n", end);
+
+	return end / mmc->read_bl_len;
+}
+#endif
+
+#ifdef CONFIG_SPL_NAND_SUPPORT
+uint32_t spl_nand_get_uboot_raw_page(void)
+{
+	int end;
+
+	end = get_imageset_end((void *)NULL, NAND_DEV);
+	end = ROUND(end, SZ_16K);
+
+	printf("Load image from NAND 0x%x\n", end);
+
+	return end;
+}
+#endif
+
+#ifdef CONFIG_SPL_NOR_SUPPORT
+unsigned long spl_nor_get_uboot_base(void)
+{
+	int end;
+
+	/* Calculate the image set end,
+	 * if it is less than CONFIG_SYS_UBOOT_BASE(0x8281000),
+	 * we use CONFIG_SYS_UBOOT_BASE
+	 * Otherwise, use the calculated address
+	 */
+	end = get_imageset_end((void *)NULL, QSPI_NOR_DEV);
+	if (end <= CONFIG_SYS_UBOOT_BASE)
+		end = CONFIG_SYS_UBOOT_BASE;
+	else
+		end = ROUND(end, SZ_1K);
+
+	printf("Load image from NOR 0x%x\n", end);
+
+	return end;
+}
+#endif
-- 
2.16.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 6/6] imx8: update README
  2019-09-20  3:27 [U-Boot] [PATCH 1/6] spl: mmc: introduce spl_mmc_get_uboot_raw_sector Peng Fan
                   ` (3 preceding siblings ...)
  2019-09-20  3:27 ` [U-Boot] [PATCH 5/6] imx8: Add support to get container image set size Peng Fan
@ 2019-09-20  3:27 ` Peng Fan
  4 siblings, 0 replies; 8+ messages in thread
From: Peng Fan @ 2019-09-20  3:27 UTC (permalink / raw)
  To: u-boot

After u-boot.cnt is padded to flash.bin automatically by script,
no need to burn the image mannually, so drop the step.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 board/freescale/imx8qm_mek/README  | 1 -
 board/freescale/imx8qxp_mek/README | 1 -
 2 files changed, 2 deletions(-)

diff --git a/board/freescale/imx8qm_mek/README b/board/freescale/imx8qm_mek/README
index ebf630c446..a187ad8a09 100644
--- a/board/freescale/imx8qm_mek/README
+++ b/board/freescale/imx8qm_mek/README
@@ -41,7 +41,6 @@ Build U-Boot
 ============
 $ make imx8qm_mek_defconfig
 $ make flash.bin
-$ dd if=u-boot.cnt of=flash.bin bs=512 seek=1984
 
 Flash the binary into the SD card
 =================================
diff --git a/board/freescale/imx8qxp_mek/README b/board/freescale/imx8qxp_mek/README
index 1ee0357961..e676e88664 100644
--- a/board/freescale/imx8qxp_mek/README
+++ b/board/freescale/imx8qxp_mek/README
@@ -41,7 +41,6 @@ Build U-Boot
 ============
 $ make imx8qxp_mek_defconfig
 $ make flash.bin
-$ dd if=u-boot.cnt of=flash.bin bs=512 seek=1984
 
 Flash the binary into the SD card
 =================================
-- 
2.16.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/6] spl: spi: introduce spl_spi_get_uboot_raw_sector
  2019-09-20  3:27 ` [U-Boot] [PATCH 2/6] spl: spi: introduce spl_spi_get_uboot_raw_sector Peng Fan
@ 2019-09-20  9:11   ` Stefan Roese
  2019-09-20 10:00     ` Peng Fan
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Roese @ 2019-09-20  9:11 UTC (permalink / raw)
  To: u-boot

Hi Peng,

On 20.09.19 05:27, Peng Fan wrote:
> Introduce a weak function spl_spi_get_uboot_raw_sector, then
> platform could have their own implementation.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> Cc: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
> Cc: Tien Fong Chee <tien.fong.chee@intel.com>
> Cc: Marek Vasut <marex@denx.de>
> Cc: Andreas Dannenberg <dannenberg@ti.com>
> Cc: Alex Kiernan <alex.kiernan@gmail.com>
> Cc: Stefan Roese <sr@denx.de>
> Cc: Patrick Delaunay <patrick.delaunay@st.com>
> Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> Cc: Michal Simek <michal.simek@xilinx.com>
> ---
>   common/spl/spl_spi.c | 10 +++++++++-
>   1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c
> index 9b74473377..1ba0e497d2 100644
> --- a/common/spl/spl_spi.c
> +++ b/common/spl/spl_spi.c
> @@ -62,6 +62,12 @@ static ulong spl_spi_fit_read(struct spl_load_info *load, ulong sector,
>   	else
>   		return 0;
>   }
> +
> +unsigned int __weak spl_spi_get_uboot_raw_sector(struct spi_flash *flash)
> +{
> +	return CONFIG_SYS_SPI_U_BOOT_OFFS;
> +}
> +
>   /*
>    * The main entry for SPI booting. It's necessary that SDRAM is already
>    * configured and available since this code loads the main U-Boot image
> @@ -71,7 +77,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
>   			      struct spl_boot_device *bootdev)
>   {
>   	int err = 0;
> -	unsigned payload_offs = CONFIG_SYS_SPI_U_BOOT_OFFS;
> +	unsigned int payload_offs;
>   	struct spi_flash *flash;
>   	struct image_header *header;
>   
> @@ -90,6 +96,8 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
>   		return -ENODEV;
>   	}
>   
> +	payload_offs = spl_spi_get_uboot_raw_sector(flash);

I don't really like the function name here "_raw_sector" as this is
not a sector number in SPI flash but an address offset.

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/6] spl: spi: introduce spl_spi_get_uboot_raw_sector
  2019-09-20  9:11   ` Stefan Roese
@ 2019-09-20 10:00     ` Peng Fan
  0 siblings, 0 replies; 8+ messages in thread
From: Peng Fan @ 2019-09-20 10:00 UTC (permalink / raw)
  To: u-boot

> Subject: Re: [PATCH 2/6] spl: spi: introduce spl_spi_get_uboot_raw_sector
> 
> Hi Peng,
> 
> On 20.09.19 05:27, Peng Fan wrote:
> > Introduce a weak function spl_spi_get_uboot_raw_sector, then platform
> > could have their own implementation.
> >
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > Cc: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
> > Cc: Tien Fong Chee <tien.fong.chee@intel.com>
> > Cc: Marek Vasut <marex@denx.de>
> > Cc: Andreas Dannenberg <dannenberg@ti.com>
> > Cc: Alex Kiernan <alex.kiernan@gmail.com>
> > Cc: Stefan Roese <sr@denx.de>
> > Cc: Patrick Delaunay <patrick.delaunay@st.com>
> > Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> > Cc: Michal Simek <michal.simek@xilinx.com>
> > ---
> >   common/spl/spl_spi.c | 10 +++++++++-
> >   1 file changed, 9 insertions(+), 1 deletion(-)
> >
> > diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c index
> > 9b74473377..1ba0e497d2 100644
> > --- a/common/spl/spl_spi.c
> > +++ b/common/spl/spl_spi.c
> > @@ -62,6 +62,12 @@ static ulong spl_spi_fit_read(struct spl_load_info
> *load, ulong sector,
> >   	else
> >   		return 0;
> >   }
> > +
> > +unsigned int __weak spl_spi_get_uboot_raw_sector(struct spi_flash
> > +*flash) {
> > +	return CONFIG_SYS_SPI_U_BOOT_OFFS;
> > +}
> > +
> >   /*
> >    * The main entry for SPI booting. It's necessary that SDRAM is already
> >    * configured and available since this code loads the main U-Boot
> > image @@ -71,7 +77,7 @@ static int spl_spi_load_image(struct
> spl_image_info *spl_image,
> >   			      struct spl_boot_device *bootdev)
> >   {
> >   	int err = 0;
> > -	unsigned payload_offs = CONFIG_SYS_SPI_U_BOOT_OFFS;
> > +	unsigned int payload_offs;
> >   	struct spi_flash *flash;
> >   	struct image_header *header;
> >
> > @@ -90,6 +96,8 @@ static int spl_spi_load_image(struct spl_image_info
> *spl_image,
> >   		return -ENODEV;
> >   	}
> >
> > +	payload_offs = spl_spi_get_uboot_raw_sector(flash);
> 
> I don't really like the function name here "_raw_sector" as this is not a sector
> number in SPI flash but an address offset.

Oh, yes. spl_spi_get_uboot_offs should be fine.

Thanks,
Peng.
 

> 
> Thanks,
> Stefan

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-09-20 10:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-20  3:27 [U-Boot] [PATCH 1/6] spl: mmc: introduce spl_mmc_get_uboot_raw_sector Peng Fan
2019-09-20  3:27 ` [U-Boot] [PATCH 2/6] spl: spi: introduce spl_spi_get_uboot_raw_sector Peng Fan
2019-09-20  9:11   ` Stefan Roese
2019-09-20 10:00     ` Peng Fan
2019-09-20  3:27 ` [U-Boot] [PATCH 3/6] spl: nor: introduce spl_nor_get_uboot_base Peng Fan
2019-09-20  3:27 ` [U-Boot] [PATCH 4/6] spl: nand: Introduce spl_nand_get_uboot_raw_page Peng Fan
2019-09-20  3:27 ` [U-Boot] [PATCH 5/6] imx8: Add support to get container image set size Peng Fan
2019-09-20  3:27 ` [U-Boot] [PATCH 6/6] imx8: update README Peng Fan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.