33、给华美A100刷固件
給HAME A100刷固件
目的:
1. 給HAME A100刷固件
2. 配置上UVC驅(qū)動(dòng)
3. 修改內(nèi)核自帶的UVC驅(qū)動(dòng),使其支持我們自制的二合一攝像頭
4. 移植mjpg-streamer
5. 實(shí)現(xiàn)開機(jī)自啟動(dòng)、熱拔插功能
便攜的無(wú)線監(jiān)控設(shè)備 = 路由器(HAME A100) + USB攝像頭(二合一攝像頭) + 手機(jī)
HAME A100:
CPU: RT5350
FLASH: 8M SPI FLASH
SDRAM: 32M
固件:
可以理解為我們自己的內(nèi)核和文件系統(tǒng)
一,環(huán)境的搭建
a,解壓100ask_toolchain.bz2:
tar xjvf 100ask_toolchain.bz2
b,安裝工具連:
cd toolchain/
sudo tar jxf buildroot-gcc342.tar.bz2 -C /opt
c,安裝內(nèi)核壓縮工具:
cd lzma-4.32.0beta5
./configure
make
sudo make install
d,安裝rootfs工具:linux 2.6
cd ..
cd mksquash_lzma-3.2
make
sudo make install
二,配置與編譯固件
tar xjvf 100ask.bz2
cd 5350_source/
vim .config
-- CONFIG_CROSS_COMPILER_PATH="/opt/buildroot-gcc342/bin"
make clean
make
結(jié)果:
flash_100ask_IP_Camera_debug_V1.0.4.bin
2.1 配置上UVC驅(qū)動(dòng)
Device Drivers --->
Multimedia devices --->
<*> Video For Linux
Video Capture Adapters --->
<*> USB Video Class (UVC)
問(wèn):“/dev/video0”該設(shè)備節(jié)點(diǎn)是誰(shuí)創(chuàng)建的?怎么取消掉?
答:
1.肯定是通過(guò)運(yùn)行腳步中的mknod這個(gè)命令來(lái)創(chuàng)建的。
通過(guò)分析內(nèi)核的啟動(dòng)流程,發(fā)現(xiàn)internet.sh是我們要
找的腳步,然后在該腳步中發(fā)現(xiàn)了如下命令:
mknod /dev/video0 c 81 0
2. 要取消掉video0這個(gè)設(shè)備節(jié)點(diǎn),只需將該行注釋掉即可。
2.2 修改UVC驅(qū)動(dòng)
三,燒寫固件
1. 連接好串口,并搭建好相應(yīng)的環(huán)境后,啟動(dòng)路由器
Please choose the operation:
1: Load system code to SDRAM via TFTP.
2: Load system code then write to Flash via TFTP.
3: Boot system code via Flash (default).
4: Entr boot command line interface.
7: Load Boot Loader code then write to Flash via Serial.
9: Load Boot Loader code then write to Flash via TFTP
2. 選擇如上選項(xiàng)的1;
Please Input new ones /or Ctrl-C to discard
Input device IP (192.168.1.155) ==:192.168.1.155 // 設(shè)備IP,與服務(wù)器IP同一個(gè)網(wǎng)段
Input server IP (192.168.1.105) ==:192.168.1.105 // 服務(wù)器IP
Input Linux Kernel filename (flash_100ask_IP_Camera_debug_V1.0.4.bin) ==:flash_100ask_IP_Camera_debug_V1.0.4.bin // 固件名稱
四,移植mjpg-streamer
1. 安裝交叉編譯器
vim /etc//environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/buildroot-gcc342/bin"
sudo reboot
mipsel-linux-gcc -v
2. 交叉編譯libjpeg
tar xzvf libjpeg-turbo-1.2.1.tar.gz
cd libjpeg-turbo-1.2.1
mkdir tmp
./configure --prefix=/work/mjpg_streamer/libjpeg-turbo-1.2.1/tmp/ --host=mipsel-linux
make
make install
cp *so* /work/hame_a100/5350_source/romfs/lib -d
3. 交叉編譯mjpg-streamer
tar xzvf mjpg-streamer-r63.tar.gz
cd mjpg-streamer-r63/
修改所有的Makefile
--(1) 將 CC=gcc 修改為 CC=mipsel-linux-gcc
--(2) 修改plugins/input_uvc/Makfile
a.將
CFLAGS += -O2 -DLINUX -D_GNU_SOURCE -Wall -shared -fPIC
改為
CFLAGS += -O2 -DLINUX -D_GNU_SOURCE -Wall -shared -fPIC -I /work/luyou/5350_source/linux2.6.21.x/include -I /work/mjpg_streamer/libjpeg-turbo-1.2.1/tmp/include
b.將
input_uvc.so: $(OTHER_HEADERS) input_uvc.c v4l2uvc.lo jpeg_utils.lo dynctrl.lo
$(CC) $(CFLAGS) -ljpeg -o $@ input_uvc.c v4l2uvc.lo jpeg_utils.lo dynctrl.lo
改為
input_uvc.so: $(OTHER_HEADERS) input_uvc.c v4l2uvc.lo jpeg_utils.lo dynctrl.lo
$(CC) $(CFLAGS) -ljpeg -L /work/mjpg_streamer/libjpeg-turbo-1.2.1/tmp/lib -o $@ input_uvc.c v4l2uvc.lo jpeg_utils.lo dynctrl.lo
make
cp *so* /work/luyou/5350_source/romfs/lib -d
cp mjpg_streamer /work/luyou/5350_source/romfs/bin/
4. 測(cè)試
1)
二合一攝像頭:
mjpg_streamer -i "input_uvc.so -f 10 -r 320*240" -o "output_http.so -w www"
一般的攝像頭:
mjpg_streamer -i "input_uvc.so -f 10 -r 320*240 -y" -o "output_http.so -w www"
2)斷開網(wǎng)線;
3)手機(jī)連接上路hame a100由器的wifi信號(hào);
4)運(yùn)行手機(jī)上的MjpegMonitor軟件;
五,熱拔插
mdev.conf的格式:
<device regex> <uid>:<gid> <octal permissions> [<@|$|*> <command>]
device regex:正則表達(dá)式,表示哪一個(gè)設(shè)備
uid: owner
gid: 組ID
octal permissions:以八進(jìn)制表示的屬性
@:創(chuàng)建設(shè)備節(jié)點(diǎn)之后執(zhí)行命令
$:刪除設(shè)備節(jié)點(diǎn)之前執(zhí)行命令
*: 創(chuàng)建設(shè)備節(jié)點(diǎn)之后 和 刪除設(shè)備節(jié)點(diǎn)之前 執(zhí)行命令
command:要執(zhí)行的命令
問(wèn):路由器上的文件系統(tǒng)中的/etc/mdev.conf是誰(shuí)創(chuàng)建的?里面的內(nèi)容又是誰(shuí)填入的?
答:
cd /work/hame_a100/5350_source/user/rt2880_app/scripts
vim
發(fā)現(xiàn):
echo "# <device regex> <uid>:<gid> <octal permissions> [<@|$|*> <command>]" > /etc/mdev.conf
echo "# The special characters have the meaning:" >> /etc/mdev.conf
echo "# @ Run after creating the device." >> /etc/mdev.conf
echo "# $ Run before removing the device." >> /etc/mdev.conf
echo "# * Run both after creating and before removing the device." >> /etc/mdev.conf
echo "sd[a-z][1-9] 0:0 0660 */sbin/automount.sh $MDEV" >> /etc/mdev.conf
echo "sd[a-z] 0:0 0660 */sbin/automount.sh $MDEV" >> /etc/mdev.conf
問(wèn):怎么實(shí)現(xiàn)攝像頭的熱拔插功能?
答:
1).
echo "video[012345]? 0:0 777 * /bin/mjpg-streamer.sh /dev/$MDEV" >> /etc/mdev.conf
2).
實(shí)現(xiàn)mjpg-streamer.sh
#!/bin/sh
NAME=mjpg_streamer
PROG=/bin/$NAME
DEVICE=$1
FPS=10
RESOLUTION=320*240
if [ $ACTION = "add" ];
then
# USB video in
if [ -e $DEVICE ];then
$PROG -i "input_uvc.so -d $DEVICE -f $FPS -r $RESOLUTION" -o "output_http.so -w www" &
else
# not find device
exit -2
fi
sleep 3
# check if mjpg_streamer is running
pgrep $NAME
if [ $? -ne 0 ];then
# try to mjpg_streamer YUYV format
$PROG -i "input_uvc.so -d $DEVICE -y -f $FPS -r $RESOLUTION" -o "output_http.so -w www" &
fi
else
killall -9 $NAME
fi
思路:
先
mjpg_streamer -i "input_uvc.so -f 10 -r 320*240" -o "output_http.so -w www"
后
mjpg_streamer -i "input_uvc.so -f 10 -r 320*240 -y" -o "output_http.so -w www"
附件:
-e file : 如果file是存在的,則返回真
pgrep: 通過(guò)進(jìn)程的名字來(lái)查詢進(jìn)程是否正常運(yùn)行的工具,一般就是用來(lái)判斷程序是否正常運(yùn)行
$?:表示最后支持的命令的推出狀態(tài),如果為0,則表示沒(méi)有錯(cuò)誤
六,開機(jī)自啟動(dòng)
1).寫一個(gè)腳本文件run.sh
#!/bin/sh
NAME=mjpg_streamer
PROG=/bin/$NAME
DEVICE=/dev/video0
FPS=10
RESOLUTION=320*240
if [ -e $DEVICE ];then
$PROG -i "input_uvc.so -d $DEVICE -f $FPS -r $RESOLUTION" -o "output_http.so -w www" &
sleep 3
# check if mjpg_streamer is running
pgrep $NAME
if [ $? -ne 0 ];then
# try to mjpg_streamer YUYV format
$PROG -i "input_uvc.so -d $DEVICE -y -f $FPS -r $RESOLUTION" -o "output_http.so -w www" &
fi
else
# not find device
exit -2
fi
2).讓系統(tǒng)自動(dòng)運(yùn)行這個(gè)腳步文件
將運(yùn)行run.sh腳本的命令添加到internet.sh中即可
七,將固件燒寫到flash
方法1:
Please choose the operation:
1: Load system code to SDRAM via TFTP.
2: Load system code then write to Flash via TFTP.
3: Boot system code via Flash (default).
4: Entr boot command line interface.
7: Load Boot Loader code then write to Flash via Serial.
9: Load Boot Loader code then write to Flash via TFTP.
You choosed 2 // 不同之處
0
2: System Load Linux Kernel then write to Flash via TFTP.
Warning!! Erase Linux in Flash then burn new one. Are you sure?(Y/N)
Please Input new ones /or Ctrl-C to discard
Input device IP (192.168.1.155) ==:192.168.1.155
Input server IP (192.168.1.105) ==:192.168.1.105
Input Linux Kernel filename (flash_100ask_IP_Camera_debug_V1.0.4.bin) ==:flash_100ask_IP_Camera_debug_V1.0.4.bin
方法2:
通過(guò)網(wǎng)絡(luò)升級(jí)的辦法來(lái)下載固件
注意:
1. 串口的波特率為57600(8N1);
總結(jié)
以上是生活随笔為你收集整理的33、给华美A100刷固件的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 计算机如何学会自动裁剪图片如何在电脑上裁
- 下一篇: dnf论坛(dnf手游官网首页)