[PATCH] UBI: support EOF block marking end of ubinized image

Rafał Miłecki zajec5 at gmail.com
Wed Mar 23 00:58:16 PDT 2022


On 19.03.2022 04:15, Zhihao Cheng wrote:
>> While I personally think that UBI should provide *any* solution for such
>> poor bootloaders it has been stated upstream won't accept this hack.
>> There is no idea for any other / cleaner solution neither.
>>
>> For details see e-mail thread:
>> Handling ubinized image flashed on not erased flash space
>> http://lists.infradead.org/pipermail/linux-mtd/2022-March/091993.html
>> http://lists.infradead.org/pipermail/linux-mtd/2022-March/092081.html
>>
>> This patch is meant for downstream usage in projects like OpenWrt /
>> Buildroot / Yocto / foo.
> Does 'downstream' mean this patch won't be applied to mainline? Eventhough, I don't think this modification is sutiable for common scenarios. The UBI image provided by poor bootloader does not follow the standard UBI format defined in [1], and linux kernel should have recognized bad image and rejected attaching rather than tries fixing bad image.

Yes, downstream means carrying on that patch in projects using Linux
kernel (I named few). They have to patch kernel with it before compiling
it.

Upstream means simply:
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

I'm not sure what do you mean by "sutiable". Linux doesn't really offer
for raw NAND flashes anything except UBI. So that's the only choice.

Of course those poor bootloaders don't "follow" UBI on-disk format. We
all know that. The problem is they are there. On millions of devices.

People out of your utopia still need a way to use UBI with them. All
crazy ideas like flashing intermediate firmware just to flash a target
one properly (with UBI proper flash setup) just don't work in real world


> Maybe there are other better solutions? Such as,
> 1. For 'EOF' ended image scenarios, DIY an userspace tool to convert bad UBI image to valid UBI image.

How does it make life easier for anyone?

1. Every distro still has to carry on such user-space tool
2. We don't have any intermediate rootfs so it needs to go to initramfs
3. That may confict with other initramfs usages
4. It requires scanning blocks twice (in user-space and then in kernel)

I don't see any gain from moving that task from kernel to user-space.


> 2. Erasing/Formatting the whole mtd partition. (BTW, why does booloader only format part of mtd partition? What will the left space in mtd partition be used for?)

Don't ask me. Ask ASUS, Linksys, Netgear, TP-Link, whoever. I think you
can even try Huawei - they seem to have some Broadcom and Ralink based
hw that does the same.



More information about the linux-mtd mailing list