標籤:
/************************************************************************** * 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=‘[\[email protected]\h \W]\$ ‘ # shell中顯示的提示資訊格式 export PATH # 匯出PATH位環境變數 alias ll=‘ls -l‘ # 設定命令別名 alias la=‘ll -a‘ export PS1=‘\[email protected]\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 &
I.MX6 Linux Qt 啟動流程跟蹤