I.MX6 Linux Qt 启动流程跟踪

时间:2020-12-26 09:21:17
/**************************************************************************
* I.MX6 Linux Qt 启动流程跟踪
* 声明:
* 1. 源代码来源MY-I.MX6;
* 2. 本文仅仅是对启动流程的解析,没有解释启动流程为什么是这样的问题。
*
* 2015-6-13 深圳 晴 南山平山村 曾剑锋
************************************************************************
*/

\\\\\\\\\\\\\
-*- 目录 -*-////////////
| 一、cat /etc/inittab
| 二、cat /etc/rc.d/rcS
| 三、cat /etc/rc.d/rc.local
| 四、cat /etc/rc.d/rc_gpu.S
| 五、cat /etc/profile
\\\\\\\\\\\\\\\\\\\
//////////////////

一、cat
/etc/inittab
# see busybox
-1.00rc2/examples/inittab for more examples
::sysinit:
/etc/rc.d/rcS # 系统启动时调用的程序1
#::respawn:
/etc/rc.d/rc_mxc.S
ttymxc0::once:
/bin/login root # 内核信息打印的串口
::sysinit:
/etc/rc.d/rc_gpu.S # 系统启动时调用的程序2
::ctrlaltdel:
/sbin/reboot
::shutdown:
/etc/rc.d/rcS stop # 关机时调用的程序
::restart:
/sbin/init # 系统重启时调用的程序

二、cat
/etc/rc.d/rcS
#
!/bin/sh
# minimal startup script, will work with msh (
this is best available in
# MMUless format).

# load the configuration information 加载配置信息,并使其生效
.
/etc/rc.d/rc.conf

# 如果没有传入第一个参数,那么就将start字符串赋给mode
# 查看inittab文件里的一下内容,就能理解这一部分:
# ::sysinit:
/etc/rc.d/rcS # 系统启动时调用的程序1
# ::sysinit:
/etc/rc.d/rc_gpu.S # 系统启动时调用的程序2
# ::shutdown:
/etc/rc.d/rcS stop # 关机时调用的程
# 如上可知,开机时不传参表示start,关机传入stop表示关机

mode
=${1:-start}
if [ $mode = "start" ]
then
services
=$cfg_services # 如果mode是start,services等于cfg_services的值
else
services
=$cfg_services_r # 如果mode是start,services等于cfg_services_r的值
fi
cfg_services
=${2:-$services} # 如果没有传入第二个参数,cfg_services等于services

# run the configured sequence
for i in $cfg_services # 迭代cfg_services
do
if [ -x /etc/rc.d/init.d/$i ] # 检查文件是否可执行
then
/etc/rc.d/init.d/$i $mode # 如果可执行,那么就执行,并传入对应的mode参数,start或stop
fi
done

