Xilinx zynq 自动登陆

版权声明:转载请关注我的公众号-青儿创客基地 https://blog.csdn.net/Zhu_Zhu_2009/article/details/81357395

原理

查看/etc/inittab文件

# /etc/inittab: init(8) configuration.
# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $

# The default runlevel.
id:5:initdefault:

# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS

# What to do in single-user mode.
~~:S:wait:/sbin/sulogin

# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.

l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# Normally not reached, but fallthrough in case of emergency.
z6:6:respawn:/sbin/sulogin
PS0:12345:respawn:/bin/start_getty 115200 ttyPS0
hvc0:12345:respawn:/bin/start_getty 115200 hvc0
# /sbin/getty invocations for the runlevels.
#
# The "id" field MUST be the same as the last
# characters of the device (after "tty").
#
# Format:
#  <id>:<runlevels>:<action>:<process>
#

1:12345:respawn:/sbin/getty 38400 tty1

注意其中的PS0:12345:respawn:/bin/start_getty 115200 ttyPS0,调用的是bin目录的start_getty,start_getty是一个脚本,内容如下:

#!/bin/sh
if [ -f /bin/autologin ] && [ -c /dev/$2 ]
then
    /sbin/getty -l /bin/autologin -n -L $1 $2
elif [ -c /dev/$2 ]
then
    /sbin/getty -L $1 $2
fi

可以看到如果存在autologin程序,则调用autologin,这和petalinux2015.2中已经不一样了,2015.2还需要手动自启动autologin,在17.4里已经不需要了,直接把autologin放入bin目录即可。autologin内容如下,

#include <stdio.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
    execlp("login", "login", "-f", "root", 0);
    return 0;
}

用2015.2的自启动方式,会输出如下错误信息:

-sh: cannot set terminal process group (2019): Inappropriate ioctl for device
-sh: no job control in this shell

猜你喜欢

转载自blog.csdn.net/Zhu_Zhu_2009/article/details/81357395