[OpenWrt-Devel] ARM: Overriding Specific bootargs

Jeff Kletsky lede at allycomm.com
Fri Feb 22 09:24:31 PST 2019


I could use some guidance to either a solution or an approach to
wresting the OEM bootloader args into an "OpenWrt-compatible" form.

(ARM; ipq40xx, in particular)

TL;DR

     What's the "best" way to override `root=ubi0:ubifs` from the
     bootloader to `root=/dev/ubiblock0_0` or otherwise make the
     OpenWrt kernel boot without changing the U-Boot environment?

     and/or

     How can I configure an OpenWrt build to have the kernel be able to
     boot with `root=ubi0:ubifs` (and not break everything that might
     expect the UBI volume be named `rootfs`)?


While I could control the U-Boot environment from an installed OpenWrt
Instance, that doesn't seem like it could provide a "serial-less"
OEM-to-OpenWrt transition.

That the device (Linksys EA8300) is a dual-firmware device and could
be booting from either partition, at least as far as I can tell, makes
a hard-coded kernel command line an unsuitable approach.


What I'm looking for is how to get from the information provided by
the bootloader about which partition is "active" into the kernel's
command line so that it can mount the proper root.

 From the OEM U-Boot:

     init=/sbin/init rootfstype=ubifs ubi.mtd=NN,2048 root=ubi0:ubifs
     rootwait rw

where NN is 11 or 13, depending on selected firmware version.


What my current build is looking for:

     ubi.mtd=NN root=/dev/ubiblock0_0



Apparently, for ARM architectures, "the bootloader is always
right" [1][2][3], adding additional challenges.

Using chosen/bootargs was confirmed to be "ignored" if the bootloader
provided bootargs.



Using chosen/bootargs-append didn't help as the result still tries to
boot from ubi0:ubifs

     init=/sbin/init rootfstype=ubifs ubi.mtd=11,2048 root=ubi0:ubifs
     rootwait rw root=/dev/ubiblock0_0 clk_ignore_unused



Testing from the boot loader with

     ubi.mtd=NN root=ubi0:rootfs

didn't boot, as apparently the kernel isn't finding the UBI volume by
name, at least as I have it configured.



I've looked at a few of the ARM Kconfig options as a "quick hack", but
none seemed to be able to get the "right" bootargs to the kernel:

* ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND
* CMDLINE_EXTEND
* CONFIG_MANGLE_BOOTARGS

This kind of "heavy handed" approach has problems with impacting other
devices on the same target, or maintenance problems as there doesn't
seem to be a way to "patch" the kernel .config for a single device.



I found, looked at, and tried

target/linux/ipq806x/patches-4.14/0067-generic-Mangle-bootloader-s-kernel-arguments.patch

which provides

* ARM_ATAG_DTB_COMPAT_CMDLINE_FROM_BOOTLOADER

but it extracts a number from the `root=` argument from the bootloader
command line and doesn't *remove* the `root=` argument.

(The three variants of this patch are all similar in function.)



=====

I can see a couple ways forward with this that allow end users to
install/revert OpenWrt without cracking the case and installing a
serial connection:

* Modify the UBI bundle to change the name of the volume from "rootfs"
   to "ubifs" (and all kernel and downstream changes needed)

* Consider the task of adding arg /removal/ to something like
   "Mangle-bootloader-s-kernel-arguments.patch" (which would allow
   "replacement" from chosen/bootargs-append)


Suggestions of the path to explore first, or other approaches, are welcome


Jeff


=====

DTS using `append-rootblock` in `master`
from `fgrep -r append-rootblock target`:

armada-385-linksys-venom.dts   append-rootblock = "root=/dev/mtdblock"
qcom-ipq8065-nbg6817.dts       append-rootblock = "root=/dev/mmcblk0p";
qcom-ipq8064-ea8500.dts        append-rootblock = "ubi.mtd="


<https://openwrt.org/toh/linksys/linksys_ea6350_v3>
is not directly applicable, as its U-Boot environment has the "right" root=

     init=/sbin/init rootfstype=squashfs
     ubi.mtd=11,2048 ubi.block=0,0 root=/dev/ubiblock0_0 rootwait ro


=====

[1] 
<https://stackoverflow.com/questions/48801998/passing-bootargs-via-chosen-node-in-device-tree-not-working-for-beaglebone-black>

[2] 
<https://lists.linaro.org/pipermail/linaro-dev/2011-February/002860.html>

[3] arch/arm/boot/compressed/atags_to_fdt.c




More information about the openwrt-devel mailing list