All of lore.kernel.org
 help / color / mirror / Atom feed
* spi-nand: how to store environment with badblock handling in qspi nand
@ 2022-06-25  8:10 Kegl Rohit
  2022-06-26  0:02 ` Daniel Golle
  0 siblings, 1 reply; 3+ messages in thread
From: Kegl Rohit @ 2022-06-25  8:10 UTC (permalink / raw)
  To: u-boot

Hello!

Is it possible to store the environment inside a mtd partition when
using a single qspi nand chip as storage?
CONFIG_MTD_SPI_NAND=y

The idea is to separate the NAND into two system A/B.

1.Solution:
mtdparts_nand0=2m(uboot),16m(system)

system will be an ubifs containing env+env_redundant +
kernel_a+dtb_a+rootfs_a + kernel_b+dtb_b+rootfs_b.
Uboot will read the env and load and start the selected a or b system.

With this solution ubifs will do all badblock handling. But system a
and b are not really isolated. All will be lost if the one ubifs gets
bad.

2.Solution:
mtdparts_nand0=2m(uboot),512k(env),512k(env_redundant),8m(system_a),8m(system_b)

system_a/b will be ubifs containing kernel+dtb+rootfs.
An environment outside the ubifs is needed to switch between system_a/b.

But I could not find a suitable option to store the environment
outside the ubi mtd partitions when using MTD_SPI_NAND.

Here are my findings:
CONFIG_ENV_IS_IN_NAND is used for the parallel NAND interface and wont
work with MTD_SPI_NAND.
CONFIG_ENV_IS_IN_SPI_FLASH is used for spi NOR flash and does not
handle badblocks => also wont work.
CONFIG_ENV_IS_IN_FLASH another flash subsystem??

Bad block handling seems to be only implemented for
CONFIG_ENV_IS_IN_NAND using CONFIG_ENV_RANGE.
Setting CONFIG_ENV_RANGE > CONFIG_ENV_SIZE will create tailing space
for skipping bad blocks.

CONFIG_ENV_IS_IN_UBI will do badblock handling, but it would be a huge
overhead to create an extra ubifs mtd partition only for the
environment.


Has anyone already created the A/B system approach with the mtd spi
nand interface and can give me some input?
Am I missing something and there is a much simpler solution?
Or would it be fine to use one big ubifs because ubi is reliable enough?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: spi-nand: how to store environment with badblock handling in qspi nand
  2022-06-25  8:10 spi-nand: how to store environment with badblock handling in qspi nand Kegl Rohit
@ 2022-06-26  0:02 ` Daniel Golle
  2022-06-27  8:23   ` Kegl Rohit
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Golle @ 2022-06-26  0:02 UTC (permalink / raw)
  To: Kegl Rohit; +Cc: u-boot

On Sat, Jun 25, 2022 at 10:10:08AM +0200, Kegl Rohit wrote:
> Hello!
> 
> Is it possible to store the environment inside a mtd partition when
> using a single qspi nand chip as storage?
> CONFIG_MTD_SPI_NAND=y
> 
> The idea is to separate the NAND into two system A/B.
> [...]
> 
> CONFIG_ENV_IS_IN_UBI will do badblock handling, but it would be a huge
> overhead to create an extra ubifs mtd partition only for the
> environment.

Actually it's not. The overhead of allocating a UBI volume is minimal
and typical logical block sizes are small enough to not be complete
overkill for something like a U-Boot environment.

> 
> 
> Has anyone already created the A/B system approach with the mtd spi
> nand interface and can give me some input?

Maybe see here for inspiration:
https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=package/boot/uboot-mediatek/patches/410-add-linksys-e8450.patch;h=fde679f3863ccf2e22a3e1fd299963b66041a0b9;hb=HEAD#l403


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: spi-nand: how to store environment with badblock handling in qspi nand
  2022-06-26  0:02 ` Daniel Golle
@ 2022-06-27  8:23   ` Kegl Rohit
  0 siblings, 0 replies; 3+ messages in thread
From: Kegl Rohit @ 2022-06-27  8:23 UTC (permalink / raw)
  To: Daniel Golle; +Cc: u-boot

On Sun, Jun 26, 2022 at 2:02 AM Daniel Golle <daniel@makrotopia.org> wrote:
>
> On Sat, Jun 25, 2022 at 10:10:08AM +0200, Kegl Rohit wrote:
> > Hello!
> >
> > Is it possible to store the environment inside a mtd partition when
> > using a single qspi nand chip as storage?
> > CONFIG_MTD_SPI_NAND=y
> >
> > The idea is to separate the NAND into two system A/B.
> > [...]
> >
> > CONFIG_ENV_IS_IN_UBI will do badblock handling, but it would be a huge
> > overhead to create an extra ubifs mtd partition only for the
> > environment.
>
> Actually it's not. The overhead of allocating a UBI volume is minimal
> and typical logical block sizes are small enough to not be complete
> overkill for something like a U-Boot environment.
>

For 1.Solution it is not a big overhead.
But if i want to isolate a/b completely e.g.

3.Solution:
mtdparts_nand0=2m(uboot),1m(env_ubi),8m(system_a),8m(system_b)
system_a/b ubifs is completely isolated and environment and
environment_redundant stored in addtional env_ubi.
It looks like ubi needs at least 2mb @ 128kb eraseblocks for itself.
So a lot of wasted space for e.g. 128kb environment.


> > Has anyone already created the A/B system approach with the mtd spi
> > nand interface and can give me some input?
>
> Maybe see here for inspiration:
> https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=package/boot/uboot-mediatek/patches/410-add-linksys-e8450.patch;h=fde679f3863ccf2e22a3e1fd299963b66041a0b9;hb=HEAD#l403
>
This seems to match my 1.Solution. system_a/b volumes are in same ubi
mtd partition and are not really isolated.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-27  8:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-25  8:10 spi-nand: how to store environment with badblock handling in qspi nand Kegl Rohit
2022-06-26  0:02 ` Daniel Golle
2022-06-27  8:23   ` Kegl Rohit

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.