Skip to contentSkip to conversation

spl: Lightweight UBI and UBI fastmap support

PATCH Superseded Ladislav Michl 4 participants 28 messages Jan 17, 2016 – Jun 4, 2016

Subsystems (3)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover spl: Lightweight UBI and UBI fastmap support

Hi,

yet another update of ubispl support. Please note, that igep00x0 specific part depends on yet unapplied "[PATCHv2 0/5] igep00x0: Minor cleanup" series

---
 README                             |    4
 arch/arm/lib/Makefile              |    2
 arch/arm/lib/bootm.c               |   32 -
 arch/arm/lib/zimage.c              |   40 +
 board/isee/igep00x0/igep00x0.c     |   12
 common/spl/Makefile                |    3
 common/spl/spl.c                   |   27 +
 common/spl/spl_ubi.c               |   68 ++
 doc/README.ubispl                  |  141 +++++
 drivers/Makefile                   |    5
 drivers/mtd/nand/nand_spl_simple.c |   62 ++
 drivers/mtd/ubispl/Makefile        |    1
 drivers/mtd/ubispl/ubi-wrapper.h   |  106 ++++
 drivers/mtd/ubispl/ubispl.c        |  926 +++++++++++++++++++++++++++++++++++++
 drivers/mtd/ubispl/ubispl.h        |  136 +++++
 include/configs/omap3_igep00x0.h   |   80 +--
 include/nand.h                     |    1
 include/spl.h                      |    4
 include/ubispl.h                   |   90 +++
#1 lore raw

PATCH v4 1/7 mtd: Sort subsystem directories aplhabeticaly in Makefile

---
 drivers/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/Makefile +2 -2
index 00da40b..1b9f8d6 100644
@@ -18,14 +18,14 @@ obj-$(CONFIG_ARMADA_38X) += ddr/marvell/a38x/
 obj-$(CONFIG_ARMADA_XP) += ddr/marvell/axp/
 obj-$(CONFIG_ALTERA_SDRAM) += ddr/altera/
 obj-$(CONFIG_SPL_SERIAL_SUPPORT) += serial/
-obj-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += mtd/spi/
 obj-$(CONFIG_SPL_SPI_SUPPORT) += spi/
 obj-$(CONFIG_SPL_POWER_SUPPORT) += power/ power/pmic/
 obj-$(CONFIG_SPL_POWER_SUPPORT) += power/regulator/
+obj-$(CONFIG_SPL_DRIVERS_MISC_SUPPORT) += misc/
 obj-$(CONFIG_SPL_MTD_SUPPORT) += mtd/
 obj-$(CONFIG_SPL_NAND_SUPPORT) += mtd/nand/
-obj-$(CONFIG_SPL_DRIVERS_MISC_SUPPORT) += misc/
 obj-$(CONFIG_SPL_ONENAND_SUPPORT) += mtd/onenand/
+obj-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += mtd/spi/
 obj-$(CONFIG_SPL_DMA_SUPPORT) += dma/
 obj-$(CONFIG_SPL_ETH_SUPPORT) += net/
 obj-$(CONFIG_SPL_ETH_SUPPORT) += net/phy/
Signature · 1 line
2.1.4
#2 lore raw

PATCH v4 1/7 mtd: Sort subsystem directories aplhabeticaly in Makefile

Hello Ladislav,

Am 17.01.2016 um 04:11 schrieb Ladislav Michl:

Quoted 5 lines
---
  drivers/Makefile | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

bye,
Heiko

Quoted 23 lines
drivers/Makefile +2 -2
index 00da40b..1b9f8d6 100644
@@ -18,14 +18,14 @@ obj-$(CONFIG_ARMADA_38X) += ddr/marvell/a38x/
  obj-$(CONFIG_ARMADA_XP) += ddr/marvell/axp/
  obj-$(CONFIG_ALTERA_SDRAM) += ddr/altera/
  obj-$(CONFIG_SPL_SERIAL_SUPPORT) += serial/
-obj-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += mtd/spi/
  obj-$(CONFIG_SPL_SPI_SUPPORT) += spi/
  obj-$(CONFIG_SPL_POWER_SUPPORT) += power/ power/pmic/
  obj-$(CONFIG_SPL_POWER_SUPPORT) += power/regulator/
+obj-$(CONFIG_SPL_DRIVERS_MISC_SUPPORT) += misc/
  obj-$(CONFIG_SPL_MTD_SUPPORT) += mtd/
  obj-$(CONFIG_SPL_NAND_SUPPORT) += mtd/nand/
-obj-$(CONFIG_SPL_DRIVERS_MISC_SUPPORT) += misc/
  obj-$(CONFIG_SPL_ONENAND_SUPPORT) += mtd/onenand/
+obj-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += mtd/spi/
  obj-$(CONFIG_SPL_DMA_SUPPORT) += dma/
  obj-$(CONFIG_SPL_ETH_SUPPORT) += net/
  obj-$(CONFIG_SPL_ETH_SUPPORT) += net/phy/
Signature · 2 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#3 lore raw

PATCH v4 2/7 nand_spl_simple: Add a simple NAND read function

In reply to Ladislav Michl

From: Thomas Gleixner <[email protected]>

To support UBI in SPL we need a simple NAND read function. Add one to nand_spl_simple and keep it as simple as it goes.

---
Changes in v3:
- Rename nand_spl_read_flash to nand_spl_read_block and optimize it.

 drivers/mtd/nand/nand_spl_simple.c | 62 ++++++++++++++++++++++++++++++++++++++
 include/nand.h                     |  1 +
 2 files changed, 63 insertions(+)
drivers/mtd/nand/nand_spl_simple.c +62 -0
index e69f662..cf80903 100644
@@ -209,6 +209,68 @@ static int nand_read_page(int block, int page, void *dst)
 }
 #endif
 
+#ifdef CONFIG_SPL_UBI
+/*
+ * Temporary storage for non NAND page aligned and non NAND page sized
+ * reads. Note: This does not support runtime detected FLASH yet, but
+ * that should be reasonably easy to fix by making the buffer large
+ * enough :)
+ */
+static u8 scratch_buf[CONFIG_SYS_NAND_PAGE_SIZE];
+
+/**
+ * nand_spl_read_block - Read data from physical eraseblock into a buffer
+ * @block:	Number of the physical eraseblock
+ * @offset:	Data offset from the start of @peb
+ * @len:	Data size to read
+ * @dst:	Address of the destination buffer
+ *
+ * This could be further optimized if we'd have a subpage read
+ * function in the simple code. On NAND which allows subpage reads
+ * this would spare quite some time to readout e.g. the VID header of
+ * UBI.
+ *
+ * Notes:
+ *	@offset + @len are not allowed to be larger than a physical
+ *	erase block. No sanity check done for simplicity reasons.
+ *
+ * To support runtime detected flash this needs to be extended by
+ * information about the actual flash geometry, but thats beyond the
+ * scope of this effort and for most applications where fast boot is
+ * required it is not an issue anyway.
+ */
+int nand_spl_read_block(int block, int offset, int len, void *dst)
+{
+	int page, read;
+
+	/* Calculate the page number */
+	page = offset / CONFIG_SYS_NAND_PAGE_SIZE;
+
+	/* Offset to the start of a flash page */
+	offset = offset % CONFIG_SYS_NAND_PAGE_SIZE;
+
+	while (len) {
+		/*
+		 * Non page aligned reads go to the scratch buffer.
+		 * Page aligned reads go directly to the destination.
+		 */
+		if (offset || len < CONFIG_SYS_NAND_PAGE_SIZE) {
+			nand_read_page(block, page, scratch_buf);
+			read = min(len, CONFIG_SYS_NAND_PAGE_SIZE - offset);
+			memcpy(dst, scratch_buf + offset, read);
+			offset = 0;
+		} else {
+			nand_read_page(block, page, dst);
+			read = CONFIG_SYS_NAND_PAGE_SIZE;
+		}
+		page++;
+		len -= read;
+		dst += read;
+	}
+	return 0;
+}
+#endif
+
 int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst)
 {
 	unsigned int block, lastblock;
include/nand.h +1 -0
index d2a53ab..2f9a1ec 100644
@@ -124,6 +124,7 @@ int nand_unlock(nand_info_t *meminfo, loff_t start, size_t length,
 int nand_get_lock_status(nand_info_t *meminfo, loff_t offset);
 
 int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst);
+int nand_spl_read_block(int block, int offset, int len, void *dst);
 void nand_deselect(void);
 
 #ifdef CONFIG_SYS_NAND_SELECT_DEVICE
Signature · 1 line
2.1.4
#4 lore raw

PATCH v4 2/7 nand_spl_simple: Add a simple NAND read function

Hello Ladislav,

Am 17.01.2016 um 04:12 schrieb Ladislav Michl:

Quoted 9 lines

From: Thomas Gleixner <[email protected]>

To support UBI in SPL we need a simple NAND read function. Add one to nand_spl_simple and keep it as simple as it goes.

Quoted 7 lines

---
Changes in v3:
- Rename nand_spl_read_flash to nand_spl_read_block and optimize it.

  drivers/mtd/nand/nand_spl_simple.c | 62 ++++++++++++++++++++++++++++++++++++++
  include/nand.h                     |  1 +
  2 files changed, 63 insertions(+)

bye,
Heiko

Quoted 87 lines
drivers/mtd/nand/nand_spl_simple.c +62 -0
index e69f662..cf80903 100644
@@ -209,6 +209,68 @@ static int nand_read_page(int block, int page, void *dst)
  }
  #endif
 
+#ifdef CONFIG_SPL_UBI
+/*
+ * Temporary storage for non NAND page aligned and non NAND page sized
+ * reads. Note: This does not support runtime detected FLASH yet, but
+ * that should be reasonably easy to fix by making the buffer large
+ * enough :)
+ */
+static u8 scratch_buf[CONFIG_SYS_NAND_PAGE_SIZE];
+
+/**
+ * nand_spl_read_block - Read data from physical eraseblock into a buffer
+ * @block:	Number of the physical eraseblock
+ * @offset:	Data offset from the start of @peb
+ * @len:	Data size to read
+ * @dst:	Address of the destination buffer
+ *
+ * This could be further optimized if we'd have a subpage read
+ * function in the simple code. On NAND which allows subpage reads
+ * this would spare quite some time to readout e.g. the VID header of
+ * UBI.
+ *
+ * Notes:
+ *	@offset + @len are not allowed to be larger than a physical
+ *	erase block. No sanity check done for simplicity reasons.
+ *
+ * To support runtime detected flash this needs to be extended by
+ * information about the actual flash geometry, but thats beyond the
+ * scope of this effort and for most applications where fast boot is
+ * required it is not an issue anyway.
+ */
+int nand_spl_read_block(int block, int offset, int len, void *dst)
+{
+	int page, read;
+
+	/* Calculate the page number */
+	page = offset / CONFIG_SYS_NAND_PAGE_SIZE;
+
+	/* Offset to the start of a flash page */
+	offset = offset % CONFIG_SYS_NAND_PAGE_SIZE;
+
+	while (len) {
+		/*
+		 * Non page aligned reads go to the scratch buffer.
+		 * Page aligned reads go directly to the destination.
+		 */
+		if (offset || len < CONFIG_SYS_NAND_PAGE_SIZE) {
+			nand_read_page(block, page, scratch_buf);
+			read = min(len, CONFIG_SYS_NAND_PAGE_SIZE - offset);
+			memcpy(dst, scratch_buf + offset, read);
+			offset = 0;
+		} else {
+			nand_read_page(block, page, dst);
+			read = CONFIG_SYS_NAND_PAGE_SIZE;
+		}
+		page++;
+		len -= read;
+		dst += read;
+	}
+	return 0;
+}
+#endif
+
  int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst)
  {
  	unsigned int block, lastblock;
include/nand.h +1 -0
index d2a53ab..2f9a1ec 100644
@@ -124,6 +124,7 @@ int nand_unlock(nand_info_t *meminfo, loff_t start, size_t length,
  int nand_get_lock_status(nand_info_t *meminfo, loff_t offset);
 
  int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst);
+int nand_spl_read_block(int block, int offset, int len, void *dst);
  void nand_deselect(void);
 
  #ifdef CONFIG_SYS_NAND_SELECT_DEVICE
Signature · 2 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#5 lore raw

PATCH v4 3/7 spl: Lightweight UBI and UBI fastmap support

In reply to Ladislav Michl

From: Thomas Gleixner <[email protected]>

Booting a payload out of NAND FLASH from the SPL is a crux today, as it requires hard partioned FLASH. Not a brilliant idea with the reliability of todays NAND FLASH chips.

The upstream UBI + UBI fastmap implementation which is about to brought to u-boot is too heavy weight for SPLs as it provides way more functionality than needed for a SPL and does not even fit into the restricted SPL areas which are loaded from the SoC boot ROM.

So this provides a fast and lightweight implementation of UBI scanning and UBI fastmap attach. The scan and logical to physical block mapping code is developed from scratch, while the fastmap implementation is lifted from the linux kernel source and stripped down to fit the SPL needs.

The text foot print on the board which I used for development is:

6854 0 0 6854 1abd
drivers/mtd/ubispl/built-in.o

Attaching a NAND chip with 4096 physical eraseblocks (4 blocks are reserved for the SPL) takes:

In full scan mode:      1172ms
In fastmap mode:          95ms

The code requires quite some storage. The largest and unknown part of it is the number of fastmap blocks to read. Therefor the data structure is not put into the BSS. The code requires a pointer to free memory handed in which is initialized by the UBI attach code itself.

See doc/README.ubispl for further information on how to use it.

This shares the ubi-media.h and crc32 implementation of drivers/mtd/ubi There is no way to share the fastmap code, as UBISPL only utilizes the slightly modified functions ubi_attach_fastmap() and ubi_scan_fastmap() from the original kernel ubi fastmap implementation.

---
Changes in v2:
- fixes ubi_calc_fm_size to include also sizeof(struct ubi_fm_sb)
- dropped private copy of ubi-media.h
- ubi-wrapper.h now contains only needed definitions from ubi.h and ubi-user.h
- used return values from errno.h

Changes in v3:
- move vol_id check to ubi_scan_vid_hdr to verify it has meaningfull value

    before testing ubi->toload

- fixed checkpatch errors except those present also in linux code

Changes in v4:
- drop unused name field from ubispl_load structure
- ipl_load returns lenght read

 README                           |   4 +
 doc/README.ubispl                | 141 ++++++
 drivers/Makefile                 |   1 +
 drivers/mtd/ubispl/Makefile      |   1 +
 drivers/mtd/ubispl/ubi-wrapper.h | 106 +++++
 drivers/mtd/ubispl/ubispl.c      | 926 +++++++++++++++++++++++++++++++++++++++
 drivers/mtd/ubispl/ubispl.h      | 136 ++++++
 include/ubispl.h                 |  90 ++++
 8 files changed, 1405 insertions(+)
 create mode 100644 doc/README.ubispl
 create mode 100644 drivers/mtd/ubispl/Makefile
 create mode 100644 drivers/mtd/ubispl/ubi-wrapper.h
 create mode 100644 drivers/mtd/ubispl/ubispl.c
 create mode 100644 drivers/mtd/ubispl/ubispl.h
 create mode 100644 include/ubispl.h
README +4 -0
index 9423c34..e3adbdc 100644
@@ -3611,6 +3611,10 @@ FIT uImage format:
 		Support for NAND boot using simple NAND drivers that
 		expose the cmd_ctrl() interface.
 
+		CONFIG_SPL_UBI
+		Support for a lightweight UBI (fastmap) scanner and
+		loader
+
 		CONFIG_SPL_MTD_SUPPORT
 		Support for the MTD subsystem within SPL.  Useful for
 		environment on NAND support within SPL.
doc/README.ubispl new file +141 -0

141 lines not on this page · raw message

drivers/Makefile +1 -0
index 1b9f8d6..7b3a3c4 100644
@@ -26,6 +26,7 @@ obj-$(CONFIG_SPL_MTD_SUPPORT) += mtd/
 obj-$(CONFIG_SPL_NAND_SUPPORT) += mtd/nand/
 obj-$(CONFIG_SPL_ONENAND_SUPPORT) += mtd/onenand/
 obj-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += mtd/spi/
+obj-$(CONFIG_SPL_UBI) += mtd/ubispl/
 obj-$(CONFIG_SPL_DMA_SUPPORT) += dma/
 obj-$(CONFIG_SPL_ETH_SUPPORT) += net/
 obj-$(CONFIG_SPL_ETH_SUPPORT) += net/phy/
drivers/mtd/ubispl/Makefile new file +1 -0
new file mode 100644
index 0000000..740dbed
@@ -0,0 +1 @@
+obj-y += ubispl.o ../ubi/crc32.o
drivers/mtd/ubispl/ubi-wrapper.h new file +106 -0

106 lines not on this page · raw message

drivers/mtd/ubispl/ubispl.c new file +926 -0

926 lines not on this page · raw message

drivers/mtd/ubispl/ubispl.h new file +136 -0

136 lines not on this page · raw message

include/ubispl.h new file +90 -0

90 lines not on this page · raw message

Signature · 1 line
2.1.4
#6 lore raw

PATCH v4 4/7 spl: support loading from UBI volumes

In reply to Ladislav Michl

Add support for loading from UBI volumes on the top of NAND.

---
 common/spl/Makefile  |  3 +++
 common/spl/spl.c     |  4 ++++
 common/spl/spl_ubi.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/spl.h        |  4 ++++
 4 files changed, 79 insertions(+)
 create mode 100644 common/spl/spl_ubi.c
common/spl/Makefile +3 -0
index 10a4589..36e5338 100644
@@ -12,8 +12,11 @@ ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SPL_FRAMEWORK) += spl.o
 obj-$(CONFIG_SPL_NOR_SUPPORT) += spl_nor.o
 obj-$(CONFIG_SPL_YMODEM_SUPPORT) += spl_ymodem.o
