* [PATCH 0/3] Add support for ubi environment to auto create volumes
@ 2026-04-17 2:35 Weijie Gao
2026-04-17 2:35 ` [PATCH 1/3] cmd: ubi: expose more APIs to public Weijie Gao
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Weijie Gao @ 2026-04-17 2:35 UTC (permalink / raw)
To: u-boot; +Cc: GSS_MTK_Uboot_upstream, Tom Rini, Marek Vasut, Weijie Gao
This patch series expose more ubi helpers to allow the ubi environment to
create ubi env volumes if not exist.
Weijie Gao (3):
cmd: ubi: expose more APIs to public
cmd: ubi: allow creating volume with all free spaces in ubi_create_vol
env: ubi: add support to create environment volume if it does not
exist
cmd/ubi.c | 16 ++++++++++------
env/Kconfig | 6 ++++++
env/ubi.c | 20 ++++++++++++++++++++
include/ubi_uboot.h | 5 +++++
4 files changed, 41 insertions(+), 6 deletions(-)
--
2.45.2
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/3] cmd: ubi: expose more APIs to public
2026-04-17 2:35 [PATCH 0/3] Add support for ubi environment to auto create volumes Weijie Gao
@ 2026-04-17 2:35 ` Weijie Gao
2026-04-18 0:47 ` Simon Glass
2026-04-17 2:35 ` [PATCH 2/3] cmd: ubi: allow creating volume with all free spaces in ubi_create_vol Weijie Gao
2026-04-17 2:35 ` [PATCH 3/3] env: ubi: add support to create environment volume if it does not exist Weijie Gao
2 siblings, 1 reply; 12+ messages in thread
From: Weijie Gao @ 2026-04-17 2:35 UTC (permalink / raw)
To: u-boot; +Cc: GSS_MTK_Uboot_upstream, Tom Rini, Marek Vasut, Weijie Gao
Export ubi_detach/ubi_create_vol/ubi_find_volume/ubi_remove_vol to
public for better ubi manipulation used by other modules.
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
---
cmd/ubi.c | 10 +++++-----
include/ubi_uboot.h | 5 +++++
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/cmd/ubi.c b/cmd/ubi.c
index 93de6f3aea2..e7fd7165457 100644
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -213,8 +213,8 @@ bad:
return err;
}
-static int ubi_create_vol(char *volume, int64_t size, int dynamic, int vol_id,
- bool skipcheck)
+int ubi_create_vol(char *volume, int64_t size, int dynamic, int vol_id,
+ bool skipcheck)
{
struct ubi_mkvol_req req;
int err;
@@ -247,7 +247,7 @@ static int ubi_create_vol(char *volume, int64_t size, int dynamic, int vol_id,
return ubi_create_volume(ubi, &req);
}
-static struct ubi_volume *ubi_find_volume(char *volume)
+struct ubi_volume *ubi_find_volume(char *volume)
{
struct ubi_volume *vol;
int i;
@@ -262,7 +262,7 @@ static struct ubi_volume *ubi_find_volume(char *volume)
return NULL;
}
-static int ubi_remove_vol(char *volume)
+int ubi_remove_vol(char *volume)
{
int err, reserved_pebs, i;
struct ubi_volume *vol;
@@ -635,7 +635,7 @@ static int ubi_set_skip_check(char *volume, bool skip_check)
return ubi_change_vtbl_record(ubi, vol->vol_id, &vtbl_rec);
}
-static int ubi_detach(void)
+int ubi_detach(void)
{
#ifdef CONFIG_CMD_UBIFS
/*
diff --git a/include/ubi_uboot.h b/include/ubi_uboot.h
index ea0db69c72a..36b5b69dbfd 100644
--- a/include/ubi_uboot.h
+++ b/include/ubi_uboot.h
@@ -47,9 +47,14 @@
extern int ubi_mtd_param_parse(const char *val, struct kernel_param *kp);
extern int ubi_init(void);
extern void ubi_exit(void);
+extern int ubi_detach(void);
extern int ubi_part(char *part_name, const char *vid_header_offset);
extern int ubi_volume_write(char *volume, void *buf, loff_t offset, size_t size);
extern int ubi_volume_read(char *volume, char *buf, loff_t offset, size_t size);
+extern int ubi_create_vol(char *volume, int64_t size, int dynamic, int vol_id,
+ bool skipcheck);
+extern struct ubi_volume *ubi_find_volume(char *volume);
+extern int ubi_remove_vol(char *volume);
extern struct ubi_device *ubi_devices[];
int cmd_ubifs_mount(char *vol_name);
--
2.45.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/3] cmd: ubi: allow creating volume with all free spaces in ubi_create_vol
2026-04-17 2:35 [PATCH 0/3] Add support for ubi environment to auto create volumes Weijie Gao
2026-04-17 2:35 ` [PATCH 1/3] cmd: ubi: expose more APIs to public Weijie Gao
@ 2026-04-17 2:35 ` Weijie Gao
2026-04-18 0:47 ` Simon Glass
2026-04-17 2:35 ` [PATCH 3/3] env: ubi: add support to create environment volume if it does not exist Weijie Gao
2 siblings, 1 reply; 12+ messages in thread
From: Weijie Gao @ 2026-04-17 2:35 UTC (permalink / raw)
To: u-boot; +Cc: GSS_MTK_Uboot_upstream, Tom Rini, Marek Vasut, Weijie Gao
Although the ubi command itself supports creating volume with all
free spaces, the api ubi_create_vol() does not.
Since negative size in invalid, this patch replaces negative size
with all free space size in ubi_create_vol().
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
---
cmd/ubi.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/cmd/ubi.c b/cmd/ubi.c
index e7fd7165457..3a1d47d1942 100644
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -226,7 +226,11 @@ int ubi_create_vol(char *volume, int64_t size, int dynamic, int vol_id,
req.vol_id = vol_id;
req.alignment = 1;
- req.bytes = size;
+
+ if (size < 0)
+ req.bytes = ubi->avail_pebs * ubi->leb_size;
+ else
+ req.bytes = size;
strcpy(req.name, volume);
req.name_len = strlen(volume);
--
2.45.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/3] env: ubi: add support to create environment volume if it does not exist
2026-04-17 2:35 [PATCH 0/3] Add support for ubi environment to auto create volumes Weijie Gao
2026-04-17 2:35 ` [PATCH 1/3] cmd: ubi: expose more APIs to public Weijie Gao
2026-04-17 2:35 ` [PATCH 2/3] cmd: ubi: allow creating volume with all free spaces in ubi_create_vol Weijie Gao
@ 2026-04-17 2:35 ` Weijie Gao
2026-04-18 0:47 ` Simon Glass
2 siblings, 1 reply; 12+ messages in thread
From: Weijie Gao @ 2026-04-17 2:35 UTC (permalink / raw)
To: u-boot; +Cc: GSS_MTK_Uboot_upstream, Tom Rini, Marek Vasut, Weijie Gao
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(+)
diff --git a/env/Kconfig b/env/Kconfig
index 7abd82ab6f3..cec1bf0bb11 100644
--- a/env/Kconfig
+++ b/env/Kconfig
@@ -716,6 +716,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
diff --git a/env/ubi.c b/env/ubi.c
index e9865b45ebc..bbd86adf176 100644
--- a/env/ubi.c
+++ b/env/ubi.c
@@ -103,6 +103,18 @@ static int env_ubi_save(void)
}
#endif /* CONFIG_ENV_REDUNDANT */
+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_ENV_REDUNDANT
static int env_ubi_load(void)
{
@@ -132,6 +144,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, 0,
CONFIG_ENV_SIZE);
if (read1_fail)
@@ -169,6 +186,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, 0, CONFIG_ENV_SIZE)) {
printf("\n** Unable to read env from %s:%s **\n",
CONFIG_ENV_UBI_PART, CONFIG_ENV_UBI_VOLUME);
--
2.45.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] cmd: ubi: expose more APIs to public
2026-04-17 2:35 ` [PATCH 1/3] cmd: ubi: expose more APIs to public Weijie Gao
@ 2026-04-18 0:47 ` Simon Glass
2026-04-20 7:18 ` Weijie Gao
0 siblings, 1 reply; 12+ messages in thread
From: Simon Glass @ 2026-04-18 0:47 UTC (permalink / raw)
To: weijie.gao; +Cc: u-boot
Hi Weijie,
On 2026-04-17T02:35:14, Weijie Gao <weijie.gao@mediatek.com> wrote:
> cmd: ubi: expose more APIs to public
>
> Export ubi_detach/ubi_create_vol/ubi_find_volume/ubi_remove_vol to
> public for better ubi manipulation used by other modules.
>
> Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
>
> cmd/ubi.c | 10 +++++-----
> include/ubi_uboot.h | 5 +++++
> 2 files changed, 10 insertions(+), 5 deletions(-)
> diff --git a/include/ubi_uboot.h b/include/ubi_uboot.h
> @@ -47,9 +47,14 @@
> +extern int ubi_create_vol(char *volume, int64_t size, int dynamic, int vol_id,
> + bool skipcheck);
> +extern struct ubi_volume *ubi_find_volume(char *volume);
> +extern int ubi_remove_vol(char *volume);
The volume parameter should be const char * since these functions do
not modify the string. In patch 3/3, env_ubi_volume_create() receives
a const char * and has to cast away const when calling these
functions. Please can you fix the signatures in both cmd/ubi.c and
ubi_uboot.h to take const char *volume.
Regards,
Simon
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] cmd: ubi: allow creating volume with all free spaces in ubi_create_vol
2026-04-17 2:35 ` [PATCH 2/3] cmd: ubi: allow creating volume with all free spaces in ubi_create_vol Weijie Gao
@ 2026-04-18 0:47 ` Simon Glass
2026-04-20 7:25 ` Weijie Gao
0 siblings, 1 reply; 12+ messages in thread
From: Simon Glass @ 2026-04-18 0:47 UTC (permalink / raw)
To: weijie.gao; +Cc: u-boot
Hi Weijie,
On 2026-04-17T02:35:14, Weijie Gao <weijie.gao@mediatek.com> wrote:
> cmd: ubi: allow creating volume with all free spaces in ubi_create_vol
>
> Although the ubi command itself supports creating volume with all
> free spaces, the api ubi_create_vol() does not.
>
> Since negative size in invalid, this patch replaces negative size
is invalid
> with all free space size in ubi_create_vol().
>
> Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
>
> cmd/ubi.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
> diff --git a/cmd/ubi.c b/cmd/ubi.c
> @@ -226,7 +226,11 @@ int ubi_create_vol(char *volume, int64_t size, int dynamic, int vol_id,
> + if (size < 0)
> + req.bytes = ubi->avail_pebs * ubi->leb_size;
> + else
> + req.bytes = size;
When size is negative, the printf() below still prints the original
negative size rather than the computed req.bytes
Regards,
Simon
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] env: ubi: add support to create environment volume if it does not exist
2026-04-17 2:35 ` [PATCH 3/3] env: ubi: add support to create environment volume if it does not exist Weijie Gao
@ 2026-04-18 0:47 ` Simon Glass
2026-04-20 7:27 ` Weijie Gao
0 siblings, 1 reply; 12+ messages in thread
From: Simon Glass @ 2026-04-18 0:47 UTC (permalink / raw)
To: weijie.gao; +Cc: u-boot
Hi Weijie,
On 2026-04-17T02:35:14, Weijie Gao <weijie.gao@mediatek.com> wrote:
> 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(+)
Could you beef up the Kconfig help text for ENV_UBI_VOLUME_CREATE -
e.g. mention when users might want to enable this, such as on first
boot of a fresh device where the UBI partition exists but no volumes
have been created yet.
> diff --git a/env/ubi.c b/env/ubi.c
> @@ -105,6 +105,18 @@ static int env_ubi_save(void)
> +int __weak env_ubi_volume_create(const char *volume)
> +{
> + struct ubi_volume *vol;
> +
> + vol = ubi_find_volume((char *)volume);
Does this function need to be weak?
ubi_find_volume() prints "Volume %s not found!" when the volume does
not exist. Since the whole point of this function is to handle missing
volumes, this message will appear every time auto-creation is used.
Please can you either add a quiet variant of ubi_find_volume(), or
suppress the message here?
> diff --git a/env/ubi.c b/env/ubi.c
> @@ -134,6 +146,11 @@ static int env_ubi_load(void)
> + 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);
> + }
The return value from env_ubi_volume_create() is not checked. If
volume creation fails (e.g. no space left), the subsequent
ubi_volume_read() will also fail, but the error message will not
indicate the underlying problem. Please can you check the return value
and print an appropriate message if creation fails?
Regards,
Simon
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] cmd: ubi: expose more APIs to public
2026-04-18 0:47 ` Simon Glass
@ 2026-04-20 7:18 ` Weijie Gao
2026-04-20 19:32 ` Simon Glass
0 siblings, 1 reply; 12+ messages in thread
From: Weijie Gao @ 2026-04-20 7:18 UTC (permalink / raw)
To: Simon Glass; +Cc: u-boot
On Sat, 2026-04-18 at 12:47 +1200, Simon Glass wrote:
> Hi Weijie,
>
> On 2026-04-17T02:35:14, Weijie Gao <weijie.gao@mediatek.com> wrote:
> > cmd: ubi: expose more APIs to public
> >
> > Export ubi_detach/ubi_create_vol/ubi_find_volume/ubi_remove_vol to
> > public for better ubi manipulation used by other modules.
> >
> > Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
> >
> > cmd/ubi.c | 10 +++++-----
> > include/ubi_uboot.h | 5 +++++
> > 2 files changed, 10 insertions(+), 5 deletions(-)
> > diff --git a/include/ubi_uboot.h b/include/ubi_uboot.h
> > @@ -47,9 +47,14 @@
> > +extern int ubi_create_vol(char *volume, int64_t size, int dynamic,
> > int vol_id,
> > + bool skipcheck);
> > +extern struct ubi_volume *ubi_find_volume(char *volume);
> > +extern int ubi_remove_vol(char *volume);
>
> The volume parameter should be const char * since these functions do
> not modify the string. In patch 3/3, env_ubi_volume_create() receives
> a const char * and has to cast away const when calling these
> functions. Please can you fix the signatures in both cmd/ubi.c and
> ubi_uboot.h to take const char *volume.
OK. We need another patch to change all existing functions with char *
to const char *.
>
> Regards,
> Simon
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] cmd: ubi: allow creating volume with all free spaces in ubi_create_vol
2026-04-18 0:47 ` Simon Glass
@ 2026-04-20 7:25 ` Weijie Gao
2026-04-20 19:32 ` Simon Glass
0 siblings, 1 reply; 12+ messages in thread
From: Weijie Gao @ 2026-04-20 7:25 UTC (permalink / raw)
To: Simon Glass; +Cc: u-boot
On Sat, 2026-04-18 at 12:47 +1200, Simon Glass wrote:
> Hi Weijie,
>
> On 2026-04-17T02:35:14, Weijie Gao <weijie.gao@mediatek.com> wrote:
> > cmd: ubi: allow creating volume with all free spaces in
> > ubi_create_vol
> >
> > Although the ubi command itself supports creating volume with all
> > free spaces, the api ubi_create_vol() does not.
> >
> > Since negative size in invalid, this patch replaces negative size
>
> is invalid
>
> > with all free space size in ubi_create_vol().
> >
> > Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
> >
> > cmd/ubi.c | 6 +++++-
> > 1 file changed, 5 insertions(+), 1 deletion(-)
> > diff --git a/cmd/ubi.c b/cmd/ubi.c
> > @@ -226,7 +226,11 @@ int ubi_create_vol(char *volume, int64_t size,
> > int dynamic, int vol_id,
> > + if (size < 0)
> > + req.bytes = ubi->avail_pebs * ubi->leb_size;
> > + else
> > + req.bytes = size;
>
> When size is negative, the printf() below still prints the original
> negative size rather than the computed req.bytes
OK. As you mentioned in patch 3/3, I think maybe we can move these
printf logs to the command's main function to avoid logs being printed
every time these API functions are called.
>
> Regards,
> Simon
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/3] env: ubi: add support to create environment volume if it does not exist
2026-04-18 0:47 ` Simon Glass
@ 2026-04-20 7:27 ` Weijie Gao
0 siblings, 0 replies; 12+ messages in thread
From: Weijie Gao @ 2026-04-20 7:27 UTC (permalink / raw)
To: Simon Glass; +Cc: u-boot
On Sat, 2026-04-18 at 12:47 +1200, Simon Glass wrote:
> Hi Weijie,
>
> On 2026-04-17T02:35:14, Weijie Gao <weijie.gao@mediatek.com> wrote:
> > 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(+)
>
> Could you beef up the Kconfig help text for ENV_UBI_VOLUME_CREATE -
> e.g. mention when users might want to enable this, such as on first
> boot of a fresh device where the UBI partition exists but no volumes
> have been created yet.
OK.
>
> > diff --git a/env/ubi.c b/env/ubi.c
> > @@ -105,6 +105,18 @@ static int env_ubi_save(void)
> > +int __weak env_ubi_volume_create(const char *volume)
> > +{
> > + struct ubi_volume *vol;
> > +
> > + vol = ubi_find_volume((char *)volume);
>
> Does this function need to be weak?
Is unnecessary at all. I added in my early test.
>
> ubi_find_volume() prints "Volume %s not found!" when the volume does
> not exist. Since the whole point of this function is to handle
> missing
> volumes, this message will appear every time auto-creation is used.
> Please can you either add a quiet variant of ubi_find_volume(), or
> suppress the message here?
As I replied in 2/3, I'll move these messages into the main command
function.
>
> > diff --git a/env/ubi.c b/env/ubi.c
> > @@ -134,6 +146,11 @@ static int env_ubi_load(void)
> > + 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);
> > + }
>
> The return value from env_ubi_volume_create() is not checked. If
> volume creation fails (e.g. no space left), the subsequent
> ubi_volume_read() will also fail, but the error message will not
> indicate the underlying problem. Please can you check the return
> value
> and print an appropriate message if creation fails?
OK.
>
> Regards,
> Simon
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] cmd: ubi: expose more APIs to public
2026-04-20 7:18 ` Weijie Gao
@ 2026-04-20 19:32 ` Simon Glass
0 siblings, 0 replies; 12+ messages in thread
From: Simon Glass @ 2026-04-20 19:32 UTC (permalink / raw)
To: Weijie Gao; +Cc: u-boot
Hi Weijie,
On Mon, 20 Apr 2026 at 19:19, Weijie Gao <weijie.gao@mediatek.com> wrote:
>
> On Sat, 2026-04-18 at 12:47 +1200, Simon Glass wrote:
> > Hi Weijie,
> >
> > On 2026-04-17T02:35:14, Weijie Gao <weijie.gao@mediatek.com> wrote:
> > > cmd: ubi: expose more APIs to public
> > >
> > > Export ubi_detach/ubi_create_vol/ubi_find_volume/ubi_remove_vol to
> > > public for better ubi manipulation used by other modules.
> > >
> > > Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
> > >
> > > cmd/ubi.c | 10 +++++-----
> > > include/ubi_uboot.h | 5 +++++
> > > 2 files changed, 10 insertions(+), 5 deletions(-)
> > > diff --git a/include/ubi_uboot.h b/include/ubi_uboot.h
> > > @@ -47,9 +47,14 @@
> > > +extern int ubi_create_vol(char *volume, int64_t size, int dynamic,
> > > int vol_id,
> > > + bool skipcheck);
> > > +extern struct ubi_volume *ubi_find_volume(char *volume);
> > > +extern int ubi_remove_vol(char *volume);
> >
> > The volume parameter should be const char * since these functions do
> > not modify the string. In patch 3/3, env_ubi_volume_create() receives
> > a const char * and has to cast away const when calling these
> > functions. Please can you fix the signatures in both cmd/ubi.c and
> > ubi_uboot.h to take const char *volume.
>
> OK. We need another patch to change all existing functions with char *
> to const char *.
Yes that sounds like a good idea.
Regards,
Simon
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] cmd: ubi: allow creating volume with all free spaces in ubi_create_vol
2026-04-20 7:25 ` Weijie Gao
@ 2026-04-20 19:32 ` Simon Glass
0 siblings, 0 replies; 12+ messages in thread
From: Simon Glass @ 2026-04-20 19:32 UTC (permalink / raw)
To: Weijie Gao; +Cc: u-boot
Hi Weijie,
On Mon, 20 Apr 2026 at 19:25, Weijie Gao <weijie.gao@mediatek.com> wrote:
>
> On Sat, 2026-04-18 at 12:47 +1200, Simon Glass wrote:
> > Hi Weijie,
> >
> > On 2026-04-17T02:35:14, Weijie Gao <weijie.gao@mediatek.com> wrote:
> > > cmd: ubi: allow creating volume with all free spaces in
> > > ubi_create_vol
> > >
> > > Although the ubi command itself supports creating volume with all
> > > free spaces, the api ubi_create_vol() does not.
> > >
> > > Since negative size in invalid, this patch replaces negative size
> >
> > is invalid
> >
> > > with all free space size in ubi_create_vol().
> > >
> > > Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
> > >
> > > cmd/ubi.c | 6 +++++-
> > > 1 file changed, 5 insertions(+), 1 deletion(-)
> > > diff --git a/cmd/ubi.c b/cmd/ubi.c
> > > @@ -226,7 +226,11 @@ int ubi_create_vol(char *volume, int64_t size,
> > > int dynamic, int vol_id,
> > > + if (size < 0)
> > > + req.bytes = ubi->avail_pebs * ubi->leb_size;
> > > + else
> > > + req.bytes = size;
> >
> > When size is negative, the printf() below still prints the original
> > negative size rather than the computed req.bytes
>
> OK. As you mentioned in patch 3/3, I think maybe we can move these
> printf logs to the command's main function to avoid logs being printed
> every time these API functions are called.
Yes, good idea.
Regards,
Simon
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2026-04-20 19:32 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-17 2:35 [PATCH 0/3] Add support for ubi environment to auto create volumes Weijie Gao
2026-04-17 2:35 ` [PATCH 1/3] cmd: ubi: expose more APIs to public Weijie Gao
2026-04-18 0:47 ` Simon Glass
2026-04-20 7:18 ` Weijie Gao
2026-04-20 19:32 ` Simon Glass
2026-04-17 2:35 ` [PATCH 2/3] cmd: ubi: allow creating volume with all free spaces in ubi_create_vol Weijie Gao
2026-04-18 0:47 ` Simon Glass
2026-04-20 7:25 ` Weijie Gao
2026-04-20 19:32 ` Simon Glass
2026-04-17 2:35 ` [PATCH 3/3] env: ubi: add support to create environment volume if it does not exist Weijie Gao
2026-04-18 0:47 ` Simon Glass
2026-04-20 7:27 ` Weijie Gao
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.