[PATCH procd] utils: fix get_active_console when kernel returns multiple values
matt at traverse.com.au
Mon Jan 31 14:18:50 PST 2022
On Mon, Jan 31, 2022, at 10:58 AM, Daniel Golle wrote:
> Hi Mathew,
> On Tue, Jan 25, 2022 at 03:12:08AM +0000, Mathew McBride wrote:
> > /sys/class/tty/console/active may return multiple values on
> > kernels where framebuffer support is enabled but the system
> > is supposed to be using a serial console.
> > e.g
> > $ cat /sys/class/tty/console/active
> > tty0 ttyS0
> On BPi-R2 (which got HDMI with console) I'm seeing this:
> root at OpenWrt:~# cat /sys/class/tty/console/active
> ttyS2 tty1
Doh! Thanks for letting me know. That ruins my assumptions.
So this issue appears to be confined to platforms where the dummy framebuffer/console is loaded in the absence of a graphical console.
> While I agree that we need to somehow unify and solve this, just
> changing the current behavior will break serial console access at least
> on the targets listed above.
Fair enough, I will see if I can come up with another solution.
> So either you should suggest to change the affected target to ship
> /etc/inittab or supply console= kernel parameter, or we change all the
> other targets above (and maybe more where console= parameter originates
> from existing non-OpenWrt-built bootchain).
> Does our current behaviour (using first active console) violate any
> universal convention we should obey?
The motivation for this is to successfully detect the console(s) on systems using EFI to boot (so we don't need to create separate images just to specify a different console= and/or inittab). The original console detection patch came from this but broke certain boards when graphical support was enabled.
Systemd manages to set up consoles correctly on these systems (without console=) so it would be nice for OpenWrt/procd to do the same.
(Specifically, "standards compliant" ARM boards, see this pull that adds EFI to armvirt: https://github.com/openwrt/openwrt/pull/4996 )
I guess the best approach now may be to generate (or act as if) an inittab based on /sys/class/tty/console/active? When inittab is not present and no console= is specified, of course.
(If there was a way to detect if tty0 was a dummy from sysfs I would do that instead, but there does not appear to be)
More information about the openwrt-devel