Merge branch 'master' into DetectAndAutoLoadEthernetDrivers

This commit is contained in:
Scott Kilau 2022-06-21 08:45:08 -05:00
commit 0bd0c36401
13 changed files with 243 additions and 62 deletions

View File

@ -33,7 +33,10 @@ Using this project can potentially expose your device to the open internet depen
* USB Mass storage enabled, mount USB SSD/HDD/flash drives
* CIFS Supported
* iptables included
* Play .wav audio files using "cmd aplay <file> <vol>" command
* Play .wav audio files using "cmd aplay \<path-to-file\> \<vol\>" command. Supported .wav files may be generated using ffmpeg as well::
```
ffmpeg -i in.wav -acodec pcm_s16le -ac 1 -ar 16000 out.wav
```
* WebCam Mode - Use your camera as a spare UVC USB Web Camera on your PC or AndroidTV!
* RTMP Streaming - Stream live video from the camera to your favorite service, youtube, twitch, or facebook live.
@ -377,10 +380,21 @@ This script will upgrade wz_mini over the air. It will backup `wz_mini.conf`, a
If there are any line differences between the old `wz_mini.conf` and the new release, the script will preserve the current config in place. Note that this means any missing or additional lines. It is recommended to download the latest wz_mini.conf from github, if there are any major changes to the file, copy the new one to your system first, set your parameteres, save the file, then perform the upgrade.
NOTE: if you are upgrading a V2 camera from a release older than 06-16-22, you must manually download the upgrade-run.sh script from this repo and place it in `wz_mini/bin/upgrade-run.sh`, then run it from there !
---
```
NIGHT_DROP_DISABLE="false"
```
Stop the camera from dropping the frame rate during nightvision.
---
## Latest Updates
* 06-19-22: Fixed no rtsp video when wz_mini is used with the old stock rtsp firmware.
* 06-18-22: Added night drop feature preventing fps drop during nightvision. Upgrade script can now work unattended. Add -F0 flag to rtsp server.
* 06-17-22: Fix custom hostname not being set. Note: The hostname variable has CHANGED! You will need to update your `wz_mini.conf` file.
* 06-16-22: Simplified the camera model detection method throughout wz_mini.
* 06-16-22: fix scp client bug, allow user modifications to app_init, updated initramfs script, moved upgrade-run to PATH, revised kernel module paths, added ENABLE_RTL8189FS_DRIVER option for v2/v3, updated kernels for v2/v3. ( NOTE: this is a major upgrade, file names for the init scripts have changed, if you are upgrading the V2, do not use the upgrade-run.sh script, please manually update )

View File

@ -50,6 +50,7 @@ echo "Launching latest upgrade-script"
/opt/wz_mini/bin/upgrade-run.sh backup_begin &
echo "Exit old script"
rm -f /dev/fd
exit 0
}
@ -130,6 +131,13 @@ reboot
}
if [[ "$1" == "unattended" ]]; then
echo "Unattended upgrade!"
rm -rf /opt/Upgrade
sync
setup
else
if [[ -e /tmp/dbgflag ]]; then
upgrade_mode_start
else
@ -157,12 +165,11 @@ read -r -p "${1:-wz_mini, this will download the latest version from github and
else
setup
fi
;;
*)
echo "User declined system update, exit"
;;
esac
fi
fi
fi

View File

@ -52,6 +52,13 @@ if [[ "$ENABLE_RTL8189FS_DRIVER" == "true" ]]; then
fi
fi
if [[ "$ENABLE_ATBM603X_DRIVER" == "true" ]]; then
echo "Enable atbm603x_wifi_sdio_24M"
if [ -f /opt/wz_mini/tmp/.T31 ]; then
sed -i 's/\/system\/driver\/atbm603x_wifi_sdio.ko/\/opt\/wz_mini\/lib\/modules\/3.10.14\_\_isvp_swan_1.0\_\_\/extra\/atbm603x_wifi_sdio_24M.ko/g' /opt/wz_mini/tmp/.storage/app_init.sh
fi
fi
##RTSP SERVER INIT
if [[ "$RTSP_HI_RES_ENABLED" == "true" ]] || [[ "$RTSP_LOW_RES_ENABLED" == "true" ]] && ! [[ -e /tmp/dbgflag ]]; then