+ifndef CONFIG_SPL_UBI
 obj-$(CONFIG_SPL_NAND_SUPPORT) += spl_nand.o
+endif
 obj-$(CONFIG_SPL_ONENAND_SUPPORT) += spl_onenand.o
+obj-$(CONFIG_SPL_UBI) += spl_ubi.o
 obj-$(CONFIG_SPL_NET_SUPPORT) += spl_net.o
 obj-$(CONFIG_SPL_MMC_SUPPORT) += spl_mmc.o
 obj-$(CONFIG_SPL_USB_SUPPORT) += spl_usb.o
common/spl/spl.c +4 -0
index e5167bf..b945a48 100644
@@ -288,8 +288,12 @@ static int spl_load_image(u32 boot_device)
 #endif
 #ifdef CONFIG_SPL_NAND_SUPPORT
 	case BOOT_DEVICE_NAND:
+#ifdef CONFIG_SPL_UBI
+		return spl_ubi_load_image(boot_device);
+#else
 		return spl_nand_load_image();
 #endif
+#endif
 #ifdef CONFIG_SPL_ONENAND_SUPPORT
 	case BOOT_DEVICE_ONENAND:
 		return spl_onenand_load_image();
common/spl/spl_ubi.c new file +68 -0

68 lines not on this page · raw message

include/spl.h +4 -0
index 92cdc04..1ab9295 100644
@@ -40,6 +40,7 @@ u32 spl_boot_mode(void);
 void spl_set_header_raw_uboot(void);
 void spl_parse_image_header(const struct image_header *header);
 void spl_board_prepare_for_linux(void);
+int spl_board_ubi_load_image(u32 boot_device);
 void __noreturn jump_to_image_linux(void *arg);
 int spl_start_uboot(void);
 void spl_display_print(void);
@@ -53,6 +54,9 @@ int spl_onenand_load_image(void);
 /* NOR SPL functions */
 int spl_nor_load_image(void);
 
+/* UBI SPL functions */
+int spl_ubi_load_image(u32 boot_device);
+
 /* MMC SPL functions */
 int spl_mmc_load_image(u32 boot_device);
 
Signature · 1 line
2.1.4
#7 lore raw

PATCH v4 4/7 spl: support loading from UBI volumes

Hello Ladislav,

Am 17.01.2016 um 04:13 schrieb Ladislav Michl:

Quoted 10 lines

Add support for loading from UBI volumes on the top of NAND.

---
  common/spl/Makefile  |  3 +++
  common/spl/spl.c     |  4 ++++
  common/spl/spl_ubi.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++
  include/spl.h        |  4 ++++
  4 files changed, 79 insertions(+)

create mode 100644 common/spl/spl_ubi.c

bye,
Heiko

Quoted 131 lines
common/spl/Makefile +3 -0
index 10a4589..36e5338 100644
@@ -12,8 +12,11 @@ ifdef CONFIG_SPL_BUILD
  obj-$(CONFIG_SPL_FRAMEWORK) += spl.o
  obj-$(CONFIG_SPL_NOR_SUPPORT) += spl_nor.o
  obj-$(CONFIG_SPL_YMODEM_SUPPORT) += spl_ymodem.o
+ifndef CONFIG_SPL_UBI
  obj-$(CONFIG_SPL_NAND_SUPPORT) += spl_nand.o
+endif
  obj-$(CONFIG_SPL_ONENAND_SUPPORT) += spl_onenand.o
+obj-$(CONFIG_SPL_UBI) += spl_ubi.o
  obj-$(CONFIG_SPL_NET_SUPPORT) += spl_net.o
  obj-$(CONFIG_SPL_MMC_SUPPORT) += spl_mmc.o
  obj-$(CONFIG_SPL_USB_SUPPORT) += spl_usb.o
common/spl/spl.c +4 -0
index e5167bf..b945a48 100644
@@ -288,8 +288,12 @@ static int spl_load_image(u32 boot_device)
  #endif
  #ifdef CONFIG_SPL_NAND_SUPPORT
  	case BOOT_DEVICE_NAND:
+#ifdef CONFIG_SPL_UBI
+		return spl_ubi_load_image(boot_device);
+#else
  		return spl_nand_load_image();
  #endif
+#endif
  #ifdef CONFIG_SPL_ONENAND_SUPPORT
  	case BOOT_DEVICE_ONENAND:
  		return spl_onenand_load_image();
common/spl/spl_ubi.c new file +68 -0
new file mode 100644
index 0000000..dd8ce36
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2016
+ * Ladislav Michl <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <config.h>
+#include <nand.h>
+#include <ubispl.h>
+#include <spl.h>
+
+int spl_ubi_load_image(u32 boot_device)
+{
+	int ret;
+	struct image_header *header;
+	struct ubispl_info info;
+	struct ubispl_load volumes[2];
+
+#ifdef CONFIG_SPL_NAND_SUPPORT
+	if (boot_device == BOOT_DEVICE_NAND)
+		nand_init();
+#endif
+	info.ubi = (struct ubi_scan_info *) CONFIG_SPL_UBI_INFO_ADDR;
+	info.fastmap = 1;
+	info.read = nand_spl_read_block;
+
+	info.peb_offset = CONFIG_SPL_UBI_PEB_OFFSET;
+	info.peb_size = CONFIG_SYS_NAND_BLOCK_SIZE;
+	info.vid_offset = CONFIG_SPL_UBI_VID_OFFSET;
+	info.leb_start = CONFIG_SPL_UBI_LEB_START;
+	info.peb_count = CONFIG_SPL_UBI_MAX_PEBS - info.peb_offset;
+
+#ifdef CONFIG_SPL_OS_BOOT
+	if (!spl_start_uboot()) {
+		volumes[0].vol_id = CONFIG_SPL_UBI_LOAD_KERNEL_ID;
+		volumes[0].load_addr = (void *)CONFIG_SYS_LOAD_ADDR;
+		volumes[1].vol_id = CONFIG_SPL_UBI_LOAD_ARGS_ID;
+		volumes[1].load_addr = (void *)CONFIG_SYS_SPL_ARGS_ADDR;
+
+		ret = ubispl_load_volumes(&info, volumes, 2);
+		if (!ret) {
+			header = (struct image_header *) volumes[0].load_addr;
+			spl_parse_image_header(header);
+			puts("Linux loaded.\n");
+			goto out;
+		}
+		puts("Loading Linux failed, falling back to U-Boot.\n");
+	}
+#endif
+	header = (struct image_header *)
+		(CONFIG_SYS_TEXT_BASE - sizeof(struct image_header));
+	volumes[0].vol_id = CONFIG_SPL_UBI_LOAD_MONITOR_ID;
+	volumes[0].load_addr = (void *)header;
+
+	ret = ubispl_load_volumes(&info, volumes, 1);
+	if (!ret)
+		spl_parse_image_header(header);
+#ifdef CONFIG_SPL_OS_BOOT
+out:
+#endif
+#ifdef CONFIG_SPL_NAND_SUPPORT
+	if (boot_device == BOOT_DEVICE_NAND)
+		nand_deselect();
+#endif
+	return ret;
+}
include/spl.h +4 -0
index 92cdc04..1ab9295 100644
@@ -40,6 +40,7 @@ u32 spl_boot_mode(void);
  void spl_set_header_raw_uboot(void);
  void spl_parse_image_header(const struct image_header *header);
  void spl_board_prepare_for_linux(void);
+int spl_board_ubi_load_image(u32 boot_device);
  void __noreturn jump_to_image_linux(void *arg);
  int spl_start_uboot(void);
  void spl_display_print(void);
@@ -53,6 +54,9 @@ int spl_onenand_load_image(void);
  /* NOR SPL functions */
  int spl_nor_load_image(void);
 
+/* UBI SPL functions */
+int spl_ubi_load_image(u32 boot_device);
+
  /* MMC SPL functions */
  int spl_mmc_load_image(u32 boot_device);
 
Signature · 2 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#8 lore raw

PATCH v5 5/7 spl: zImage support in Falcon mode

In reply to Ladislav Michl

Other payload than uImage is currently considered to be raw U-Boot image. Check also for zImage in Falcon mode.

---
 arch/arm/lib/Makefile |  2 ++
 arch/arm/lib/bootm.c  | 32 --------------------------------
 arch/arm/lib/zimage.c | 40 ++++++++++++++++++++++++++++++++++++++++
 common/spl/spl.c      | 23 +++++++++++++++++++++++
 4 files changed, 65 insertions(+), 32 deletions(-)
 create mode 100644 arch/arm/lib/zimage.c
arch/arm/lib/Makefile +2 -0
index f3db7b5..07a9019 100644
@@ -26,11 +26,13 @@ endif
 obj-$(CONFIG_CPU_V7M) += cmd_boot.o
 obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
+obj-$(CONFIG_CMD_BOOTM) += zimage.o
 obj-$(CONFIG_SYS_L2_PL310) += cache-pl310.o
 obj-$(CONFIG_USE_ARCH_MEMSET) += memset.o
 obj-$(CONFIG_USE_ARCH_MEMCPY) += memcpy.o
 else
 obj-$(CONFIG_SPL_FRAMEWORK) += spl.o
+obj-$(CONFIG_SPL_FRAMEWORK) += zimage.o
 endif
 obj-$(CONFIG_SEMIHOSTING) += semihosting.o
 
arch/arm/lib/bootm.c +0 -32
index a477cae..fbfc0ad 100644
@@ -348,38 +348,6 @@ int do_bootm_linux(int flag, int argc, char * const argv[],
 	return 0;
 }
 
-#ifdef CONFIG_CMD_BOOTZ
-
-struct zimage_header {
-	uint32_t	code[9];
-	uint32_t	zi_magic;
-	uint32_t	zi_start;
-	uint32_t	zi_end;
-};
-
-#define	LINUX_ARM_ZIMAGE_MAGIC	0x016f2818
-
-int bootz_setup(ulong image, ulong *start, ulong *end)
-{
-	struct zimage_header *zi;
-
-	zi = (struct zimage_header *)map_sysmem(image, 0);
-	if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC) {
-		puts("Bad Linux ARM zImage magic!\n");
-		return 1;
-	}
-
-	*start = zi->zi_start;
-	*end = zi->zi_end;
-
-	printf("Kernel image @ %#08lx [ %#08lx - %#08lx ]\n", image, *start,
-	      *end);
-
-	return 0;
-}
-
-#endif	/* CONFIG_CMD_BOOTZ */
-
 #if defined(CONFIG_BOOTM_VXWORKS)
 void boot_prep_vxworks(bootm_headers_t *images)
 {
arch/arm/lib/zimage.c new file +40 -0
new file mode 100644
index 0000000..f870d72
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2016
+ * Ladislav Michl <[email protected]>
+ *
+ * bootz code:
+ * Copyright (C) 2012 Marek Vasut <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#include <common.h>
+
+#define	LINUX_ARM_ZIMAGE_MAGIC	0x016f2818
+
+struct arm_z_header {
+	uint32_t	code[9];
+	uint32_t	zi_magic;
+	uint32_t	zi_start;
+	uint32_t	zi_end;
+} __attribute__ ((__packed__));
+
+int bootz_setup(ulong image, ulong *start, ulong *end)
+{
+	struct arm_z_header *zi = (struct arm_z_header *) image;
+
+	if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC) {
+#ifndef CONFIG_SPL_FRAMEWORK
+		puts("Bad Linux ARM zImage magic!\n");
+#endif
+		return 1;
+	}
+
+	*start = zi->zi_start;
+	*end = zi->zi_end;
+#ifndef CONFIG_SPL_FRAMEWORK
+	printf("Kernel image @ %#08lx [ %#08lx - %#08lx ]\n", image, *start,
+	      *end);
+#endif
+
+	return 0;
+}
common/spl/spl.c +23 -0
index b945a48..7fd8e5d 100644
@@ -52,6 +52,15 @@ __weak int spl_start_uboot(void)
 	puts("SPL: Direct Linux boot not active!\n");
 	return 1;
 }
