public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: valentio@free.fr
To: "Rafał Miłecki" <zajec5@gmail.com>
Cc: OpenWrt Development List <openwrt-devel@lists.openwrt.org>,
	 MTD Maling List <linux-mtd@lists.infradead.org>
Subject: Re: Identifying UBI volume instance / storing UBI volume metadata
Date: Thu, 9 Dec 2021 21:17:00 +0100 (CET)	[thread overview]
Message-ID: <740398666.171888898.1639081020251.JavaMail.root@zimbra59-e10.priv.proxad.net> (raw)
In-Reply-To: <CACna6rwRtP-_SoAZVV0ZjFAcWQucRWVoZ0bxSZrFtDFW2McyYw@mail.gmail.com>

Hello Rafał,

How about storing the squashfs into the rootfs ubi volume (as a bare file), start with an initramfs appended to the kernel and mount the root file with loopback block dev. The RW overlay part would be stored directly in the ubifs. (All modifications to the root image file would go in the overlay, so impossible to break the image)

This way, when you flash a new firmware, everything gets wiped, and you can factory reset by rm the RW directory.

It diverges quite a bit from OpenWRT usual way though.

Regards,

--
Olivier

----- Mail original -----
> De: "Rafał Miłecki" <zajec5@gmail.com>
> À: "MTD Maling List" <linux-mtd@lists.infradead.org>
> Cc: "OpenWrt Development List" <openwrt-devel@lists.openwrt.org>
> Envoyé: Jeudi 9 Décembre 2021 14:22:30
> Objet: Identifying UBI volume instance / storing UBI volume metadata
> 
> Hi,
> 
> I'm Linux developer involved in OpenWrt & buildroot projects. I work
> on building firmware images for home routers but I need to work with
> existing designs. I don't work for Broadcom (or any other
> manufacturer) and so I can't change how firmware images are handled
> by
> original software.
> 
> I'm dealing right now with BCM4908 platform that uses UBI and I need
> some help.
> 
> By Broadcom's design BCM4908 uses two relevant UBI volumes:
> 1. bootfs
> 2. rootfs
> 
> Every firmware file (accepted by bootloader & original firmware UI)
> contains two images: bootfs (with kernel & DTBs) and rootfs. Flashing
> firmware (through bootloader of original UI) is a process of simply
> writing firmware-contained "bootfs" and "rootfs" images to
> corresponding UBI volumes.
> 
> 
> My problem is making OpenWrt's design fit that BCM4908 case. OpenWrt
> uses two *rootfs* volumes:
> 1. rootfs: squashfs RO
> 2. overlay: ubifs overlay
> 
> As you can see "overlay" needs to be created by OpenWrt's user space.
> It can't be part of flashed firmware file.
> 
> My problem is /linking/ "overlay" with currently running firmware.
> Let
> m explain:
> Whenever a new flashing happens the OLD "overlay" needs to be
> recognized and wiped.
> It's required to make sure newly flashed firmware doesn't use non-own
> data.
> 
> 
> My ideas I have for solving that:
> 
> 1. Getting "bootfs" / "rootfs" volume per-flashing unique number and
> writing it in "overlay" ubifs. Then wipe "overlay" on mismatch.
> Unfortunately I can't see anything flashing-specific number in UBI
> volume header.
> Image sequence does never change in my case as UBI doesn't get
> reformatted.
> I'm not sure if sqnum is unique but it seems it can change anyway
> when
> UBI needs to handle with flash wearing.
> 
> 2. Generating random number and writing it in some metadata of RO
> "bootfs" or "rootfs" AND in "overlay" ubifs. Then wipe "overlay" on
> mismatch.
> That I think would require adding a custom field in the
> "ubi_vtbl_record" struct. I'm not sure if upstream UBI can be
> extended
> like that and I don't want such heavy downstream (OpenWrt) hacks.
> 
> 
> Any adivces, please?
> 
> --
> Rafał
> 
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
> 

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2021-12-09 20:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-09 13:22 Identifying UBI volume instance / storing UBI volume metadata Rafał Miłecki
2021-12-09 20:17 ` valentio [this message]
     [not found] ` <48BBA9D3-3DFB-4666-9FC5-6D4431486314@free.fr>
2021-12-09 22:14   ` Rafał Miłecki

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=740398666.171888898.1639081020251.JavaMail.root@zimbra59-e10.priv.proxad.net \
    --to=valentio@free.fr \
    --cc=linux-mtd@lists.infradead.org \
    --cc=openwrt-devel@lists.openwrt.org \
    --cc=zajec5@gmail.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