[U-Boot] [PATCHv3 4/4] igep00x0: UBIize

Heiko Schocher hs at denx.de
Mon Jan 11 07:20:06 CET 2016


Hello Ladislav,

Am 11.01.2016 um 00:18 schrieb Ladislav Michl:
> This patch converts IGEP board to use UBI volumes for environment,
> u-boot, kernel... With exception of first four sectors read by SoC
> boot ROM whole NAND is UBI managed. Code is too big, so I dropped
> CONFIG_SPL_EXT_SUPPORT to make it fit. It is meant more likely as a test
> of Thomas' patch, so more people can play with that.
>
> Signed-off-by: Ladislav Michl <ladis at linux-mips.org>
> ---
>   board/isee/igep00x0/igep00x0.c    | 76 +++++++++++++++++++++++++++++++++++++++
>   common/spl/Makefile               |  5 ++-
>   common/spl/spl.c                  | 13 +++++++
>   common/spl/spl_ubi.c              | 36 +++++++++++++++++++
>   include/configs/omap3_igep00x0.h  | 64 +++++++++++++++------------------
>   include/configs/ti_armv7_common.h |  1 -
>   include/spl.h                     |  4 +++
>   7 files changed, 162 insertions(+), 37 deletions(-)
>   create mode 100644 common/spl/spl_ubi.c

Could you seperate common changes in "common/*" and your special
board changes?

Beside of that, this patch does not apply ...

pollux:u-boot-smartweb hs [master] $ git am mbox
Wende an: igep00x0: UBIize
error: Anwendung des Patches fehlgeschlagen: board/isee/igep00x0/igep00x0.c:212
error: board/isee/igep00x0/igep00x0.c: Patch konnte nicht angewendet werden
/work/hs/tbot/u-boot-smartweb/.git/rebase-apply/patch:194: new blank line at EOF.
+
error: Anwendung des Patches fehlgeschlagen: include/configs/omap3_igep00x0.h:77
error: include/configs/omap3_igep00x0.h: Patch konnte nicht angewendet werden
Anwendung des Patches fehlgeschlagen bei 0001 igep00x0: UBIize
Die Kopie des fehlgeschlagenen Patches befindet sich in:
    /work/hs/tbot/u-boot-smartweb/.git/rebase-apply/patch
Wenn Sie das Problem gelöst haben, führen Sie "git am --continue" aus.
Falls Sie diesen Patch auslassen möchten, führen Sie stattdessen
"git am --skip" aus.
Um den ursprünglichen Branch wiederherzustellen und die Anwendung der
Patches abzubrechen, führen Sie "git am --abort" aus.
pollux:u-boot-smartweb hs [master] $ git am --abort

"git am -3 mbox" fails also ...

I used as base:
commit e6c516a973dff2718488d065d859bcfe64fb05aa
Merge: d77a092 b5e7c1e
Author: Tom Rini <trini at konsulko.com>
Date:   Sun Jan 10 09:17:52 2016 -0500

     Merge branch 'master' of git://www.denx.de/git/u-boot-imx

With the "patch" command it works:

pollux:u-boot-smartweb hs [master] $ patch -p1 < mbox
patching file board/isee/igep00x0/igep00x0.c
Hunk #2 succeeded at 210 with fuzz 1 (offset -5 lines).
patching file common/spl/Makefile
patching file common/spl/spl.c
patching file common/spl/spl_ubi.c
patching file include/configs/omap3_igep00x0.h
Hunk #1 succeeded at 80 with fuzz 2 (offset 3 lines).
Hunk #2 succeeded at 94 (offset 7 lines).
Hunk #3 succeeded at 108 (offset 7 lines).
Hunk #4 succeeded at 125 with fuzz 1 (offset 7 lines).
Hunk #5 succeeded at 175 (offset 7 lines).
patching file include/configs/ti_armv7_common.h
patching file include/spl.h
pollux:u-boot-smartweb hs [master] $

Do you have local changes in "include/configs/omap3_igep00x0.h" ?

> diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
> index e2fce50..51e4eea 100644
> --- a/board/isee/igep00x0/igep00x0.c
> +++ b/board/isee/igep00x0/igep00x0.c
> @@ -10,6 +10,9 @@
>   #include <ns16550.h>
>   #include <twl4030.h>
>   #include <netdev.h>
> +#include <nand.h>
> +#include <ubispl.h>
> +#include <spl.h>
>   #include <asm/gpio.h>
>   #include <asm/io.h>
>   #include <asm/arch/mem.h>
> @@ -212,3 +215,76 @@ int board_eth_init(bd_t *bis)
>   #endif
>   }
>   #endif
> +
> +#undef CONFIG_SPL_OS_BOOT
> +
> +#ifdef CONFIG_SPL_BUILD
> +#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;
> +}
> +
> +static void spl_set_header_linux(void)
> +{
> +	spl_image.size = 3 * 1024 * 1024;
> +	spl_image.entry_point = 0x82000000;
> +	spl_image.load_addr = 0x82000000;
> +	spl_image.os = IH_OS_LINUX;
> +	spl_image.name = "Linux";
> +}
> +#endif
> +
> +int spl_board_ubi_load_image(u32 boot_device)
> +{
> +	int ret;
> +	struct image_header *header;
> +	struct ubispl_info info;
> +	struct ubispl_load volumes[2];
> +
> +	info.ubi = (struct ubi_scan_info *)
> +		(CONFIG_SYS_SPL_MALLOC_START + CONFIG_SYS_SPL_MALLOC_SIZE);
> +	info.fastmap = 1;
> +	info.read = nand_spl_read_block;
> +
> +	info.peb_offset = 4;
> +	info.peb_size = CONFIG_SYS_NAND_BLOCK_SIZE;
> +	info.vid_offset = 512;
> +	info.leb_start = 2048;
> +	info.peb_count = 4096 - info.peb_offset;
> +
> +#ifdef CONFIG_SPL_OS_BOOT
> +	if (!spl_start_uboot()) {
> +		volumes[0].name = "kernel";
> +		volumes[0].vol_id = 3;
> +		volumes[0].load_addr = (void *)0x82000000;
> +		volumes[1].name = "dtb";
> +		volumes[1].vol_id = 4;
> +		volumes[1].load_addr = (void *)0x88000000;

Maybe you would use defines here instead hardcoded numbers?

> +
> +		ret = ubispl_load_volumes(&info, volumes, 2);
> +		if (!ret) {
> +			puts("Linux loaded.\n");
> +			spl_set_header_linux();
> +			return 0;
> +		}
> +		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].name = "loader";
> +	volumes[0].vol_id = 0;
> +	volumes[0].load_addr = (void *)header;
> +
> +	ret = ubispl_load_volumes(&info, volumes, 1);
> +	if (!ret)
> +		spl_parse_image_header(header);
> +
> +	return ret;
> +}
> +#endif
> diff --git a/common/spl/Makefile b/common/spl/Makefile
> index 10a4589..e4535c4 100644
> --- a/common/spl/Makefile
> +++ b/common/spl/Makefile
> @@ -10,10 +10,13 @@
>
>   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_NOR_SUPPORT) += spl_nor.o
>   obj-$(CONFIG_SPL_NAND_SUPPORT) += spl_nand.o
>   obj-$(CONFIG_SPL_ONENAND_SUPPORT) += spl_onenand.o
> +endif
> +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
> diff --git a/common/spl/spl.c b/common/spl/spl.c
> index 6e6dee7..048a325 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -286,6 +286,18 @@ static int spl_load_image(u32 boot_device)
>   	case BOOT_DEVICE_MMC2_2:
>   		return spl_mmc_load_image(boot_device);
>   #endif
> +#ifdef CONFIG_SPL_UBI
> +#ifdef CONFIG_SPL_NAND_SUPPORT
> +	case BOOT_DEVICE_NAND:
> +#endif
> +#ifdef CONFIG_SPL_ONENAND_SUPPORT
> +	case BOOT_DEVICE_ONENAND:
> +#endif
> +#ifdef CONFIG_SPL_NOR_SUPPORT
> +	case BOOT_DEVICE_NOR:
> +#endif
> +		return spl_ubi_load_image(boot_device);