+
+/*
+ * Weak default function for arch specific zImage check. Return zero
+ * and fill start and end address if image is recognized.
+ */
+int __weak bootz_setup(ulong image, ulong *start, ulong *end)
+{
+	 return 1;
+}
 #endif
 
 /*
@@ -112,6 +121,20 @@ void spl_parse_image_header(const struct image_header *header)
 		 */
 		panic("** no mkimage signature but raw image not supported");
 #else
+#ifdef CONFIG_SPL_OS_BOOT
+		ulong start, end;
+
+		if (!bootz_setup((ulong)header, &start, &end)) {
+			spl_image.name = "Linux";
+			spl_image.os = IH_OS_LINUX;
+			spl_image.load_addr = CONFIG_SYS_LOAD_ADDR;
+			spl_image.entry_point = CONFIG_SYS_LOAD_ADDR;
+			spl_image.size = end - start;
+			debug("spl: payload zImage, load addr: 0x%x size: %d\n",
+				spl_image.load_addr, spl_image.size);
+			return;
+		}
+#endif
 		/* Signature not found - assume u-boot.bin */
 		debug("mkimage signature not found - ih_magic = %x\n",
 			header->ih_magic);
Signature · 1 line
2.1.4
#9 lore raw

PATCH v5 5/7 spl: zImage support in Falcon mode

Hello Ladislav,

Am 17.01.2016 um 04:15 schrieb Ladislav Michl:

Quoted 11 lines

Other payload than uImage is currently considered to be raw U-Boot image. Check also for zImage in Falcon mode.

---
  arch/arm/lib/Makefile |  2 ++
  arch/arm/lib/bootm.c  | 32 --------------------------------
  arch/arm/lib/zimage.c | 40 ++++++++++++++++++++++++++++++++++++++++
  common/spl/spl.c      | 23 +++++++++++++++++++++++
  4 files changed, 65 insertions(+), 32 deletions(-)

create mode 100644 arch/arm/lib/zimage.c

bye,
Heiko

Quoted 150 lines
arch/arm/lib/Makefile +2 -0
index f3db7b5..07a9019 100644
@@ -26,11 +26,13 @@ endif
  obj-$(CONFIG_CPU_V7M) += cmd_boot.o
  obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o
  obj-$(CONFIG_CMD_BOOTM) += bootm.o
+obj-$(CONFIG_CMD_BOOTM) += zimage.o
  obj-$(CONFIG_SYS_L2_PL310) += cache-pl310.o
  obj-$(CONFIG_USE_ARCH_MEMSET) += memset.o
  obj-$(CONFIG_USE_ARCH_MEMCPY) += memcpy.o
  else
  obj-$(CONFIG_SPL_FRAMEWORK) += spl.o
+obj-$(CONFIG_SPL_FRAMEWORK) += zimage.o
  endif
  obj-$(CONFIG_SEMIHOSTING) += semihosting.o
 
arch/arm/lib/bootm.c +0 -32
index a477cae..fbfc0ad 100644
@@ -348,38 +348,6 @@ int do_bootm_linux(int flag, int argc, char * const argv[],
  	return 0;
  }
 
-#ifdef CONFIG_CMD_BOOTZ
-
-struct zimage_header {
-	uint32_t	code[9];
-	uint32_t	zi_magic;
-	uint32_t	zi_start;
-	uint32_t	zi_end;
-};
-
-#define	LINUX_ARM_ZIMAGE_MAGIC	0x016f2818
-
-int bootz_setup(ulong image, ulong *start, ulong *end)
-{
-	struct zimage_header *zi;
-
-	zi = (struct zimage_header *)map_sysmem(image, 0);
-	if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC) {
-		puts("Bad Linux ARM zImage magic!\n");
-		return 1;
-	}
-
-	*start = zi->zi_start;
-	*end = zi->zi_end;
-
-	printf("Kernel image @ %#08lx [ %#08lx - %#08lx ]\n", image, *start,
-	      *end);
-
-	return 0;
-}
-
-#endif	/* CONFIG_CMD_BOOTZ */
-
  #if defined(CONFIG_BOOTM_VXWORKS)
  void boot_prep_vxworks(bootm_headers_t *images)
  {
arch/arm/lib/zimage.c new file +40 -0
new file mode 100644
index 0000000..f870d72
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2016
+ * Ladislav Michl <[email protected]>
+ *
+ * bootz code:
+ * Copyright (C) 2012 Marek Vasut <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#include <common.h>
+
+#define	LINUX_ARM_ZIMAGE_MAGIC	0x016f2818
+
+struct arm_z_header {
+	uint32_t	code[9];
+	uint32_t	zi_magic;
+	uint32_t	zi_start;
+	uint32_t	zi_end;
+} __attribute__ ((__packed__));
+
+int bootz_setup(ulong image, ulong *start, ulong *end)
+{
+	struct arm_z_header *zi = (struct arm_z_header *) image;
+
+	if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC) {
+#ifndef CONFIG_SPL_FRAMEWORK
+		puts("Bad Linux ARM zImage magic!\n");
+#endif
+		return 1;
+	}
+
+	*start = zi->zi_start;
+	*end = zi->zi_end;
+#ifndef CONFIG_SPL_FRAMEWORK
+	printf("Kernel image @ %#08lx [ %#08lx - %#08lx ]\n", image, *start,
+	      *end);
+#endif
+
+	return 0;
+}
common/spl/spl.c +23 -0
index b945a48..7fd8e5d 100644
@@ -52,6 +52,15 @@ __weak int spl_start_uboot(void)
  	puts("SPL: Direct Linux boot not active!\n");
  	return 1;
  }
+
+/*
+ * Weak default function for arch specific zImage check. Return zero
+ * and fill start and end address if image is recognized.
+ */
+int __weak bootz_setup(ulong image, ulong *start, ulong *end)
+{
+	 return 1;
+}
  #endif
 
  /*
@@ -112,6 +121,20 @@ void spl_parse_image_header(const struct image_header *header)
  		 */
  		panic("** no mkimage signature but raw image not supported");
  #else
+#ifdef CONFIG_SPL_OS_BOOT
+		ulong start, end;
+
+		if (!bootz_setup((ulong)header, &start, &end)) {
+			spl_image.name = "Linux";
+			spl_image.os = IH_OS_LINUX;
+			spl_image.load_addr = CONFIG_SYS_LOAD_ADDR;
+			spl_image.entry_point = CONFIG_SYS_LOAD_ADDR;
+			spl_image.size = end - start;
+			debug("spl: payload zImage, load addr: 0x%x size: %d\n",
+				spl_image.load_addr, spl_image.size);
+			return;
+		}
+#endif
  		/* Signature not found - assume u-boot.bin */
  		debug("mkimage signature not found - ih_magic = %x\n",
  			header->ih_magic);
Signature · 2 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#10 lore raw

PATCH v7 6/7 igep00x0: UBIize

In reply to Ladislav Michl

Convert IGEP board to use UBI volumes for U-Boot, its environment and kernel. With exception of first four sectors read by SoC boot ROM whole NAND is UBI managed. As code is too big now, drop CONFIG_SPL_EXT_SUPPORT to make it fit.

---
 include/configs/omap3_igep00x0.h | 80 ++++++++++++++++++++++------------------
 1 file changed, 45 insertions(+), 35 deletions(-)
include/configs/omap3_igep00x0.h +45 -35
index 5da6cfd..9afbcbe 100644
@@ -74,6 +74,8 @@
 #define CONFIG_CMD_CACHE
 #ifdef CONFIG_BOOT_ONENAND
 #define CONFIG_CMD_ONENAND	/* ONENAND support		*/
+#else
+#define CONFIG_CMD_UBI
 #endif
 #define CONFIG_CMD_DHCP
 #define CONFIG_CMD_PING
@@ -86,6 +88,10 @@
 	"stdout=serial\0" \
 	"stderr=serial\0"
 
+#define ENV_MTD_SETTINGS \
+	"mtdids=nand0=gpmc-nand.0\0" \
+	"mtdparts=mtdparts=gpmc-nand.0:512k(SPL),-(UBI)\0"
+
 #define MEM_LAYOUT_SETTINGS \
 	DEFAULT_LINUX_BOOT_ENV \
 	"scriptaddr=0x87E00000\0" \
@@ -96,36 +102,15 @@
 
 #include <config_distro_bootcmd.h>
 
-
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	ENV_DEVICE_SETTINGS \
+	ENV_MTD_SETTINGS \
 	MEM_LAYOUT_SETTINGS \
 	BOOTENV
 
 #endif
 
 /*
- * FLASH and environment organization
- */
-
-#ifdef CONFIG_BOOT_ONENAND
-#define CONFIG_SYS_ONENAND_BASE		ONENAND_MAP
-
-#define ONENAND_ENV_OFFSET		0x260000 /* environment starts here */
-
-#define CONFIG_ENV_IS_IN_ONENAND	1
-#define CONFIG_ENV_SIZE			(512 << 10) /* Total Size Environment */
-#define CONFIG_ENV_ADDR			ONENAND_ENV_OFFSET
-#endif
-
-#ifdef CONFIG_NAND
-#define CONFIG_ENV_OFFSET		0x260000 /* environment starts here */
-#define CONFIG_ENV_IS_IN_NAND	        1
-#define CONFIG_ENV_SIZE			(512 << 10) /* Total Size Environment */
-#define CONFIG_ENV_ADDR			NAND_ENV_OFFSET
-#endif
-
-/*
  * SMSC911x Ethernet
  */
 #if defined(CONFIG_CMD_NET)
@@ -134,19 +119,50 @@
 #define CONFIG_SMC911X_BASE		0x2C000000
 #endif /* (CONFIG_CMD_NET) */
 
+/*
+ * FLASH and environment organization
+ */
+#ifdef CONFIG_NAND
+#define CONFIG_SPL_UBI			1
+#define CONFIG_SPL_UBI_MAX_VOL_LEBS	256
+#define CONFIG_SPL_UBI_MAX_PEB_SIZE	(256*1024)
+#define CONFIG_SPL_UBI_MAX_PEBS		4096
+#define CONFIG_SPL_UBI_VOL_IDS		8
+#define CONFIG_SPL_UBI_LOAD_MONITOR_ID	0
+#define CONFIG_SPL_UBI_LOAD_KERNEL_ID	3
+#define CONFIG_SPL_UBI_LOAD_ARGS_ID	4
+#define CONFIG_SPL_UBI_PEB_OFFSET	4
+#define CONFIG_SPL_UBI_VID_OFFSET	512
+#define CONFIG_SPL_UBI_LEB_START	2048
+#define CONFIG_SPL_UBI_INFO_ADDR	0x88080000
+
+#define CONFIG_ENV_IS_IN_UBI		1
+#define CONFIG_ENV_UBI_PART		"UBI"
+#define CONFIG_ENV_UBI_VOLUME		"config"
+#define CONFIG_ENV_UBI_VOLUME_REDUND	"config_r"
+#define CONFIG_UBI_SILENCE_MSG		1
+#define CONFIG_UBIFS_SILENCE_MSG	1
+#else
+#define CONFIG_ENV_IS_NOWHERE
+#endif
+#define CONFIG_ENV_SIZE			(32*1024)
+
+#define CONFIG_RBTREE
+#define CONFIG_MTD_PARTITIONS
+#define MTDIDS_DEFAULT			"nand0=gpmc-nand.0"
+#define MTDPARTS_DEFAULT		"mtdparts=gpmc-nand.0:512k(SPL),-(UBI)"
+
 /* OneNAND boot config */
 #ifdef CONFIG_BOOT_ONENAND
 #define CONFIG_SPL_ONENAND_SUPPORT
-#define CONFIG_SYS_ONENAND_U_BOOT_OFFS  0x80000
 #define CONFIG_SYS_ONENAND_PAGE_SIZE	2048
-#define CONFIG_SPL_ONENAND_LOAD_ADDR    0x80000
-#define CONFIG_SPL_ONENAND_LOAD_SIZE    \
-	(512 * 1024 - CONFIG_SPL_ONENAND_LOAD_ADDR)
-
+#define CONFIG_SYS_ONENAND_BASE		ONENAND_MAP
+#define CONFIG_SYS_ONENAND_U_BOOT_OFFS	0x80000
 #endif
 
 /* NAND boot config */
 #ifdef CONFIG_NAND
+#define CONFIG_SPL_NAND_SUPPORT
 #define CONFIG_SYS_NAND_BUSWIDTH_16BIT
 #define CONFIG_SYS_NAND_5_ADDR_CYCLE
 #define CONFIG_SYS_NAND_PAGE_COUNT	64
@@ -166,14 +182,8 @@
 #define CONFIG_NAND_OMAP_ECCSCHEME	OMAP_ECC_BCH8_CODE_HW_DETECTION_SW
 #define CONFIG_NAND_OMAP_GPMC
 #define CONFIG_BCH
-
-#define CONFIG_SYS_NAND_U_BOOT_OFFS	0x80000
-/* NAND: SPL falcon mode configs */
-#ifdef CONFIG_SPL_OS_BOOT
-#define CONFIG_CMD_SPL_NAND_OFS		0x240000
-#define CONFIG_SYS_NAND_SPL_KERNEL_OFFS	0x280000
-#define CONFIG_CMD_SPL_WRITE_SIZE	0x2000
-#endif
 #endif
 
+#undef CONFIG_SPL_EXT_SUPPORT
+
 #endif /* __IGEP00X0_H */
Signature · 1 line
2.1.4
#11 lore raw

