33. Flash firmware for Huamei A100

Flash firmware for HAME A100

Purpose:
1. Flash firmware for HAME A100
2. Configure UVC driver
3. Modify the UVC driver that comes with the kernel to support our self-made two-in-one camera
4. Transplant mjpg-streamer
5. Realize self-start and hot-plug Plug-in function

Portable wireless monitoring device = router (HAME A100) + USB camera (two-in-one camera) + mobile phone

HAME A100:
CPU: RT5350
FLASH: 8M SPI FLASH
SDRAM: 32M

Firmware:
can be understood as our own kernel and file system

 

First, the construction of the environment

a, decompress 100ask_toolchain.bz2:
  tar xjvf 100ask_toolchain.bz2

b, install the toolchain:
  cd toolchain/
  sudo tar jxf buildroot-gcc342.tar.bz2 -C /opt

c, install the kernel compression tool:
  cd lzma-4.32.0beta5
  ./ configure
  make
  sudo make install

d, install rootfs tools: linux 2.6
  cd ..
  cd mksquash_lzma-3.2
  make
  sudo make install

 

Second, configure and compile the firmware
  tar xjvf 100ask.bz2
  cd 5350_source/
  vim .config
    -- CONFIG_CROSS_COMPILER_PATH="/opt/buildroot-gcc342/bin"
  make clean
  make

result:
  flash_100ask_IP_Camera_debug_V1.0.4.bin

2.1 Configure the UVC driver

Device Drivers --->
  Multimedia devices --->
    <*> Video For Linux
    Video Capture Adapters --->
      <*> USB Video Class (UVC)

Q: Who created the device node "/dev/video0"? How to cancel?
Answer:
1. It must be created by running the mknod command in the footsteps.
By analyzing the startup process of the kernel, we found that internet.sh is
the footstep we were looking for, and then found the following command in the footstep:
mknod /dev/video0 c 81 0

2. To cancel the video0 device node, just add the Just comment out the line.

2.2 Modify UVC driver

3. Program firmware
1. After connecting the serial port and setting up the corresponding environment, start the router
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. Select 1 of the above options;
Please Input new ones /or Ctrl-C to discard
Input device IP (192.168.1.155) ==:192.168.1.155 // Device IP, same network segment as
server IP Input server IP (192.168.1.105) ==:192.168. 1.105 // Server IP
Input Linux Kernel filename (flash_100ask_IP_Camera_debug_V1.0.4.bin) ==:flash_100ask_IP_Camera_debug_V1.0.4.bin // firmware name

 

Fourth, transplant mjpg-streamer

1. Install the cross compiler
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. Cross-compile mjpg-streamer
tar xzvf mjpg-streamer-r63.tar.gz
cd mjpg-streamer-r63/
modify all Makefiles
  --(1) Change CC=gcc to CC=mipsel-linux-gcc
  --( 2) Modify plugins/input_uvc/Makfile
    a. Change
    CFLAGS += -O2 -DLINUX -D_GNU_SOURCE -Wall -shared -fPIC
    to
    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. will
    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
    to
    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. Test
1) 2-in
-1 camera:
mjpg_streamer -i "input_uvc.so -f 10 -r 320*240" -o "output_http.so -w www"

General camera:
mjpg_streamer -i "input_uvc.so -f 10 -r 320*240 -y" -o "output_http.so -w www"

2) Disconnect the network cable;
3) Connect the mobile phone to the wifi signal of the hame a100 router;
4) Run the MjpegMonitor software on the mobile phone;

Five, hot swap

mdev.conf的格式:
<device regex> <uid>:<gid> <octal permissions> [<@|$|*> <command>]

device regex: Regular expression, indicating which device
uid: owner
gid: group ID
octal permissions: attributes expressed in octal
@: execute command after creating device node
$: execute command before deleting device node
*: after creating device node and delete Execute the command command before the device node
: the command to be executed


Q: Who created /etc/mdev.conf in the file system on the router? Who filled in the content?
Answer:
cd /work/hame_a100/5350_source/user/rt2880_app/scripts
vim
found:
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[az][1-9] 0:0 0660 */sbin/automount.sh \$MDEV" >> /etc/mdev.conf
echo "sd[az] 0:0 0660 */sbin/automount.

Q: How to realize the hot-plugging function of the camera?
Answer:
1).
echo "video[012345]? 0:0 777 * /bin/mjpg-streamer.sh /dev/\$MDEV" >> /etc/mdev.conf

2).
Implement 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"

Attachment:
-e file : If the file exists, return true
pgrep: A tool to query whether the process is running normally by the name of the process, generally used to judge whether the program is running normally
$?: Indicates the launch status of the last supported command , if 0, there is no error

 

6. Self-start at boot

1). Write a script file 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). Let the system automatically run this script file

Add the command to run the run.sh script to internet.sh

Seven, burn the firmware to 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 chosen 2 // the difference

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

Method 2:
Download firmware via network upgrade


Note:
1. The baud rate of the serial port is 57600 (8N1);

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324494385&siteId=291194637