add v2 support

This commit is contained in:
Alfonso Gamboa 2022-05-23 17:56:53 -07:00
parent 54fe16fdfe
commit 80378fbd5e
12 changed files with 327 additions and 100 deletions

View File

@ -1,7 +1,7 @@
# wz_mini_hacks # wz_mini_hacks
### v3/PANv2 devices ONLY ### v2/v3/PANv2 devices ONLY
Run whatever firmware you want on your v3/PANv2 and have root access to the device. This is in early stages of testing, use CAUTION if you are unsure of what you are doing. No support whatsoever is offered with this release. Run whatever firmware you want on your v2/v3/PANv2 and have root access to the device. This is in early stages of testing, use CAUTION if you are unsure of what you are doing. No support whatsoever is offered with this release.
**Do not contact the manufacturer for information or support, they will not be able to assist or advise you!** **Do not contact the manufacturer for information or support, they will not be able to assist or advise you!**
@ -55,27 +55,50 @@ Using this project can potentially expose your device to the open internet depen
* Person * Person
* Computer * Computer
* 256MB or larger Micro-SD Card is required! * 256MB or larger Micro-SD Card is required!
* Higher class Micro-SD cards will ensure better performance
## What Works / What Doesn't Work ## What Works / What Doesn't Work
* Everything works except: * Everything works except:
1. PAN v2: 1. PAN v2:
- Tilt (Vertical) only works at motor speed 9 - Tilt (Vertical) only works at motor speed 9
2. v2
- webcam mode does not work on v2
- usb direct does not work on v2 yet
- rndis mode on v2 is untested
## Setup ## Setup v3/PANv2
1. git clone the repo or download the repo zip 1. git clone the repo or download the repo zip
2. format micro-sd card as fat-32 ( this is a hard requirement, the bootloader does not support ex-fat or ext, and thus will not load wz_mini ), volume name does not matter. 2. format micro-sd card as fat-32 ( this is a hard requirement, the bootloader does not support ex-fat or ext, and thus will not load wz_mini ), volume name does not matter.
2. copy all the files inside of SD_ROOT to your micro sd card 2. copy all the files inside of SD_ROOT to your micro sd card
3. __SSH is enabled, but is secured using public key authentication for security. Edit the file ```wz_mini/etc/ssh/authorized_keys``` and enter your public key here. If you need a simple guide, [how to use public key authentication](https://averagelinuxuser.com/how-to-use-public-key-authentication/)__ 3. __SSH is enabled, but is secured using public key authentication for security. Edit the file ```wz_mini/etc/ssh/authorized_keys``` and enter your public key here. If you need a simple guide, [how to use public key authentication](https://averagelinuxuser.com/how-to-use-public-key-authentication/)__
## Installation ## Installation v3/PANv2
1. Turn off the camera 1. Turn off the camera
2. Insert the micro sd memory card into the camera 2. Insert the micro sd memory card into the camera
3. Turn on the camera 3. Turn on the camera
4. The camera will proceed to boot, then you may connect via the IP address of your device using SSH, port 22. The username is root. It may take a few minutes for the device to finish booting and connect to Wi-Fi, then launch the SSH server. Be patient. 4. The camera will proceed to boot, then you may connect via the IP address of your device using SSH, port 22. The username is root. It may take a few minutes for the device to finish booting and connect to Wi-Fi, then launch the SSH server. Be patient.
5. You may also login via the serial console, password is WYom2020 5. You may also login via the serial console, password is WYom2020
## Setup v2
1. git clone the repo or download the repo zip
2. format micro-sd card as fat-32 ( this is a hard requirement, the bootloader does not support ex-fat or ext, and thus will not load wz_mini ), volume name does not matter.
3. Run `compile_image.sh` using linux, wait for the script to finish.
4. Copy all the files inside of SD_ROOT to your micro sd card
5. Copy the generated `demo.bin` to root of your micro sd card
6. __SSH is enabled, but is secured using public key authentication for security. Edit the file ```wz_mini/etc/ssh/authorized_keys``` and enter your public key here. If you need a simple guide, [how to use public key authentication](https://averagelinuxuser.com/how-to-use-public-key-authentication/)__
## Installation v2
1. Insert the micro sd memory card into the camera
2. Hold down reset button while powering unit on. This is the standard manual firmware restore procedure.
3. Wait for camera to flash the latest modified firmware, and reboot, do not remove the micro sd card.
4. The camera will proceed to boot, then you may connect via the IP address of your device using SSH, port 22. The username is root. It may take a few minutes for the device to finish booting and connect to Wi-Fi, then launch the SSH server. Be patient. You should hear audio prompts from the camera once it has booted successfully.
5. You may also login via the serial console, password is WYom2020
## Removal ## Removal
1. Delete the files you copied to the memory card, or remove the memory card all together. The next time you boot the camera, you will return to stock firmware. 1. Delete the files you copied to the memory card, or remove the memory card all together. The next time you boot the camera, you will return to stock firmware.
@ -235,6 +258,7 @@ WEB_CAM_FPS_RATE="25"
## Latest Updates ## Latest Updates
* 05-22-22: Update wz_mini scripts and libraries to support v2 camera. experimental.
* 05-20-22: updated to latest libcallback including mp4write, bug fixes: usb direct mac addr, usb webcam mode bad variable. * 05-20-22: updated to latest libcallback including mp4write, bug fixes: usb direct mac addr, usb webcam mode bad variable.
* 05-18-22: Added PC Web Camera functionality, changed RTSP server, when you use enable more than one stream, they share the port and use different paths. * 05-18-22: Added PC Web Camera functionality, changed RTSP server, when you use enable more than one stream, they share the port and use different paths.
* 05-15-22: fixed rtsp audio for low-res rtsp stream, patched libcallback sources for audio channel 1. * 05-15-22: fixed rtsp audio for low-res rtsp stream, patched libcallback sources for audio channel 1.

View File

@ -21,29 +21,47 @@ echo '
set -x set -x
#lets test this out and see how it goes, patched udhcpc for iCamera #test for v2
mount -t jffs2 /dev/mtdblock9 /params
if cat /params/config/.product_config | grep WYZEC1-JZ; then
V2="true"
fi
umount /params
mount --bind /opt/wz_mini/bin/busybox /bin/busybox mount --bind /opt/wz_mini/bin/busybox /bin/busybox
#WCV3 GPIO #WCV3 GPIO
GPIO=63 GPIO=63
#Check model, change GPIO is HL_PAN2 #Check model, change GPIO is HL_PAN2
mount -t jffs2 /dev/mtdblock6 /configs if [[ "$V2" == "false" ]]; then
if [[ $(cat /configs/.product_config | grep PRODUCT_MODEL) == "PRODUCT_MODEL=HL_PAN2" ]]; then mount -t jffs2 /dev/mtdblock6 /configs
umount /configs if [[ $(cat /configs/.product_config | grep PRODUCT_MODEL) == "PRODUCT_MODEL=HL_PAN2" ]]; then
GPIO=7 umount /configs
GPIO=7
fi
else
echo "v2, no need to check"
fi fi
if [[ -e /opt/wz_mini/etc/.first_boot ]]; then if [[ -e /opt/wz_mini/etc/.first_boot ]]; then
echo "first boot already completed" echo "first boot already completed"
else else
echo "first boot, initializing" echo "first boot, initializing"
if [[ "$V2" == "true" ]]; then
insmod /opt/wz_mini/lib/modules/3.10.14_v2/kernel/audio.ko
LD_LIBRARY_PATH='/opt/wz_mini/lib' /opt/wz_mini/bin/audioplay_t20 /opt/wz_mini/usr/share/audio/init_v2.wav 70
rmmod audio
else
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/audio.ko spk_gpio=$GPIO alc_mode=0 mic_gain=0 insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/audio.ko spk_gpio=$GPIO alc_mode=0 mic_gain=0
/opt/wz_mini/bin/audioplay_t31 /opt/wz_mini/usr/share/audio/init.wav 50 /opt/wz_mini/bin/audioplay_t31 /opt/wz_mini/usr/share/audio/init.wav 50
rmmod audio rmmod audio
touch /opt/wz_mini/etc/.first_boot fi
fi fi
touch /opt/wz_mini/etc/.first_boot
mount --bind /opt/wz_mini/etc/inittab /etc/inittab mount --bind /opt/wz_mini/etc/inittab /etc/inittab
echo "bind /etc/profile for local/ssh shells" echo "bind /etc/profile for local/ssh shells"
@ -53,8 +71,13 @@ echo "mounting tmpfs"
mount -t tmpfs /tmp mount -t tmpfs /tmp
echo "mount system to replace factorycheck with dummy, to prevent bind unmount" echo "mount system to replace factorycheck with dummy, to prevent bind unmount"
mount /dev/mtdblock3 /system if [[ ! "$V2" == "true" ]]; then
mount --bind /opt/wz_mini/bin/factorycheck /system/bin/factorycheck mount /dev/mtdblock3 /system
mount --bind /opt/wz_mini/bin/factorycheck /system/bin/factorycheck
else
echo "v2 doesn't need factorycheck"
fi
touch /tmp/usrflag touch /tmp/usrflag
echo "replace stock fstab" echo "replace stock fstab"
@ -89,13 +112,16 @@ cp /opt/wz_mini/etc/shadow /opt/wz_mini/tmp/.storage/shadow
mount --bind /opt/wz_mini/tmp/.storage/shadow /etc/shadow mount --bind /opt/wz_mini/tmp/.storage/shadow /etc/shadow
chmod 400 /etc/shadow chmod 400 /etc/shadow
echo "mount kernel modules"
mount --bind /opt/wz_mini/lib/modules /lib/modules
if [[ -e /opt/wz_mini/swap.gz ]]; then if [[ -e /opt/wz_mini/swap.gz ]]; then
if [[ "$V2" == "true" ]]; then
insmod /opt/wz_mini/lib/modules/3.10.14_v2/kernel/audio.ko
LD_LIBRARY_PATH='/opt/wz_mini/lib' /opt/wz_mini/bin/audioplay_t20 /opt/wz_mini/usr/share/audio/swap_v2.wav 70
rmmod audio
else
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/audio.ko spk_gpio=$GPIO alc_mode=0 mic_gain=0 insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/audio.ko spk_gpio=$GPIO alc_mode=0 mic_gain=0
/opt/wz_mini/bin/audioplay_t31 /opt/wz_mini/usr/share/audio/swap.wav 50 /opt/wz_mini/bin/audioplay_t31 /opt/wz_mini/usr/share/audio/swap.wav 50
rmmod audio rmmod audio
fi
echo "swap archive present, extracting" echo "swap archive present, extracting"
gzip -d /opt/wz_mini/swap.gz gzip -d /opt/wz_mini/swap.gz
mkswap /opt/wz_mini/swap mkswap /opt/wz_mini/swap
@ -116,13 +142,13 @@ echo "Run dropbear ssh server"
/opt/wz_mini/bin/dropbear -R -s -g /opt/wz_mini/bin/dropbear -R -s -g
if [[ $(cat /opt/wz_mini/run_mmc.sh | grep "DEBUG_ENABLED\=") == "DEBUG_ENABLED\=\"true\"" ]]; then if [[ $(cat /opt/wz_mini/run_mmc.sh | grep "DEBUG_ENABLED\=") == "DEBUG_ENABLED\=\"true\"" ]]; then
sed -i '/app_init.sh/,+3d' /opt/wz_mini/tmp/.storage/rcS sed -i '/app_init.sh/,+4d' /opt/wz_mini/tmp/.storage/rcS
sed -i '/^# Run init/i/bin/sh /etc/profile' /opt/wz_mini/tmp/.storage/rcS sed -i '/^# Run init/i/bin/sh /etc/profile' /opt/wz_mini/tmp/.storage/rcS
touch /tmp/dbgflag touch /tmp/dbgflag
else else
if [[ $(cat /opt/wz_mini/run_mmc.sh | grep "WEB_CAM_ENABLE\=") == "WEB_CAM_ENABLE\=\"true\"" ]]; then if [[ $(cat /opt/wz_mini/run_mmc.sh | grep "WEB_CAM_ENABLE\=") == "WEB_CAM_ENABLE\=\"true\"" ]]; then
sed -i '/app_init.sh/,+3d' /opt/wz_mini/tmp/.storage/rcS sed -i '/app_init.sh/,+4d' /opt/wz_mini/tmp/.storage/rcS
sed -i '/^# Run init/i/opt/wz_mini/etc/init.d/wz_cam.sh' /opt/wz_mini/tmp/.storage/rcS sed -i '/^# Run init/i/opt/wz_mini/etc/init.d/wz_cam.sh' /opt/wz_mini/tmp/.storage/rcS
touch /tmp/dbgflag touch /tmp/dbgflag
fi fi

View File

@ -4,25 +4,40 @@
exec 1> /opt/wz_mini/log/v3_post.log 2>&1 exec 1> /opt/wz_mini/log/v3_post.log 2>&1
set -x
echo "welcome to v3_post.sh" echo "welcome to v3_post.sh"
echo "PID $$" echo "PID $$"
set -x echo "mount kernel modules"
mount --bind /opt/wz_mini/lib/modules /lib/modules
echo "v3_post.sh exec"
if [[ $(cat /opt/wz_mini/run_mmc.sh | grep "RTSP_HI_RES_ENABLED\=") == "RTSP_HI_RES_ENABLED\=\"true\"" ]] || [[ $(cat /opt/wz_mini/run_mmc.sh | grep "RTSP_LOW_RES_ENABLED\=") == "RTSP_LOW_RES_ENABLED\=\"true\"" ]] && ! [[ -e /tmp/dbgflag ]]; then if [[ $(cat /opt/wz_mini/run_mmc.sh | grep "RTSP_HI_RES_ENABLED\=") == "RTSP_HI_RES_ENABLED\=\"true\"" ]] || [[ $(cat /opt/wz_mini/run_mmc.sh | grep "RTSP_LOW_RES_ENABLED\=") == "RTSP_LOW_RES_ENABLED\=\"true\"" ]] && ! [[ -e /tmp/dbgflag ]]; then
if [[ $(cat /opt/wz_mini/run_mmc.sh | grep "RTSP_LOW_RES_ENABLED\=") == "RTSP_LOW_RES_ENABLED\=\"true\"" ]] && [[ $(cat /opt/wz_mini/run_mmc.sh | grep "RTSP_HI_RES_ENABLED\=") == "RTSP_HI_RES_ENABLED\=\"true\"" ]]; then if [[ $(cat /opt/wz_mini/run_mmc.sh | grep "RTSP_LOW_RES_ENABLED\=") == "RTSP_LOW_RES_ENABLED\=\"true\"" ]] && [[ $(cat /opt/wz_mini/run_mmc.sh | grep "RTSP_HI_RES_ENABLED\=") == "RTSP_HI_RES_ENABLED\=\"true\"" ]]; then
if [[ -d /etc/hotplug ]]; then
echo "load video loopback driver at video6 video7"
insmod /opt/wz_mini/lib/modules/3.10.14_v2/kernel/v4l2loopback_V2.ko video_nr=6,7
else
echo "load video loopback driver at video1 video2" echo "load video loopback driver at video1 video2"
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/v4l2loopback.ko video_nr=1,2 insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/v4l2loopback.ko video_nr=1,2
fi
elif [[ $(cat /opt/wz_mini/run_mmc.sh | grep "RTSP_LOW_RES_ENABLED\=") == "RTSP_LOW_RES_ENABLED\=\"true\"" ]]; then elif [[ $(cat /opt/wz_mini/run_mmc.sh | grep "RTSP_LOW_RES_ENABLED\=") == "RTSP_LOW_RES_ENABLED\=\"true\"" ]]; then
if [[ -d /etc/hotplug ]]; then
echo "load video loopback driver at video7"
insmod /opt/wz_mini/lib/modules/3.10.14_v2/kernel/v4l2loopback_V2.ko video_nr=7
else
echo "load video loopback driver at video2" echo "load video loopback driver at video2"
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/v4l2loopback.ko video_nr=2 insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/v4l2loopback.ko video_nr=2
fi
elif [[ $(cat /opt/wz_mini/run_mmc.sh | grep "RTSP_HI_RES_ENABLED\=") == "RTSP_HI_RES_ENABLED\=\"true\"" ]]; then elif [[ $(cat /opt/wz_mini/run_mmc.sh | grep "RTSP_HI_RES_ENABLED\=") == "RTSP_HI_RES_ENABLED\=\"true\"" ]]; then
if [[ -d /etc/hotplug ]]; then
echo "load video loopback driver at video6"
insmod /opt/wz_mini/lib/modules/3.10.14_v2/kernel/v4l2loopback_V2.ko video_nr=6
else
echo "load video loopback driver at video1" echo "load video loopback driver at video1"
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/v4l2loopback.ko video_nr=1 insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/v4l2loopback.ko video_nr=1
fi fi
fi
cp /system/bin/iCamera /opt/wz_mini/tmp/.storage/ cp /system/bin/iCamera /opt/wz_mini/tmp/.storage/
mount -o ro,bind /opt/wz_mini/usr/bin/iCamera /system/bin/iCamera mount -o ro,bind /opt/wz_mini/usr/bin/iCamera /system/bin/iCamera

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -87,7 +87,7 @@ wait_sdroot() {
##Stall execution if the micro-sd card isn't mounted yet, iCamera controls this internally. ##Stall execution if the micro-sd card isn't mounted yet, iCamera controls this internally.
while true while true
do do
if [[ -d /media/mmc/wz_mini ]]; then if [[ -d /media/mmc/wz_mini ]] || [[ -d /media/mmcblk0p1/wz_mini ]]; then
echo "sd card ready" echo "sd card ready"
break break
fi fi
@ -135,7 +135,11 @@ eth_wlan_up() {
ifconfig wlan0 up ifconfig wlan0 up
pkill udhcpc pkill udhcpc
udhcpc -i wlan0 -x hostname:$HOSTNAME -p /var/run/udhcpc.pid -b udhcpc -i wlan0 -x hostname:$HOSTNAME -p /var/run/udhcpc.pid -b
if [[ "$V2" == "true" ]]; then
mount -o bind /media/mmc/wz_mini/bin/wpa_cli.sh /system/bin/wpa_cli
else
mount -o bind /media/mmc/wz_mini/bin/wpa_cli.sh /bin/wpa_cli mount -o bind /media/mmc/wz_mini/bin/wpa_cli.sh /bin/wpa_cli
fi
break break
} }
@ -190,6 +194,13 @@ first_run_check
wait_sdroot wait_sdroot
wait_wlan wait_wlan
if [[ -d /etc/hotplug ]]; then
V2="true"
KMOD_PATH="/opt/wz_mini/lib/modules/3.10.14_v2"
else
V2="false"
KMOD_PATH="/opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__"
fi
if [[ "$ENABLE_SWAP" == "true" ]]; then if [[ "$ENABLE_SWAP" == "true" ]]; then
if cat /proc/swaps | grep "mini" ; then if cat /proc/swaps | grep "mini" ; then
@ -208,39 +219,42 @@ else
fi fi
if [[ "$ENABLE_NFSv4" == "true" ]]; then if [[ "$ENABLE_NFSv4" == "true" ]]; then
insmod /lib/modules/3.10.14__isvp_swan_1.0__/kernel/lib/oid_registry.ko insmod $KMOD_PATH/kernel/lib/oid_registry.ko
insmod /lib/modules/3.10.14__isvp_swan_1.0__/kernel/net/dns_resolver/dns_resolver.ko insmod $KMOD_PATH/kernel/net/dns_resolver/dns_resolver.ko
insmod /lib/modules/3.10.14__isvp_swan_1.0__/kernel/fs/nfs/nfsv4.ko insmod $KMOD_PATH/kernel/fs/nfs/nfsv4.ko
insmod /lib/modules/3.10.14__isvp_swan_1.0__/kernel/net/sunrpc/auth_gss/auth_rpcgss.ko insmod $KMOD_PATH/kernel/net/sunrpc/auth_gss/auth_rpcgss.ko
echo nfsv4 enabled echo nfsv4 enabled
else else
echo nfsv4 disabled echo nfsv4 disabled
fi fi
if [[ "$ENABLE_IPTABLES" == "true" ]]; then if [[ "$ENABLE_IPTABLES" == "true" ]]; then
if [[ "$V2" == "true" ]]; then
echo "v2 has iptables built in"
else
insmod /lib/modules/3.10.14__isvp_swan_1.0__/kernel/net/netfilter/x_tables.ko insmod /lib/modules/3.10.14__isvp_swan_1.0__/kernel/net/netfilter/x_tables.ko
insmod /lib/modules/3.10.14__isvp_swan_1.0__/kernel/net/ipv4/netfilter/ip_tables.ko insmod /lib/modules/3.10.14__isvp_swan_1.0__/kernel/net/ipv4/netfilter/ip_tables.ko
insmod /lib/modules/3.10.14__isvp_swan_1.0__/kernel/net/ipv4/netfilter/ipt_REJECT.ko insmod /lib/modules/3.10.14__isvp_swan_1.0__/kernel/net/ipv4/netfilter/ipt_REJECT.ko
insmod /lib/modules/3.10.14__isvp_swan_1.0__/kernel/net/ipv4/netfilter/iptable_filter.ko insmod /lib/modules/3.10.14__isvp_swan_1.0__/kernel/net/ipv4/netfilter/iptable_filter.ko
insmod /lib/modules/3.10.14__isvp_swan_1.0__/kernel/net/ipv4/netfilter/iptable_mangle.ko insmod /lib/modules/3.10.14__isvp_swan_1.0__/kernel/net/ipv4/netfilter/iptable_mangle.ko
echo "iptables ipv4 enabled" echo "iptables ipv4 enabled"
fi
if [[ "$ENABLE_IPV6" == "true" ]]; then if [[ "$ENABLE_IPV6" == "true" ]]; then
insmod /lib/modules/3.10.14__isvp_swan_1.0__/kernel/net/ipv6/netfilter/ip6_tables.ko insmod $KMOD_PATH/kernel/net/ipv6/netfilter/ip6_tables.ko
insmod /lib/modules/3.10.14__isvp_swan_1.0__/kernel/net/ipv6/netfilter/ip6t_REJECT.ko insmod $KMOD_PATH/kernel/net/ipv6/netfilter/ip6t_REJECT.ko
insmod /lib/modules/3.10.14__isvp_swan_1.0__/kernel/net/ipv6/netfilter/ip6table_filter.ko insmod $KMOD_PATH/kernel/net/ipv6/netfilter/ip6table_filter.ko
insmod /lib/modules/3.10.14__isvp_swan_1.0__/kernel/net/ipv6/netfilter/ip6table_mangle.ko insmod $KMOD_PATH/kernel/net/ipv6/netfilter/ip6table_mangle.ko
echo "iptables ipv6 enabled" echo "iptables ipv6 enabled"
fi fi
else else
echo "iptables disabled" echo "iptables disabled"
fi fi
if [[ "$ENABLE_USB_ETH" == "true" ]]; then if [[ "$ENABLE_USB_ETH" == "true" ]]; then
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/drivers/net/usb/usbnet.ko insmod $KMOD_PATH/kernel/drivers/net/usb/usbnet.ko
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/drivers/net/usb/asix.ko insmod $KMOD_PATH/kernel/drivers/net/usb/asix.ko
if [[ "$ENABLE_SWAP" == "true" ]]; then if [[ "$ENABLE_SWAP" == "true" ]]; then
echo "swap already enabled" echo "swap already enabled"
@ -264,10 +278,13 @@ if [[ "$ENABLE_USB_DIRECT" == "true" ]]; then
host_macaddr=$(echo $HOSTNAME|md5sum|sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/') host_macaddr=$(echo $HOSTNAME|md5sum|sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/')
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/drivers/usb/gadget/libcomposite.ko if [[ "$V2" == "false" ]]; then
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/drivers/usb/gadget/u_ether.ko insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/drivers/usb/gadget/u_ether.ko
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/drivers/usb/gadget/usb_f_ncm.ko insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/drivers/usb/gadget/usb_f_ncm.ko
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/drivers/usb/gadget/g_ncm.ko iManufacturer=wz_mini_ncm host_addr=$host_macaddr dev_addr=$USB_DIRECT_MAC_ADDR fi
insmod $KMOD_PATH/kernel/drivers/usb/gadget/libcomposite.ko
insmod $KMOD_PATH/kernel/drivers/usb/gadget/g_ncm.ko iManufacturer=wz_mini_ncm host_addr=$host_macaddr dev_addr=$USB_DIRECT_MAC_ADDR
sleep 1 sleep 1
@ -290,9 +307,9 @@ fi
if [[ "$ENABLE_USB_RNDIS" == "true" ]]; then if [[ "$ENABLE_USB_RNDIS" == "true" ]]; then
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/drivers/net/usb/usbnet.ko insmod $KMOD_PATH/kernel/drivers/net/usb/usbnet.ko
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/drivers/net/usb/cdc_ether.ko insmod $KMOD_PATH/kernel/drivers/net/usb/cdc_ether.ko
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/drivers/net/usb/rndis_host.ko insmod $KMOD_PATH/kernel/drivers/net/usb/rndis_host.ko
sleep 1 sleep 1
@ -314,31 +331,35 @@ if [[ "$ENABLE_USB_RNDIS" == "true" ]]; then
fi fi
if [[ "$ENABLE_WIREGUARD" == "true" ]]; then if [[ "$ENABLE_WIREGUARD" == "true" ]]; then
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/net/ipv4/tunnel4.ko insmod $KMOD_PATH/kernel/net/ipv4/tunnel4.ko
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/net/ipv4/ip_tunnel.ko insmod $KMOD_PATH/kernel/net/ipv4/ip_tunnel.ko
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/net/wireguard/wireguard.ko insmod $KMOD_PATH/kernel/net/wireguard/wireguard.ko
else else
echo "wireguard disabled" echo "wireguard disabled"
fi fi
if [[ "$ENABLE_CIFS" == "true" ]]; then if [[ "$ENABLE_CIFS" == "true" ]]; then
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/fs/cifs/cifs.ko insmod $KMOD_PATH/kernel/fs/cifs/cifs.ko
else else
echo "cifs disabled" echo "cifs disabled"
fi fi
if [[ "$ENABLE_USB_STORAGE" == "true" ]]; then if [[ "$ENABLE_USB_STORAGE" == "true" ]]; then
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/drivers/scsi/scsi_mod.ko insmod $KMOD_PATH/kernel/drivers/scsi/scsi_mod.ko
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/drivers/scsi/sd_mod.ko insmod $KMOD_PATH/kernel/drivers/scsi/sd_mod.ko
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/drivers/usb/storage/usb-storage.ko insmod $KMOD_PATH/kernel/drivers/usb/storage/usb-storage.ko
else else
echo "usb_storage disabled" echo "usb_storage disabled"
fi fi
if [[ "$ENABLE_EXT4" == "true" ]]; then if [[ "$ENABLE_EXT4" == "true" ]]; then
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/fs/jbd2/jbd2.ko if [[ "$V2" == "true" ]]; then
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/fs/mbcache.ko insmod $KMOD_PATH/kernel/lib/crc16.ko
insmod /opt/wz_mini/lib/modules/3.10.14__isvp_swan_1.0__/kernel/fs/ext4/ext4.ko fi
insmod $KMOD_PATH/kernel/fs/jbd2/jbd2.ko
insmod $KMOD_PATH/kernel/fs/mbcache.ko
insmod $KMOD_PATH/kernel/fs/ext4/ext4.ko
else else
echo "ext4 disabled" echo "ext4 disabled"
fi fi
@ -350,7 +371,7 @@ if [[ "$DISABLE_FW_UPGRADE" == "true" ]]; then
mount --bind /opt/wz_mini/tmp/.storage/hosts /etc/hosts mount --bind /opt/wz_mini/tmp/.storage/hosts /etc/hosts
else else
mkdir /tmp/Upgrade mkdir /tmp/Upgrade
/opt/wz_mini/bin/busybox inotifyd /opt/wz_mini/usr/bin/watch_up.sh /tmp/Upgrade:n & /opt/wz_mini/bin/busybox inotifyd /opt/wz_mini/usr/bin/watch_up.sh /tmp:n &
fi fi
if [[ "$REMOTE_SPOTLIGHT" == "true" ]]; then if [[ "$REMOTE_SPOTLIGHT" == "true" ]]; then
@ -369,6 +390,12 @@ fi
if [[ "$RTSP_HI_RES_ENABLED" == "true" ]]; then if [[ "$RTSP_HI_RES_ENABLED" == "true" ]]; then
if [[ -d /etc/hotplug ]]; then
HI_VIDEO_DEV="/dev/video6"
else
HI_VIDEO_DEV="/dev/video1"
fi
if [[ "$ENABLE_SWAP" == "true" ]]; then if [[ "$ENABLE_SWAP" == "true" ]]; then
echo "swap already enabled" echo "swap already enabled"
else else
@ -385,23 +412,35 @@ if [[ "$RTSP_HI_RES_ENABLED" == "true" ]]; then
/opt/wz_mini/bin/cmd audio on /opt/wz_mini/bin/cmd audio on
AUDIO_CH="-C 1" AUDIO_CH="-C 1"
AUDIO_FMT="-a S16_LE" AUDIO_FMT="-a S16_LE"
DEVICE1="/dev/video1,hw:Loopback,0" DEVICE1="$HI_VIDEO_DEV,hw:Loopback,0"
else else
DEVICE1="/dev/video1" DEVICE1="$HI_VIDEO_DEV"
echo "rtsp audio disabled" echo "rtsp audio disabled"
fi fi
if [[ "$RTSP_HI_RES_ENC_PARAMETER" != "" ]]; then if [[ "$RTSP_HI_RES_ENC_PARAMETER" != "" ]]; then
if [[ "$V2" == "true" ]]; then
watch -n10 -t "/system/bin/impdbg --enc_rc_s 0:0:4:$RTSP_LOW_RES_ENC_PARAMETER" > /dev/null 2>&1 &
else
watch -n10 -t "/system/bin/impdbg --enc_rc_s 0:44:4:$RTSP_HI_RES_ENC_PARAMETER" > /dev/null 2>&1 & watch -n10 -t "/system/bin/impdbg --enc_rc_s 0:44:4:$RTSP_HI_RES_ENC_PARAMETER" > /dev/null 2>&1 &
fi fi
fi
if [[ "$RTSP_HI_RES_MAX_BITRATE" != "" ]]; then if [[ "$RTSP_HI_RES_MAX_BITRATE" != "" ]]; then
if [[ "$V2" == "true" ]]; then
watch -n10 -t "/system/bin/impdbg --enc_rc_s 0:28:4:$RTSP_LOW_RES_MAX_BITRATE" > /dev/null 2>&1 &
else
watch -n10 -t "/system/bin/impdbg --enc_rc_s 0:48:4:$RTSP_HI_RES_MAX_BITRATE" > /dev/null 2>&1 & watch -n10 -t "/system/bin/impdbg --enc_rc_s 0:48:4:$RTSP_HI_RES_MAX_BITRATE" > /dev/null 2>&1 &
fi fi
fi
if [[ "$RTSP_HI_RES_TARGET_BITRATE" != "" ]]; then if [[ "$RTSP_HI_RES_TARGET_BITRATE" != "" ]]; then
if [[ "$V2" == "true" ]]; then
echo "not supported on v2"
else
watch -n10 -t "/system/bin/impdbg --enc_rc_s 0:52:4:$RTSP_HI_RES_TARGET_BITRATE" > /dev/null 2>&1 & watch -n10 -t "/system/bin/impdbg --enc_rc_s 0:52:4:$RTSP_HI_RES_TARGET_BITRATE" > /dev/null 2>&1 &
fi fi
fi
else else
echo "rtsp disabled" echo "rtsp disabled"
@ -411,6 +450,13 @@ fi
if [[ "$RTSP_LOW_RES_ENABLED" == "true" ]]; then if [[ "$RTSP_LOW_RES_ENABLED" == "true" ]]; then
if [[ -d /etc/hotplug ]]; then
LOW_VIDEO_DEV="/dev/video7"
else
LOW_VIDEO_DEV="/dev/video2"
fi
if [[ "$ENABLE_SWAP" == "true" ]]; then if [[ "$ENABLE_SWAP" == "true" ]]; then
echo "swap already enabled" echo "swap already enabled"
else else
@ -427,23 +473,35 @@ if [[ "$RTSP_LOW_RES_ENABLED" == "true" ]]; then
/opt/wz_mini/bin/cmd audio on1 /opt/wz_mini/bin/cmd audio on1
AUDIO_CH="-C 1" AUDIO_CH="-C 1"
AUDIO_FMT="-a S16_LE" AUDIO_FMT="-a S16_LE"
DEVICE2="/dev/video2,hw:Loopback,1" DEVICE2="$LOW_VIDEO_DEV,hw:Loopback,1"
else else
DEVICE2="/dev/video2" DEVICE2="$LOW_VIDEO_DEV"
echo "rtsp audio disabled" echo "rtsp audio disabled"
fi fi
if [[ "$RTSP_LOW_RES_ENC_PARAMETER" != "" ]]; then if [[ "$RTSP_LOW_RES_ENC_PARAMETER" != "" ]]; then
if [[ "$V2" == "true" ]]; then
watch -n10 -t "/system/bin/impdbg --enc_rc_s 1:0:4:$RTSP_LOW_RES_ENC_PARAMETER" > /dev/null 2>&1 &
else
watch -n10 -t "/system/bin/impdbg --enc_rc_s 1:44:4:$RTSP_LOW_RES_ENC_PARAMETER" > /dev/null 2>&1 & watch -n10 -t "/system/bin/impdbg --enc_rc_s 1:44:4:$RTSP_LOW_RES_ENC_PARAMETER" > /dev/null 2>&1 &
fi fi
fi
if [[ "$RTSP_LOW_RES_MAX_BITRATE" != "" ]]; then if [[ "$RTSP_LOW_RES_MAX_BITRATE" != "" ]]; then
if [[ "$V2" == "true" ]]; then
watch -n10 -t "/system/bin/impdbg --enc_rc_s 1:28:4:$RTSP_LOW_RES_MAX_BITRATE" > /dev/null 2>&1 &
else
watch -n10 -t "/system/bin/impdbg --enc_rc_s 1:48:4:$RTSP_LOW_RES_MAX_BITRATE" > /dev/null 2>&1 & watch -n10 -t "/system/bin/impdbg --enc_rc_s 1:48:4:$RTSP_LOW_RES_MAX_BITRATE" > /dev/null 2>&1 &
fi fi
fi
if [[ "$RTSP_LOW_RES_TARGET_BITRATE" != "" ]]; then if [[ "$RTSP_LOW_RES_TARGET_BITRATE" != "" ]]; then
if [[ "$V2" == "true" ]]; then
echo "not supported on v2"
else
watch -n10 -t "/system/bin/impdbg --enc_rc_s 1:52:4:$RTSP_LOW_RES_TARGET_BITRATE" > /dev/null 2>&1 & watch -n10 -t "/system/bin/impdbg --enc_rc_s 1:52:4:$RTSP_LOW_RES_TARGET_BITRATE" > /dev/null 2>&1 &
fi fi
fi
else else
echo "rtsp disabled" echo "rtsp disabled"

View File

@ -1,14 +1,37 @@
#!/bin/sh #!/bin/sh
exec 1>> /opt/wz_mini/log/watch_up.log 2>&1
set -x
event="$1" event="$1"
directory="$2" directory="$2"
file="$3" file="$3"
case "$event" in case "$event" in
n) if [[ "$file" == "upgraderun.sh" ]]; then n) date; if [[ "$file" == "img" ]]; then
set -x
#hook the v2
if cat /params/config/.product_config | grep WYZEC1-JZ; then
while [ ! -f /tmp/Upgrade/upgraderun.sh ]
do
sed -i '/pgrep/,+4d' /tmp/Upgrade/upgraderun.sh
find /tmp/Upgrade > /opt/upgrade_find.log &
sleep 0.1
done
else
#t31
while [ ! -f /tmp/Upgrade/upgraderun.sh ]
do
pkill -f "sh /tmp/Upgrade/upgraderun.sh" pkill -f "sh /tmp/Upgrade/upgraderun.sh"
mv /tmp/Upgrade/upgraderun.sh /tmp/Upgrade/upgraderun.old mv /tmp/Upgrade/upgraderun.sh /tmp/Upgrade/upgraderun.old
echo "squashed upgraderun.sh" echo "squashed upgraderun.sh"
sleep 0.1
done
echo "start countdown" echo "start countdown"
secs=30 secs=30
@ -24,6 +47,16 @@ case "$event" in
fi fi
fi fi
done done
fi
if cat /params/config/.product_config | grep WYZEC1-JZ; then
echo "v2 found"
upgrade_path=$(find /tmp/Upgrade | grep upgradecp.sh)
sed -i '/wc -c $KERNEL/,+14d' $upgrade_path
#mv /tmp/Upgrade/upgraderun.sh /tmp/Upgrade/run_upg.sh
#sh /tmp/Upgrade/run_upg.sh
/tmp/Upgrade/system_upgrade.sh
else
if [[ -e /tmp/Upgrade/app ]]; then if [[ -e /tmp/Upgrade/app ]]; then
echo "found app image, flashing" echo "found app image, flashing"
@ -48,11 +81,15 @@ case "$event" in
else else
echo "no root image present" echo "no root image present"
fi fi
/opt/wz_mini/bin/busybox sync /opt/wz_mini/bin/busybox sync
/opt/wz_mini/bin/busybox sync /opt/wz_mini/bin/busybox sync
sleep 5 sleep 5
echo reboot
/opt/wz_mini/bin/busybox reboot /opt/wz_mini/bin/busybox reboot
fi
fi;; fi;;
*) echo "This script must be run from inotifyd";; *) echo "This script must be run from inotifyd";;
esac esac