PATCH v7 6/7 igep00x0: UBIize

Hello Ladislav,

Am 17.01.2016 um 04:16 schrieb Ladislav Michl:

Quoted 9 lines

Convert IGEP board to use UBI volumes for U-Boot, its environment and kernel. With exception of first four sectors read by SoC boot ROM whole NAND is UBI managed. As code is too big now, drop CONFIG_SPL_EXT_SUPPORT to make it fit.

---
  include/configs/omap3_igep00x0.h | 80 ++++++++++++++++++++++------------------
  1 file changed, 45 insertions(+), 35 deletions(-)

bye,
Heiko

Quoted 137 lines
include/configs/omap3_igep00x0.h +45 -35
index 5da6cfd..9afbcbe 100644
@@ -74,6 +74,8 @@
  #define CONFIG_CMD_CACHE
  #ifdef CONFIG_BOOT_ONENAND
  #define CONFIG_CMD_ONENAND	/* ONENAND support		*/
+#else
+#define CONFIG_CMD_UBI
  #endif
  #define CONFIG_CMD_DHCP
  #define CONFIG_CMD_PING
@@ -86,6 +88,10 @@
  	"stdout=serial\0" \
  	"stderr=serial\0"
 
+#define ENV_MTD_SETTINGS \
+	"mtdids=nand0=gpmc-nand.0\0" \
+	"mtdparts=mtdparts=gpmc-nand.0:512k(SPL),-(UBI)\0"
+
  #define MEM_LAYOUT_SETTINGS \
  	DEFAULT_LINUX_BOOT_ENV \
  	"scriptaddr=0x87E00000\0" \
@@ -96,36 +102,15 @@
 
  #include <config_distro_bootcmd.h>
 
-
  #define CONFIG_EXTRA_ENV_SETTINGS \
  	ENV_DEVICE_SETTINGS \
+	ENV_MTD_SETTINGS \
  	MEM_LAYOUT_SETTINGS \
  	BOOTENV
 
  #endif
 
  /*
- * FLASH and environment organization
- */
-
-#ifdef CONFIG_BOOT_ONENAND
-#define CONFIG_SYS_ONENAND_BASE		ONENAND_MAP
-
-#define ONENAND_ENV_OFFSET		0x260000 /* environment starts here */
-
-#define CONFIG_ENV_IS_IN_ONENAND	1
-#define CONFIG_ENV_SIZE			(512 << 10) /* Total Size Environment */
-#define CONFIG_ENV_ADDR			ONENAND_ENV_OFFSET
-#endif
-
-#ifdef CONFIG_NAND
-#define CONFIG_ENV_OFFSET		0x260000 /* environment starts here */
-#define CONFIG_ENV_IS_IN_NAND	        1
-#define CONFIG_ENV_SIZE			(512 << 10) /* Total Size Environment */
-#define CONFIG_ENV_ADDR			NAND_ENV_OFFSET
-#endif
-
-/*
   * SMSC911x Ethernet
   */
  #if defined(CONFIG_CMD_NET)
@@ -134,19 +119,50 @@
  #define CONFIG_SMC911X_BASE		0x2C000000
  #endif /* (CONFIG_CMD_NET) */
 
+/*
+ * FLASH and environment organization
+ */
+#ifdef CONFIG_NAND
+#define CONFIG_SPL_UBI			1
+#define CONFIG_SPL_UBI_MAX_VOL_LEBS	256
+#define CONFIG_SPL_UBI_MAX_PEB_SIZE	(256*1024)
+#define CONFIG_SPL_UBI_MAX_PEBS		4096
+#define CONFIG_SPL_UBI_VOL_IDS		8
+#define CONFIG_SPL_UBI_LOAD_MONITOR_ID	0
+#define CONFIG_SPL_UBI_LOAD_KERNEL_ID	3
+#define CONFIG_SPL_UBI_LOAD_ARGS_ID	4
+#define CONFIG_SPL_UBI_PEB_OFFSET	4
+#define CONFIG_SPL_UBI_VID_OFFSET	512
+#define CONFIG_SPL_UBI_LEB_START	2048
+#define CONFIG_SPL_UBI_INFO_ADDR	0x88080000
+
+#define CONFIG_ENV_IS_IN_UBI		1
+#define CONFIG_ENV_UBI_PART		"UBI"
+#define CONFIG_ENV_UBI_VOLUME		"config"
+#define CONFIG_ENV_UBI_VOLUME_REDUND	"config_r"
+#define CONFIG_UBI_SILENCE_MSG		1
+#define CONFIG_UBIFS_SILENCE_MSG	1
+#else
+#define CONFIG_ENV_IS_NOWHERE
+#endif
+#define CONFIG_ENV_SIZE			(32*1024)
+
+#define CONFIG_RBTREE
+#define CONFIG_MTD_PARTITIONS
+#define MTDIDS_DEFAULT			"nand0=gpmc-nand.0"
+#define MTDPARTS_DEFAULT		"mtdparts=gpmc-nand.0:512k(SPL),-(UBI)"
+
  /* OneNAND boot config */
  #ifdef CONFIG_BOOT_ONENAND
  #define CONFIG_SPL_ONENAND_SUPPORT
-#define CONFIG_SYS_ONENAND_U_BOOT_OFFS  0x80000
  #define CONFIG_SYS_ONENAND_PAGE_SIZE	2048
-#define CONFIG_SPL_ONENAND_LOAD_ADDR    0x80000
-#define CONFIG_SPL_ONENAND_LOAD_SIZE    \
-	(512 * 1024 - CONFIG_SPL_ONENAND_LOAD_ADDR)
-
+#define CONFIG_SYS_ONENAND_BASE		ONENAND_MAP
+#define CONFIG_SYS_ONENAND_U_BOOT_OFFS	0x80000
  #endif
 
  /* NAND boot config */
  #ifdef CONFIG_NAND
+#define CONFIG_SPL_NAND_SUPPORT
  #define CONFIG_SYS_NAND_BUSWIDTH_16BIT
  #define CONFIG_SYS_NAND_5_ADDR_CYCLE
  #define CONFIG_SYS_NAND_PAGE_COUNT	64
@@ -166,14 +182,8 @@
  #define CONFIG_NAND_OMAP_ECCSCHEME	OMAP_ECC_BCH8_CODE_HW_DETECTION_SW
  #define CONFIG_NAND_OMAP_GPMC
  #define CONFIG_BCH
-
-#define CONFIG_SYS_NAND_U_BOOT_OFFS	0x80000
-/* NAND: SPL falcon mode configs */
-#ifdef CONFIG_SPL_OS_BOOT
-#define CONFIG_CMD_SPL_NAND_OFS		0x240000
-#define CONFIG_SYS_NAND_SPL_KERNEL_OFFS	0x280000
-#define CONFIG_CMD_SPL_WRITE_SIZE	0x2000
-#endif
  #endif
 
+#undef CONFIG_SPL_EXT_SUPPORT
+
  #endif /* __IGEP00X0_H */
Signature · 2 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#12 lore raw

PATCH v7 6/7 igep00x0: UBIize

Hi Ladis,

Many thanks for your work on this, see some comments below ...

2016-01-21 7:07 GMT+01:00 Heiko Schocher <[email protected]>:

Quoted 40 lines

Hello Ladislav,

Am 17.01.2016 um 04:16 schrieb Ladislav Michl:

Quoted 11 lines

Convert IGEP board to use UBI volumes for U-Boot, its environment and kernel. With exception of first four sectors read by SoC boot ROM whole NAND is UBI managed. As code is too big now, drop CONFIG_SPL_EXT_SUPPORT to make it fit.

---
  include/configs/omap3_igep00x0.h | 80
++++++++++++++++++++++------------------
  1 file changed, 45 insertions(+), 35 deletions(-)

bye,
Heiko

Quoted 19 lines
include/configs/omap3_igep00x0.h +2 -0
index 5da6cfd..9afbcbe 100644
@@ -74,6 +74,8 @@
  #define CONFIG_CMD_CACHE
  #ifdef CONFIG_BOOT_ONENAND
  #define CONFIG_CMD_ONENAND    /* ONENAND support              */
+#else
+#define CONFIG_CMD_UBI
  #endif
  #define CONFIG_CMD_DHCP
  #define CONFIG_CMD_PING
@@ -86,6 +88,10 @@
        "stdout=serial\0" \
        "stderr=serial\0"
 
Quoted 4 lines

include/configs/omap3_igep00x0.h line 94

Quoted 4 lines
include/configs/omap3_igep00x0.h +4 -0
+#define ENV_MTD_SETTINGS \
+       "mtdids=nand0=gpmc-nand.0\0" \
+       "mtdparts=mtdparts=gpmc-nand.0:512k(SPL),-(UBI)\0"
+

I think this should be protected by CONFIG_BOOT_NAND, if is defined CONFIG_BOOT_ONENAND the ENV_MTD_SETTINGS are wrong.

Also, as we're changing the memory map, I'd like to change the reserved space for SPL to 2M instead of 512k, so we cover all NAND block sizes from (64KB to 512KB)

Quoted 75 lines
Quoted 75 lines
include/configs/omap3_igep00x0.h +1 -8
  #define MEM_LAYOUT_SETTINGS \
        DEFAULT_LINUX_BOOT_ENV \
        "scriptaddr=0x87E00000\0" \
@@ -96,36 +102,15 @@
 
  #include <config_distro_bootcmd.h>
 
-
  #define CONFIG_EXTRA_ENV_SETTINGS \
        ENV_DEVICE_SETTINGS \
+       ENV_MTD_SETTINGS \
        MEM_LAYOUT_SETTINGS \
        BOOTENV
 
  #endif
 
  /*
- * FLASH and environment organization
- */
-
-#ifdef CONFIG_BOOT_ONENAND
-#define CONFIG_SYS_ONENAND_BASE                ONENAND_MAP
-
-#define ONENAND_ENV_OFFSET             0x260000 /* environment starts

here */

include/configs/omap3_igep00x0.h +0 -3
-
-#define CONFIG_ENV_IS_IN_ONENAND       1
-#define CONFIG_ENV_SIZE                        (512 << 10) /* Total Size

Environment */

include/configs/omap3_igep00x0.h +0 -5
-#define CONFIG_ENV_ADDR                        ONENAND_ENV_OFFSET
-#endif
-
-#ifdef CONFIG_NAND
-#define CONFIG_ENV_OFFSET              0x260000 /* environment starts

here */

include/configs/omap3_igep00x0.h +0 -2
-#define CONFIG_ENV_IS_IN_NAND          1
-#define CONFIG_ENV_SIZE                        (512 << 10) /* Total Size

Environment */

include/configs/omap3_igep00x0.h +26 -4
-#define CONFIG_ENV_ADDR                        NAND_ENV_OFFSET
-#endif
-
-/*
   * SMSC911x Ethernet
   */
  #if defined(CONFIG_CMD_NET)
@@ -134,19 +119,50 @@
  #define CONFIG_SMC911X_BASE           0x2C000000
  #endif /* (CONFIG_CMD_NET) */
 
+/*
+ * FLASH and environment organization
+ */
+#ifdef CONFIG_NAND
+#define CONFIG_SPL_UBI                 1
+#define CONFIG_SPL_UBI_MAX_VOL_LEBS    256
+#define CONFIG_SPL_UBI_MAX_PEB_SIZE    (256*1024)
+#define CONFIG_SPL_UBI_MAX_PEBS                4096
+#define CONFIG_SPL_UBI_VOL_IDS         8
+#define CONFIG_SPL_UBI_LOAD_MONITOR_ID 0
+#define CONFIG_SPL_UBI_LOAD_KERNEL_ID  3
+#define CONFIG_SPL_UBI_LOAD_ARGS_ID    4
+#define CONFIG_SPL_UBI_PEB_OFFSET      4
+#define CONFIG_SPL_UBI_VID_OFFSET      512
+#define CONFIG_SPL_UBI_LEB_START       2048
+#define CONFIG_SPL_UBI_INFO_ADDR       0x88080000
+
+#define CONFIG_ENV_IS_IN_UBI           1
+#define CONFIG_ENV_UBI_PART            "UBI"
+#define CONFIG_ENV_UBI_VOLUME          "config"
+#define CONFIG_ENV_UBI_VOLUME_REDUND   "config_r"
+#define CONFIG_UBI_SILENCE_MSG         1
+#define CONFIG_UBIFS_SILENCE_MSG       1
+#else
+#define CONFIG_ENV_IS_NOWHERE
+#endif
Quoted 8 lines
Quoted 8 lines
include/configs/omap3_igep00x0.h +6 -0
+#define CONFIG_ENV_SIZE                        (32*1024)
+
+#define CONFIG_RBTREE
+#define CONFIG_MTD_PARTITIONS
+#define MTDIDS_DEFAULT                 "nand0=gpmc-nand.0"
+#define MTDPARTS_DEFAULT

"mtdparts=gpmc-nand.0:512k(SPL),-(UBI)"
+

Same comment as above.

Quoted 33 lines
Quoted 33 lines
  /* OneNAND boot config */
  #ifdef CONFIG_BOOT_ONENAND
  #define CONFIG_SPL_ONENAND_SUPPORT
include/configs/omap3_igep00x0.h +3 -13
-#define CONFIG_SYS_ONENAND_U_BOOT_OFFS  0x80000
  #define CONFIG_SYS_ONENAND_PAGE_SIZE  2048
-#define CONFIG_SPL_ONENAND_LOAD_ADDR    0x80000
-#define CONFIG_SPL_ONENAND_LOAD_SIZE    \
-       (512 * 1024 - CONFIG_SPL_ONENAND_LOAD_ADDR)
-
+#define CONFIG_SYS_ONENAND_BASE                ONENAND_MAP
+#define CONFIG_SYS_ONENAND_U_BOOT_OFFS 0x80000
  #endif
 
  /* NAND boot config */
  #ifdef CONFIG_NAND
+#define CONFIG_SPL_NAND_SUPPORT
  #define CONFIG_SYS_NAND_BUSWIDTH_16BIT
  #define CONFIG_SYS_NAND_5_ADDR_CYCLE
  #define CONFIG_SYS_NAND_PAGE_COUNT    64
@@ -166,14 +182,8 @@
  #define CONFIG_NAND_OMAP_ECCSCHEME    OMAP_ECC_BCH8_CODE_HW_DETECTION_SW
  #define CONFIG_NAND_OMAP_GPMC
  #define CONFIG_BCH
