2017-04-23 20:40 GMT+02:00 Bjørn Mork <bj...@mork.no>:
Hello,

Many devices make use of "dual firmware" configurations, splitting the
available flash and allowing two complete and independent installations.
This works fine for devices like the Linksys WRT1900AC etc, where the
boot loader make sure the kernel command line "root=" parameter matches
the booted kernel.

It does not work so well with ar71xx devices like the Ubiquiti UniFi AC
Pro. The original firmware use this layout:

dev:    size   erasesize  name
mtd0: 00060000 00010000 "u-boot"
mtd1: 00010000 00010000 "u-boot-env"
mtd2: 00790000 00010000 "kernel0"
mtd3: 00790000 00010000 "kernel1"
mtd4: 00020000 00010000 "bs"
mtd5: 00040000 00010000 "cfg"
mtd6: 00010000 00010000 "EEPROM"


The current LEDE images configure this as:
  MTDPARTS = 
spi0.0:384k(u-boot)ro,64k(u-boot-env)ro,7744k(firmware),7744k(ubnt-airos)ro,128k(bs)ro,256k(cfg)ro,64k(EEPROM)ro


Note that "kernel0" is statically mapped to "firmware", and that
"kernel1" (or "ubnt-airos") is made read-only.  This sort of works as
long as LEDE is installed on "kernel0". But LEDE/OpenWrt does its magic
partition splitting based of the "firmware" partifion name.  And it will
do this even if the currently booting LEDE kernel is located on
"ubnt-airos"/"kernel1".

Due to limited understanding of how the Ubiquiti U-Boot selects between
"kernel0" and "kernel1", there are instructions out there telling users
to try to install LEDE on both "kernel0" and "kernel1".  But what
happens if the boot loader is actually loading the "kernel1" image? We
will then have a system with the kernel loaded from "kernel1" but the
rootfs loaded from "kernel0".  This is bad.  When sysupgrading, the
image on "kernel0" (aka "firmare") is replaced, But the boot loader will
still continue to load the old LEDE kernel from "kernel1".  If you are
lucky, it will boot successfully using the new rootfs.  You can then use
the mtd-rw package to make "ubnt-airos" writeable and copy the new
kernel there.  Extremely confusing and unfriendly to users...

This should be fixed somehow.  But I don't know how.  The best would be
to make the kernel dynamically figure out which of the partitions it
booted from and then force the rootfs there.  But I don't know if this
can be done without the help of the boot loader?

Hey Bjørn,

I had a similar problem with the dual image feature of brnboot in lantiq. It resulted in the following two patches:

https://git.lede-project.org/d7438ce3152e2e0dc1678dcb24ca050dbc2733c8
https://git.lede-project.org/60ac4852745c69ae13a770dc343b648925b73ca2

Since lantiq uses the device tree it is a device tree focused solution. It is for sure not the holy grial in terms of reusability and there might be more elegant ways to do it. But it might give you an idea.

As there is no sysupgrade support for the board at all, I never had to think about ways to change the active partition bit from userspace. But as far as I understand your mail, replicating the dual boot feature in LEDE isn't your primary objective.

Mathias

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev

Reply via email to