From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Christian Marangi <ansuelsmth@gmail.com>
Cc: Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Saravana Kannan <saravanak@google.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
Wolfram Sang <wsa+renesas@sang-engineering.com>,
linux-mtd@lists.infradead.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
Lorenzo Bianconi <lorenzo@kernel.org>,
upstream@airoha.com
Subject: Re: [PATCH 2/3] dt-bindings: mtd: Add Documentation for Airoha fixed-partitions
Date: Wed, 2 Oct 2024 10:00:06 +0200 [thread overview]
Message-ID: <20241002100006.5995fd10@xps-13> (raw)
In-Reply-To: <66fbcee8.df0a0220.2ad0cb.4f6a@mx.google.com>
Hi Christian,
> > > > > Ok probably the description isn't clear enough. The missing info that
> > > > > require this parser is the flash end.
> > > > >
> > > > > Following the example we know the size of rootfs_data and start offset
> > > > > AND we know the size of the ART partition.
> > > > >
> > > > > There might be a space in the middle unused between the rootfs_data
> > > > > partition and the art partition. What is derived is the starting offset
> > > > > of the art partition that is flash end - art partition size.
> > > > > (where flash end change and is not always the same due to how the special
> > > > > bad block managament table reserved space is handled)
> > > > >
> > > > > This is why 0xffffffff, used as a dummy offset to signal it will be parsed at
> > > > > runtime. On second tought tho maybe using this dummy offset is wrong and
> > > > > I should just have something like
> > > > >
> > > > > length = <0x300000>;
> > > > >
> > > > > Is it clear now? Sorry for any confusion.
> > > >
> > > > I'm sorry but not really. You know the end of the physical device and
> > > > the size of the ART partition, so you must know its start as well?
> > > >
> > >
> > > Before the system boot we know:
> > > - size of the ART partition
> > > - real size of the physical device (512mb... 1G... 64mb...)
> > >
> > > When the physical device is probed (nand) a special driver is loaded
> > > (before mtd parsing logic) that change the physical size of the device
> > > (mtd->size) as at the end of the nand some space is reserved for bad
> > > block management and other metadata info.
> >
> > Here you are explaining what you intend Linux to do, right? I would
> > like to understand what you are trying to solve. I dont understand why
> > you need the size change, I don't understand why you don't know the
> > start of the ART partition, I don't understand what the data you are
> > hiding contains and who uses it :-) I'm sorry, this is too unclear yet.
>
> Totally not a problem and thanks a lot for you keep asking them... More
> than happy to clear things, I'm trying to solve a problem present on
> Airoha SoC and upstreaming a correct parser for it.
>
> What I'm trying to solve:
>
> Correct access to this partition at the end of the flash in an automated
> way.
>
> The content of this partition is the usual ART partition found on lots of
> embedded devices. MAC address, wifi calibration data, serial. Usage is
> NVMEM cells and userspace with dd command to extract data from.
>
> Airoha use something also used by some mediatek SoC. They call it BMT
> and it's currently used downstream in OpenWrt and they firmware. This is
> also used in the bootloader.
>
> The usage of BMT is a custom way to handle bad blocks entirely by
> software. At the end of the flash some space is reserved where info
> about all the blocks of the flash are put. I'm not 100% sure about the
> functionality of this but it can relocate block and do magic things to
> handle bad blocks. For the scope of this change, the important info is
> that after the BMT is probed, the operation of "reserving space" is done
> by reducing the MTD flash size. So from the MTD subsystem, it does see a
> smaller flash than it actually is.
>
> The reserved space change! Across SoC or even devices but the BMT is a
> must where it's used as bootloader makes use of it and writing to it
> might confuse the bootloader corrupting data. (one block might be
> flagged as bad ad data moved, BMT driver validates his table and do
> operation)
Ok, I think that's way clearer now.
So the BMT driver does not exist in mainline Linux, but you would like
to skip this part of the MTD device to avoid smashing it. And it is in
use by the vendor Bootloader I guess?
Is it some kind of table that is written by the chip itself in order to
maintain a list of auto-replacement blocks for bad blocks? Can the size
of this table move with the use of the device? (if yes, it's
problematic, we don't want to resize MTD partitions without noticing,
it would break eg. UBI).
I believe this BMT block is going against the bad block handling in
Linux, so I really wonder how one can use both mechanisms in a system.
If the BMT layer takes "one random block" to map a corrupted one on it,
it totally defeats the current bad block model we have in MTD/UBI
and simply cannot be supported at all. Just skipping the
currently-used-for-BMT blocks sounds like a very bad idea that will
break your system, later.
Thanks,
Miquèl
next prev parent reply other threads:[~2024-10-02 8:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-25 10:13 [PATCH 0/3] mtd: Add support for Airoha partition scheme Christian Marangi
2024-09-25 10:13 ` [PATCH 1/3] of: also export of_update_property Christian Marangi
2024-09-25 10:13 ` [PATCH 2/3] dt-bindings: mtd: Add Documentation for Airoha fixed-partitions Christian Marangi
2024-09-25 11:30 ` Miquel Raynal
2024-09-25 11:35 ` Christian Marangi
2024-09-25 11:52 ` Miquel Raynal
2024-09-25 12:06 ` Christian Marangi
2024-09-30 9:48 ` Miquel Raynal
2024-09-30 10:10 ` Christian Marangi
2024-10-01 8:42 ` Miquel Raynal
2024-10-01 10:28 ` Christian Marangi
2024-10-02 8:00 ` Miquel Raynal [this message]
2024-10-16 7:33 ` Christian Marangi
2024-10-16 8:58 ` Miquel Raynal
2024-10-16 17:33 ` Andreas Gnau
2024-09-25 10:13 ` [PATCH 3/3] mtd: parser: add support for Airoha parser Christian Marangi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241002100006.5995fd10@xps-13 \
--to=miquel.raynal@bootlin.com \
--cc=ansuelsmth@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=f.fainelli@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=lorenzo@kernel.org \
--cc=richard@nod.at \
--cc=robh@kernel.org \
--cc=saravanak@google.com \
--cc=tsbogend@alpha.franken.de \
--cc=upstream@airoha.com \
--cc=vigneshr@ti.com \
--cc=wsa+renesas@sang-engineering.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).