diff mbox

[OpenWrt-Devel] procd/inittab with a delayed console

Message ID C89EFD3CD56F64468D3D206D683A8D2203B889D8@ldam-msx2.fugro-nl.local
State RFC
Headers show

Commit Message

Michel Stam Jan. 9, 2015, 12:33 p.m. UTC
Hello Owen,

I was wondering, is the kernel driver for your console not placed in
/etc/modules-boot.d ?

/sbin/init executes procd, but prior to doing this executes kmodloader
to load all modules in /etc/modules-boot.d. If your module is mentioned
in this directory, this should load your console driver, thus making it
available before procd checks /etc/inittab.

This, to me, seems the most logical solution, as consoles should be
available to the init process early on during boot, and not hot-plugged
in afterwards. Do you agree?

To put modules in /etc/modules-boot.d, make sure that their
KernelPackage definition contains:
AUTOLOAD:=$(call AutoLoad,<NUM>,<MODULE>,1) 

Where <NUM> is the load order and <MODULE> is the name of your kernel
module (or modules). The presence of the ,1 argument indicates whether
the module is placed in /etc/modules-boot.d or /etc/modules.d.

Kind regards,

Michel Stam
Embedded System Engineer
Hi,

I'm not sure if this is a bug with procd's implementation of inittab or 
if I'm just doing something wrong in my inittab. However, we have a 
board that has multiple serial console ports, one of which relies on a 
kernel module and procd refuses to start a console on the second port. 
What seems to be happening is that procd loads inittab before the kernel 
modules are loaded, therefore the tty device doesn't exist yet and the 
check for dev_exist() fails and procd never forks a worker for that console.

I was able to fix it for my board with the following patch, but I'm not 
sure if this is would be the entire fix for the problem since it seems 
like fork_worker() should be a little more graceful in handling tty 
devices that don't exist yet.

Any thoughts or suggestions on better ways to fix this?

Thanks,
Owen

--

Comments

Karl Palsson Jan. 9, 2015, 5:51 p.m. UTC | #1
"Stam, Michel [FINT]" <M.Stam@fugro.nl> wrote:
> This, to me, seems the most logical solution, as consoles should be
> available to the init process early on during boot, and not hot-plugged
> in afterwards. Do you agree?


Well, I don't.   What about a usb serial port?  I'd like to plug in the
usb cable, providing vbus to power up a cp210x, which then becomes a new
/dev/ttyUSBxxx and I'd like inittab to offer me a console there.  It's not there at boot though...

Sincerely,
Karl P
Michael Heimpold Jan. 9, 2015, 6:33 p.m. UTC | #2
Am Freitag, 9. Januar 2015, 17:51:48 schrieb Karl Palsson:
> 
> "Stam, Michel [FINT]" <M.Stam@fugro.nl> wrote:
> > This, to me, seems the most logical solution, as consoles should be
> > available to the init process early on during boot, and not hot-plugged
> > in afterwards. Do you agree?
> 
> 
> Well, I don't.   What about a usb serial port?  I'd like to plug in the
> usb cable, providing vbus to power up a cp210x, which then becomes a new
> /dev/ttyUSBxxx and I'd like inittab to offer me a console there.  It's not there at boot though...

+1
Owen Kirby Jan. 9, 2015, 9:15 p.m. UTC | #3
On 15-01-09 09:51 AM, Karl Palsson wrote:
> "Stam, Michel [FINT]" <M.Stam@fugro.nl> wrote:
>> This, to me, seems the most logical solution, as consoles should be
>> available to the init process early on during boot, and not hot-plugged
>> in afterwards. Do you agree?
>
> Well, I don't.   What about a usb serial port?  I'd like to plug in the
> usb cable, providing vbus to power up a cp210x, which then becomes a new
> /dev/ttyUSBxxx and I'd like inittab to offer me a console there.  It's not there at boot though...
>
This is actually very close to what we're doing on this board, it has 
two console ports: one
is a UART which the bootloader and kernel are using, and a second 
console port which is really
just a USB device controller. The UART lines are a pain to get to 
without a soldering iron so
under AA and BB we would just connect a laptop into the USB port and get 
a console on the router.

However, it's not quite real hotplugging since /dev/ttyGS0 is present 
whenever the driver is
loaded, just that it depends on the USB gadget drivers which get loaded 
a little too late for
inittab to find it. Hotplugging does sound like a cool feature though.

Cheers,
Owen
Owen Kirby Jan. 9, 2015, 9:51 p.m. UTC | #4
Michel,

Thanks for the suggestion, this particular driver was being loaded from
/etc/modules.d, however even when I moved it into /etc/modules-boot.d it
still doesn't create /dev/ttyGS0 in time for procd to start the console.

I'll try fiddling around with the load order to see if I can get it
working without my changes to procd

Thanks,
Owen

On 15-01-09 04:33 AM, Stam, Michel [FINT] wrote:
> Hello Owen,
>
> I was wondering, is the kernel driver for your console not placed in
> /etc/modules-boot.d ?
>
> /sbin/init executes procd, but prior to doing this executes kmodloader
> to load all modules in /etc/modules-boot.d. If your module is mentioned
> in this directory, this should load your console driver, thus making it
> available before procd checks /etc/inittab.
>
> This, to me, seems the most logical solution, as consoles should be
> available to the init process early on during boot, and not hot-plugged
> in afterwards. Do you agree?
>
> To put modules in /etc/modules-boot.d, make sure that their
> KernelPackage definition contains:
> AUTOLOAD:=$(call AutoLoad,<NUM>,<MODULE>,1)
>
> Where <NUM> is the load order and <MODULE> is the name of your kernel
> module (or modules). The presence of the ,1 argument indicates whether
> the module is placed in /etc/modules-boot.d or /etc/modules.d.
>
> Kind regards,
>
> Michel Stam
> Embedded System Engineer
diff mbox

Patch

diff --git a/inittab.c b/inittab.c
index 2efbf4d..7b12e10 100644
--- a/inittab.c
+++ b/inittab.c
@@ -161,7 +161,7 @@  static void askfirst(struct init_action *a)
  {
         int i;

-       if (!dev_exist(a->id) || (console && !strcmp(console, a->id))) {
+       if (console && !strcmp(console, a->id)) {
                 DEBUG(4, "Skipping %s\n", a->id);
                 return;
         }