View File

@ -71,16 +71,71 @@ rename_interface() {
eth_wlan_up
}
rename_interface_and_setup_bonding() {
##Fool iCamera by renaming the hardline interface to wlan0
## $1 Bonding Interface, $2 Primary Interface, $3 Secondary Interface
bonding_interface=$1
primary_interface=$2
secondary_interface=$3
echo "renaming interfaces"
# Bring all interfaces down
ifconfig $bonding_interface down
ifconfig $primary_interface down
ifconfig $secondary_interface down
# Have to bring bonding interface up to be able to bond our slaves.
/opt/wz_mini/bin/busybox ip link set $bonding_interface up
# Rename the real wlan0 interface if needed/used
if [[ "$primary_interface" == "wlan0" ]]; then
/opt/wz_mini/bin/busybox ip link set $primary_interface name wlanold
/opt/wz_mini/bin/busybox ip addr flush dev wlanold
primary_interface="wlanold"
# Because we just changed the name of the primary interface, we need to
# tell the bonding driver about the name change as well.
echo "$primary_interface" > /sys/devices/virtual/net/$bonding_interface/bonding/primary
fi
if [[ "$secondary_interface" == "wlan0" ]]; then
/opt/wz_mini/bin/busybox ip link set $secondary_interface name wlanold
/opt/wz_mini/bin/busybox ip addr flush dev wlanold
secondary_interface="wlanold"
fi
# Enslave the Ethernet and Original Wifi interfaces
# under the bonding interface.
/opt/wz_mini/tmp/.bin/ifenslave $bonding_interface $primary_interface $secondary_interface
# Have to bring bonding interface down to be rename the interface
/opt/wz_mini/bin/busybox ip link set $bonding_interface down
# Name the bonding interface to be the "new" wlan0 interface
/opt/wz_mini/bin/busybox ip link set $bonding_interface name wlan0
# Bring the newly renamed wlan0 (actually the bond interface) back up
eth_wlan_up
}
eth_wlan_up() {
##Run DHCP client, and bind mount our fake wpa_cli.sh to fool iCamera
ifconfig wlan0 up
pkill udhcpc
udhcpc -i wlan0 -x hostname:$CUSTOM_HOSTNAME -p /var/run/udhcpc.pid -b
# If running with Interface Bonding enabled, kill any existing
# wpa_supplicant that might be running and spawn our own instead
if [[ "$BONDING_ENABLED" == "true" ]] && [[ "$ENABLE_USB_ETH" == "true" ]]; then
/opt/wz_mini/bin/busybox killall wpa_supplicant
wpa_supplicant -D nl80211 -i wlanold -c /tmp/wpa_supplicant.conf -B -s
fi
if [ -f /opt/wz_mini/tmp/.T20 ]; then
mount -o bind /opt/wz_mini/bin/wpa_cli.sh /system/bin/wpa_cli
else
mount -o bind /opt/wz_mini/bin/wpa_cli.sh /bin/wpa_cli
fi
break
}
@ -108,8 +163,12 @@ wlanold_check() {
eth_wlan_up
else
echo "wlanold doesn't exist"
if [[ "$BONDING_ENABLED" == "true" ]] && [[ "$ENABLE_USB_ETH" == "true" ]]; then
rename_interface_and_setup_bonding bond0 "$BONDING_PRIMARY_INTERFACE" "$BONDING_SECONDARY_INTERFACE"
else
rename_interface $1
fi
fi
}
netloop() {
@ -246,6 +305,27 @@ if [[ "$ENABLE_USB_ETH" == "true" ]]; then
esac
done
if [[ "$BONDING_ENABLED" == "true" ]]; then
if [[ "$BONDING_LINK_MONITORING_FREQ_MS" == "" ]]; then
"$BONDING_LINK_MONITORING_FREQ_MS" = "100"
fi
if [[ "$BONDING_DOWN_DELAY_MS" == "" ]]; then
"$BONDING_DOWN_DELAY_MS" = "5000"
fi
if [[ "$BONDING_UP_DELAY_MS" == "" ]]; then
"$BONDING_UP_DELAY_MS" = "5000"
fi
if [[ "$BONDING_PRIMARY_INTERFACE" == "" ]]; then
"$BONDING_PRIMARY_INTERFACE" = "eth0"
fi
if [[ "$BONDING_SECONDARY_INTERFACE" == "" ]]; then
"$BONDING_SECONDARY_INTERFACE" = "wlan0"
fi
# Insert the bonding driver into the kernel
insmod $KMOD_PATH/kernel/drivers/net/bonding/bonding.ko mode=active-backup miimon="$BONDING_LINK_MONITORING_FREQ_MS" downdelay="$BONDING_DOWN_DELAY_MS" updelay="$BONDING_UP_DELAY_MS" primary="$BONDING_PRIMARY_INTERFACE"
fi
swap_enable
netloop eth0
@ -559,7 +639,7 @@ if [[ "$RTSP_LOW_RES_ENABLED" == "true" ]] || [[ "$RTSP_HI_RES_ENABLED" == "true
echo "delay RTSP for iCamera"
#This delay is required. Sometimes, if you start the rtsp server too soon, live view will break on the app.
sleep 5
LD_LIBRARY_PATH=/opt/wz_mini/lib /opt/wz_mini/bin/v4l2rtspserver $AUDIO_CH $AUDIO_FMT -U "$RTSP_LOGIN":"$RTSP_PASSWORD" -P "$RTSP_PORT" $DEVICE1 $DEVICE2 &
LD_LIBRARY_PATH=/opt/wz_mini/lib /opt/wz_mini/bin/v4l2rtspserver $AUDIO_CH $AUDIO_FMT -F0 -U "$RTSP_LOGIN":"$RTSP_PASSWORD" -P "$RTSP_PORT" $DEVICE1 $DEVICE2 &
fi
if ([[ "$RTSP_LOW_RES_ENABLED" == "true" ]] || [[ "$RTSP_HI_RES_ENABLED" == "true" ]]) && [[ "$RTMP_STREAM_ENABLED" == "true" ]] && ([[ "$RTSP_LOW_RES_ENABLE_AUDIO" == "true" ]] || [[ "$RTSP_HI_RES_ENABLE_AUDIO" == "true" ]]); then
@ -572,6 +652,10 @@ if ([[ "$RTSP_LOW_RES_ENABLED" == "true" ]] || [[ "$RTSP_HI_RES_ENABLED" == "tru
/opt/wz_mini/bin/rtmp-stream.sh "$RMTP_STREAM_SERVICE" "$RTMP_AUDIO"
fi
if [[ "$NIGHT_DROP_DISABLE" == "true" ]]; then
touch /opt/wz_mini/tmp/.nd
fi
hostname_set
touch /opt/wz_mini/tmp/.wz_user_firstrun
pkill -f dumpload #Kill dumpload so it won't waste cpu or ram gathering cores and uploading them when something crashes

Binary file not shown.

View File

@ -33,6 +33,14 @@ ENABLE_NFSv4="false"
ENABLE_RTL8189FS_DRIVER="false"
##### NETWORK INTERFACE BONDING #####
BONDING_ENABLED="false"
BONDING_PRIMARY_INTERFACE="eth0"
BONDING_SECONDARY_INTERFACE="wlan0"
BONDING_LINK_MONITORING_FREQ_MS="100"
BONDING_DOWN_DELAY_MS="5000"
BONDING_UP_DELAY_MS="5000"
#####ACCESSORIES#####
REMOTE_SPOTLIGHT="false"
REMOTE_SPOTLIGHT_HOST="0.0.0.0"
@ -75,6 +83,7 @@ ENABLE_CIFS="false"
DISABLE_FW_UPGRADE="false"
AUDIO_PROMPT_VOLUME="50"
ENABLE_MP4_WRITE="false"
NIGHT_DROP_DISABLE="false"
#####DEBUG#####
#drops you to a shell via serial, doesn't load app_init.sh

View File

@ -3,8 +3,8 @@ d41d8cd98f00b204e9800998ecf8427e SD_ROOT/wz_mini/mnt/.gitignore
34c6a4c3a941ff2becd9f487826d7692 SD_ROOT/wz_mini/etc/uvc.config
ad7d1a2f9db3079617731b5854ce3b6a SD_ROOT/wz_mini/etc/init.d/wz_cam.sh
0774518c06d6ef8e7181d35f194777cc SD_ROOT/wz_mini/etc/init.d/wz_init.sh
c94845a6a1bd6c20f643daf4595b03f9 SD_ROOT/wz_mini/etc/init.d/wz_user.sh
48c4fd27a194459efda6e92b446f51a0 SD_ROOT/wz_mini/etc/init.d/wz_post.sh
04473a0de3ebbf562d253c5df3ddfdde SD_ROOT/wz_mini/etc/init.d/wz_user.sh
babb83cd8cdbd5af8639cfaecbca2d70 SD_ROOT/wz_mini/etc/init.d/wz_post.sh
e3034eac02d8eda9902ca9cf89f0a586 SD_ROOT/wz_mini/etc/inittab
840aa9c26726201f7cffbf001bee193a SD_ROOT/wz_mini/etc/uvc_jxf22.config
2609cae8b3b084d83e84299528d8bc93 SD_ROOT/wz_mini/etc/wz_mini.conf.dist
@ -49,7 +49,7 @@ a8970288e72c871bff6a4484f1e733d6 SD_ROOT/wz_mini/bin/readelf
41b56bb30f02bce5f5e2598073151e16 SD_ROOT/wz_mini/bin/ffmpeg
e37474a12d76cae16336476cba61e8b8 SD_ROOT/wz_mini/bin/neofetch
7fcc716cda1e024dae1045050a135beb SD_ROOT/wz_mini/bin/audioplay_t31
1b34a65eae3c4aed0704cc90e59757ce SD_ROOT/wz_mini/bin/upgrade-run.sh
03a42f7f175f88903c0dc52013f11205 SD_ROOT/wz_mini/bin/upgrade-run.sh
e6a6a9dd8ce138686083a3d4303cea40 SD_ROOT/wz_mini/bin/iperf3
0468ffb319707687557353242a518923 SD_ROOT/wz_mini/bin/wg
65510c6c4d0db4b4679fc92d1c617fdd SD_ROOT/wz_mini/bin/rtmp-stream.sh
@ -81,7 +81,7 @@ b339aee882a5d1c943ad08e4282ec3fd SD_ROOT/wz_mini/usr/bin/iCamera-dbg
4c780f0455481d106d47d89f0ae04ed5 SD_ROOT/wz_mini/lib/uClibc.tar
9afeb088e4cbabbe0b04033b560204d0 SD_ROOT/wz_mini/lib/libimp.so
4100755cb6cc6e3b76da20c7e3690e16 SD_ROOT/wz_mini/lib/libalog.so
11efb592b989c853d0db65b5aa5e5413 SD_ROOT/wz_mini/lib/libcallback.so
d63e45dd1a05a62ad91ef3d70eae44de SD_ROOT/wz_mini/lib/libcallback.so
baf8d0b7a28f2fbb49a19ae0980779da SD_ROOT/wz_mini/lib/modules/3.10.14/modules.order
70775da41db88e4450d910b4ee8621c0 SD_ROOT/wz_mini/lib/modules/3.10.14/kernel/crypto/md4.ko
abbaa461e044b5688814423a087fbc52 SD_ROOT/wz_mini/lib/modules/3.10.14/kernel/fs/ext4/ext4.ko
@ -184,5 +184,5 @@ ccf8f3611141656ba5594771bec06202 SD_ROOT/wz_mini/lib/modules/3.10.14__isvp_swan
14865a6e2e2df87a8362c6f20377a934 SD_ROOT/wz_mini/lib/libtinyalsa.so.2
bd383994491e4bdca81788c168feb2eb SD_ROOT/wz_mini/lib/libasound.so.2
f6f0d5a9ebd916de6bdb9695067809ae SD_ROOT/wz_mini/lib/libaudioProcess.so
2609cae8b3b084d83e84299528d8bc93 SD_ROOT/wz_mini/wz_mini.conf
aa102e670336c6bf165f1a9925d9d4fc SD_ROOT/wz_mini/wz_mini.conf
d41d8cd98f00b204e9800998ecf8427e SD_ROOT/wz_mini/tmp/.gitignore

View File

@ -2,7 +2,7 @@
CC = /openmiko/build/mips-gcc472-glibc216-64bit/bin/mips-linux-uclibc-gnu-gcc
CFLAGS = -fPIC -std=gnu99 -shared -ldl -ltinyalsa -lm -pthread
CC_SRCS = video_callback.c audio_callback.c jpeg.c setlinebuf.c mmc_format.c curl.c freopen.c opendir.c remove.c motor.c command.c gmtime_r.c wait_motion.c irled.c audio_play.c mp4write.c imp_control.c
CC_SRCS = video_callback.c audio_callback.c jpeg.c setlinebuf.c mmc_format.c curl.c freopen.c opendir.c remove.c motor.c command.c gmtime_r.c wait_motion.c irled.c audio_play.c mp4write.c imp_control.c night_drop.c
TARGET = libcallback.so
all: ${TARGET}

View File

@ -158,21 +158,20 @@ int fps_den = 1;
IMP_ISP_Tuning_SetHVFLIP(3);
}
} else if(!strcmp(p, "fps_set")) {
//encoder framerate failed
p = strtok_r(NULL, " \t\r\n", &tokenPtr);
// fps_val = 20;
if(p) fps_val = atoi(p);
// IMP_ISP_EnableTuning();
// IMP_ISP_Tuning_SetSensorFPS(fps_val, fps_den);
IMP_ISP_EnableTuning();
IMP_ISP_Tuning_SetSensorFPS(fps_val, fps_den);
paracfg_set_user_config_item(5,fps_val);
//encoder framerate failed
// paracfg_set_user_config_item(5,fps_val);
set_fs_chn_config_fps(encChn, fps_val);
set_fs_chn_config_fps(encChn1, fps_val);
// set_fs_chn_config_fps(encChn, fps_val);
// set_fs_chn_config_fps(encChn1, fps_val);
set_video_max_fps(fps_val);
local_sdk_video_set_fps(fps_val);
// set_video_max_fps(fps_val);
// local_sdk_video_set_fps(fps_val);
// local_sdk_video_set_gop(encChn, fps_val);

View File

@ -0,0 +1,45 @@
#define _GNU_SOURCE
#include <dlfcn.h>
#include <stdio.h>
#include <unistd.h>
#include <stdint.h>
#include <fcntl.h>
static uint32_t (*real_local_sdk_video_set_fps)(int encChn);
int local_sdk_video_set_fps(int encChn) {
fprintf(stderr, "[command] [night_drop.c] local_sdk_video_set_fps called with fps value: %d\n", encChn);
const char *nd_enable="/opt/wz_mini/tmp/.nd";
const char *product_T31="/opt/wz_mini/tmp/.T31";
const char *product_T20="/opt/wz_mini/tmp/.T20";
if( access( nd_enable, F_OK ) != -1 ) {
printf("[command] [night_drop.c] Night Drop Enabled\n");
if( encChn == 15 && access( product_T31, F_OK ) != -1 ) {
printf("[command] [night_drop.c] T31 detected\n");
fprintf(stderr, "[command] [night_drop.c] Night Time Requested FPS Drop Value: %d\n", encChn);
printf("[command] [night_drop.c] Night FPS Drop Stopped\n");
} else if ( encChn >= 15 && access( product_T20, F_OK ) != -1 ) {
printf("[command] [night_drop.c] T20 detected\n");
fprintf(stderr, "[command] [night_drop.c] Night Time Requested FPS Drop Value: %d\n", encChn);
printf("[command] [night_drop.c] Night FPS Drop Stopped\n");
} else {
fprintf(stderr, "[command] [night_drop.c] Requested FPS Value: %d\n", encChn);
fprintf(stderr, "[command] [night_drop.c] Calling local_sdk_video_set_fps to: %d\n", encChn);
real_local_sdk_video_set_fps(encChn);
}
//If nd is disabled, pass all requests along
} else {
printf("[command] [night_drop.c] Night Drop not enabled\n");
fprintf(stderr, "[command] [night_drop.c] Requested FPS Value: %d\n", encChn);
fprintf(stderr, "[command] [night_drop.c] Calling local_sdk_video_set_fps to: %d\n", encChn);
real_local_sdk_video_set_fps(encChn);
}
}
static void __attribute ((constructor)) night_drop_init(void) {
real_local_sdk_video_set_fps = dlsym(dlopen("/system/lib/liblocalsdk.so", RTLD_LAZY), "local_sdk_video_set_fps");
}

View File

@ -186,6 +186,10 @@ int local_sdk_video_set_encode_frame_callback(int ch, void *callback) {
video_encode_cb = callback;
fprintf(stderr,"enc func injection save video_encode_cb=0x%x\n", video_encode_cb);
callback = video_encode_capture;
} else if( (ch == 0) && ch_count == 3) {
video_encode_cb = callback;
fprintf(stderr,"RTSP FIRMWARE enc func injection save video_encode_cb=0x%x\n", video_encode_cb);
callback = video_encode_capture;
}
fprintf(stderr,"ch count is %x\n", ch_count);

View File

@ -3,28 +3,40 @@
UA_STRING="Mozilla/5.0 (Macintosh; Intel Mac OS X 12_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15"
DL_URL=$(wget --header="Accept: text/html" --user-agent="$UA_STRING" -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"
echo "checking for tools"
command -v wget >/dev/null 2>&1 || { echo >&2 "wget is not installed. Aborting."; exit 1; }
command -v mkimage >/dev/null 2>&1 || { echo >&2 "mkimage is not installed. Aborting."; exit 1; }
command -v unzip >/dev/null 2>&1 || { echo >&2 "unzip is not installed. Aborting."; exit 1; }
echo "create temporary work directory"
mkdir v2_ro
echo "download latest firmware"
echo "check for local zip"
if [ -f demo_4.9.8.1002.zip ]; then
echo "local archive found"
mv demo_4.9.8.1002.zip ./v2_ro/
else
echo "local archive not found"
echo "downloading latest firmware"
wget $DL_URL -P ./v2_ro/
fi
echo "extracting firmware to workdir"
echo "extracting firmware to temporary work directory"
unzip v2_ro/demo_4.9.8.1002.zip -d ./v2_ro/
echo "create firmware dir"
mkdir v2_ro/tmp_dir
echo "create firmware directory"
mkdir v2_ro/fw_dir
echo "unpack stock firmware"
./fw_tool.sh unpack v2_ro/demo_4.9.8.1002.bin v2_ro/tmp_dir
echo "unpack stock firmware image"
./fw_tool.sh unpack v2_ro/demo_4.9.8.1002.bin v2_ro/fw_dir
echo "replace kernel"
cp v2_kernel.bin v2_ro/tmp_dir/kernel.bin
echo "replace factory kernel"
cp v2_kernel.bin v2_ro/fw_dir/kernel.bin
echo "pack firmware with new kernel"
./fw_tool.sh pack v2_ro/tmp_dir/ demo.bin
echo "pack firmware image with new kernel"
./fw_tool.sh pack v2_ro/fw_dir/ demo.bin
echo "md5sum is: " `md5sum demo.bin`
echo "remove temporary work directory"
rm -rf v2_ro
echo "demo.bin ready. Please copy demo.bin to your memory card"