if [ $# -ge 2 ] # 如果参数个数大于2,到这里也就执行完毕了,不执行下面内容
then
exit
0
fi
# show all kernel log messages # 设置内核信息输出等级
#echo
8 > /proc/sys/kernel/printk

# run rc.local
if present and executable
if [ -x /etc/rc.d/rc.local ] # 检查rc.local是否可执行
then
/etc/rc.d/rc.local $mode # 运行该脚本,跟踪该脚本
fi

三、cat
/etc/rc.d/rc.local
#
!/bin/sh
#
# This script will be executed
*after* all the other init scripts.
# You can put your own initialization stuff
in here
# 本人查看过
/usr/bin/rpm文件,不存在,所以if判断里的内容可以无视
# 当然系统运行起来之后,也没发现下面echo出来的调试信息
if [ -x "/usr/bin/rpm" -a -e "/tmp/ltib" ]
then
echo
"rebuilding rpm database"
rm
-rf /tmp/ltib
rpm
--rebuilddb
fi

# fix up permissions
# 修改
/home/user的权限
if [ -d /home/user ]
then
chown
-R user.user /home/user
fi

# 创建一些设备节点,这之后的代码没发现对程序运行有太大价值的内容

# Add nodes when running under the hypervisor and
static devices
if [ -r /sys/class/misc/fsl-hv/dev -a ! -r /dev/fsl-hv ]
then
echo
"creating hypervisor nodes"
DEVID
=`cat /sys/class/misc/fsl-hv/dev`
if [ -n "$DEVID" ]
then
MAJOR
="${DEVID%:*}"
MINOR
="${DEVID##*:}"

if [ \( "$MAJOR" -gt 0 \) -a \( "$MINOR" -gt 0 \) ]
then
rm
-f /dev/fsl-hv
mknod
/dev/fsl-hv c $MAJOR $MINOR
fi
fi
for i in 0 1 2 3 4 5 6 7
do
mknod
/dev/hvc$i c 229 $i
done
fi

# add the fm device nodes
if [ -n "$(cat /proc/devices | grep fm | sed 's/\([0-9]*\).*/\1/')" -a ! -r /dev/fm0 ]
then
echo
"creating fman device nodes"
cd
/usr/share/doc/fmd-uspace-01.01/test/
sh fm_dev_create
cd
-
fi

for i in 0 1 2; do
if [ -e /sys/class/graphics/fb$i ]; then
chmod
0666 /sys/class/graphics/fb$i/pan
fi
done

四、cat
/etc/rc.d/rc_gpu.S
#
!/bin/bash
# 获取CPU的一些信息
CPUREV
=$(cat /proc/cpuinfo | grep Revision | awk '{print $3}' | awk '{print substr($0,1,2)}')
# 设置一些变量,从变量的值来看,主要还解决不同CPU环境下的一些
# 依赖库的问题,后面内容都是为了处理这件事
FILEVG
=/usr/lib/libOpenVG.so
FILEVG3D
=/usr/lib/libOpenVG_3D.so
FILEVG355
=/usr/lib/libOpenVG_355.so
echo
4 > /sys/module/galcore/parameters/gpu3DMinClock
if [ -e $FILEVG3D ] && [ -e $FILEVG355 ]
then
if [ $CPUREV == "61" ] || [ $CPUREV == "63" ] || [ $CPUREV == "60" ] && [ -e $FILEVG ]
then
rm
-f $FILEVG
fi
if [ $CPUREV == "61" ]
then
ln
-s $FILEVG3D $FILEVG
fi
if [ $CPUREV == "63" ]
then
ln
-s $FILEVG355 $FILEVG
fi
if [ $CPUREV == "60" ]
then
ln
-s $FILEVG355 $FILEVG
fi
fi

五、cat
/etc/profile
# 设置PATH环境变量
PATH
=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin

PS1
='[\u@\h \W]\$ ' # shell中显示的提示信息格式

export PATH # 导出PATH位环境变量

alias ll
='ls -l' # 设置命令别名
alias la
='ll -a'

export PS1
='\u@\h \w$ ' # 导出一些环境变量
export PS2
='> '
export PS3
='? '
export PS4
='[$LINENO]+'

# 设置TSLIB、QT的库的相关信息

export GST_PLUGIN_PATH
=/usr/lib/fsl_mm_linux/lib/gstreamer-0.10

export TSLIB_ROOT
=/usr/local/tslib-install
export TSLIB_TSDEVICE
=/dev/input/event1
export TSLIB_CALIBFILE
=/etc/pointercal
export TSLIB_CONFFILE
=$TSLIB_ROOT/etc/ts.conf
export TSLIB_PLUGINDIR
=$TSLIB_ROOT/lib/ts
export TSLIB_FBDEVICE
=/dev/fb0
export PATH
=/usr/local/tslib-install:$PATH
export LD_LIBRARY_PATH
=/usr/local/Trolltech/QtEmbedded-4.8.5-arm/lib
export QT_QWS_FONTDIR
=/usr/local/Trolltech/QtEmbedded-4.8.5-arm/lib/fonts
export QWS_MOUSE_PROTO
=tslib:/dev/input/event1

# 查看
/etc/pointercal文件是否存在并且是正规文件
# 通过这个文件来确定是否需要来调用触摸屏矫正程序
if [ -f /etc/pointercal ];then
echo
"MXS touchscreen have calibrate!"
else
/usr/local/tslib-install/bin/ts_calibrate
fi

# 运行QT程序,传入qws参数,并置于后台运行
/qt_app/myzr -qws &