29
v2_install/compile_image.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
DL_URL=$(wget --user-agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)" -qO- https://support.wyze.com/hc/en-us/articles/360024852172-Release-Notes-Firmware | grep -Eo "(http|https)://[a-zA-Z0-9./?=_-]*" | grep /v2/ | sort -t . -k2r,5 | grep demo | head -1)
echo "create work directory"
mkdir v2_ro
echo "download latest firmware"
wget $DL_URL -P ./v2_ro/
echo "extracting firmware to workdir"
unzip v2_ro/demo_4.9.8.1002.zip -d ./v2_ro/
echo "create firmware dir"
mkdir v2_ro/tmp_dir
echo "unpack stock firmware"
./fw_tool.sh unpack v2_ro/demo_4.9.8.1002.bin v2_ro/tmp_dir
echo "replace kernel"
cp v2_kernel.bin v2_ro/tmp_dir/kernel.bin
echo "pack firmware with new kernel"
./fw_tool.sh pack v2_ro/tmp_dir/ demo.bin
echo "md5sum is: " `md5sum demo.bin`
rm -rf v2_ro
echo "demo.bin ready. Please copy demo.bin to your memory card"

38
v2_install/fw_tool.sh Executable file
View File

@ -0,0 +1,38 @@
#!/bin/sh
#custom for V2
ACTION=$1
KERNEL_OFFSET=$((64))
ROOTFS_OFFSET=$((2097216))
DRIVER_OFFSET=$((5570624))
APPFS_OFFSET=$((6225984))
if [ "$ACTION" = "unpack" ]; then
DEMO_IN=$2
OUT_DIR=$3
dd if=${DEMO_IN} of=$OUT_DIR/kernel.bin skip=$KERNEL_OFFSET count=$(($ROOTFS_OFFSET-$KERNEL_OFFSET)) bs=1
md5sum $OUT_DIR/kernel.bin
dd if=${DEMO_IN} of=$OUT_DIR/rootfs.bin skip=$ROOTFS_OFFSET count=$(($DRIVER_OFFSET-$ROOTFS_OFFSET)) bs=1
md5sum $OUT_DIR/rootfs.bin
dd if=${DEMO_IN} of=$OUT_DIR/driver.bin skip=$DRIVER_OFFSET count=$(($APPFS_OFFSET-$DRIVER_OFFSET)) bs=1
md5sum $OUT_DIR/driver.bin
IMAGE_END=$(($(stat -c %s ${DEMO_IN})))
dd if=${DEMO_IN} of=$OUT_DIR/appfs.bin skip=$APPFS_OFFSET count=$(($IMAGE_END-$APPFS_OFFSET)) bs=1
md5sum $OUT_DIR/appfs.bin
elif [ "$ACTION" = "pack" ]; then
TMP_DIR=$2
DEMO_OUT=$3
# need to pad kernel is its smaller than the stock kernel size, 2097152 bytes
dd if=/dev/zero of=$TMP_DIR/kernel.bin bs=1 count=1 seek=2097151
cat $TMP_DIR/kernel.bin $TMP_DIR/rootfs.bin $TMP_DIR/driver.bin $TMP_DIR/appfs.bin > $TMP_DIR/flash.bin
mkimage -A MIPS -O linux -T firmware -C none -a 0 -e 0 -n jz_fw -d $TMP_DIR/flash.bin $DEMO_OUT
else
echo "Unknown action '$ACTION'"
fi

BIN
v2_install/v2_kernel.bin Normal file

Binary file not shown.