How to disable console on serial when needed ? - Linux

This is a discussion on How to disable console on serial when needed ? - Linux ; Hi I want to disable console on serial when I need to use the serial port to control some serial device. But I still need to use it for log on when these serial device are not in use. So ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: How to disable console on serial when needed ?

  1. How to disable console on serial when needed ?

    Hi
    I want to disable console on serial when I need to use the serial port
    to control some serial device.
    But I still need to use it for log on when these serial device are not
    in use. So I can't just remove the console on serial support from kernel at
    compile time.
    And what I need is the ability to detach / attach console to serial port
    after bootup.

    Is there any possible way to achieve this?

    Thanks.

    Raymond



  2. Re: How to disable console on serial when needed ?

    Raymond wrote:
    > Hi
    > I want to disable console on serial when I need to use the serial port
    > to control some serial device.
    > But I still need to use it for log on when these serial device are not
    > in use. So I can't just remove the console on serial support from kernel at
    > compile time.
    > And what I need is the ability to detach / attach console to serialport
    > after bootup.
    >
    > Is there any possible way to achieve this?


    First you must make sure noone is logged in on the serial line.
    Then all you need to do is to disable (comment) the corresponding entry
    in /etc/inittab and tell init about this ("/sbin/telinit q").
    Then there will be no more process (of the getty family) on that serial
    line and you can re-use it for your device. When you have reconnected
    the modem/terminal/whatever, just re-enable (un-comment) the entry in
    /etc/inittab and "/sbin/telinit q".

    --
    Josef Möllers (Pinguinpfleger bei FSC)
    If failure had no penalty success would not be a prize
    -- T. Pratchett


  3. Re: How to disable console on serial when needed ?

    Josef Moellers wrote:
    >Raymond wrote:
    >> Hi
    >> I want to disable console on serial when I need to use the serial port
    >> to control some serial device.
    >> But I still need to use it for log on when these serial device are not
    >> in use. So I can't just remove the console on serial support from kernel at
    >> compile time.
    >> And what I need is the ability to detach / attach console to serial port
    >> after bootup.
    >> Is there any possible way to achieve this?

    >
    >First you must make sure noone is logged in on the serial line.
    >Then all you need to do is to disable (comment) the
    >corresponding entry in /etc/inittab and tell init about this
    >("/sbin/telinit q").
    >Then there will be no more process (of the getty family) on that
    >serial line and you can re-use it for your device. When you have
    >reconnected the modem/terminal/whatever, just re-enable
    >(un-comment) the entry in /etc/inittab and "/sbin/telinit q".


    It would be better to use a different runlevel, rather than edit
    /etc/inittab each time. Each distribution is free to chose its
    own configuration for runlevels, so which runlevel to choose
    depends on the distribution. Below are the comments from a
    Slackware /etc/inittab file as an example (which makes it very
    obvious that with Slackware the runlevel to choose is 2, because
    it is unused and configured the same as the default).

    # These are the default runlevels in Slackware:
    # 0 = halt
    # 1 = single user mode
    # 2 = unused (but configured the same as runlevel 3)
    # 3 = multiuser mode (default Slackware runlevel)
    # 4 = X11 with KDM/GDM/XDM (session managers)
    # 5 = unused (but configured the same as runlevel 3)
    # 6 = reboot

    At some other place in /etc/inittab will be the entry for
    the serial line, which might look something like this:

    s1:12345:respawn:/sbin/agetty -L ttyS0 9600 vt100

    The trick is to remove runlevel 2 from that entry, making it
    look like this,

    s1:1345:respawn:/sbin/agetty -L ttyS0 9600 vt100

    The default is to boot into runlevel 3, and this line causes
    /sbin/agtty to be invoked as shown. To use /dev/ttyS0 for other
    purposes, switch to runlevel 2. If a user is logged in, they
    will *not* be logged out and the serial port will not be
    available. But when that user does log out, instead of being
    prepped for another login, the serial port will remain idle and
    be available. At any time runlevel 3 is restored, the port will
    again be available for a login.

    --
    Floyd L. Davidson
    Ukpeagvik (Barrow, Alaska) floyd@apaflo.com

  4. Re: How to disable console on serial when needed ?


    "Floyd L. Davidson" ??????:87bqlxcyzk.fld@apaflo.com...
    > Josef Moellers wrote:
    >>Raymond wrote:
    >>> Hi
    >>> I want to disable console on serial when I need to use the serial
    >>> port
    >>> to control some serial device.
    >>> But I still need to use it for log on when these serial device are
    >>> not
    >>> in use. So I can't just remove the console on serial support from kernel
    >>> at
    >>> compile time.
    >>> And what I need is the ability to detach / attach console to serial
    >>> port
    >>> after bootup.
    >>> Is there any possible way to achieve this?

    >>
    >>First you must make sure noone is logged in on the serial line.
    >>Then all you need to do is to disable (comment) the
    >>corresponding entry in /etc/inittab and tell init about this
    >>("/sbin/telinit q").
    >>Then there will be no more process (of the getty family) on that
    >>serial line and you can re-use it for your device. When you have
    >>reconnected the modem/terminal/whatever, just re-enable
    >>(un-comment) the entry in /etc/inittab and "/sbin/telinit q".

    >
    > It would be better to use a different runlevel, rather than edit
    > /etc/inittab each time. Each distribution is free to chose its
    > own configuration for runlevels, so which runlevel to choose
    > depends on the distribution. Below are the comments from a
    > Slackware /etc/inittab file as an example (which makes it very
    > obvious that with Slackware the runlevel to choose is 2, because
    > it is unused and configured the same as the default).
    >
    > # These are the default runlevels in Slackware:
    > # 0 = halt
    > # 1 = single user mode
    > # 2 = unused (but configured the same as runlevel 3)
    > # 3 = multiuser mode (default Slackware runlevel)
    > # 4 = X11 with KDM/GDM/XDM (session managers)
    > # 5 = unused (but configured the same as runlevel 3)
    > # 6 = reboot
    >
    > At some other place in /etc/inittab will be the entry for
    > the serial line, which might look something like this:
    >
    > s1:12345:respawn:/sbin/agetty -L ttyS0 9600 vt100
    >
    > The trick is to remove runlevel 2 from that entry, making it
    > look like this,
    >
    > s1:1345:respawn:/sbin/agetty -L ttyS0 9600 vt100
    >
    > The default is to boot into runlevel 3, and this line causes
    > /sbin/agtty to be invoked as shown. To use /dev/ttyS0 for other
    > purposes, switch to runlevel 2. If a user is logged in, they
    > will *not* be logged out and the serial port will not be
    > available. But when that user does log out, instead of being
    > prepped for another login, the serial port will remain idle and
    > be available. At any time runlevel 3 is restored, the port will
    > again be available for a login.
    >
    > --
    > Floyd L. Davidson
    > Ukpeagvik (Barrow, Alaska) floyd@apaflo.com


    Thanks for the advise.

    However , I might not get my situation clear enough.
    My platform is an Arm embeded board.
    And the /Dev/Console is not a link to first VT but with dev node major 5
    minor 1

    And in the inittab there are no getty to direct console to ttyS0
    infact I even do not need a inittab.

    instead in the kernel's main.c , there are something like :

    static int init(void * unused)
    {
    lock_kernel();
    do_basic_setup();

    prepare_namespace();

    /*
    * Ok, we have completed the initial bootup, and
    * we're essentially up and running. Get rid of the
    * initmem segments and start the user-mode stuff..
    */
    free_initmem();
    unlock_kernel();

    if (open("/dev/console", O_RDWR, 0) < 0)
    printk("Warning: unable to open an initial console.\n");

    (void) dup(0);
    (void) dup(0);
    ..
    ..
    ..

    }

    So , What can I do now ?

    Raymond http://rgbbones.googlepages.com




+ Reply to Thread