电子说
随便看看
启动系统后板子上的LED灯就开始闪烁了,具体是什么灯呢,这个还不知道,正常有LED设备的话可以查看LED的所代表的行为,但是经过查找一番,没找到LED设备,那么就先看看有什么任务吧
[root@milkv]/sys/class/gpio# ps
PID USER COMMAND
1 root init
2 root [kthreadd]
3 root [rcu_gp]
4 root [rcu_par_gp]
7 root [kworker/u2:0-ev]
8 root [mm_percpu_wq]
9 root [ksoftirqd/0]
10 root [rcu_preempt]
11 root [kdevtmpfs]
12 root [rcu_tasks_kthre]
13 root [oom_reaper]
14 root [writeback]
15 root [kcompactd0]
24 root [kblockd]
25 root [watchdogd]
27 root [kworker/0:1H-kb]
28 root [rpciod]
29 root [kworker/u3:0]
30 root [xprtiod]
31 root [cfg80211]
32 root [kswapd0]
33 root [nfsiod]
34 root [stmmac_wq]
35 root [kworker/u2:1]
68 root [irq/43-cviusb-o]
69 root [irq/44-cd-gpio-]
70 root [sdhci]
71 root [irq/21-mmc0]
73 root [ion_system_heap]
74 root [mmc_complete]
79 root [jbd2/mmcblk0p2-]
80 root [ext4-rsv-conver]
96 root /sbin/syslogd -n
100 root /sbin/klogd -n
128 root [kworker/0:3-eve]
146 root /usr/sbin/dropbear -R
151 nobody /usr/sbin/dnsmasq
161 root [cvitask_isp_pre]
162 root [cvitask_isp_bla]
163 root [cvitask_isp_err]
165 root [cvitask_vpss_0]
166 root [cvitask_vpss_1]
168 root [gdc_work]
173 root [cvitask_tpu_wor]
178 root {S99user} /bin/sh /etc/init.d/S99user start
183 root [kworker/0:2H]
187 root -sh
268 root /usr/sbin/dropbear -R
282 root -sh
2390 root [kworker/0:0-eve]
3097 root [kworker/0:1-eve]
3650 root ps
3651 root sleep 0.5
在里面看到了一个S99user的启动脚本,那么看看内容是什么呢?
[root@milkv]/sys/class/gpio# cat /etc/init.d/S99user
#!/bin/sh
${CVI_SHOPTS}
#
# Start firmware
#
export USERDATAPATH=/mnt/data/
export SYSTEMPATH=/mnt/system/
case "$1" in
start)
echo "init mpp system..."
if [ -d $SYSTEMPATH/ko ]; then
sh $SYSTEMPATH/ko/loadsystemko.sh
fi
echo "Starting app..."
if [ -f $SYSTEMPATH/blink.sh ]; then
. $SYSTEMPATH/blink.sh &
fi
if [ -f $SYSTEMPATH/rndis.sh ]; then
. $SYSTEMPATH/rndis.sh &
fi
if [ -f $USERDATAPATH/auto.sh ]; then
usleep 30000
. $USERDATAPATH/auto.sh &
exit 1
fi
if [ -f $SYSTEMPATH/auto.sh ]; then
usleep 30000
. $SYSTEMPATH/auto.sh &
fi
;;
stop)
;;
restart|reload)
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?
通过查看脚本可以看到/mnt/data/
下面会检测auto.sh,/mnt/system/
下面会检测ko/loadsystemko.sh,blink.sh,rndis.sh,auto.sh
分别看看这些文件都有什么东西:
[root@milkv]/mnt# ls
system
[root@milkv]/mnt# cat system/ko/loadsystemko.sh
#!/bin/sh
${CVI_SHOPTS}
#
# Start to insert kernel modules
#
insmod /mnt/system/ko/cv180x_sys.ko
insmod /mnt/system/ko/cv180x_base.ko
insmod /mnt/system/ko/cv180x_rtos_cmdqu.ko
insmod /mnt/system/ko/cv180x_fast_image.ko
insmod /mnt/system/ko/cvi_mipi_rx.ko
insmod /mnt/system/ko/snsr_i2c.ko
insmod /mnt/system/ko/cv180x_vi.ko
insmod /mnt/system/ko/cv180x_vpss.ko
insmod /mnt/system/ko/cv180x_dwa.ko
#insmod /mnt/system/ko/cv180x_vo.ko
#insmod /mnt/system/ko/cv180x_mipi_tx.ko
insmod /mnt/system/ko/cv180x_rgn.ko
#insmod /mnt/system/ko/cv180x_wdt.ko
insmod /mnt/system/ko/cv180x_thermal.ko
insmod /mnt/system/ko/cv180x_clock_cooling.ko
insmod /mnt/system/ko/cv180x_tpu.ko
insmod /mnt/system/ko/cv180x_vcodec.ko
insmod /mnt/system/ko/cv180x_jpeg.ko
insmod /mnt/system/ko/cvi_vc_driver.ko MaxVencChnNum=9 MaxVdecChnNum=9
#insmod /mnt/system/ko/cv180x_rtc.ko
#insmod /mnt/system/ko/cv180x_ive.ko
echo 3 > /proc/sys/vm/drop_caches
dmesg -n 4
#usb hub control
#/etc/uhubon.sh host
exit $?
[root@milkv]/mnt# cat system/blink.sh
#!/bin/sh
LED_GPIO=/sys/class/gpio/gpio440
if test -d $LED_GPIO; then
echo "GPIO440 already exported"
else
echo 440 > /sys/class/gpio/export
fi
echo out > $LED_GPIO/direction
while true; do
echo 0 > $LED_GPIO/value
sleep 0.5
echo 1 > $LED_GPIO/value
sleep 0.5
done
[root@milkv]/mnt# cat system/rndis.sh
#!/bin/sh
/etc/uhubon.sh device > > /tmp/rndis.log 2 >&1
/etc/run_usb.sh probe rndis > > /tmp/rndis.log 2 >&1
/etc/run_usb.sh start rndis > > /tmp/rndis.log 2 >&1
sleep 0.5
ifconfig usb0 192.168.42.1
count=`ps | grep dnsmasq | grep -v grep | wc -l`
if [ ${count} -lt 1 ] ;then
echo "/etc/init.d/S80dnsmasq start" > > /tmp/rndis.log 2 >&1
/etc/init.d/S80dnsmasq start > > /tmp/rndis.log 2 >&1
fi
[root@milkv]/mnt# cat system/auto.sh
#!/bin/sh
${CVI_SHOPTS}
export LD_LIBRARY_PATH="/lib:/lib/3rd:/lib/arm-linux-gnueabihf:/usr/lib:/usr/local/lib:/mnt/system/lib:/mnt/system/usr/lib:/mnt/system/usr/lib/3rd:/mnt/data/lib"
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/mnt/system/usr/bin:/mnt/system/usr/sbin:/mnt/data/bin:/mnt/data/sbin"
if [ ! -f "/tmp/evb_init" ];then
echo 1 > /tmp/evb_init
else
exit 1
fi
GPIO
通过查看脚本看到了LED是通过脚本来控制的功能是周期1S的闪烁,RNDIS是在脚本里面设置的IP地址,直接设置为192.168.42.1
关于LED引脚,原理图上面写的是XGPIOC[24]
而教程里面是用GPIOx(x=0,1,2…)来表示的,通过测试GPIOA=GPIO0,GPIOB=GPIO1以此类推,GPIOC[24]=416+24=440,与脚本的引脚号一致,所以把blink.sh脚本干掉之后手动控制一下试试,发现输出结果符合预期,但是输出模式好像不能读取电平,读到的电平一直是0。
[root@milkv]/sys/class/gpio# ls
export gpiochip352 gpiochip384 gpiochip416 gpiochip448 gpiochip480 unexport
[root@milkv]/sys/class/gpio# echo 440 > export
[root@milkv]/sys/class/gpio# ls
export gpio440 gpiochip352 gpiochip384 gpiochip416 gpiochip448 gpiochip480 unexport
[root@milkv]/sys/class/gpio# cd gpio440/
[root@milkv]/sys/devices/platform/3022000.gpio/gpiochip2/gpio/gpio440# ls
active_low device direction edge subsystem uevent value
[root@milkv]/sys/devices/platform/3022000.gpio/gpiochip2/gpio/gpio440# cat direction
in
[root@milkv]/sys/devices/platform/3022000.gpio/gpiochip2/gpio/gpio440# echo out >direction
[root@milkv]/sys/devices/platform/3022000.gpio/gpiochip2/gpio/gpio440# cat value
0
[root@milkv]/sys/devices/platform/3022000.gpio/gpiochip2/gpio/gpio440# echo 1 > value
[root@milkv]/sys/devices/platform/3022000.gpio/gpiochip2/gpio/gpio440# cat value
0
[root@milkv]/sys/devices/platform/3022000.gpio/gpiochip2/gpio/gpio440# echo 0 > value
[root@milkv]/sys/devices/platform/3022000.gpio/gpiochip2/gpio/gpio440# cat value
0
[root@milkv]/sys/devices/platform/3022000.gpio/gpiochip2/gpio/gpio440#
然后测试其他引脚,比如说GPIO14(GPIOA[14])和GPIO15(GPIOA[15]),即494和495
结果与LED引脚不一样,电平不受控制,原因未知,可能是受其他模块影响吧,换GPIO6(GPIOA[23])和GPIO17(GPIOA[24]),即503和504试试,结果是符合预期的。
至此GPIO的测试就完成了
审核编辑:汤梓红
全部0条评论
快来发表一下你的评论吧 !