-
-#define CONFIG_SYS_NAND_U_BOOT_OFFS    0x80000
-/* NAND: SPL falcon mode configs */
-#ifdef CONFIG_SPL_OS_BOOT
-#define CONFIG_CMD_SPL_NAND_OFS                0x240000
-#define CONFIG_SYS_NAND_SPL_KERNEL_OFFS        0x280000
-#define CONFIG_CMD_SPL_WRITE_SIZE      0x2000
-#endif
  #endif
 
Quoted 5 lines

include/configs/omap3_igep00x0.h line 189

Quoted 4 lines
include/configs/omap3_igep00x0.h +2 -0
+#undef CONFIG_SPL_EXT_SUPPORT
+
  #endif /* __IGEP00X0_H */

About the new layout you propose the following, right?

volume 0 is u-boot.img, 1 and 2 env, 3 kernel, 4 FDT, 5 rootfs (ubifs)

It's not possible load the kernel and the FDT from the rootfs directly, right?

BTW, I created the 5 volumes and copied the files to every volume but I get following errors, do you know what I am missing?

U-Boot SPL 2016.01-00358-g4efe05f (Jan 22 2016 - 17:16:04) Trying to boot from NAND
UBI warning: LEB 0 of 1 is missing
UBI warning: Failed to load volume 3
UBI warning: LEB 0 of 1 is missing
UBI warning: Failed to load volume 3
UBI warning: Failed
Loading Linux failed, falling back to U-Boot.
UBI warning: LEB 0 of 1 is missing
UBI warning: Failed to load volume 0
UBI warning: LEB 0 of 1 is missing
UBI warning: Failed to load volume 0
UBI warning: Failed
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

Thanks,
Enric

Quoted 8 lines

--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#13 lore raw

PATCH v7 6/7 igep00x0: UBIize

Hi Enric,

On Fri, Jan 22, 2016 at 11:35:49PM +0100, Enric Balletbo Serra wrote:
[...]

Quoted 1 line
Quoted 1 line

Am 17.01.2016 um 04:16 schrieb Ladislav Michl:

[...]

Quoted 7 lines
Quoted 4 lines

include/configs/omap3_igep00x0.h line 94

Quoted 4 lines
include/configs/omap3_igep00x0.h +4 -0
+#define ENV_MTD_SETTINGS \
+       "mtdids=nand0=gpmc-nand.0\0" \
+       "mtdparts=mtdparts=gpmc-nand.0:512k(SPL),-(UBI)\0"
+

I think this should be protected by CONFIG_BOOT_NAND, if is defined CONFIG_BOOT_ONENAND the ENV_MTD_SETTINGS are wrong.

Ah, right! I'll do that in next version. Btw, I hope to have OneNAND board version too, so I would be able to test that as well.

Quoted 3 lines

Also, as we're changing the memory map, I'd like to change the reserved space for SPL to 2M instead of 512k, so we cover all NAND block sizes from (64KB to 512KB)

What if we do that dynamically? It is not problem in U-Boot as we are already running FDT fixup, so adding one more shouldn't hurt too much. And we need to run 'spl export' anyway to fixup RAM size, so it is not problem for falcon mode, too.

[...]

Quoted 3 lines

About the new layout you propose the following, right?

volume 0 is u-boot.img, 1 and 2 env, 3 kernel, 4 FDT, 5 rootfs (ubifs)

Yes, that's right. U-Boot does not care about volumes above 4, it is purely Linux thing, but I'm using it that way (and somewhere in distant future I'd like to run database directly on top of UBI volume)

Quoted 1 line

It's not possible load the kernel and the FDT from the rootfs directly, right?

UBIFS will certainly not fit into SPL size.

Quoted 18 lines

BTW, I created the 5 volumes and copied the files to every volume but I get following errors, do you know what I am missing?

U-Boot SPL 2016.01-00358-g4efe05f (Jan 22 2016 - 17:16:04) Trying to boot from NAND
UBI warning: LEB 0 of 1 is missing
UBI warning: Failed to load volume 3
UBI warning: LEB 0 of 1 is missing
UBI warning: Failed to load volume 3
UBI warning: Failed
Loading Linux failed, falling back to U-Boot.
UBI warning: LEB 0 of 1 is missing
UBI warning: Failed to load volume 0
UBI warning: LEB 0 of 1 is missing
UBI warning: Failed to load volume 0
UBI warning: Failed
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

I've never seen that. How did you copy files into volumes? Btw, I haven't tried doing that using U-Boot, but did:

$ ubiformat /dev/mtd1 -f root.ubi
(where root.ubi is product of PTXdist build)
Later I used f.e. 
$ ubiupdatevol /dev/ubi0_0 u-boot.img
to load files into volumes.

ladis

#14 lore raw

PATCH v7 6/7 igep00x0: UBIize

In reply to Enric Balletbo Serra

Hello Enric, Ladislav,

Am 22.01.2016 um 23:35 schrieb Enric Balletbo Serra:

Quoted 3 lines

Hi Ladis,

Many thanks for your work on this, see some comments below ...

Sorry, pull request is sent with this patch, see:

http://lists.denx.de/pipermail/u-boot/2016-January/239855.html

@Ladislav: Please send changes in a follow up patch, thanks!

Quoted 41 lines

2016-01-21 7:07 GMT+01:00 Heiko Schocher <[email protected]>:

Quoted 40 lines

Hello Ladislav,

Am 17.01.2016 um 04:16 schrieb Ladislav Michl:

Quoted 11 lines

Convert IGEP board to use UBI volumes for U-Boot, its environment and kernel. With exception of first four sectors read by SoC boot ROM whole NAND is UBI managed. As code is too big now, drop CONFIG_SPL_EXT_SUPPORT to make it fit.

---
   include/configs/omap3_igep00x0.h | 80
++++++++++++++++++++++------------------
   1 file changed, 45 insertions(+), 35 deletions(-)

bye,
Heiko

Quoted 19 lines
include/configs/omap3_igep00x0.h +2 -0
index 5da6cfd..9afbcbe 100644
@@ -74,6 +74,8 @@
   #define CONFIG_CMD_CACHE
   #ifdef CONFIG_BOOT_ONENAND
   #define CONFIG_CMD_ONENAND    /* ONENAND support              */
+#else
+#define CONFIG_CMD_UBI
   #endif
   #define CONFIG_CMD_DHCP
   #define CONFIG_CMD_PING
@@ -86,6 +88,10 @@
         "stdout=serial\0" \
         "stderr=serial\0"
 
Quoted 7 lines
Quoted 4 lines

include/configs/omap3_igep00x0.h line 94

Quoted 4 lines
include/configs/omap3_igep00x0.h +4 -0
+#define ENV_MTD_SETTINGS \
+       "mtdids=nand0=gpmc-nand.0\0" \
+       "mtdparts=mtdparts=gpmc-nand.0:512k(SPL),-(UBI)\0"
+

I think this should be protected by CONFIG_BOOT_NAND, if is defined CONFIG_BOOT_ONENAND the ENV_MTD_SETTINGS are wrong.

Good point ...

Quoted 3 lines

Also, as we're changing the memory map, I'd like to change the reserved space for SPL to 2M instead of 512k, so we cover all NAND block sizes from (64KB to 512KB)

I do not understand this, but I have no details about the hw ...

Quoted 125 lines
Quoted 75 lines
Quoted 75 lines
include/configs/omap3_igep00x0.h +1 -8
   #define MEM_LAYOUT_SETTINGS \
         DEFAULT_LINUX_BOOT_ENV \
         "scriptaddr=0x87E00000\0" \
@@ -96,36 +102,15 @@
 
   #include <config_distro_bootcmd.h>
 
-
   #define CONFIG_EXTRA_ENV_SETTINGS \
         ENV_DEVICE_SETTINGS \
+       ENV_MTD_SETTINGS \
         MEM_LAYOUT_SETTINGS \
         BOOTENV
 
   #endif
 
   /*
- * FLASH and environment organization
- */
-
-#ifdef CONFIG_BOOT_ONENAND
-#define CONFIG_SYS_ONENAND_BASE                ONENAND_MAP
-
-#define ONENAND_ENV_OFFSET             0x260000 /* environment starts

here */

include/configs/omap3_igep00x0.h +0 -3
-
-#define CONFIG_ENV_IS_IN_ONENAND       1
-#define CONFIG_ENV_SIZE                        (512 << 10) /* Total Size

Environment */

include/configs/omap3_igep00x0.h +0 -5
-#define CONFIG_ENV_ADDR                        ONENAND_ENV_OFFSET
-#endif
-
-#ifdef CONFIG_NAND
-#define CONFIG_ENV_OFFSET              0x260000 /* environment starts

here */

include/configs/omap3_igep00x0.h +0 -2
-#define CONFIG_ENV_IS_IN_NAND          1
-#define CONFIG_ENV_SIZE                        (512 << 10) /* Total Size

Environment */

include/configs/omap3_igep00x0.h +26 -4
-#define CONFIG_ENV_ADDR                        NAND_ENV_OFFSET
-#endif
-
-/*
    * SMSC911x Ethernet
    */
   #if defined(CONFIG_CMD_NET)
@@ -134,19 +119,50 @@
   #define CONFIG_SMC911X_BASE           0x2C000000
   #endif /* (CONFIG_CMD_NET) */
 
+/*
+ * FLASH and environment organization
+ */
+#ifdef CONFIG_NAND
+#define CONFIG_SPL_UBI                 1
+#define CONFIG_SPL_UBI_MAX_VOL_LEBS    256
+#define CONFIG_SPL_UBI_MAX_PEB_SIZE    (256*1024)
+#define CONFIG_SPL_UBI_MAX_PEBS                4096
+#define CONFIG_SPL_UBI_VOL_IDS         8
+#define CONFIG_SPL_UBI_LOAD_MONITOR_ID 0
+#define CONFIG_SPL_UBI_LOAD_KERNEL_ID  3
+#define CONFIG_SPL_UBI_LOAD_ARGS_ID    4
+#define CONFIG_SPL_UBI_PEB_OFFSET      4
+#define CONFIG_SPL_UBI_VID_OFFSET      512
+#define CONFIG_SPL_UBI_LEB_START       2048
+#define CONFIG_SPL_UBI_INFO_ADDR       0x88080000
+
+#define CONFIG_ENV_IS_IN_UBI           1
+#define CONFIG_ENV_UBI_PART            "UBI"
+#define CONFIG_ENV_UBI_VOLUME          "config"
+#define CONFIG_ENV_UBI_VOLUME_REDUND   "config_r"
+#define CONFIG_UBI_SILENCE_MSG         1
+#define CONFIG_UBIFS_SILENCE_MSG       1
+#else
+#define CONFIG_ENV_IS_NOWHERE
+#endif
Quoted 8 lines
Quoted 8 lines
include/configs/omap3_igep00x0.h +6 -0
+#define CONFIG_ENV_SIZE                        (32*1024)
+
+#define CONFIG_RBTREE
+#define CONFIG_MTD_PARTITIONS
+#define MTDIDS_DEFAULT                 "nand0=gpmc-nand.0"
+#define MTDPARTS_DEFAULT

"mtdparts=gpmc-nand.0:512k(SPL),-(UBI)"
+

Same comment as above.

Quoted 33 lines
Quoted 33 lines
   /* OneNAND boot config */
   #ifdef CONFIG_BOOT_ONENAND
   #define CONFIG_SPL_ONENAND_SUPPORT
include/configs/omap3_igep00x0.h +3 -13
-#define CONFIG_SYS_ONENAND_U_BOOT_OFFS  0x80000
   #define CONFIG_SYS_ONENAND_PAGE_SIZE  2048
-#define CONFIG_SPL_ONENAND_LOAD_ADDR    0x80000
-#define CONFIG_SPL_ONENAND_LOAD_SIZE    \
-       (512 * 1024 - CONFIG_SPL_ONENAND_LOAD_ADDR)
-
+#define CONFIG_SYS_ONENAND_BASE                ONENAND_MAP
+#define CONFIG_SYS_ONENAND_U_BOOT_OFFS 0x80000
   #endif
 
   /* NAND boot config */
   #ifdef CONFIG_NAND
+#define CONFIG_SPL_NAND_SUPPORT
   #define CONFIG_SYS_NAND_BUSWIDTH_16BIT
   #define CONFIG_SYS_NAND_5_ADDR_CYCLE
   #define CONFIG_SYS_NAND_PAGE_COUNT    64
@@ -166,14 +182,8 @@
   #define CONFIG_NAND_OMAP_ECCSCHEME    OMAP_ECC_BCH8_CODE_HW_DETECTION_SW
   #define CONFIG_NAND_OMAP_GPMC
   #define CONFIG_BCH
-
-#define CONFIG_SYS_NAND_U_BOOT_OFFS    0x80000
-/* NAND: SPL falcon mode configs */
-#ifdef CONFIG_SPL_OS_BOOT
-#define CONFIG_CMD_SPL_NAND_OFS                0x240000
-#define CONFIG_SYS_NAND_SPL_KERNEL_OFFS        0x280000
-#define CONFIG_CMD_SPL_WRITE_SIZE      0x2000
-#endif
   #endif
 
Quoted 5 lines

include/configs/omap3_igep00x0.h line 189

Quoted 4 lines
include/configs/omap3_igep00x0.h +2 -0
+#undef CONFIG_SPL_EXT_SUPPORT
+
   #endif /* __IGEP00X0_H */
Quoted 5 lines

About the new layout you propose the following, right?

volume 0 is u-boot.img, 1 and 2 env, 3 kernel, 4 FDT, 5 rootfs (ubifs)

It's not possible load the kernel and the FDT from the rootfs directly, right?

That would be nice, but for this we need UBIFS support in SPL. Patches are welcome ;-)

Quoted 19 lines

BTW, I created the 5 volumes and copied the files to every volume but I get following errors, do you know what I am missing?

U-Boot SPL 2016.01-00358-g4efe05f (Jan 22 2016 - 17:16:04) Trying to boot from NAND
UBI warning: LEB 0 of 1 is missing
UBI warning: Failed to load volume 3
UBI warning: LEB 0 of 1 is missing
UBI warning: Failed to load volume 3
UBI warning: Failed
Loading Linux failed, falling back to U-Boot.
UBI warning: LEB 0 of 1 is missing
UBI warning: Failed to load volume 0
UBI warning: LEB 0 of 1 is missing
UBI warning: Failed to load volume 0
UBI warning: Failed
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

Quoted 2 lines

Thanks,
Enric

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#15 lore raw

