[PATCH] mtd: parsers: trx: Rewrite partition parsing

Linus Walleij linus.walleij at linaro.org
Mon Oct 17 04:50:13 PDT 2022


On Mon, Oct 17, 2022 at 7:34 AM Rafał Miłecki <zajec5 at gmail.com> wrote:

> You're trying to workaround mtd write limitation by hacking mtd
> partition. TRX header is NOT a part of kernel image. It should not be
> part of the "linux" MTD partition.

OK

> > 2. Scan for several TRX headers
> >
> > Currently only the first flash block is scanned for a TRX
> > header, but several flashes have multiple TRX headers
> > each with up to 3 partitions.
>
> That's because it's a TRX parser. It's meant to parse TRX container.
> Just that.
(...)
> Let's keep things simple. Let TRX parser just parse TRX. Use another
> parser to deal with your specific flash space layout.

OK maybe that should be elsewhere like a subpartition.

> So please just use/write a proper parser for your device flash space.
> Make it register "firmware" (or similar) MTD partition for actual TRX
> content. Then let TRX parser do its job.

But what about this part of the present code, which is actually
the most problematic:

     u64 next_part_offset = (i < curr_part - 1) ?
                      parts[i + 1].offset : mtd->size;

This mtd->size is what really makes my UBI partition unmountable.

The way I solved it was to scan ahead for UBI magic to determine how
big the UBI partition is.

The "length" field in the TRX header clearly cannot be trusted.

Yours,
Linus Walleij



More information about the linux-mtd mailing list