/*************************************************************************** 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.Sttymxc0::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" ] thenservices=$cfg_services # 如果mode是start,services等于cfg_services的值elseservices=$cfg_services_r # 如果mode是start,services等于cfg_services_r的值ficfg_services=${2:-$services} # 如果没有传入第二个参数,cfg_services等于services# run the configured sequencefor i in $cfg_services # 迭代cfg_servicesdoif [ -x /etc/rc.d/init.d/$i ] # 检查文件是否可执行then /etc/rc.d/init.d/$i $mode # 如果可执行,那么就执行,并传入对应的mode参数,start或stopfi doneif [ $# -ge 2 ] # 如果参数个数大于2,到这里也就执行完毕了,不执行下面内容then exit 0fi# show all kernel log messages # 设置内核信息输出等级#echo 8 > /proc/sys/kernel/printk# run rc.local if present and executableif [ -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" ]thenecho "rebuilding rpm database"rm -rf /tmp/ltibrpm --rebuilddbfi# fix up permissions# 修改/home/user的权限if [ -d /home/user ]thenchown -R user.user /home/userfi# 创建一些设备节点,这之后的代码没发现对程序运行有太大价值的内容# Add nodes when running under the hypervisor and static devicesif [ -r /sys/class/misc/fsl-hv/dev -a ! -r /dev/fsl-hv ]thenecho "creating hypervisor nodes"DEVID=`cat /sys/class/misc/fsl-hv/dev`if [ -n "$DEVID" ]thenMAJOR="${DEVID%:*}"MINOR="${DEVID##*:}"if [ \( "$MAJOR" -gt 0 \) -a \( "$MINOR" -gt 0 \) ]thenrm -f /dev/fsl-hvmknod /dev/fsl-hv c $MAJOR $MINORfififor i in 0 1 2 3 4 5 6 7domknod /dev/hvc$i c 229 $idonefi# add the fm device nodesif [ -n "$(cat /proc/devices | grep fm | sed 's/\([0-9]*\).*/\1/')" -a ! -r /dev/fm0 ]thenecho "creating fman device nodes"cd /usr/share/doc/fmd-uspace-01.01/test/sh fm_dev_createcd -fifor i in 0 1 2; doif [ -e /sys/class/graphics/fb$i ]; thenchmod 0666 /sys/class/graphics/fb$i/panfidone四、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.soFILEVG3D=/usr/lib/libOpenVG_3D.soFILEVG355=/usr/lib/libOpenVG_355.soecho 4 > /sys/module/galcore/parameters/gpu3DMinClockif [ -e $FILEVG3D ] && [ -e $FILEVG355 ]thenif [ $CPUREV == "61" ] || [ $CPUREV == "63" ] || [ $CPUREV == "60" ] && [ -e $FILEVG ]thenrm -f $FILEVGfiif [ $CPUREV == "61" ]thenln -s $FILEVG3D $FILEVGfiif [ $CPUREV == "63" ]thenln -s $FILEVG355 $FILEVGfiif [ $CPUREV == "60" ]thenln -s $FILEVG355 $FILEVGfifi五、cat /etc/profile# 设置PATH环境变量PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/binPS1='[\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.10export TSLIB_ROOT=/usr/local/tslib-installexport 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:$PATHexport LD_LIBRARY_PATH=/usr/local/Trolltech/QtEmbedded-4.8.5-arm/libexport QT_QWS_FONTDIR=/usr/local/Trolltech/QtEmbedded-4.8.5-arm/lib/fontsexport 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 &