PATCH v7 6/7 igep00x0: UBIize

Hi,

2016-01-25 7:39 GMT+01:00 Heiko Schocher <[email protected]>:

Quoted 71 lines

Hello Enric, Ladislav,

Am 22.01.2016 um 23:35 schrieb Enric Balletbo Serra:

Quoted 4 lines

Hi Ladis,

Many thanks for your work on this, see some comments below ...

Sorry, pull request is sent with this patch, see:

http://lists.denx.de/pipermail/u-boot/2016-January/239855.html

@Ladislav: Please send changes in a follow up patch, thanks!

Quoted 44 lines

2016-01-21 7:07 GMT+01:00 Heiko Schocher <[email protected]>:

Quoted 43 lines

Hello Ladislav,

Am 17.01.2016 um 04:16 schrieb Ladislav Michl:

Quoted 7 lines

Convert IGEP board to use UBI volumes for U-Boot, its environment and kernel. With exception of first four sectors read by SoC boot ROM whole NAND is UBI managed. As code is too big now, drop CONFIG_SPL_EXT_SUPPORT to make it fit.

Quoted 5 lines
---
   include/configs/omap3_igep00x0.h | 80
++++++++++++++++++++++------------------
   1 file changed, 45 insertions(+), 35 deletions(-)

bye,
Heiko

Quoted 19 lines
include/configs/omap3_igep00x0.h +2 -0
index 5da6cfd..9afbcbe 100644
@@ -74,6 +74,8 @@
   #define CONFIG_CMD_CACHE
   #ifdef CONFIG_BOOT_ONENAND
   #define CONFIG_CMD_ONENAND    /* ONENAND support              */
+#else
+#define CONFIG_CMD_UBI
   #endif
   #define CONFIG_CMD_DHCP
   #define CONFIG_CMD_PING
@@ -86,6 +88,10 @@
         "stdout=serial\0" \
         "stderr=serial\0"
 
Quoted 8 lines
Quoted 4 lines

include/configs/omap3_igep00x0.h line 94

Quoted 4 lines
include/configs/omap3_igep00x0.h +4 -0
+#define ENV_MTD_SETTINGS \
+       "mtdids=nand0=gpmc-nand.0\0" \
+       "mtdparts=mtdparts=gpmc-nand.0:512k(SPL),-(UBI)\0"
+

I think this should be protected by CONFIG_BOOT_NAND, if is defined CONFIG_BOOT_ONENAND the ENV_MTD_SETTINGS are wrong.

Quoted 9 lines

Good point ...

Quoted 3 lines

Also, as we're changing the memory map, I'd like to change the reserved space for SPL to 2M instead of 512k, so we cover all NAND block sizes from (64KB to 512KB)

I do not understand this, but I have no details about the hw ...

The ROM boot on OMAP reads the first 4 blocks searching for the SPL, in production is a practice flash the SPL 4 times. OneNAND/NAND devices can have different block sizes and the OMAP ROM boot supports block sizes from 64KB to 512K. For IGEP boards in particular, at least there are boards that have block size of 128K and 256K. What I would meant here is set as default the mtdparts variable to reserve 2M for SPL, just to cover all the cases.

mtdparts=mtdparts=gpmc-nand.0:2m(SPL),-(UBI)\0

Quoted 132 lines
Quoted 132 lines
Quoted 78 lines
Quoted 78 lines
include/configs/omap3_igep00x0.h +1 -8
   #define MEM_LAYOUT_SETTINGS \
         DEFAULT_LINUX_BOOT_ENV \
         "scriptaddr=0x87E00000\0" \
@@ -96,36 +102,15 @@
 
   #include <config_distro_bootcmd.h>
 
-
   #define CONFIG_EXTRA_ENV_SETTINGS \
         ENV_DEVICE_SETTINGS \
+       ENV_MTD_SETTINGS \
         MEM_LAYOUT_SETTINGS \
         BOOTENV
 
   #endif
 
   /*
- * FLASH and environment organization
- */
-
-#ifdef CONFIG_BOOT_ONENAND
-#define CONFIG_SYS_ONENAND_BASE                ONENAND_MAP
-
-#define ONENAND_ENV_OFFSET             0x260000 /* environment starts

here */

include/configs/omap3_igep00x0.h +0 -3
-
-#define CONFIG_ENV_IS_IN_ONENAND       1
-#define CONFIG_ENV_SIZE                        (512 << 10) /* Total

Size
Environment */

include/configs/omap3_igep00x0.h +0 -5
-#define CONFIG_ENV_ADDR                        ONENAND_ENV_OFFSET
-#endif
-
-#ifdef CONFIG_NAND
-#define CONFIG_ENV_OFFSET              0x260000 /* environment starts

here */

include/configs/omap3_igep00x0.h +0 -2
-#define CONFIG_ENV_IS_IN_NAND          1
-#define CONFIG_ENV_SIZE                        (512 << 10) /* Total

Size
Environment */

include/configs/omap3_igep00x0.h +26 -4
-#define CONFIG_ENV_ADDR                        NAND_ENV_OFFSET
-#endif
-
-/*
    * SMSC911x Ethernet
    */
   #if defined(CONFIG_CMD_NET)
@@ -134,19 +119,50 @@
   #define CONFIG_SMC911X_BASE           0x2C000000
   #endif /* (CONFIG_CMD_NET) */
 
+/*
+ * FLASH and environment organization
+ */
+#ifdef CONFIG_NAND
+#define CONFIG_SPL_UBI                 1
+#define CONFIG_SPL_UBI_MAX_VOL_LEBS    256
+#define CONFIG_SPL_UBI_MAX_PEB_SIZE    (256*1024)
+#define CONFIG_SPL_UBI_MAX_PEBS                4096
+#define CONFIG_SPL_UBI_VOL_IDS         8
+#define CONFIG_SPL_UBI_LOAD_MONITOR_ID 0
+#define CONFIG_SPL_UBI_LOAD_KERNEL_ID  3
+#define CONFIG_SPL_UBI_LOAD_ARGS_ID    4
+#define CONFIG_SPL_UBI_PEB_OFFSET      4
+#define CONFIG_SPL_UBI_VID_OFFSET      512
+#define CONFIG_SPL_UBI_LEB_START       2048
+#define CONFIG_SPL_UBI_INFO_ADDR       0x88080000
+
+#define CONFIG_ENV_IS_IN_UBI           1
+#define CONFIG_ENV_UBI_PART            "UBI"
+#define CONFIG_ENV_UBI_VOLUME          "config"
+#define CONFIG_ENV_UBI_VOLUME_REDUND   "config_r"
+#define CONFIG_UBI_SILENCE_MSG         1
+#define CONFIG_UBIFS_SILENCE_MSG       1
+#else
+#define CONFIG_ENV_IS_NOWHERE
+#endif
Quoted 8 lines
Quoted 8 lines
include/configs/omap3_igep00x0.h +6 -0
+#define CONFIG_ENV_SIZE                        (32*1024)
+
+#define CONFIG_RBTREE
+#define CONFIG_MTD_PARTITIONS
+#define MTDIDS_DEFAULT                 "nand0=gpmc-nand.0"
+#define MTDPARTS_DEFAULT

"mtdparts=gpmc-nand.0:512k(SPL),-(UBI)"
+

Same comment as above.

Quoted 34 lines
Quoted 34 lines
   /* OneNAND boot config */
   #ifdef CONFIG_BOOT_ONENAND
   #define CONFIG_SPL_ONENAND_SUPPORT
include/configs/omap3_igep00x0.h +3 -5
-#define CONFIG_SYS_ONENAND_U_BOOT_OFFS  0x80000
   #define CONFIG_SYS_ONENAND_PAGE_SIZE  2048
-#define CONFIG_SPL_ONENAND_LOAD_ADDR    0x80000
-#define CONFIG_SPL_ONENAND_LOAD_SIZE    \
-       (512 * 1024 - CONFIG_SPL_ONENAND_LOAD_ADDR)
-
+#define CONFIG_SYS_ONENAND_BASE                ONENAND_MAP
+#define CONFIG_SYS_ONENAND_U_BOOT_OFFS 0x80000
   #endif
 
   /* NAND boot config */
   #ifdef CONFIG_NAND
+#define CONFIG_SPL_NAND_SUPPORT
   #define CONFIG_SYS_NAND_BUSWIDTH_16BIT
   #define CONFIG_SYS_NAND_5_ADDR_CYCLE
   #define CONFIG_SYS_NAND_PAGE_COUNT    64
@@ -166,14 +182,8 @@
   #define CONFIG_NAND_OMAP_ECCSCHEME

OMAP_ECC_BCH8_CODE_HW_DETECTION_SW

   #define CONFIG_NAND_OMAP_GPMC
   #define CONFIG_BCH
include/configs/omap3_igep00x0.h +0 -8
-
-#define CONFIG_SYS_NAND_U_BOOT_OFFS    0x80000
-/* NAND: SPL falcon mode configs */
-#ifdef CONFIG_SPL_OS_BOOT
-#define CONFIG_CMD_SPL_NAND_OFS                0x240000
-#define CONFIG_SYS_NAND_SPL_KERNEL_OFFS        0x280000
-#define CONFIG_CMD_SPL_WRITE_SIZE      0x2000
-#endif
   #endif
Quoted 5 lines

include/configs/omap3_igep00x0.h line 189

Quoted 4 lines
include/configs/omap3_igep00x0.h +2 -0
+#undef CONFIG_SPL_EXT_SUPPORT
+
   #endif /* __IGEP00X0_H */

About the new layout you propose the following, right?

Quoted 9 lines
Quoted 4 lines

volume 0 is u-boot.img, 1 and 2 env, 3 kernel, 4 FDT, 5 rootfs (ubifs)

It's not possible load the kernel and the FDT from the rootfs directly, right?

That would be nice, but for this we need UBIFS support in SPL. Patches are welcome ;-)

Hehe, yes, I think the problem is fit the ubifs into the SPL size.

Quoted 29 lines
Quoted 19 lines

BTW, I created the 5 volumes and copied the files to every volume but I get following errors, do you know what I am missing?

U-Boot SPL 2016.01-00358-g4efe05f (Jan 22 2016 - 17:16:04) Trying to boot from NAND
UBI warning: LEB 0 of 1 is missing
UBI warning: Failed to load volume 3
UBI warning: LEB 0 of 1 is missing
UBI warning: Failed to load volume 3
UBI warning: Failed
Loading Linux failed, falling back to U-Boot.
UBI warning: LEB 0 of 1 is missing
UBI warning: Failed to load volume 0
UBI warning: LEB 0 of 1 is missing
UBI warning: Failed to load volume 0
UBI warning: Failed
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

Quoted 2 lines

Thanks,
Enric

bye,
Heiko

--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

#16 lore raw

PATCH v7 6/7 igep00x0: UBIize

Hello Enric,

Am 25.01.2016 um 08:26 schrieb Enric Balletbo Serra:

Quoted 84 lines

Hi,

2016-01-25 7:39 GMT+01:00 Heiko Schocher <[email protected]>:

Quoted 71 lines

Hello Enric, Ladislav,

Am 22.01.2016 um 23:35 schrieb Enric Balletbo Serra:

Quoted 4 lines

Hi Ladis,

Many thanks for your work on this, see some comments below ...

Sorry, pull request is sent with this patch, see:

http://lists.denx.de/pipermail/u-boot/2016-January/239855.html

@Ladislav: Please send changes in a follow up patch, thanks!

Quoted 44 lines

2016-01-21 7:07 GMT+01:00 Heiko Schocher <[email protected]>:

Quoted 43 lines

Hello Ladislav,

Am 17.01.2016 um 04:16 schrieb Ladislav Michl:

Quoted 7 lines

Convert IGEP board to use UBI volumes for U-Boot, its environment and kernel. With exception of first four sectors read by SoC boot ROM whole NAND is UBI managed. As code is too big now, drop CONFIG_SPL_EXT_SUPPORT to make it fit.

Quoted 5 lines
---
    include/configs/omap3_igep00x0.h | 80
++++++++++++++++++++++------------------
    1 file changed, 45 insertions(+), 35 deletions(-)

bye,
Heiko

Quoted 19 lines
include/configs/omap3_igep00x0.h +2 -0
index 5da6cfd..9afbcbe 100644
@@ -74,6 +74,8 @@
    #define CONFIG_CMD_CACHE
    #ifdef CONFIG_BOOT_ONENAND
    #define CONFIG_CMD_ONENAND    /* ONENAND support              */
+#else
+#define CONFIG_CMD_UBI
    #endif
    #define CONFIG_CMD_DHCP
    #define CONFIG_CMD_PING
@@ -86,6 +88,10 @@
          "stdout=serial\0" \
          "stderr=serial\0"
 
Quoted 8 lines
Quoted 4 lines

include/configs/omap3_igep00x0.h line 94

Quoted 4 lines
include/configs/omap3_igep00x0.h +4 -0
+#define ENV_MTD_SETTINGS \
+       "mtdids=nand0=gpmc-nand.0\0" \
+       "mtdparts=mtdparts=gpmc-nand.0:512k(SPL),-(UBI)\0"
+

I think this should be protected by CONFIG_BOOT_NAND, if is defined CONFIG_BOOT_ONENAND the ENV_MTD_SETTINGS are wrong.

Quoted 9 lines

Good point ...

Quoted 3 lines

Also, as we're changing the memory map, I'd like to change the reserved space for SPL to 2M instead of 512k, so we cover all NAND block sizes from (64KB to 512KB)

I do not understand this, but I have no details about the hw ...

Quoted 7 lines

The ROM boot on OMAP reads the first 4 blocks searching for the SPL, in production is a practice flash the SPL 4 times. OneNAND/NAND devices can have different block sizes and the OMAP ROM boot supports block sizes from 64KB to 512K. For IGEP boards in particular, at least there are boards that have block size of 128K and 256K. What I would meant here is set as default the mtdparts variable to reserve 2M for SPL, just to cover all the cases.

Thanks for the explanation.

Quoted 141 lines

mtdparts=mtdparts=gpmc-nand.0:2m(SPL),-(UBI)\0

Quoted 138 lines
Quoted 136 lines
Quoted 78 lines
Quoted 78 lines
include/configs/omap3_igep00x0.h +1 -8
    #define MEM_LAYOUT_SETTINGS \
          DEFAULT_LINUX_BOOT_ENV \
          "scriptaddr=0x87E00000\0" \
@@ -96,36 +102,15 @@
 
    #include <config_distro_bootcmd.h>
 
