aboutsummaryrefslogtreecommitdiffstats
path: root/package/boot/uboot-mediatek/patches/100-26-env-ubi-add-support-to-create-environment-volume-if-.patch
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2022-08-07 12:06:56 +0200
committerDaniel Golle <daniel@makrotopia.org>2022-08-28 20:33:15 +0100
commitd3a337a592bc26be374a70d1aca4aa20080527d4 (patch)
tree10e40ed6084c5e1ad063fbde7e95e5f4d680e067 /package/boot/uboot-mediatek/patches/100-26-env-ubi-add-support-to-create-environment-volume-if-.patch
parentc09eb08dadae341e7f68d34e9ec3f15afd86e469 (diff)
downloadupstream-d3a337a592bc26be374a70d1aca4aa20080527d4.tar.gz
upstream-d3a337a592bc26be374a70d1aca4aa20080527d4.tar.bz2
upstream-d3a337a592bc26be374a70d1aca4aa20080527d4.zip
uboot-mediatek: additions from MTK SDK
* updated SNAND/SNFI driver brings support for MT7981 * add support for MediaTek NAND Memory bad Block Management (NMBM) (not used for any boards atm, but could be useful in future) * wire up NMBM support for MT7622, MT7629, MT7981 and MT7986 * replace some local patches with updated version from SDK * bring some legacy precompiler symbols which haven't been converted into Kconfig symbols in U-Boot 2022.07, remove when bumbping to U-Boot 2022.10: 100-28-include-configs-mt7986-h-from-SDK.patch Source: https://github.com/mtk-openwrt/u-boot Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'package/boot/uboot-mediatek/patches/100-26-env-ubi-add-support-to-create-environment-volume-if-.patch')
-rw-r--r--package/boot/uboot-mediatek/patches/100-26-env-ubi-add-support-to-create-environment-volume-if-.patch72
1 files changed, 72 insertions, 0 deletions
diff --git a/package/boot/uboot-mediatek/patches/100-26-env-ubi-add-support-to-create-environment-volume-if-.patch b/package/boot/uboot-mediatek/patches/100-26-env-ubi-add-support-to-create-environment-volume-if-.patch
new file mode 100644
index 0000000000..08b14a6b29
--- /dev/null
+++ b/package/boot/uboot-mediatek/patches/100-26-env-ubi-add-support-to-create-environment-volume-if-.patch
@@ -0,0 +1,72 @@
+From fc0c70a7c6a088072d0c77e5a59d5e9b7754c6db Mon Sep 17 00:00:00 2001
+From: Weijie Gao <weijie.gao@mediatek.com>
+Date: Mon, 25 Jul 2022 17:01:20 +0800
+Subject: [PATCH 61/71] env: ubi: add support to create environment volume if
+ it does not exist
+
+Add an option to allow environment volume being auto created if not exist.
+
+Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
+---
+ env/Kconfig | 6 ++++++
+ env/ubi.c | 20 ++++++++++++++++++++
+ 2 files changed, 26 insertions(+)
+
+--- a/env/Kconfig
++++ b/env/Kconfig
+@@ -647,6 +647,12 @@ config ENV_UBI_VOLUME_REDUND
+ help
+ Name of the redundant volume that you want to store the environment in.
+
++config ENV_UBI_VOLUME_CREATE
++ bool "Create UBI volume if not exist"
++ depends on ENV_IS_IN_UBI
++ help
++ Create the UBI volume if it does not exist.
++
+ config ENV_UBI_VID_OFFSET
+ int "ubi environment VID offset"
+ depends on ENV_IS_IN_UBI
+--- a/env/ubi.c
++++ b/env/ubi.c
+@@ -100,6 +100,18 @@ static int env_ubi_save(void)
+ #endif /* CONFIG_SYS_REDUNDAND_ENVIRONMENT */
+ #endif /* CONFIG_CMD_SAVEENV */
+
++int __weak env_ubi_volume_create(const char *volume)
++{
++ struct ubi_volume *vol;
++
++ vol = ubi_find_volume((char *)volume);
++ if (vol)
++ return 0;
++
++ return ubi_create_vol((char *)volume, CONFIG_ENV_SIZE, true,
++ UBI_VOL_NUM_AUTO, false);
++}
++
+ #ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT
+ static int env_ubi_load(void)
+ {
+@@ -129,6 +141,11 @@ static int env_ubi_load(void)
+ return -EIO;
+ }
+
++ if (IS_ENABLED(CONFIG_ENV_UBI_VOLUME_CREATE)) {
++ env_ubi_volume_create(CONFIG_ENV_UBI_VOLUME);
++ env_ubi_volume_create(CONFIG_ENV_UBI_VOLUME_REDUND);
++ }
++
+ read1_fail = ubi_volume_read(CONFIG_ENV_UBI_VOLUME, (void *)tmp_env1,
+ CONFIG_ENV_SIZE);
+ if (read1_fail)
+@@ -166,6 +183,9 @@ static int env_ubi_load(void)
+ return -EIO;
+ }
+
++ if (IS_ENABLED(CONFIG_ENV_UBI_VOLUME_CREATE))
++ env_ubi_volume_create(CONFIG_ENV_UBI_VOLUME);
++
+ if (ubi_volume_read(CONFIG_ENV_UBI_VOLUME, buf, CONFIG_ENV_SIZE)) {
+ printf("\n** Unable to read env from %s:%s **\n",
+ CONFIG_ENV_UBI_PART, CONFIG_ENV_UBI_VOLUME);