I am unsure here if we should disable raw nor read complete
when enabling UBISPL, but this is maybe a theoretical case, so
this is OK for me. If someone needs it we can change this here
later.

> +#else
>   #ifdef CONFIG_SPL_NAND_SUPPORT
>   	case BOOT_DEVICE_NAND:
>   		return spl_nand_load_image();
> @@ -298,6 +310,7 @@ static int spl_load_image(u32 boot_device)
>   	case BOOT_DEVICE_NOR:
>   		return spl_nor_load_image();
>   #endif
> +#endif /* CONFIG_SPL_UBI */
>   #ifdef CONFIG_SPL_YMODEM_SUPPORT
>   	case BOOT_DEVICE_UART:
>   		return spl_ymodem_load_image();
> diff --git a/common/spl/spl_ubi.c b/common/spl/spl_ubi.c
> new file mode 100644
> index 0000000..a292841
> --- /dev/null
> +++ b/common/spl/spl_ubi.c
> @@ -0,0 +1,36 @@
> +/*
> + * Copyright (C) 2016
> + * Ladislav Michl <ladis at linux-mips.org>
> + *
> + * SPDX-License-Identifier:	GPL-2.0+
> + */
> +#include <common.h>
> +#include <config.h>
> +#include <spl.h>
> +#include <asm/io.h>
> +#include <nand.h>
> +
> +__weak int spl_board_ubi_load_image(u32 boot_device)
> +{
> +	return -EINVAL;
> +}
> +
> +int spl_ubi_load_image(u32 boot_device)
> +{
> +	int ret;
> +
> +#ifdef CONFIG_SPL_NAND_SUPPORT
> +	if (boot_device == BOOT_DEVICE_NAND)
> +		nand_init();
> +#endif
> +
> +	ret = spl_board_ubi_load_image(boot_device);
> +
> +#ifdef CONFIG_SPL_NAND_SUPPORT
> +	if (boot_device == BOOT_DEVICE_NAND)
> +		nand_deselect();
> +#endif
> +
> +	return ret;
> +}
> +
> diff --git a/include/configs/omap3_igep00x0.h b/include/configs/omap3_igep00x0.h
> index 5da6cfd..451e511 100644
> --- a/include/configs/omap3_igep00x0.h
> +++ b/include/configs/omap3_igep00x0.h
> @@ -77,6 +77,7 @@
>   #endif
>   #define CONFIG_CMD_DHCP
>   #define CONFIG_CMD_PING
> +#define CONFIG_CMD_UBI
>
>   #ifndef CONFIG_SPL_BUILD
>
> @@ -86,6 +87,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 +101,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 +118,37 @@
>   #define CONFIG_SMC911X_BASE		0x2C000000
>   #endif /* (CONFIG_CMD_NET) */
>
> +/*
> + * FLASH and environment organization
> + */
> +#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_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
> +#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)
> -
>   #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 +168,6 @@
>   #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
>
>   #endif /* __IGEP00X0_H */
> diff --git a/include/configs/ti_armv7_common.h b/include/configs/ti_armv7_common.h
> index 2087eb1..45bdd75 100644
> --- a/include/configs/ti_armv7_common.h
> +++ b/include/configs/ti_armv7_common.h
> @@ -232,7 +232,6 @@
>   #define CONFIG_SPL_LIBDISK_SUPPORT
>   #define CONFIG_SPL_MMC_SUPPORT
>   #define CONFIG_SPL_FAT_SUPPORT
> -#define CONFIG_SPL_EXT_SUPPORT
>   #endif
>
>   #define CONFIG_SYS_THUMB_BUILD
> diff --git a/include/spl.h b/include/spl.h
> index 92cdc04..1ab9295 100644
> --- a/include/spl.h
> +++ b/include/spl.h
> @@ -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);
>
>

Looks good to me, please seperate the common changes into a seperate
patch, and I think we can add the patchserie to mainline, if merge
window opens.

Thanks for your work!

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


More information about the U-Boot mailing list