-
    #define CONFIG_EXTRA_ENV_SETTINGS \
          ENV_DEVICE_SETTINGS \
+       ENV_MTD_SETTINGS \
          MEM_LAYOUT_SETTINGS \
          BOOTENV
 
    #endif
 
    /*
- * FLASH and environment organization
- */
-
-#ifdef CONFIG_BOOT_ONENAND
-#define CONFIG_SYS_ONENAND_BASE                ONENAND_MAP
-
-#define ONENAND_ENV_OFFSET             0x260000 /* environment starts

here */

include/configs/omap3_igep00x0.h +0 -3
-
-#define CONFIG_ENV_IS_IN_ONENAND       1
-#define CONFIG_ENV_SIZE                        (512 << 10) /* Total

Size
Environment */

include/configs/omap3_igep00x0.h +0 -5
-#define CONFIG_ENV_ADDR                        ONENAND_ENV_OFFSET
-#endif
-
-#ifdef CONFIG_NAND
-#define CONFIG_ENV_OFFSET              0x260000 /* environment starts

here */

include/configs/omap3_igep00x0.h +0 -2
-#define CONFIG_ENV_IS_IN_NAND          1
-#define CONFIG_ENV_SIZE                        (512 << 10) /* Total

Size
Environment */

include/configs/omap3_igep00x0.h +26 -4
-#define CONFIG_ENV_ADDR                        NAND_ENV_OFFSET
-#endif
-
-/*
     * SMSC911x Ethernet
     */
    #if defined(CONFIG_CMD_NET)
@@ -134,19 +119,50 @@
    #define CONFIG_SMC911X_BASE           0x2C000000
    #endif /* (CONFIG_CMD_NET) */
 
+/*
+ * FLASH and environment organization
+ */
+#ifdef CONFIG_NAND
+#define CONFIG_SPL_UBI                 1
+#define CONFIG_SPL_UBI_MAX_VOL_LEBS    256
+#define CONFIG_SPL_UBI_MAX_PEB_SIZE    (256*1024)
+#define CONFIG_SPL_UBI_MAX_PEBS                4096
+#define CONFIG_SPL_UBI_VOL_IDS         8
+#define CONFIG_SPL_UBI_LOAD_MONITOR_ID 0
+#define CONFIG_SPL_UBI_LOAD_KERNEL_ID  3
+#define CONFIG_SPL_UBI_LOAD_ARGS_ID    4
+#define CONFIG_SPL_UBI_PEB_OFFSET      4
+#define CONFIG_SPL_UBI_VID_OFFSET      512
+#define CONFIG_SPL_UBI_LEB_START       2048
+#define CONFIG_SPL_UBI_INFO_ADDR       0x88080000
+
+#define CONFIG_ENV_IS_IN_UBI           1
+#define CONFIG_ENV_UBI_PART            "UBI"
+#define CONFIG_ENV_UBI_VOLUME          "config"
+#define CONFIG_ENV_UBI_VOLUME_REDUND   "config_r"
+#define CONFIG_UBI_SILENCE_MSG         1
+#define CONFIG_UBIFS_SILENCE_MSG       1
+#else
+#define CONFIG_ENV_IS_NOWHERE
+#endif
Quoted 8 lines
Quoted 8 lines
include/configs/omap3_igep00x0.h +6 -0
+#define CONFIG_ENV_SIZE                        (32*1024)
+
+#define CONFIG_RBTREE
+#define CONFIG_MTD_PARTITIONS
+#define MTDIDS_DEFAULT                 "nand0=gpmc-nand.0"
+#define MTDPARTS_DEFAULT

"mtdparts=gpmc-nand.0:512k(SPL),-(UBI)"
+

Same comment as above.

Quoted 34 lines
Quoted 34 lines
    /* OneNAND boot config */
    #ifdef CONFIG_BOOT_ONENAND
    #define CONFIG_SPL_ONENAND_SUPPORT
include/configs/omap3_igep00x0.h +3 -5
-#define CONFIG_SYS_ONENAND_U_BOOT_OFFS  0x80000
    #define CONFIG_SYS_ONENAND_PAGE_SIZE  2048
-#define CONFIG_SPL_ONENAND_LOAD_ADDR    0x80000
-#define CONFIG_SPL_ONENAND_LOAD_SIZE    \
-       (512 * 1024 - CONFIG_SPL_ONENAND_LOAD_ADDR)
-
+#define CONFIG_SYS_ONENAND_BASE                ONENAND_MAP
+#define CONFIG_SYS_ONENAND_U_BOOT_OFFS 0x80000
    #endif
 
    /* NAND boot config */
    #ifdef CONFIG_NAND
+#define CONFIG_SPL_NAND_SUPPORT
    #define CONFIG_SYS_NAND_BUSWIDTH_16BIT
    #define CONFIG_SYS_NAND_5_ADDR_CYCLE
    #define CONFIG_SYS_NAND_PAGE_COUNT    64
@@ -166,14 +182,8 @@
    #define CONFIG_NAND_OMAP_ECCSCHEME

OMAP_ECC_BCH8_CODE_HW_DETECTION_SW

    #define CONFIG_NAND_OMAP_GPMC
    #define CONFIG_BCH
include/configs/omap3_igep00x0.h +0 -8
-
-#define CONFIG_SYS_NAND_U_BOOT_OFFS    0x80000
-/* NAND: SPL falcon mode configs */
-#ifdef CONFIG_SPL_OS_BOOT
-#define CONFIG_CMD_SPL_NAND_OFS                0x240000
-#define CONFIG_SYS_NAND_SPL_KERNEL_OFFS        0x280000
-#define CONFIG_CMD_SPL_WRITE_SIZE      0x2000
-#endif
    #endif
Quoted 5 lines

include/configs/omap3_igep00x0.h line 189

Quoted 4 lines
include/configs/omap3_igep00x0.h +2 -0
+#undef CONFIG_SPL_EXT_SUPPORT
+
    #endif /* __IGEP00X0_H */

About the new layout you propose the following, right?

volume 0 is u-boot.img, 1 and 2 env, 3 kernel, 4 FDT, 5 rootfs (ubifs)

It's not possible load the kernel and the FDT from the rootfs directly, right?

Quoted 5 lines
Quoted 3 lines

That would be nice, but for this we need UBIFS support in SPL. Patches are welcome ;-)

Hehe, yes, I think the problem is fit the ubifs into the SPL size.

Yes, maybe ...

bye,
Heiko

Quoted 31 lines
Quoted 30 lines
Quoted 20 lines

BTW, I created the 5 volumes and copied the files to every volume but I get following errors, do you know what I am missing?

U-Boot SPL 2016.01-00358-g4efe05f (Jan 22 2016 - 17:16:04) Trying to boot from NAND
UBI warning: LEB 0 of 1 is missing
UBI warning: Failed to load volume 3
UBI warning: LEB 0 of 1 is missing
UBI warning: Failed to load volume 3
UBI warning: Failed
Loading Linux failed, falling back to U-Boot.
UBI warning: LEB 0 of 1 is missing
UBI warning: Failed to load volume 0
UBI warning: LEB 0 of 1 is missing
UBI warning: Failed to load volume 0
UBI warning: Failed
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

Quoted 2 lines

Thanks,
Enric

bye,
Heiko

--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

Signature · 2 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#17 lore raw

PATCH v7 6/7 igep00x0: UBIize

In reply to Enric Balletbo Serra

Hi Enric,

Quoted 9 lines · Enric Balletbo Serra

The ROM boot on OMAP reads the first 4 blocks searching for the SPL, in production is a practice flash the SPL 4 times. OneNAND/NAND devices can have different block sizes and the OMAP ROM boot supports block sizes from 64KB to 512K. For IGEP boards in particular, at least there are boards that have block size of 128K and 256K. What I would meant here is set as default the mtdparts variable to reserve 2M for SPL, just to cover all the cases.

mtdparts=mtdparts=gpmc-nand.0:2m(SPL),-(UBI)\0

So far there was no ack or nack to yesterday's proposal making that dynamic; Both boot ROM and ubispl code thinks in terms of eraseblocks, only mtd needs fixed offset. So I'd like to see this offset calculated as 4*block_size, not some "worst case" value...

ladis

#18 lore raw

PATCH v7 6/7 igep00x0: UBIize

Hi Ladis,

2016-01-25 16:56 GMT+01:00 Ladislav Michl <[email protected]>:

Quoted 11 lines

Hi Enric,

Quoted 8 lines · Enric Balletbo Serra

The ROM boot on OMAP reads the first 4 blocks searching for the SPL, in production is a practice flash the SPL 4 times. OneNAND/NAND devices can have different block sizes and the OMAP ROM boot supports block sizes from 64KB to 512K. For IGEP boards in particular, at least there are boards that have block size of 128K and 256K. What I would meant here is set as default the mtdparts variable to reserve 2M for SPL, just to cover all the cases.

Quoted 8 lines
Quoted 1 line

mtdparts=mtdparts=gpmc-nand.0:2m(SPL),-(UBI)\0

So far there was no ack or nack to yesterday's proposal making that dynamic; Both boot ROM and ubispl code thinks in terms of eraseblocks, only mtd needs fixed offset. So I'd like to see this offset calculated as 4*block_size, not some "worst case" value...

ladis

Your proposal looks good to me.

#19 lore raw

PATCH v7 6/7 igep00x0: UBIize

Hello Enric,

Am 25.01.2016 um 17:56 schrieb Enric Balletbo Serra:

Quoted 16 lines

Hi Ladis,

2016-01-25 16:56 GMT+01:00 Ladislav Michl <[email protected]>:

Quoted 13 lines

Hi Enric,

Quoted 9 lines · Enric Balletbo Serra

The ROM boot on OMAP reads the first 4 blocks searching for the SPL, in production is a practice flash the SPL 4 times. OneNAND/NAND devices can have different block sizes and the OMAP ROM boot supports block sizes from 64KB to 512K. For IGEP boards in particular, at least there are boards that have block size of 128K and 256K. What I would meant here is set as default the mtdparts variable to reserve 2M for SPL, just to cover all the cases.

mtdparts=mtdparts=gpmc-nand.0:2m(SPL),-(UBI)\0

Quoted 9 lines
Quoted 6 lines

So far there was no ack or nack to yesterday's proposal making that dynamic; Both boot ROM and ubispl code thinks in terms of eraseblocks, only mtd needs fixed offset. So I'd like to see this offset calculated as 4*block_size, not some "worst case" value...

ladis

Your proposal looks good to me.

Are there any updates for this patch? The UBI SPL support is pending for a while ...

I pushed my last (rebased to mainline) state to:

http://git.denx.de/?p=u-boot/u-boot-ubi.git;a=shortlog;h=refs/heads/ubi-spl

without the 2 igep00x0 board patches:

- [U-Boot,PATCHv7,6/7] igep00x0: UBIize
https://patchwork.ozlabs.org/patch/569214/

- [U-Boot,PATCHv4,7/7] igep00x0: Falcon mode
https://patchwork.ozlabs.org/patch/569215/

Could you please update your patches for the board support, so we can push the UBI SPL support to mainline?

Thanks!

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#20 lore raw

PATCH v7 6/7 igep00x0: UBIize

2016-04-13 7:19 GMT+02:00 Heiko Schocher <[email protected]>:

Quoted 44 lines

Hello Enric,

Am 25.01.2016 um 17:56 schrieb Enric Balletbo Serra:

Quoted 25 lines

Hi Ladis,

2016-01-25 16:56 GMT+01:00 Ladislav Michl <[email protected]>:

Quoted 21 lines

Hi Enric,

Quoted 10 lines · Enric Balletbo Serra

The ROM boot on OMAP reads the first 4 blocks searching for the SPL, in production is a practice flash the SPL 4 times. OneNAND/NAND devices can have different block sizes and the OMAP ROM boot supports block sizes from 64KB to 512K. For IGEP boards in particular, at least there are boards that have block size of 128K and 256K. What I would meant here is set as default the mtdparts variable to reserve 2M for SPL, just to cover all the cases.

mtdparts=mtdparts=gpmc-nand.0:2m(SPL),-(UBI)\0

So far there was no ack or nack to yesterday's proposal making that dynamic; Both boot ROM and ubispl code thinks in terms of eraseblocks, only mtd needs fixed offset. So I'd like to see this offset calculated as 4*block_size, not some "worst case" value...

Quoted 5 lines
Quoted 1 line

ladis

Your proposal looks good to me.

Are there any updates for this patch? The UBI SPL support is pending for a while ...

I pushed my last (rebased to mainline) state to:

http://git.denx.de/?p=u-boot/u-boot-ubi.git;a=shortlog;h=refs/heads/ubi-spl

without the 2 igep00x0 board patches:

Quoted 9 lines

- [U-Boot,PATCHv7,6/7] igep00x0: UBIize
https://patchwork.ozlabs.org/patch/569214/

- [U-Boot,PATCHv4,7/7] igep00x0: Falcon mode
https://patchwork.ozlabs.org/patch/569215/

Could you please update your patches for the board support, so we can push the UBI SPL support to mainline?

Ladis, did you have a chance to look and solve the latest comments I did?

These patch series looks really interesting, like Heiko I would like to see these merged.

Quoted 8 lines

Thanks!

bye,
Heiko
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

#21 lore raw

PATCH v7 6/7 igep00x0: UBIize

Hi Ladislav,

2016-04-13 13:39 GMT+02:00 Enric Balletbo Serra <[email protected]>:

Quoted 48 lines

2016-04-13 7:19 GMT+02:00 Heiko Schocher <[email protected]>:

Quoted 47 lines

Hello Enric,

Am 25.01.2016 um 17:56 schrieb Enric Balletbo Serra:

Quoted 25 lines

Hi Ladis,

2016-01-25 16:56 GMT+01:00 Ladislav Michl <[email protected]>:

Quoted 21 lines

Hi Enric,

Quoted 10 lines · Enric Balletbo Serra

The ROM boot on OMAP reads the first 4 blocks searching for the SPL, in production is a practice flash the SPL 4 times. OneNAND/NAND devices can have different block sizes and the OMAP ROM boot supports block sizes from 64KB to 512K. For IGEP boards in particular, at least there are boards that have block size of 128K and 256K. What I would meant here is set as default the mtdparts variable to reserve 2M for SPL, just to cover all the cases.

mtdparts=mtdparts=gpmc-nand.0:2m(SPL),-(UBI)\0

