[PATCH 0/2] moveconfig fixes
Two fixes to moveconfig: the first addresses a potential security issue reported by Heinrich Schuchardt caused by using the Python built-in eval to expand CONFIG_ value expressions. Running moveconfig on a maliciously prepared CONFIG could lead to execution of arbitrary Python code. The second is a Python3 bugfix. Markus Klotzbuecher (2): moveconfig: replace unsafe eval with asteval moveconfig: convert ps.stderr to string tools/moveconfig.py | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.25.0
[PATCH 2/2] moveconfig: convert ps.stderr to string
Printing the error message in verbose mode fails, since python3 doesn't implicitely convert bytes to strings. Signed-off-by: Markus Klotzbuecher Cc: Simon Glass Cc: Tom Rini Cc: Masahiro Yamada --- tools/moveconfig.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/moveconfig.py b/tools/moveconfig.py index df20ec66af..d8bf7fd071 100755 --- a/tools/moveconfig.py +++ b/tools/moveconfig.py @@ -1217,7 +1217,7 @@ class Slot: "Failed to process.\n") if self.options.verbose: self.log += color_text(self.options.color, COLOR_LIGHT_CYAN, - self.ps.stderr.read()) + self.ps.stderr.read().decode()) self.finish(False) def do_defconfig(self): -- 2.25.0
[PATCH 1/2] moveconfig: replace unsafe eval with asteval
Commit b237d358b "moveconfig: expand simple expressions" added support for expanding expressions in configs, but used the unsafe python built-in "eval". This patch fixes this by replacing eval with the asteval module. Signed-off-by: Markus Klotzbuecher Cc: Heinrich Schuchardt Cc: Heiko Schocher Cc: Tom Rini Cc: Simon Glass Cc: Joe Hershberger Cc: Masahiro Yamada --- tools/moveconfig.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/moveconfig.py b/tools/moveconfig.py index 36160a3977..df20ec66af 100755 --- a/tools/moveconfig.py +++ b/tools/moveconfig.py @@ -295,6 +295,7 @@ To see the complete list of supported options, run """ +import asteval import collections import copy import difflib @@ -808,10 +809,11 @@ def try_expand(line): return line try: +aeval = asteval.Interpreter( usersyms=SIZES, minimal=True ) cfg, val = re.split("=", line) val= val.strip('\"') if re.search("[*+-/]|<<|SZ_+|\(([^\)]+)\)", val): -newval = hex(eval(val, SIZES)) +newval = hex(aeval(val)) print("\tExpanded expression %s to %s" % (val, newval)) return cfg+'='+newval except: -- 2.25.0
Re: [U-Boot] [PATCH v2 1/9] moveconfig: expand simple expressions
Hi Heinrich On Sat, Jan 25, 2020 at 10:46:04PM +0100, Heinrich Schuchardt wrote: >On 5/15/19 3:15 PM, Markus Klotzbuecher wrote: >> From: Markus Klotzbuecher >> >> Add support for expanding simple expressions and sizes such as >> "(4 * 1024)", "(512 << 10)" or "(SZ_256K)". >> >> This can help to significantly reduce the number of "suspicious" >> moves, such as >> >> 'CONFIG_ENV_SIZE="(64 << 10)"' was removed by savedefconfig. >> >> If the expansion fails, it falls back to the original string. >> >> Signed-off-by: Markus Klotzbuecher >> Cc: Masahiro Yamada >> Cc: Heiko Schocher >> --- >> Changes for v2: new patch >> >> tools/moveconfig.py | 41 + >> 1 file changed, 41 insertions(+) >> >> diff --git a/tools/moveconfig.py b/tools/moveconfig.py >> index 1a214c5605..0bbc7c1991 100755 >> --- a/tools/moveconfig.py >> +++ b/tools/moveconfig.py >> @@ -354,6 +354,26 @@ CONFIG_DATABASE = 'moveconfig.db' >> >> CONFIG_LEN = len('CONFIG_') >> >> +SIZES = { >> +"SZ_1":0x0001, "SZ_2":0x0002, >> +"SZ_4":0x0004, "SZ_8":0x0008, >> +"SZ_16": 0x0010, "SZ_32": 0x0020, >> +"SZ_64": 0x0040, "SZ_128": 0x0080, >> +"SZ_256": 0x0100, "SZ_512": 0x0200, >> +"SZ_1K": 0x0400, "SZ_2K": 0x0800, >> +"SZ_4K": 0x1000, "SZ_8K": 0x2000, >> +"SZ_16K": 0x4000, "SZ_32K": 0x8000, >> +"SZ_64K": 0x0001, "SZ_128K": 0x0002, >> +"SZ_256K": 0x0004, "SZ_512K": 0x0008, >> +"SZ_1M": 0x0010, "SZ_2M": 0x0020, >> +"SZ_4M": 0x0040, "SZ_8M": 0x0080, >> +"SZ_16M": 0x0100, "SZ_32M": 0x0200, >> +"SZ_64M": 0x0400, "SZ_128M": 0x0800, >> +"SZ_256M": 0x1000, "SZ_512M": 0x2000, >> +"SZ_1G": 0x4000, "SZ_2G": 0x8000, >> +"SZ_4G": 0x1 >> +} >> + >> ### helper functions ### >> def get_devnull(): >> """Get the file object of '/dev/null' device.""" >> @@ -777,6 +797,25 @@ def cleanup_readme(configs, options): >> with open('README', 'w') as f: >> f.write(''.join(newlines)) >> >> +def try_expand(line): >> +"""If value looks like an expression, try expanding it >> +Otherwise just return the existing value >> +""" >> +if line.find('=') == -1: >> +return line >> + >> +try: >> +cfg, val = re.split("=", line) >> +val= val.strip('\"') >> +if re.search("[*+-/]|<<|SZ_+|\(([^\)]+)\)", val): >> +newval = hex(eval(val, SIZES)) > >The if clause evaluates to true for values like: > >val = "os.execl('/sbin/fdisk')" > >As eval() can be used to execute arbitrary commands this patch should be >corrected. Fair point. I took a quick look at python sandboxing, and apparently it's difficult to be done in a secure way (see pysandbox). As introducing a CONFIG with something like the above clearly has malicious intent, just preventing "accidential" execution will not be sufficient. Perhaps we can use ast.literal_eval instead. I'll take a closer look. Best regards Markus -- Markus Klotzbuecher Freelancer Embedded, Distributed & Real-time Systems Am See 28, 78465 Konstanz, Germany www.mkio.de
Re: [U-Boot] [PATCH v2 0/9] miscellaneous ubispl and ubi improvements
Hello Heiko On Wed, May 15, 2019 at 03:15:51PM +0200, Markus Klotzbuecher wrote: >From: Markus Klotzbuecher > >This series contains a couple of UBI and UBI SPL improvements, notably >a ubispl extension to allow loading volumes by name. The motivation is >to use the UBI atomic volume rename functionality to allow double copy >software updates of U-Boot on UBI. To do that we configured the SPL to >always load the same volume name (e.g. "u-boot"), and the software >updater always installs into the secondary volume "u-boot_r". After a >successful upgrade, these two volume names are switched. > >This extension is protected by #ifdefs as it will somewhat slow down >loading of volumes by id. This is because the code needs to disable >the optimization of ignoring all volume ids which are not >to-be-loaded, since these can only be resolved after attaching. > >We have tested both with and without fastmap enabled and both paths >seems to work reliably. > >As per Heikos request, this v2 adds two patches that migrate the >omap2plus and at91 CONFIG_ENV_* to defconfigs and likewise for the two >boards using ubispl. The first migration was supported by an extension >to the moveconfig script (patch 1) to expand simple expressions. Both >migrations were tested to be binary equal before and after the change. > >Changes v2: >- Add a patch (1) for moveconfig to expand simple expressions >- Add patch (3) to move at91 and omap2plus CONFIG_ENV_ to defconfigs >- Add patch (7) to migrate boards using ubispl to KConfig >- Add missing commit messages >- Indicate version of kernel code which was used in ubispl I don't mean to bug, just wanted to ask if there's anything missing for this v2 series... Thanks, Markus -- Markus Klotzbuecher Freelancer Embedded, Distributed & Real-time Am See 28, 78465 Konstanz, Germany ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH 1/6] env: ubi: KConfig: add CONFIG_ENV_UBI_VOLUME_REDUND
From: Markus Klotzbuecher Signed-off-by: Markus Klotzbuecher Cc: Heiko Schocher Cc: Kyungmin Park --- env/Kconfig | 6 ++ scripts/config_whitelist.txt | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/env/Kconfig b/env/Kconfig index 78300660c7..44c47220c2 100644 --- a/env/Kconfig +++ b/env/Kconfig @@ -513,6 +513,12 @@ config ENV_UBI_VOLUME help Name of the volume that you want to store the environment in. +config ENV_UBI_VOLUME_REDUND + string "UBI redundant volume name" + depends on ENV_IS_IN_UBI + help + Name of the redundant volume that you want to store the environment in. + endif config USE_DEFAULT_ENV_FILE diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index fa98efc24c..5d76c781d3 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -504,7 +504,6 @@ CONFIG_ENV_SROM_BANK CONFIG_ENV_TOTAL_SIZE CONFIG_ENV_UBIFS_OPTION CONFIG_ENV_UBI_MTD -CONFIG_ENV_UBI_VOLUME_REDUND CONFIG_ENV_VERSION CONFIG_EP9302 CONFIG_EP9307 -- 2.20.1 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH 0/6] miscellaneous ubispl and ubi improvements
From: Markus Klotzbuecher Hello Heiko and Kyungmin This series contains a couple of UBI and UBI SPL improvements, notably a ubispl extension to allow loading volumes by name. The motivation is to use the UBI atomic volume rename functionality to allow double copy software updates of U-Boot on UBI. To do that we configured the SPL to always load the same volume name (e.g. "u-boot"), and the software updater always installs into the secondary volume "u-boot_r". After a successful upgrade, these two volume names are switched. This extension is protected by #ifdefs as it will somewhat slow down loading of volumes by id. This is because the code needs to disable the optimization of ignoring all volume ids which are not to-be-loaded, since these can only be resolved after attaching. We have tested both with and without fastmap enabled and both paths seems to work reliably. I also moved the ubispl config to Kconfig. There seem to be two boards that use this (Maintainers cc'ed on patch). I have not updated their defconfigs (not being sure if I should) but would be pleased to do so. Hamish Guthrie (2): env: ubi: support configurable VID offset ubispl: add support for loading volumes by name Markus Klotzbuecher (4): env: ubi: KConfig: add CONFIG_ENV_UBI_VOLUME_REDUND ubi: fix UBI_SILENCE_MSG ubispl: migrate configuration to Kconfig ubispl: introduce separate CONFIG_UBI_SPL_SILENCE_MSG common/spl/Kconfig | 98 common/spl/spl_ubi.c | 7 ++ drivers/mtd/ubi/Kconfig | 2 +- drivers/mtd/ubi/io.c | 2 + drivers/mtd/ubispl/ubispl.c | 215 ++- drivers/mtd/ubispl/ubispl.h | 9 +- env/Kconfig | 12 ++ env/ubi.c| 17 ++- include/ubispl.h | 6 + scripts/config_whitelist.txt | 13 --- 10 files changed, 360 insertions(+), 21 deletions(-) -- 2.20.1 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH 2/6] env: ubi: support configurable VID offset
From: Hamish Guthrie Signed-off-by: Hamish Guthrie Signed-off-by: Markus Klotzbuecher Cc: Heiko Schocher Cc: Kyungmin Park --- env/Kconfig | 6 ++ env/ubi.c | 17 + 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/env/Kconfig b/env/Kconfig index 44c47220c2..595b658c26 100644 --- a/env/Kconfig +++ b/env/Kconfig @@ -519,6 +519,12 @@ config ENV_UBI_VOLUME_REDUND help Name of the redundant volume that you want to store the environment in. +config ENV_UBI_VID_OFFSET + int "ubi environment VID offset" + depends on ENV_IS_IN_UBI + help + UBI VID offset for environment. + endif config USE_DEFAULT_ENV_FILE diff --git a/env/ubi.c b/env/ubi.c index 1dfdf0a8c8..67379f2557 100644 --- a/env/ubi.c +++ b/env/ubi.c @@ -15,6 +15,15 @@ #include #undef crc32 +#define _QUOTE(x) #x +#define QUOTE(x) _QUOTE(x) + +#ifdef CONFIG_ENV_UBI_VID_OFFSET + #define UBI_VID_OFFSET QUOTE(CONFIG_ENV_UBI_VID_OFFSET) +#else + #define UBI_VID_OFFSET NULL +#endif + DECLARE_GLOBAL_DATA_PTR; #ifdef CONFIG_CMD_SAVEENV @@ -28,7 +37,7 @@ static int env_ubi_save(void) if (ret) return ret; - if (ubi_part(CONFIG_ENV_UBI_PART, NULL)) { + if (ubi_part(CONFIG_ENV_UBI_PART, UBI_VID_OFFSET)) { printf("\n** Cannot find mtd partition \"%s\"\n", CONFIG_ENV_UBI_PART); return 1; @@ -70,7 +79,7 @@ static int env_ubi_save(void) if (ret) return ret; - if (ubi_part(CONFIG_ENV_UBI_PART, NULL)) { + if (ubi_part(CONFIG_ENV_UBI_PART, UBI_VID_OFFSET)) { printf("\n** Cannot find mtd partition \"%s\"\n", CONFIG_ENV_UBI_PART); return 1; @@ -111,7 +120,7 @@ static int env_ubi_load(void) tmp_env1 = (env_t *)env1_buf; tmp_env2 = (env_t *)env2_buf; - if (ubi_part(CONFIG_ENV_UBI_PART, NULL)) { + if (ubi_part(CONFIG_ENV_UBI_PART, UBI_VID_OFFSET)) { printf("\n** Cannot find mtd partition \"%s\"\n", CONFIG_ENV_UBI_PART); set_default_env(NULL, 0); @@ -148,7 +157,7 @@ static int env_ubi_load(void) */ memset(buf, 0x0, CONFIG_ENV_SIZE); - if (ubi_part(CONFIG_ENV_UBI_PART, NULL)) { + if (ubi_part(CONFIG_ENV_UBI_PART, UBI_VID_OFFSET)) { printf("\n** Cannot find mtd partition \"%s\"\n", CONFIG_ENV_UBI_PART); set_default_env(NULL, 0); -- 2.20.1 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH 3/6] ubi: fix UBI_SILENCE_MSG
From: Markus Klotzbuecher - drop CONFIG_ prefix from kconfig entry - fix small compilation issue with CONFIG_UBI_SILENCE_MSG Signed-off-by: Markus Klotzbuecher Cc: Heiko Schocher Cc: Kyungmin Park --- drivers/mtd/ubi/Kconfig | 2 +- drivers/mtd/ubi/io.c| 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/ubi/Kconfig b/drivers/mtd/ubi/Kconfig index cf84783356..e22dda8564 100644 --- a/drivers/mtd/ubi/Kconfig +++ b/drivers/mtd/ubi/Kconfig @@ -1,6 +1,6 @@ menu "UBI support" -config CONFIG_UBI_SILENCE_MSG +config UBI_SILENCE_MSG bool "UBI silence verbose messages" default ENV_IS_IN_UBI help diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c index 8ef7823b37..688fb509d2 100644 --- a/drivers/mtd/ubi/io.c +++ b/drivers/mtd/ubi/io.c @@ -1351,6 +1351,7 @@ static int self_check_write(struct ubi_device *ubi, const void *buf, int pnum, ubi_err(ubi, "self-check failed for PEB %d:%d, len %d", pnum, offset, len); +#if !defined(CONFIG_UBI_SILENCE_MSG) ubi_msg(ubi, "data differ at position %d", i); ubi_msg(ubi, "hex dump of the original buffer from %d to %d", i, i + dump_len); @@ -1360,6 +1361,7 @@ static int self_check_write(struct ubi_device *ubi, const void *buf, int pnum, i, i + dump_len); print_hex_dump("", DUMP_PREFIX_OFFSET, 32, 1, buf1 + i, dump_len, 1); +#endif dump_stack(); err = -EINVAL; goto out_free; -- 2.20.1 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH 4/6] ubispl: migrate configuration to Kconfig
From: Markus Klotzbuecher Signed-off-by: Markus Klotzbuecher Cc: Heiko Schocher Cc: Kyungmin Park Cc: Javier Martinez Canillas Cc: Enric Balletbo i Serra --- common/spl/Kconfig | 79 scripts/config_whitelist.txt | 12 -- 2 files changed, 79 insertions(+), 12 deletions(-) diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 206c24076d..71bedea638 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -549,6 +549,85 @@ config SPL_NAND_SUPPORT This enables the drivers in drivers/mtd/nand/raw as part of an SPL build. +config SPL_UBI + bool "Support UBI" + help + Enable support for loading payloads from UBI. See + README.ubispl for more info. + +if SPL_UBI +config SPL_UBI_MAX_VOL_LEBS + int "Maximum number of LEBs per volume" + depends on SPL_UBI + help + The maximum number of logical eraseblocks which a static volume + to load can contain. Used for sizing the scan data structure. + +config SPL_UBI_MAX_PEB_SIZE + int "Maximum PEB size" + depends on SPL_UBI + help + The maximum physical erase block size. + +config SPL_UBI_MAX_PEBS + int "Maximum number of PEBs" + depends on SPL_UBI + help + The maximum physical erase block size. If not overridden by + board code, this value will be used as the actual number of PEBs. + +config SPL_UBI_PEB_OFFSET + int "Offset to first UBI PEB" + depends on SPL_UBI + help + The offset in number of PEBs from the start of flash to the first + PEB part of the UBI image. + +config SPL_UBI_VID_OFFSET + int "Offset to VID header" + depends on SPL_UBI + +config SPL_UBI_LEB_START + int "Offset to LEB in PEB" + depends on SPL_UBI + help + The offset in bytes to the LEB within a PEB. + +config SPL_UBI_INFO_ADDR + hex "Address to place UBI scan info" + depends on SPL_UBI + help + Address for ubispl to place the scan info. Read README.ubispl to + determine the required size + +config SPL_UBI_VOL_IDS + int "Maximum volume id" + depends on SPL_UBI + help + The maximum volume id which can be loaded. Used for sizing the + scan data structure. + +config SPL_UBI_LOAD_MONITOR_ID + int "id of U-Boot volume" + depends on SPL_UBI + help + The UBI volume id from which to load U-Boot + +config SPL_UBI_LOAD_KERNEL_ID + int "id of kernel volume" + depends on SPL_OS_BOOT && SPL_UBI + help + The UBI volume id from which to load the kernel + +config SPL_UBI_LOAD_ARGS_ID + int "id of kernel args volume" + depends on SPL_OS_BOOT && SPL_UBI + help + The UBI volume id from which to load the device tree + + +endif # if SPL_UBI + config SPL_NET_SUPPORT bool "Support networking" help diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index 5d76c781d3..d72e7c4ff4 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -1886,18 +1886,6 @@ CONFIG_SPL_STACK_SIZE CONFIG_SPL_START_S_PATH CONFIG_SPL_TARGET CONFIG_SPL_TEXT_BASE -CONFIG_SPL_UBI -CONFIG_SPL_UBI_INFO_ADDR -CONFIG_SPL_UBI_LEB_START -CONFIG_SPL_UBI_LOAD_ARGS_ID -CONFIG_SPL_UBI_LOAD_KERNEL_ID -CONFIG_SPL_UBI_LOAD_MONITOR_ID -CONFIG_SPL_UBI_MAX_PEBS -CONFIG_SPL_UBI_MAX_PEB_SIZE -CONFIG_SPL_UBI_MAX_VOL_LEBS -CONFIG_SPL_UBI_PEB_OFFSET -CONFIG_SPL_UBI_VID_OFFSET -CONFIG_SPL_UBI_VOL_IDS CONFIG_SPL_UBOOT_KEY_HASH CONFIG_SRAM_BASE CONFIG_SRAM_SIZE -- 2.20.1 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH 5/6] ubispl: add support for loading volumes by name
From: Hamish Guthrie The motivation is to use the UBI atomic volume rename functionality to allow double copy software updates on UBI. To that end the SPL is configured to always load the same volume name (e.g. "u-boot"), whereas a software updater always installs into the secondary volume "u-boot_r". After successful installation, these two volume names are switched. This extension is protected by #ifdefs as it will somewhat slow down loading of volumes by id. This is because the code needs to disable the optimization of ignoring all volume ids which are not to-be-loaded, since these can only be resolved after attaching. Signed-off-by: Hamish Guthrie Signed-off-by: Markus Klotzbuecher Cc: Heiko Schocher Cc: Kyungmin Park --- common/spl/Kconfig | 13 +++ common/spl/spl_ubi.c| 7 ++ drivers/mtd/ubispl/ubispl.c | 215 +++- drivers/mtd/ubispl/ubispl.h | 7 ++ include/ubispl.h| 6 + 5 files changed, 246 insertions(+), 2 deletions(-) diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 71bedea638..0e91bd309b 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -556,6 +556,13 @@ config SPL_UBI README.ubispl for more info. if SPL_UBI +config SPL_UBI_LOAD_BY_VOLNAME + bool "Support loading volumes by name" + help + This enables support for loading UBI volumes by name. When this + is set, CONFIG_SPL_UBI_LOAD_MONITOR_VOLNAME can be used to + configure the volume name from which to load U-Boot. + config SPL_UBI_MAX_VOL_LEBS int "Maximum number of LEBs per volume" depends on SPL_UBI @@ -613,6 +620,12 @@ config SPL_UBI_LOAD_MONITOR_ID help The UBI volume id from which to load U-Boot +config SPL_UBI_LOAD_MONITOR_VOLNAME + string "volume name of U-Boot volume" + depends on SPL_UBI_LOAD_BY_VOLNAME + help + The UBI volume name from which to load U-Boot + config SPL_UBI_LOAD_KERNEL_ID int "id of kernel volume" depends on SPL_OS_BOOT && SPL_UBI diff --git a/common/spl/spl_ubi.c b/common/spl/spl_ubi.c index 67e5fadd7c..0cb5080882 100644 --- a/common/spl/spl_ubi.c +++ b/common/spl/spl_ubi.c @@ -62,7 +62,14 @@ int spl_ubi_load_image(struct spl_image_info *spl_image, } #endif header = spl_get_load_buffer(-sizeof(*header), sizeof(header)); +#ifdef CONFIG_SPL_UBI_LOAD_BY_VOLNAME + volumes[0].vol_id = -1; + strncpy(volumes[0].name, + CONFIG_SPL_UBI_LOAD_MONITOR_VOLNAME, + UBI_VOL_NAME_MAX + 1); +#else volumes[0].vol_id = CONFIG_SPL_UBI_LOAD_MONITOR_ID; +#endif volumes[0].load_addr = (void *)header; ret = ubispl_load_volumes(&info, volumes, 1); diff --git a/drivers/mtd/ubispl/ubispl.c b/drivers/mtd/ubispl/ubispl.c index eeb1cbefb7..3f3b9b4367 100644 --- a/drivers/mtd/ubispl/ubispl.c +++ b/drivers/mtd/ubispl/ubispl.c @@ -45,6 +45,187 @@ static int ubi_io_is_bad(struct ubi_scan_info *ubi, int peb) return peb >= ubi->peb_count || peb < 0; } +#ifdef CONFIG_SPL_UBI_LOAD_BY_VOLNAME + +/** + * ubi_dump_vtbl_record - dump a &struct ubi_vtbl_record object. + * @r: the object to dump + * @idx: volume table index + */ +void ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx) +{ + int name_len = be16_to_cpu(r->name_len); + + ubi_dbg("Volume table record %d dump: size: %d", + idx, sizeof(struct ubi_vtbl_record)); + ubi_dbg("\treserved_pebs %d", be32_to_cpu(r->reserved_pebs)); + ubi_dbg("\talignment %d", be32_to_cpu(r->alignment)); + ubi_dbg("\tdata_pad%d", be32_to_cpu(r->data_pad)); + ubi_dbg("\tvol_type%d", (int)r->vol_type); + ubi_dbg("\tupd_marker %d", (int)r->upd_marker); + ubi_dbg("\tname_len%d", name_len); + + if (r->name[0] == '\0') { + ubi_dbg("\tnameNULL"); + return; + } + + if (name_len <= UBI_VOL_NAME_MAX && + strnlen(&r->name[0], name_len + 1) == name_len) { + ubi_dbg("\tname%s", &r->name[0]); + } else { + ubi_dbg("\t1st 5 characters of name: %c%c%c%c%c", + r->name[0], r->name[1], r->name[2], r->name[3], + r->name[4]); + } + ubi_dbg("\tcrc %#08x", be32_to_cpu(r->crc)); +} + +/* Empty volume table record */ +static struct ubi_vtbl_record empty_vtbl_record; + +/** + * vtbl_check - check if volume table is not corrupted and sensible. + * @ubi: UBI device description object + * @vtbl: volume table + * + * This function returns zero if @vtbl is all right, %1 if CRC is inco
Re: [U-Boot] [PATCH 0/6] miscellaneous ubispl and ubi improvements
Hello Heiko On Tue, Apr 16, 2019 at 05:52:15AM +0200, Heiko Schocher wrote: > >Am 15.04.2019 um 17:32 schrieb Markus Klotzbuecher: >> From: Markus Klotzbuecher >> >> Hello Heiko and Kyungmin >> >> This series contains a couple of UBI and UBI SPL improvements, notably >> a ubispl extension to allow loading volumes by name. The motivation is >> to use the UBI atomic volume rename functionality to allow double copy >> software updates of U-Boot on UBI. To do that we configured the SPL to >> always load the same volume name (e.g. "u-boot"), and the software >> updater always installs into the secondary volume "u-boot_r". After a >> successful upgrade, these two volume names are switched. > >Ok ... Hmm... if you use the bootcounter in SPL, you may have a chance >to unbreak he board, if "u-boot" does not boot? > >How do you detect a successfull upgrade ? At this point, if writing to the to-be-updated volume succeeds, we consider it a successful upgrade. If not, the rename is not carried out and the old volume will remain the active one. To further improve reliability, this could be combined with an SPL bootcounter, however to really be an improvement, that should probably use an environment on UBI too (or anything more reliable than raw NAND). >> This extension is protected by #ifdefs as it will somewhat slow down >> loading of volumes by id. This is because the code needs to disable >> the optimization of ignoring all volume ids which are not >> to-be-loaded, since these can only be resolved after attaching. >> >> We have tested both with and without fastmap enabled and both paths >> seems to work reliably. > >Fine, thanks! > >> I also moved the ubispl config to Kconfig. There seem to be two boards > >Thanks! > >> that use this (Maintainers cc'ed on patch). I have not updated their >> defconfigs (not being sure if I should) but would be pleased to do so. > >I prefer that you do so, but we will see, if the board maintainers >give some feedback. > >Give me some time to look through your patches. Sure, thank you! Best regards Markus -- Markus Klotzbuecher Freelancer Embedded, Distributed & Real-time Am See 28, 78465 Konstanz, Germany ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH 0/6] miscellaneous ubispl and ubi improvements
Hello Heiko On Tue, Apr 16, 2019 at 06:03:31AM +0200, Heiko Schocher wrote: >may I am to dummy, but I cannot find your patches in patchwork :-( > >any ideas? As this was a first post from this address, I think they are still in the list moderation queue... Best regards Markus -- Markus Klotzbuecher Freelancer Embedded, Distributed & Real-time Am See 28, 78465 Konstanz, Germany ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH 6/6] ubispl: introduce separate CONFIG_UBI_SPL_SILENCE_MSG
From: Markus Klotzbuecher This allows to silence ubi and ubispl individually. Signed-off-by: Markus Klotzbuecher Cc: Heiko Schocher Cc: Kyungmin Park --- common/spl/Kconfig | 6 ++ drivers/mtd/ubispl/ubispl.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 0e91bd309b..37dce69e81 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -638,6 +638,12 @@ config SPL_UBI_LOAD_ARGS_ID help The UBI volume id from which to load the device tree +config UBI_SPL_SILENCE_MSG + bool "silence UBI SPL messages" + default n + help + Disable messages from UBI SPL. This leaves warnings + and errors enabled. endif # if SPL_UBI diff --git a/drivers/mtd/ubispl/ubispl.h b/drivers/mtd/ubispl/ubispl.h index bcc376c6d7..b7cb7fc941 100644 --- a/drivers/mtd/ubispl/ubispl.h +++ b/drivers/mtd/ubispl/ubispl.h @@ -129,7 +129,7 @@ struct ubi_scan_info { #define ubi_dbg(fmt, ...) #endif -#ifdef CONFIG_UBI_SILENCE_MSG +#ifdef CONFIG_UBI_SPL_SILENCE_MSG #define ubi_msg(fmt, ...) #else #define ubi_msg(fmt, ...) printf("UBI: " fmt "\n", ##__VA_ARGS__) -- 2.20.1 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH 1/6] env: ubi: KConfig: add CONFIG_ENV_UBI_VOLUME_REDUND
Hello Heiko On Tue, Apr 30, 2019 at 06:54:01AM +0200, Heiko Schocher wrote: >Am 15.04.2019 um 17:32 schrieb Markus Klotzbuecher: >> From: Markus Klotzbuecher > >please add a commit message. > >> Signed-off-by: Markus Klotzbuecher >> Cc: Heiko Schocher >> Cc: Kyungmin Park >> --- >> env/Kconfig | 6 ++ >> scripts/config_whitelist.txt | 1 - >> 2 files changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/env/Kconfig b/env/Kconfig >> index 78300660c7..44c47220c2 100644 >> --- a/env/Kconfig >> +++ b/env/Kconfig >> @@ -513,6 +513,12 @@ config ENV_UBI_VOLUME >> help >>Name of the volume that you want to store the environment in. >> +config ENV_UBI_VOLUME_REDUND >> +string "UBI redundant volume name" >> +depends on ENV_IS_IN_UBI >> +help >> + Name of the redundant volume that you want to store the environment >> in. >> + >> endif >> config USE_DEFAULT_ENV_FILE >> diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt >> index fa98efc24c..5d76c781d3 100644 >> --- a/scripts/config_whitelist.txt >> +++ b/scripts/config_whitelist.txt >> @@ -504,7 +504,6 @@ CONFIG_ENV_SROM_BANK >> CONFIG_ENV_TOTAL_SIZE >> CONFIG_ENV_UBIFS_OPTION >> CONFIG_ENV_UBI_MTD >> -CONFIG_ENV_UBI_VOLUME_REDUND >> CONFIG_ENV_VERSION >> CONFIG_EP9302 >> CONFIG_EP9307 >> > >Please move from the config files: > >./include/configs/omap3_igep00x0.h >./include/configs/gardena-smart-gateway-at91sam.h >./include/configs/am335x_igep003x.h > >also the symbols to the defconfig files, thanks. > >BTW: you can use the tool tools/moveconfig.py in u-boot source >for this purpose. > >Beside of this, you can add my: > >Reviewed-by: Heiko Schocher Thank you for your feedback! I will go through it and submit a v2 within a few days. Best regards Markus -- Markus Klotzbuecher Freelancer Embedded, Distributed & Real-time Systems Am See 28, 78465 Konstanz, Germany ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] ubispl: how to configure number of PEBs on the fly?
Dear All We are using ubispl to load u-boot from a UBI volume on a TI am335x based board using the am335x_spl_bch driver. In the current ubispl code (common/spl/spl_ubi.c, line 45), the number of PEBs is hardcoded to CONFIG_SPL_UBI_MAX_PEBS. In order to support multiple hardware variants with different flash sizes with one SPL, it would be nice to set this value on the fly. However if I understand correctly, the SPL nand driver does not autodetect such properties. Is there a practical way to determine this value in the SPL context? Or should it be provided by board init code? What would be the preferred way to handle this? Thanks in advance! Markus Markus Klotzbuecher Embedded System Architect -- Kistler Instrumente AG Eulachstrasse 22, 8408 Winterthur, Switzerland Direct +41 52 224 17 54, Main Office +41 52 224 11 11 markus.klotzbuec...@kistler.com, www.kistler.com ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH 1/6] env: ubi: KConfig: add CONFIG_ENV_UBI_VOLUME_REDUND
Hello Heiko On Tue, Apr 30, 2019 at 06:54:01AM +0200, Heiko Schocher wrote: >Am 15.04.2019 um 17:32 schrieb Markus Klotzbuecher: >> From: Markus Klotzbuecher > >please add a commit message. > >> Signed-off-by: Markus Klotzbuecher >> Cc: Heiko Schocher >> Cc: Kyungmin Park >> --- >> env/Kconfig | 6 ++ >> scripts/config_whitelist.txt | 1 - >> 2 files changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/env/Kconfig b/env/Kconfig >> index 78300660c7..44c47220c2 100644 >> --- a/env/Kconfig >> +++ b/env/Kconfig >> @@ -513,6 +513,12 @@ config ENV_UBI_VOLUME >> help >>Name of the volume that you want to store the environment in. >> +config ENV_UBI_VOLUME_REDUND >> +string "UBI redundant volume name" >> +depends on ENV_IS_IN_UBI >> +help >> + Name of the redundant volume that you want to store the environment >> in. >> + >> endif >> config USE_DEFAULT_ENV_FILE >> diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt >> index fa98efc24c..5d76c781d3 100644 >> --- a/scripts/config_whitelist.txt >> +++ b/scripts/config_whitelist.txt >> @@ -504,7 +504,6 @@ CONFIG_ENV_SROM_BANK >> CONFIG_ENV_TOTAL_SIZE >> CONFIG_ENV_UBIFS_OPTION >> CONFIG_ENV_UBI_MTD >> -CONFIG_ENV_UBI_VOLUME_REDUND >> CONFIG_ENV_VERSION >> CONFIG_EP9302 >> CONFIG_EP9307 >> > >Please move from the config files: > >./include/configs/omap3_igep00x0.h >./include/configs/gardena-smart-gateway-at91sam.h >./include/configs/am335x_igep003x.h > >also the symbols to the defconfig files, thanks. I have a question: to convert these, I need to make available the additional ENV_ configs to OMAP2PLUS and AT91: diff --git a/env/Kconfig b/env/Kconfig index 44c47220c2..1250656d74 100644 --- a/env/Kconfig +++ b/env/Kconfig @@ -470,7 +470,7 @@ config ENV_EXT4_FILE It's a string of the EXT4 file name. This file use to store the environment (explicit path to the file) -if ARCH_ROCKCHIP || ARCH_SUNXI || ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_VERSAL || ARC +if ARCH_ROCKCHIP || ARCH_SUNXI || ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_VERSAL || ARC || ARCH_OMAP2PLUS || ARCH_AT91 However, this "if" region contains a few other, non UBI settings such as ENV_SIZE, which would become visible to a large number of OMAP2PLUS and AT91 boards, which still define this in the headers. I'm a bit hesitant to touch all of these. What is the suggested way to solve this? Thank you, Markus -- Markus Klotzbuecher Freelancer Embedded, Distributed & Real-time Systems Am See 28, 78465 Konstanz, Germany ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH 1/6] env: ubi: KConfig: add CONFIG_ENV_UBI_VOLUME_REDUND
Hello Heiko On Thu, May 09, 2019 at 01:17:06PM +0200, Heiko Schocher wrote: > >Am 09.05.2019 um 10:59 schrieb Markus Klotzbuecher: >> Hello Heiko >> >> On Tue, Apr 30, 2019 at 06:54:01AM +0200, Heiko Schocher wrote: >> >> > Am 15.04.2019 um 17:32 schrieb Markus Klotzbuecher: >> > > From: Markus Klotzbuecher >> > >> > please add a commit message. >> > >> > > Signed-off-by: Markus Klotzbuecher >> > > Cc: Heiko Schocher >> > > Cc: Kyungmin Park >> > > --- >> > >env/Kconfig | 6 ++ >> > >scripts/config_whitelist.txt | 1 - >> > >2 files changed, 6 insertions(+), 1 deletion(-) >> > > >> > > diff --git a/env/Kconfig b/env/Kconfig >> > > index 78300660c7..44c47220c2 100644 >> > > --- a/env/Kconfig >> > > +++ b/env/Kconfig >> > > @@ -513,6 +513,12 @@ config ENV_UBI_VOLUME >> > > help >> > >Name of the volume that you want to store the environment in. >> > > +config ENV_UBI_VOLUME_REDUND >> > > +string "UBI redundant volume name" >> > > +depends on ENV_IS_IN_UBI >> > > +help >> > > + Name of the redundant volume that you want to store the >> > > environment in. >> > > + >> > >endif >> > >config USE_DEFAULT_ENV_FILE >> > > diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt >> > > index fa98efc24c..5d76c781d3 100644 >> > > --- a/scripts/config_whitelist.txt >> > > +++ b/scripts/config_whitelist.txt >> > > @@ -504,7 +504,6 @@ CONFIG_ENV_SROM_BANK >> > >CONFIG_ENV_TOTAL_SIZE >> > >CONFIG_ENV_UBIFS_OPTION >> > >CONFIG_ENV_UBI_MTD >> > > -CONFIG_ENV_UBI_VOLUME_REDUND >> > >CONFIG_ENV_VERSION >> > >CONFIG_EP9302 >> > >CONFIG_EP9307 >> > > >> > >> > Please move from the config files: >> > >> > ./include/configs/omap3_igep00x0.h >> > ./include/configs/gardena-smart-gateway-at91sam.h >> > ./include/configs/am335x_igep003x.h >> > >> > also the symbols to the defconfig files, thanks. >> >> I have a question: to convert these, I need to make available the >> additional ENV_ configs to OMAP2PLUS and AT91: >> >> diff --git a/env/Kconfig b/env/Kconfig >> index 44c47220c2..1250656d74 100644 >> --- a/env/Kconfig >> +++ b/env/Kconfig >> @@ -470,7 +470,7 @@ config ENV_EXT4_FILE >>It's a string of the EXT4 file name. This file use to store the >>environment (explicit path to the file) >> -if ARCH_ROCKCHIP || ARCH_SUNXI || ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_VERSAL >> || ARC >> +if ARCH_ROCKCHIP || ARCH_SUNXI || ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_VERSAL >> || ARC || ARCH_OMAP2PLUS || ARCH_AT91 >> >> However, this "if" region contains a few other, non UBI settings such >> as ENV_SIZE, which would become visible to a large number of OMAP2PLUS >> and AT91 boards, which still define this in the headers. > >Huch? > >If so, than they are not converted (yet) ... :-( > >> I'm a bit hesitant to touch all of these. What is the suggested way to >> solve this? > >I think, they should be converted too ... OK. >Sorry for the additional work ... I can understand your hesitantion >to do such a conversion... No problem, I just wasn't sure how handle this. I'm now trying to run moveconfig as follows $ grep -l "ARCH_OMAP2PLUS\|ARCH_AT91" configs/* | ./tools/moveconfig.py -s ENV_OFFSET ENV_SIZE ENV_SECT_SIZE -d - but the command hangs infinitely. If I run it for all boards without "-d", it starts processing and gets through about 50 configs and then hangs too. Any idea what may be the cause? I'm using python 2.7.16rc1. >Hmm... I used some year(s) ago tbot for checking, if a config change >did not introduced diffs in created binaries for all boards [1] ... > >In principal I did: > >- build all boards with "SOURCE_DATE_EPOCH=0" > and created a md5sum from each binary >- apply patch(es) >- build again, create md5sums and check if mdsum is the same > >Unfortunately not converted this testcase to the new tbot ... > >But may it is possible to convert this into a script ? Thank you, I'll take a look at it one I get that far. Best regards Markus -- Markus Klotzbuecher Freelancer Embedded, Distributed & Real-time Systems Am See 28, 78465 Konstanz, Germany ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v2 0/9] miscellaneous ubispl and ubi improvements
From: Markus Klotzbuecher This series contains a couple of UBI and UBI SPL improvements, notably a ubispl extension to allow loading volumes by name. The motivation is to use the UBI atomic volume rename functionality to allow double copy software updates of U-Boot on UBI. To do that we configured the SPL to always load the same volume name (e.g. "u-boot"), and the software updater always installs into the secondary volume "u-boot_r". After a successful upgrade, these two volume names are switched. This extension is protected by #ifdefs as it will somewhat slow down loading of volumes by id. This is because the code needs to disable the optimization of ignoring all volume ids which are not to-be-loaded, since these can only be resolved after attaching. We have tested both with and without fastmap enabled and both paths seems to work reliably. As per Heikos request, this v2 adds two patches that migrate the omap2plus and at91 CONFIG_ENV_* to defconfigs and likewise for the two boards using ubispl. The first migration was supported by an extension to the moveconfig script (patch 1) to expand simple expressions. Both migrations were tested to be binary equal before and after the change. Changes v2: - Add a patch (1) for moveconfig to expand simple expressions - Add patch (3) to move at91 and omap2plus CONFIG_ENV_ to defconfigs - Add patch (7) to migrate boards using ubispl to KConfig - Add missing commit messages - Indicate version of kernel code which was used in ubispl Hamish Guthrie (2): env: ubi: support configurable VID offset ubispl: add support for loading volumes by name Markus Klotzbuecher (7): moveconfig: expand simple expressions env: ubi: KConfig: add CONFIG_ENV_UBI_VOLUME_REDUND at91, omap2plus: configs: migrate CONFIG_ENV_ to defconfigs ubi: fix UBI_SILENCE_MSG ubispl: migrate configuration to Kconfig configs: migrate ubispl boards to KConfig ubispl: introduce separate CONFIG_UBI_SPL_SILENCE_MSG common/spl/Kconfig| 98 common/spl/spl_ubi.c | 7 + configs/am335x_guardian_defconfig | 2 + configs/am335x_igep003x_defconfig | 16 ++ configs/am335x_pdu001_defconfig | 1 + configs/am335x_shc_defconfig | 2 + configs/am335x_shc_ict_defconfig | 2 + configs/am335x_shc_netboot_defconfig | 2 + configs/am335x_shc_sdboot_defconfig | 2 + configs/am335x_sl50_defconfig | 1 + configs/am43xx_evm_defconfig | 1 + configs/am43xx_evm_qspiboot_defconfig | 3 + configs/am43xx_evm_rtconly_defconfig | 1 + configs/am43xx_evm_usbhost_boot_defconfig | 1 + configs/am43xx_hs_evm_defconfig | 1 + configs/at91rm9200ek_defconfig| 3 + configs/at91rm9200ek_ram_defconfig| 3 + configs/at91sam9260ek_dataflash_cs0_defconfig | 3 + configs/at91sam9260ek_dataflash_cs1_defconfig | 3 + configs/at91sam9261ek_dataflash_cs0_defconfig | 3 + configs/at91sam9261ek_dataflash_cs3_defconfig | 3 + configs/at91sam9263ek_dataflash_cs0_defconfig | 3 + configs/at91sam9263ek_dataflash_defconfig | 3 + configs/at91sam9263ek_norflash_boot_defconfig | 3 + configs/at91sam9263ek_norflash_defconfig | 3 + configs/at91sam9g10ek_dataflash_cs0_defconfig | 3 + configs/at91sam9g10ek_dataflash_cs3_defconfig | 3 + configs/at91sam9g20ek_2mmc_defconfig | 2 + configs/at91sam9g20ek_dataflash_cs0_defconfig | 3 + configs/at91sam9g20ek_dataflash_cs1_defconfig | 3 + configs/at91sam9m10g45ek_mmc_defconfig| 1 + configs/at91sam9n12ek_mmc_defconfig | 1 + configs/at91sam9n12ek_spiflash_defconfig | 3 + configs/at91sam9rlek_dataflash_defconfig | 3 + configs/at91sam9rlek_mmc_defconfig| 1 + configs/at91sam9x5ek_dataflash_defconfig | 3 + configs/at91sam9x5ek_mmc_defconfig| 1 + configs/at91sam9x5ek_spiflash_defconfig | 3 + configs/at91sam9xeek_dataflash_cs0_defconfig | 3 + configs/at91sam9xeek_dataflash_cs1_defconfig | 3 + configs/axm_defconfig | 1 + configs/brppt1_mmc_defconfig | 2 + configs/brppt1_nand_defconfig | 2 + configs/brppt1_spi_defconfig | 3 + configs/brxre1_defconfig | 2 + configs/chiliboard_defconfig | 2 + configs/cm_t335_defconfig | 2 + configs/cm_t35_defconfig | 1 + configs/cm_t43_defconfig | 3 + configs/cm_t54_defconfig | 2 + configs/corvus_defconfig | 1 + configs/draco_defconfig | 1 + configs/eco5pk_defconfig | 1 + configs/etamin_defconfig | 2 + configs/ethernut5_defconfig
[U-Boot] [PATCH v2 1/9] moveconfig: expand simple expressions
From: Markus Klotzbuecher Add support for expanding simple expressions and sizes such as "(4 * 1024)", "(512 << 10)" or "(SZ_256K)". This can help to significantly reduce the number of "suspicious" moves, such as 'CONFIG_ENV_SIZE="(64 << 10)"' was removed by savedefconfig. If the expansion fails, it falls back to the original string. Signed-off-by: Markus Klotzbuecher Cc: Masahiro Yamada Cc: Heiko Schocher --- Changes for v2: new patch tools/moveconfig.py | 41 + 1 file changed, 41 insertions(+) diff --git a/tools/moveconfig.py b/tools/moveconfig.py index 1a214c5605..0bbc7c1991 100755 --- a/tools/moveconfig.py +++ b/tools/moveconfig.py @@ -354,6 +354,26 @@ CONFIG_DATABASE = 'moveconfig.db' CONFIG_LEN = len('CONFIG_') +SIZES = { +"SZ_1":0x0001, "SZ_2":0x0002, +"SZ_4":0x0004, "SZ_8":0x0008, +"SZ_16": 0x0010, "SZ_32": 0x0020, +"SZ_64": 0x0040, "SZ_128": 0x0080, +"SZ_256": 0x0100, "SZ_512": 0x0200, +"SZ_1K": 0x0400, "SZ_2K": 0x0800, +"SZ_4K": 0x1000, "SZ_8K": 0x2000, +"SZ_16K": 0x4000, "SZ_32K": 0x8000, +"SZ_64K": 0x0001, "SZ_128K": 0x0002, +"SZ_256K": 0x0004, "SZ_512K": 0x0008, +"SZ_1M": 0x0010, "SZ_2M": 0x0020, +"SZ_4M": 0x0040, "SZ_8M": 0x0080, +"SZ_16M": 0x0100, "SZ_32M": 0x0200, +"SZ_64M": 0x0400, "SZ_128M": 0x0800, +"SZ_256M": 0x1000, "SZ_512M": 0x2000, +"SZ_1G": 0x4000, "SZ_2G": 0x8000, +"SZ_4G": 0x1 +} + ### helper functions ### def get_devnull(): """Get the file object of '/dev/null' device.""" @@ -777,6 +797,25 @@ def cleanup_readme(configs, options): with open('README', 'w') as f: f.write(''.join(newlines)) +def try_expand(line): +"""If value looks like an expression, try expanding it +Otherwise just return the existing value +""" +if line.find('=') == -1: +return line + +try: +cfg, val = re.split("=", line) +val= val.strip('\"') +if re.search("[*+-/]|<<|SZ_+|\(([^\)]+)\)", val): +newval = hex(eval(val, SIZES)) +print "\tExpanded expression %s to %s" % (val, newval) +return cfg+'='+newval +except: +print "\tFailed to expand expression in %s" % line + +return line + ### classes ### class Progress: @@ -891,6 +930,8 @@ class KconfigParser: else: new_val = not_set +new_val = try_expand(new_val) + for line in dotconfig_lines: line = line.rstrip() if line.startswith(config + '=') or line == not_set: -- 2.20.1 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v2 2/9] env: ubi: KConfig: add CONFIG_ENV_UBI_VOLUME_REDUND
From: Markus Klotzbuecher Introduce the KConfig option CONFIG_ENV_UBI_VOLUME_REDUND for defining the name of the UBI volume used to store the redundant environment. Signed-off-by: Markus Klotzbuecher Reviewed-by: Heiko Schocher Cc: Kyungmin Park --- Changes for v2: - Extend commit message env/Kconfig | 6 ++ scripts/config_whitelist.txt | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/env/Kconfig b/env/Kconfig index 70858d3b40..9ae6b19ec5 100644 --- a/env/Kconfig +++ b/env/Kconfig @@ -513,6 +513,12 @@ config ENV_UBI_VOLUME help Name of the volume that you want to store the environment in. +config ENV_UBI_VOLUME_REDUND + string "UBI redundant volume name" + depends on ENV_IS_IN_UBI + help + Name of the redundant volume that you want to store the environment in. + endif config USE_DEFAULT_ENV_FILE diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index b16bc6ae34..af7eb73e4a 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -493,7 +493,6 @@ CONFIG_ENV_SROM_BANK CONFIG_ENV_TOTAL_SIZE CONFIG_ENV_UBIFS_OPTION CONFIG_ENV_UBI_MTD -CONFIG_ENV_UBI_VOLUME_REDUND CONFIG_ENV_VERSION CONFIG_EP9302 CONFIG_EP9307 -- 2.20.1 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v2 5/9] ubi: fix UBI_SILENCE_MSG
From: Markus Klotzbuecher - drop CONFIG_ prefix from kconfig entry - fix small compilation issue with CONFIG_UBI_SILENCE_MSG Signed-off-by: Markus Klotzbuecher Reviewed-by: Heiko Schocher Cc: Kyungmin Park --- Changes for v2: None drivers/mtd/ubi/Kconfig | 2 +- drivers/mtd/ubi/io.c| 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/ubi/Kconfig b/drivers/mtd/ubi/Kconfig index 2b17eae947..a78fd51ba7 100644 --- a/drivers/mtd/ubi/Kconfig +++ b/drivers/mtd/ubi/Kconfig @@ -1,6 +1,6 @@ menu "UBI support" -config CONFIG_UBI_SILENCE_MSG +config UBI_SILENCE_MSG bool "UBI silence verbose messages" default ENV_IS_IN_UBI help diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c index 8ef7823b37..688fb509d2 100644 --- a/drivers/mtd/ubi/io.c +++ b/drivers/mtd/ubi/io.c @@ -1351,6 +1351,7 @@ static int self_check_write(struct ubi_device *ubi, const void *buf, int pnum, ubi_err(ubi, "self-check failed for PEB %d:%d, len %d", pnum, offset, len); +#if !defined(CONFIG_UBI_SILENCE_MSG) ubi_msg(ubi, "data differ at position %d", i); ubi_msg(ubi, "hex dump of the original buffer from %d to %d", i, i + dump_len); @@ -1360,6 +1361,7 @@ static int self_check_write(struct ubi_device *ubi, const void *buf, int pnum, i, i + dump_len); print_hex_dump("", DUMP_PREFIX_OFFSET, 32, 1, buf1 + i, dump_len, 1); +#endif dump_stack(); err = -EINVAL; goto out_free; -- 2.20.1 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v2 3/9] at91, omap2plus: configs: migrate CONFIG_ENV_ to defconfigs
From: Markus Klotzbuecher Enable the extended ENV options for AT91 and OMAP2PLUS in order to be able to use CONFIG_ENV_UBI_* on these architectures. As this change also makes the configs ENV_SIZE, ENV_SECT_SIZE, ENV_OFFSET visible to AT91 and OMAP2PLUS, migrate users of these to KConfig. This migration was run using an extended moveconfig.py which evaluates expressions such as "(512 << 10)". See patch ("moveconfig: expand simple expressions"). All modified boards were built with SOURCE_DATE_EPOCH=0 before and after the change and successfully confirmed that the identical binary is generated (the only exception was igep00x0, which does not define CONFIG_ENV_IS_IN_UBI in the original board header. Once that is defined, the test passes too). Signed-off-by: Markus Klotzbuecher Cc: Heiko Schocher Cc: Eugen Hristev Cc: Tom Rini --- Changes for v2: new patch configs/am335x_guardian_defconfig | 2 ++ configs/am335x_igep003x_defconfig | 4 configs/am335x_pdu001_defconfig | 1 + configs/am335x_shc_defconfig| 2 ++ configs/am335x_shc_ict_defconfig| 2 ++ configs/am335x_shc_netboot_defconfig| 2 ++ configs/am335x_shc_sdboot_defconfig | 2 ++ configs/am335x_sl50_defconfig | 1 + configs/am43xx_evm_defconfig| 1 + configs/am43xx_evm_qspiboot_defconfig | 3 +++ configs/am43xx_evm_rtconly_defconfig| 1 + configs/am43xx_evm_usbhost_boot_defconfig | 1 + configs/am43xx_hs_evm_defconfig | 1 + configs/at91rm9200ek_defconfig | 3 +++ configs/at91rm9200ek_ram_defconfig | 3 +++ configs/at91sam9260ek_dataflash_cs0_defconfig | 3 +++ configs/at91sam9260ek_dataflash_cs1_defconfig | 3 +++ configs/at91sam9261ek_dataflash_cs0_defconfig | 3 +++ configs/at91sam9261ek_dataflash_cs3_defconfig | 3 +++ configs/at91sam9263ek_dataflash_cs0_defconfig | 3 +++ configs/at91sam9263ek_dataflash_defconfig | 3 +++ configs/at91sam9263ek_norflash_boot_defconfig | 3 +++ configs/at91sam9263ek_norflash_defconfig| 3 +++ configs/at91sam9g10ek_dataflash_cs0_defconfig | 3 +++ configs/at91sam9g10ek_dataflash_cs3_defconfig | 3 +++ configs/at91sam9g20ek_2mmc_defconfig| 2 ++ configs/at91sam9g20ek_dataflash_cs0_defconfig | 3 +++ configs/at91sam9g20ek_dataflash_cs1_defconfig | 3 +++ configs/at91sam9m10g45ek_mmc_defconfig | 1 + configs/at91sam9n12ek_mmc_defconfig | 1 + configs/at91sam9n12ek_spiflash_defconfig| 3 +++ configs/at91sam9rlek_dataflash_defconfig| 3 +++ configs/at91sam9rlek_mmc_defconfig | 1 + configs/at91sam9x5ek_dataflash_defconfig| 3 +++ configs/at91sam9x5ek_mmc_defconfig | 1 + configs/at91sam9x5ek_spiflash_defconfig | 3 +++ configs/at91sam9xeek_dataflash_cs0_defconfig| 3 +++ configs/at91sam9xeek_dataflash_cs1_defconfig| 3 +++ configs/axm_defconfig | 1 + configs/brppt1_mmc_defconfig| 2 ++ configs/brppt1_nand_defconfig | 2 ++ configs/brppt1_spi_defconfig| 3 +++ configs/brxre1_defconfig| 2 ++ configs/chiliboard_defconfig| 2 ++ configs/cm_t335_defconfig | 2 ++ configs/cm_t35_defconfig| 1 + configs/cm_t43_defconfig| 3 +++ configs/cm_t54_defconfig| 2 ++ configs/corvus_defconfig| 1 + configs/draco_defconfig | 1 + configs/eco5pk_defconfig| 1 + configs/etamin_defconfig| 2 ++ configs/ethernut5_defconfig | 3 +++ configs/gardena-smart-gateway-at91sam_defconfig | 4 configs/gurnard_defconfig | 2 ++ configs/igep00x0_defconfig | 5 + configs/mcx_defconfig | 1 + configs/meesc_dataflash_defconfig | 3 +++ configs/meesc_defconfig | 1 + configs/mt_ventoux_defconfig| 1 + configs/omap3_overo_defconfig | 1 + configs/omap4_sdp4430_defconfig | 1 + configs/pengwyn_defconfig | 1 + configs/picosam9g45_defconfig | 1 + configs/pm9261_defconfig| 3 +++ configs/pm9263_defconfig| 3 +++ configs/pxm2_defconfig | 1 + configs/rastaban_defconfig | 1 + configs/rut_defconfig | 1 + configs/sama5d27_som1_ek_mmc1_defconfig | 1 + configs/sama5d27_som1_ek_mmc_defconfig | 1 + configs/sama5d2_icp_mmc_defconfig
[U-Boot] [PATCH v2 6/9] ubispl: migrate configuration to Kconfig
From: Markus Klotzbuecher Move the ubispl configuration to KConfig and drop them from the whitelist. Signed-off-by: Markus Klotzbuecher Cc: Heiko Schocher Cc: Kyungmin Park Cc: Javier MartÃnez Canillas Cc: Enric Balletbo i Serra --- Changes for v2: None common/spl/Kconfig | 79 scripts/config_whitelist.txt | 12 -- 2 files changed, 79 insertions(+), 12 deletions(-) diff --git a/common/spl/Kconfig b/common/spl/Kconfig index c7cd34449a..fa63746909 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -556,6 +556,85 @@ config SPL_NAND_SUPPORT This enables the drivers in drivers/mtd/nand/raw as part of an SPL build. +config SPL_UBI + bool "Support UBI" + help + Enable support for loading payloads from UBI. See + README.ubispl for more info. + +if SPL_UBI +config SPL_UBI_MAX_VOL_LEBS + int "Maximum number of LEBs per volume" + depends on SPL_UBI + help + The maximum number of logical eraseblocks which a static volume + to load can contain. Used for sizing the scan data structure. + +config SPL_UBI_MAX_PEB_SIZE + int "Maximum PEB size" + depends on SPL_UBI + help + The maximum physical erase block size. + +config SPL_UBI_MAX_PEBS + int "Maximum number of PEBs" + depends on SPL_UBI + help + The maximum physical erase block size. If not overridden by + board code, this value will be used as the actual number of PEBs. + +config SPL_UBI_PEB_OFFSET + int "Offset to first UBI PEB" + depends on SPL_UBI + help + The offset in number of PEBs from the start of flash to the first + PEB part of the UBI image. + +config SPL_UBI_VID_OFFSET + int "Offset to VID header" + depends on SPL_UBI + +config SPL_UBI_LEB_START + int "Offset to LEB in PEB" + depends on SPL_UBI + help + The offset in bytes to the LEB within a PEB. + +config SPL_UBI_INFO_ADDR + hex "Address to place UBI scan info" + depends on SPL_UBI + help + Address for ubispl to place the scan info. Read README.ubispl to + determine the required size + +config SPL_UBI_VOL_IDS + int "Maximum volume id" + depends on SPL_UBI + help + The maximum volume id which can be loaded. Used for sizing the + scan data structure. + +config SPL_UBI_LOAD_MONITOR_ID + int "id of U-Boot volume" + depends on SPL_UBI + help + The UBI volume id from which to load U-Boot + +config SPL_UBI_LOAD_KERNEL_ID + int "id of kernel volume" + depends on SPL_OS_BOOT && SPL_UBI + help + The UBI volume id from which to load the kernel + +config SPL_UBI_LOAD_ARGS_ID + int "id of kernel args volume" + depends on SPL_OS_BOOT && SPL_UBI + help + The UBI volume id from which to load the device tree + + +endif # if SPL_UBI + config SPL_NET_SUPPORT bool "Support networking" help diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index af7eb73e4a..eeddc6a974 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -1871,18 +1871,6 @@ CONFIG_SPL_STACK_ADDR CONFIG_SPL_STACK_SIZE CONFIG_SPL_START_S_PATH CONFIG_SPL_TARGET -CONFIG_SPL_UBI -CONFIG_SPL_UBI_INFO_ADDR -CONFIG_SPL_UBI_LEB_START -CONFIG_SPL_UBI_LOAD_ARGS_ID -CONFIG_SPL_UBI_LOAD_KERNEL_ID -CONFIG_SPL_UBI_LOAD_MONITOR_ID -CONFIG_SPL_UBI_MAX_PEBS -CONFIG_SPL_UBI_MAX_PEB_SIZE -CONFIG_SPL_UBI_MAX_VOL_LEBS -CONFIG_SPL_UBI_PEB_OFFSET -CONFIG_SPL_UBI_VID_OFFSET -CONFIG_SPL_UBI_VOL_IDS CONFIG_SPL_UBOOT_KEY_HASH CONFIG_SRAM_BASE CONFIG_SRAM_SIZE -- 2.20.1 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v2 4/9] env: ubi: support configurable VID offset
From: Hamish Guthrie Introduce KConfig CONFIG_ENV_UBI_VID_OFFSET to allow providing custom VID header offsets for the environment on UBI. Signed-off-by: Hamish Guthrie Signed-off-by: Markus Klotzbuecher Reviewed-by: Heiko Schocher Cc: Kyungmin Park --- Changes for v2: - default to no custom vid offset env/Kconfig | 7 +++ env/ubi.c | 17 + 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/env/Kconfig b/env/Kconfig index a57b1fc70b..c4c3309c09 100644 --- a/env/Kconfig +++ b/env/Kconfig @@ -522,6 +522,13 @@ config ENV_UBI_VOLUME_REDUND help Name of the redundant volume that you want to store the environment in. +config ENV_UBI_VID_OFFSET + int "ubi environment VID offset" + depends on ENV_IS_IN_UBI + default 0 + help + UBI VID offset for environment. If 0, no custom VID offset is used. + endif config USE_DEFAULT_ENV_FILE diff --git a/env/ubi.c b/env/ubi.c index 1dfdf0a8c8..e4b85167ec 100644 --- a/env/ubi.c +++ b/env/ubi.c @@ -15,6 +15,15 @@ #include #undef crc32 +#define _QUOTE(x) #x +#define QUOTE(x) _QUOTE(x) + +#if (CONFIG_ENV_UBI_VID_OFFSET == 0) + #define UBI_VID_OFFSET NULL +#else + #define UBI_VID_OFFSET QUOTE(CONFIG_ENV_UBI_VID_OFFSET) +#endif + DECLARE_GLOBAL_DATA_PTR; #ifdef CONFIG_CMD_SAVEENV @@ -28,7 +37,7 @@ static int env_ubi_save(void) if (ret) return ret; - if (ubi_part(CONFIG_ENV_UBI_PART, NULL)) { + if (ubi_part(CONFIG_ENV_UBI_PART, UBI_VID_OFFSET)) { printf("\n** Cannot find mtd partition \"%s\"\n", CONFIG_ENV_UBI_PART); return 1; @@ -70,7 +79,7 @@ static int env_ubi_save(void) if (ret) return ret; - if (ubi_part(CONFIG_ENV_UBI_PART, NULL)) { + if (ubi_part(CONFIG_ENV_UBI_PART, UBI_VID_OFFSET)) { printf("\n** Cannot find mtd partition \"%s\"\n", CONFIG_ENV_UBI_PART); return 1; @@ -111,7 +120,7 @@ static int env_ubi_load(void) tmp_env1 = (env_t *)env1_buf; tmp_env2 = (env_t *)env2_buf; - if (ubi_part(CONFIG_ENV_UBI_PART, NULL)) { + if (ubi_part(CONFIG_ENV_UBI_PART, UBI_VID_OFFSET)) { printf("\n** Cannot find mtd partition \"%s\"\n", CONFIG_ENV_UBI_PART); set_default_env(NULL, 0); @@ -148,7 +157,7 @@ static int env_ubi_load(void) */ memset(buf, 0x0, CONFIG_ENV_SIZE); - if (ubi_part(CONFIG_ENV_UBI_PART, NULL)) { + if (ubi_part(CONFIG_ENV_UBI_PART, UBI_VID_OFFSET)) { printf("\n** Cannot find mtd partition \"%s\"\n", CONFIG_ENV_UBI_PART); set_default_env(NULL, 0); -- 2.20.1 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v2 7/9] configs: migrate ubispl boards to KConfig
From: Markus Klotzbuecher Migrate the ubispl configuration for the omap3_igep00x0 and am335x_igep003x boards to KConfig. Both boards were built with SOURCE_DATE_EPOCH=0 and found to be equal before and after. Signed-off-by: Markus Klotzbuecher Cc: Heiko Schocher Cc: Kyungmin Park Cc: Javier MartÃnez Canillas Cc: Enric Balletbo i Serra --- Changes for v2: new patch configs/am335x_igep003x_defconfig | 12 configs/igep00x0_defconfig| 12 include/configs/am335x_igep003x.h | 16 include/configs/omap3_igep00x0.h | 14 -- 4 files changed, 24 insertions(+), 30 deletions(-) diff --git a/configs/am335x_igep003x_defconfig b/configs/am335x_igep003x_defconfig index f44fb09b31..5874831ba1 100644 --- a/configs/am335x_igep003x_defconfig +++ b/configs/am335x_igep003x_defconfig @@ -21,6 +21,18 @@ CONFIG_VERSION_VARIABLE=y CONFIG_SPL_FS_EXT4=y CONFIG_SPL_I2C_SUPPORT=y CONFIG_SPL_MTD_SUPPORT=y +CONFIG_SPL_UBI=y +CONFIG_SPL_UBI_MAX_VOL_LEBS=256 +CONFIG_SPL_UBI_MAX_PEB_SIZE=262144 +CONFIG_SPL_UBI_MAX_PEBS=4096 +CONFIG_SPL_UBI_PEB_OFFSET=4 +CONFIG_SPL_UBI_VID_OFFSET=512 +CONFIG_SPL_UBI_LEB_START=2048 +CONFIG_SPL_UBI_INFO_ADDR=0x8808 +CONFIG_SPL_UBI_VOL_IDS=8 +CONFIG_SPL_UBI_LOAD_MONITOR_ID=0 +CONFIG_SPL_UBI_LOAD_KERNEL_ID=3 +CONFIG_SPL_UBI_LOAD_ARGS_ID=4 CONFIG_SPL_OS_BOOT=y CONFIG_SPL_POWER_SUPPORT=y CONFIG_SPL_WATCHDOG_SUPPORT=y diff --git a/configs/igep00x0_defconfig b/configs/igep00x0_defconfig index 927d7f0ecd..ab11935f48 100644 --- a/configs/igep00x0_defconfig +++ b/configs/igep00x0_defconfig @@ -17,6 +17,18 @@ CONFIG_SPL_TEXT_BASE=0x4020 CONFIG_SPL_SYS_MALLOC_SIMPLE=y # CONFIG_SPL_FS_EXT4 is not set CONFIG_SPL_MTD_SUPPORT=y +CONFIG_SPL_UBI=y +CONFIG_SPL_UBI_MAX_VOL_LEBS=256 +CONFIG_SPL_UBI_MAX_PEB_SIZE=262144 +CONFIG_SPL_UBI_MAX_PEBS=4096 +CONFIG_SPL_UBI_PEB_OFFSET=4 +CONFIG_SPL_UBI_VID_OFFSET=512 +CONFIG_SPL_UBI_LEB_START=2048 +CONFIG_SPL_UBI_INFO_ADDR=0x8808 +CONFIG_SPL_UBI_VOL_IDS=8 +CONFIG_SPL_UBI_LOAD_MONITOR_ID=0 +CONFIG_SPL_UBI_LOAD_KERNEL_ID=3 +CONFIG_SPL_UBI_LOAD_ARGS_ID=4 CONFIG_SPL_ONENAND_SUPPORT=y CONFIG_SPL_OS_BOOT=y CONFIG_CMD_SPL=y diff --git a/include/configs/am335x_igep003x.h b/include/configs/am335x_igep003x.h index 5131cd38e4..5b5e16026e 100644 --- a/include/configs/am335x_igep003x.h +++ b/include/configs/am335x_igep003x.h @@ -106,22 +106,6 @@ /* NAND support */ #define CONFIG_SYS_NAND_ONFI_DETECTION 1 -/* SPL */ - -/* UBI configuration */ -#define CONFIG_SPL_UBI 1 -#define CONFIG_SPL_UBI_MAX_VOL_LEBS256 -#define CONFIG_SPL_UBI_MAX_PEB_SIZE(256*1024) -#define CONFIG_SPL_UBI_MAX_PEBS4096 -#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_ID4 -#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 0x8808 - /* NAND config */ #define CONFIG_SYS_NAND_5_ADDR_CYCLE #define CONFIG_SYS_NAND_PAGE_COUNT (CONFIG_SYS_NAND_BLOCK_SIZE / \ diff --git a/include/configs/omap3_igep00x0.h b/include/configs/omap3_igep00x0.h index a95a9cc664..4ad7dc18b1 100644 --- a/include/configs/omap3_igep00x0.h +++ b/include/configs/omap3_igep00x0.h @@ -96,18 +96,4 @@ #define CONFIG_SYS_NAND_ECCBYTES 14 #define CONFIG_NAND_OMAP_ECCSCHEME OMAP_ECC_BCH8_CODE_HW_DETECTION_SW -/* UBI configuration */ -#define CONFIG_SPL_UBI 1 -#define CONFIG_SPL_UBI_MAX_VOL_LEBS256 -#define CONFIG_SPL_UBI_MAX_PEB_SIZE(256*1024) -#define CONFIG_SPL_UBI_MAX_PEBS4096 -#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_ID4 -#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 0x8808 - #endif /* __IGEP00X0_H */ -- 2.20.1 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v2 9/9] ubispl: introduce separate CONFIG_UBI_SPL_SILENCE_MSG
From: Markus Klotzbuecher This allows to silence ubi and ubispl individually. Signed-off-by: Markus Klotzbuecher Reviewed-by: Heiko Schocher Cc: Kyungmin Park --- Changes for v2: None common/spl/Kconfig | 6 ++ drivers/mtd/ubispl/ubispl.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 624d084d03..ebe61969f9 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -645,6 +645,12 @@ config SPL_UBI_LOAD_ARGS_ID help The UBI volume id from which to load the device tree +config UBI_SPL_SILENCE_MSG + bool "silence UBI SPL messages" + default n + help + Disable messages from UBI SPL. This leaves warnings + and errors enabled. endif # if SPL_UBI diff --git a/drivers/mtd/ubispl/ubispl.h b/drivers/mtd/ubispl/ubispl.h index bcc376c6d7..b7cb7fc941 100644 --- a/drivers/mtd/ubispl/ubispl.h +++ b/drivers/mtd/ubispl/ubispl.h @@ -129,7 +129,7 @@ struct ubi_scan_info { #define ubi_dbg(fmt, ...) #endif -#ifdef CONFIG_UBI_SILENCE_MSG +#ifdef CONFIG_UBI_SPL_SILENCE_MSG #define ubi_msg(fmt, ...) #else #define ubi_msg(fmt, ...) printf("UBI: " fmt "\n", ##__VA_ARGS__) -- 2.20.1 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH v2 8/9] ubispl: add support for loading volumes by name
From: Hamish Guthrie The motivation is to use the UBI atomic volume rename functionality to allow double copy software updates on UBI. To that end the SPL is configured to always load the same volume name (e.g. "u-boot"), whereas a software updater always installs into the secondary volume "u-boot_r". After successful installation, these two volume names are switched. This extension is protected by #ifdefs as it will somewhat slow down loading of volumes by id. This is because the code needs to disable the optimization of ignoring all volume ids which are not to-be-loaded, since these can only be resolved after attaching. This adds two vtbl related functions from Linux, which are taken from the same kernel version as the current main U-Boot UBI code (Linux 4.2 64291f7db5bd8). Signed-off-by: Hamish Guthrie Signed-off-by: Markus Klotzbuecher Reviewed-by: Heiko Schocher Cc: Kyungmin Park --- Changes for v2: - indicate version of Kernel from which code was copied common/spl/Kconfig | 13 +++ common/spl/spl_ubi.c| 7 ++ drivers/mtd/ubispl/ubispl.c | 215 +++- drivers/mtd/ubispl/ubispl.h | 7 ++ include/ubispl.h| 6 + 5 files changed, 246 insertions(+), 2 deletions(-) diff --git a/common/spl/Kconfig b/common/spl/Kconfig index fa63746909..624d084d03 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -563,6 +563,13 @@ config SPL_UBI README.ubispl for more info. if SPL_UBI +config SPL_UBI_LOAD_BY_VOLNAME + bool "Support loading volumes by name" + help + This enables support for loading UBI volumes by name. When this + is set, CONFIG_SPL_UBI_LOAD_MONITOR_VOLNAME can be used to + configure the volume name from which to load U-Boot. + config SPL_UBI_MAX_VOL_LEBS int "Maximum number of LEBs per volume" depends on SPL_UBI @@ -620,6 +627,12 @@ config SPL_UBI_LOAD_MONITOR_ID help The UBI volume id from which to load U-Boot +config SPL_UBI_LOAD_MONITOR_VOLNAME + string "volume name of U-Boot volume" + depends on SPL_UBI_LOAD_BY_VOLNAME + help + The UBI volume name from which to load U-Boot + config SPL_UBI_LOAD_KERNEL_ID int "id of kernel volume" depends on SPL_OS_BOOT && SPL_UBI diff --git a/common/spl/spl_ubi.c b/common/spl/spl_ubi.c index 67e5fadd7c..0cb5080882 100644 --- a/common/spl/spl_ubi.c +++ b/common/spl/spl_ubi.c @@ -62,7 +62,14 @@ int spl_ubi_load_image(struct spl_image_info *spl_image, } #endif header = spl_get_load_buffer(-sizeof(*header), sizeof(header)); +#ifdef CONFIG_SPL_UBI_LOAD_BY_VOLNAME + volumes[0].vol_id = -1; + strncpy(volumes[0].name, + CONFIG_SPL_UBI_LOAD_MONITOR_VOLNAME, + UBI_VOL_NAME_MAX + 1); +#else volumes[0].vol_id = CONFIG_SPL_UBI_LOAD_MONITOR_ID; +#endif volumes[0].load_addr = (void *)header; ret = ubispl_load_volumes(&info, volumes, 1); diff --git a/drivers/mtd/ubispl/ubispl.c b/drivers/mtd/ubispl/ubispl.c index eeb1cbefb7..3f3b9b4367 100644 --- a/drivers/mtd/ubispl/ubispl.c +++ b/drivers/mtd/ubispl/ubispl.c @@ -45,6 +45,187 @@ static int ubi_io_is_bad(struct ubi_scan_info *ubi, int peb) return peb >= ubi->peb_count || peb < 0; } +#ifdef CONFIG_SPL_UBI_LOAD_BY_VOLNAME + +/** + * ubi_dump_vtbl_record - dump a &struct ubi_vtbl_record object. + * @r: the object to dump + * @idx: volume table index + */ +void ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx) +{ + int name_len = be16_to_cpu(r->name_len); + + ubi_dbg("Volume table record %d dump: size: %d", + idx, sizeof(struct ubi_vtbl_record)); + ubi_dbg("\treserved_pebs %d", be32_to_cpu(r->reserved_pebs)); + ubi_dbg("\talignment %d", be32_to_cpu(r->alignment)); + ubi_dbg("\tdata_pad%d", be32_to_cpu(r->data_pad)); + ubi_dbg("\tvol_type%d", (int)r->vol_type); + ubi_dbg("\tupd_marker %d", (int)r->upd_marker); + ubi_dbg("\tname_len%d", name_len); + + if (r->name[0] == '\0') { + ubi_dbg("\tnameNULL"); + return; + } + + if (name_len <= UBI_VOL_NAME_MAX && + strnlen(&r->name[0], name_len + 1) == name_len) { + ubi_dbg("\tname%s", &r->name[0]); + } else { + ubi_dbg("\t1st 5 characters of name: %c%c%c%c%c", + r->name[0], r->name[1], r->name[2], r->name[3], + r->name[4]); + } + ubi_dbg("\tcrc %#08x", be32_to_cpu(r->crc)); +} + +/* Empty volume table record */ +static struct ubi_vtbl_re