So far there was no ack or nack to yesterday's proposal making that dynamic; Both boot ROM and ubispl code thinks in terms of eraseblocks, only mtd needs fixed offset. So I'd like to see this offset calculated as 4*block_size, not some "worst case" value...

Quoted 5 lines
Quoted 1 line

ladis

Your proposal looks good to me.

Are there any updates for this patch? The UBI SPL support is pending for a while ...

I pushed my last (rebased to mainline) state to:

http://git.denx.de/?p=u-boot/u-boot-ubi.git;a=shortlog;h=refs/heads/ubi-spl

without the 2 igep00x0 board patches:

- [U-Boot,PATCHv7,6/7] igep00x0: UBIize
https://patchwork.ozlabs.org/patch/569214/

Quoted 9 lines
Quoted 6 lines

- [U-Boot,PATCHv4,7/7] igep00x0: Falcon mode
https://patchwork.ozlabs.org/patch/569215/

Could you please update your patches for the board support, so we can push the UBI SPL support to mainline?

Ladis, did you have a chance to look and solve the latest comments I did?

If you don't have enough time maybe I can pickup the patches and finish the work, if it's ok. I'll have some time this weekend.

Quoted 11 lines

These patch series looks really interesting, like Heiko I would like to see these merged.

Quoted 8 lines

Thanks!

bye,
Heiko
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

#22 lore raw

RFC 1/1 runtime mtdparts_default; was: igep00x0: UBIize

In reply to Ladislav Michl

Hi Enric and all,

Quoted 11 lines · Ladislav Michl

Hi Enric,

Quoted 8 lines · Enric Balletbo Serra

The ROM boot on OMAP reads the first 4 blocks searching for the SPL, in production is a practice flash the SPL 4 times. OneNAND/NAND devices can have different block sizes and the OMAP ROM boot supports block sizes from 64KB to 512K. For IGEP boards in particular, at least there are boards that have block size of 128K and 256K. What I would meant here is set as default the mtdparts variable to reserve 2M for SPL, just to cover all the cases.

Quoted 6 lines
Quoted 1 line

mtdparts=mtdparts=gpmc-nand.0:2m(SPL),-(UBI)\0

So far there was no ack or nack to yesterday's proposal making that dynamic; Both boot ROM and ubispl code thinks in terms of eraseblocks, only mtd needs fixed offset. So I'd like to see this offset calculated as 4*block_size, not some "worst case" value...

So to make mtdparts_default runtime configurable, we need to fill it before relocating env, but after mtd devices get probed, see curent hack in code.

Do we want some generic way of producing board specific mtdpart defaults? Patch bellow gives some clue how it could work, but implementation is not nice. Would something like that in principle acceptable (either weak function or config option)?

Btw, current mtdparts init code is broken for non-relocated env as it assigns parts name pointer to tmp_parts, so later check for that pointer being null (env variable not found) does not really check for that variable. I'll send separate patch for that.

Best regards,
ladis

PS: patch is based on the top of ubi spl series...

board/isee/igep00x0/igep00x0.c +18 -0
index 759daef..b5b5cc4 100644
@@ -18,6 +18,7 @@
 #include <asm/arch/mux.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/mach-types.h>
+#include <linux/mtd/mtd.h>
 #include "igep00x0.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -167,6 +168,23 @@ void set_fdt(void)
 	}
 }
 
+char igep00x0_mtdids[24];
+char igep00x0_mtdparts[48];
+
+void mtdids_generate(void)
+{
+	struct mtd_info *mtd = get_mtd_device(NULL, 0);
+	if (mtd) {
+		const char *linux_name = "omap2-nand";
+		snprintf(igep00x0_mtdids, sizeof(igep00x0_mtdids),
+		         "%s=%s",
+		         mtd->name, linux_name);
+		snprintf(igep00x0_mtdparts, sizeof(igep00x0_mtdparts),
+		         "mtdparts=%s:%dk(SPL),-(UBI)",
+		         linux_name, 4 * mtd->erasesize >> 10);
+	}
+}
+
 /*
  * Routine: misc_init_r
  * Description: Configure board specific parts
cmd/mtdparts.c +24 -15
index 44b2c3a..d05b8cf 100644
@@ -110,15 +110,15 @@ DECLARE_GLOBAL_DATA_PTR;
 
 /* default values for mtdids and mtdparts variables */
 #if defined(MTDIDS_DEFAULT)
-static const char *const mtdids_default = MTDIDS_DEFAULT;
+static char *mtdids_default = MTDIDS_DEFAULT;
 #else
-static const char *const mtdids_default = NULL;
+static char *mtdids_default = NULL;
 #endif
 
 #if defined(MTDPARTS_DEFAULT)
-static const char *const mtdparts_default = MTDPARTS_DEFAULT;
+static char *mtdparts_default = MTDPARTS_DEFAULT;
 #else
-static const char *const mtdparts_default = NULL;
+static char *mtdparts_default = NULL;
 #endif
 
 /* copies of last seen 'mtdids', 'mtdparts' and 'partition' env variables */
@@ -1524,7 +1524,7 @@ static int spread_partitions(void)
  */
 static int parse_mtdparts(const char *const mtdparts)
 {
-	const char *p = mtdparts;
+	const char *p = NULL;
 	struct mtd_device *dev;
 	int err = 1;
 	char tmp_parts[MTDPARTS_MAXLEN];
@@ -1541,10 +1541,13 @@ static int parse_mtdparts(const char *const mtdparts)
 	if (gd->flags & GD_FLG_ENV_READY) {
 		p = getenv("mtdparts");
 	} else {
-		p = tmp_parts;
-		getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN);
+		if (getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN) != -1)
+			p = tmp_parts;
 	}
 
+	if (!p)
+		p = mtdparts;
+
 	if (strncmp(p, "mtdparts=", 9) != 0) {
 		printf("mtdparts variable doesn't start with 'mtdparts='\n");
 		return err;
@@ -1720,11 +1723,13 @@ int mtdparts_init(void)
 	 * before the env is relocated, then we need to use our own stack
 	 * buffer.  gd->env_buf will be too small.
 	 */
-	if (gd->flags & GD_FLG_ENV_READY) {
+	if (gd->flags & GD_FLG_ENV_READY)
 		parts = getenv("mtdparts");
-	} else {
-		parts = tmp_parts;
-		getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN);
+	else {
+		if (getenv_f("mtdparts", tmp_parts, MTDPARTS_MAXLEN) == -1)
+			parts = NULL;
+		else
+			parts = tmp_parts;
 	}
 	current_partition = getenv("partition");
 
@@ -1758,10 +1763,14 @@ int mtdparts_init(void)
 		return 1;
 	}
 
-	/* do no try to use defaults when mtdparts variable is not defined,
-	 * just check the length */
-	if (!parts)
-		printf("mtdparts variable not set, see 'help mtdparts'\n");
+	/* use defaults when mtdparts variable is not defined, but do not save
+	 * it to environment */
+	if (!parts) {
+		if (mtdparts_default)
+			parts = mtdparts_default;
+		else
+			printf("mtdparts variable not set, see 'help mtdparts'\n");
+	}
 
 	if (parts && (strlen(parts) > MTDPARTS_MAXLEN - 1)) {
 		printf("mtdparts too long (> %d)\n", MTDPARTS_MAXLEN);
common/board_r.c +4 -0
index d959ad3..b9b2d7f 100644
@@ -491,8 +491,12 @@ static int should_load_env(void)
 #endif
 }
 
+extern void mtdids_generate(void);
+
 static int initr_env(void)
 {
+	mtdids_generate();
+
 	/* initialize environment */
 	if (should_load_env())
 		env_relocate();
include/configs/omap3_igep00x0.h +6 -7
index c9157a8..213525d 100644
@@ -90,10 +90,6 @@
 	"stdout=serial\0" \
 	"stderr=serial\0"
 
-#define ENV_MTD_SETTINGS \
-	"mtdids=nand0=gpmc-nand.0\0" \
-	"mtdparts=mtdparts=gpmc-nand.0:512k(SPL),-(UBI)\0"
-
 #define MEM_LAYOUT_SETTINGS \
 	DEFAULT_LINUX_BOOT_ENV \
 	"scriptaddr=0x87E00000\0" \
@@ -106,7 +102,6 @@
 
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	ENV_DEVICE_SETTINGS \
-	ENV_MTD_SETTINGS \
 	MEM_LAYOUT_SETTINGS \
 	BOOTENV
 
@@ -151,8 +146,12 @@
 
 #define CONFIG_RBTREE
 #define CONFIG_MTD_PARTITIONS
-#define MTDIDS_DEFAULT			"nand0=gpmc-nand.0"
-#define MTDPARTS_DEFAULT		"mtdparts=gpmc-nand.0:512k(SPL),-(UBI)"
+#ifndef __ASSEMBLY__
+extern char igep00x0_mtdids[];
+extern char igep00x0_mtdparts[];
+#endif
+#define MTDIDS_DEFAULT			igep00x0_mtdids
+#define MTDPARTS_DEFAULT		igep00x0_mtdparts
 
 /* OneNAND boot config */
 #ifdef CONFIG_BOOT_ONENAND
#23 lore raw

PATCH v7 6/7 igep00x0: UBIize

In reply to Heiko Schocher
Quoted 10 lines · Heiko Schocher

Hello Enric, Ladislav,

Am 22.01.2016 um 23:35 schrieb Enric Balletbo Serra:

Quoted 3 lines

Hi Ladis,

Many thanks for your work on this, see some comments below ...

Sorry, pull request is sent with this patch, see:

http://lists.denx.de/pipermail/u-boot/2016-January/239855.html

Note that the PR there just lists one patch...

Quoted 1 line

@Ladislav: Please send changes in a follow up patch, thanks!

No, sorry. I had intentionally not yet grabbed the PR there yet since I didn't want this series in until Enric had ack'd them as it's a behavior change and he is listed as the maintainer. You grabbed them a bit too early, sorry!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160125/621656be/attachment.sig>
#24 lore raw

PATCH v7 6/7 igep00x0: UBIize

Hello Tom,

Am 25.01.2016 um 16:13 schrieb Tom Rini:

Quoted 6 lines · Heiko Schocher
Quoted 5 lines

Hello Enric, Ladislav,

Am 22.01.2016 um 23:35 schrieb Enric Balletbo Serra:

Quoted 2 lines

Hi Ladis,

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Many thanks for your work on this, see some comments below ...

Sorry, pull request is sent with this patch, see:

http://lists.denx.de/pipermail/u-boot/2016-January/239855.html

Note that the PR there just lists one patch...

wrong link, sorry.

Quoted 6 lines
Quoted 1 line

@Ladislav: Please send changes in a follow up patch, thanks!

No, sorry. I had intentionally not yet grabbed the PR there yet since I didn't want this series in until Enric had ack'd them as it's a behavior change and he is listed as the maintainer. You grabbed them a bit too early, sorry!

Ups, sorry (may I was to happy for having UBI support in SPL)

Ok, so I wait for a new version for this patch.

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#25 lore raw

PATCH v4 7/7 igep00x0: Falcon mode

In reply to Ladislav Michl

Implement spl_start_uboot to let Falcon mode work.

---
 board/isee/igep00x0/igep00x0.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
board/isee/igep00x0/igep00x0.c +12 -0
index e2fce50..92811d8 100644
@@ -10,6 +10,7 @@
 #include <ns16550.h>
 #include <twl4030.h>
 #include <netdev.h>
+#include <spl.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
 #include <asm/arch/mem.h>
@@ -212,3 +213,14 @@ int board_eth_init(bd_t *bis)
 #endif
 }
 #endif
+
+#ifdef CONFIG_SPL_OS_BOOT
+int spl_start_uboot(void)
+{
+	/* break into full u-boot on 'c' */
+	if (serial_tstc() && serial_getc() == 'c')
+		return 1;
+
+	return 0;
+}
+#endif
Signature · 1 line
2.1.4
#26 lore raw

PATCH v4 7/7 igep00x0: Falcon mode

Hello Ladislav,

Am 17.01.2016 um 04:16 schrieb Ladislav Michl:

Quoted 6 lines

Implement spl_start_uboot to let Falcon mode work.

---
  board/isee/igep00x0/igep00x0.c | 12 ++++++++++++
  1 file changed, 12 insertions(+)

bye,
Heiko

Quoted 29 lines
board/isee/igep00x0/igep00x0.c +12 -0
index e2fce50..92811d8 100644
@@ -10,6 +10,7 @@
  #include <ns16550.h>
  #include <twl4030.h>
  #include <netdev.h>
+#include <spl.h>
  #include <asm/gpio.h>
  #include <asm/io.h>
  #include <asm/arch/mem.h>
@@ -212,3 +213,14 @@ int board_eth_init(bd_t *bis)
  #endif
  }
  #endif
+
+#ifdef CONFIG_SPL_OS_BOOT
+int spl_start_uboot(void)
+{
+	/* break into full u-boot on 'c' */
+	if (serial_tstc() && serial_getc() == 'c')
+		return 1;
+
+	return 0;
+}
+#endif
Signature · 2 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#27 lore raw

PATCH v4 7/7 igep00x0: Falcon mode

2016-01-21 7:08 GMT+01:00 Heiko Schocher <[email protected]>:

Quoted 52 lines

Hello Ladislav,

Am 17.01.2016 um 04:16 schrieb Ladislav Michl:

Quoted 7 lines

Implement spl_start_uboot to let Falcon mode work.

---
  board/isee/igep00x0/igep00x0.c | 12 ++++++++++++
  1 file changed, 12 insertions(+)

bye,
Heiko

Quoted 20 lines
board/isee/igep00x0/igep00x0.c +2 -0
index e2fce50..92811d8 100644
@@ -10,6 +10,7 @@
  #include <ns16550.h>
  #include <twl4030.h>
  #include <netdev.h>
+#include <spl.h>
  #include <asm/gpio.h>
  #include <asm/io.h>
  #include <asm/arch/mem.h>
@@ -212,3 +213,14 @@ int board_eth_init(bd_t *bis)
  #endif
  }
  #endif
+

board/isee/igep00x0/igep00x0.c int board_eth_init(bd_t *bis) · line 226

Quoted 10 lines
board/isee/igep00x0/igep00x0.c +10 -0
+#ifdef CONFIG_SPL_OS_BOOT
+int spl_start_uboot(void)
+{
+       /* break into full u-boot on 'c' */
+       if (serial_tstc() && serial_getc() == 'c')
+               return 1;
+
+       return 0;
+}
+#endif

--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

Quoted 4 lines

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot