fixed fw upgrade issues

This commit is contained in:
Alfonso Gamboa 2022-04-21 03:01:51 -07:00
parent 07eeeb57c3
commit 0ec18d876a
6 changed files with 93 additions and 19 deletions

View File

@ -58,7 +58,6 @@ Run whatever firmware you want on your v3/PANv2 and have root access to the devi
Edit run_mmc.sh, this is a script stored on the micro sd card that is run when the camera boots. You can change the hostname of the camera, mount NFS, add ping commands, anything you like.
---
**DO NOT ENABLE FIRMWARE UPDATES (unless you know what you are doing), CURRENTLY THERE IS A BOOTLOADER BUG WHICH RESULTS IN A BROKEN SYSTEM. currently set to true by default.**
To disable automatic firmware updates, edit run_mmc.sh in the wz_mini directory on your micro sd card,
change:
```
@ -69,7 +68,9 @@ to:
```
DISABLE_FW_UPGRADE="true"
```
If a remote or app update is initiated, the camera will reboot due to the failure of the update. The firmware update should not proceed again for some time, or at all.
If a remote or app update is initiated, the camera will reboot due to the failure of the update. The firmware update should not proceed again for some time, or at all.
When a firmware update is initiated, due to a bootloader bug, we intercept the update process and flash it manually. This should now result in a successful update, if it doesn't, please restore the unit's firmware manually using demo_wcv3.bin on the micro sd card.
---
@ -139,6 +140,7 @@ __WARNING__: If using the wyze app to view the live stream, viewing in "HD" or
## Latest Updates
* 04-21-22: Workaround for bootloader F/W upgrade bug, F/W blocking is now disabled by default.
* 04-19-22: Add RTSP Server functionality
* 04-17-22: Add remote spotlight accessory capability
* 04-15-22: Enable USB Direct functionality. Allows you to connect camera using a USB cable to a device supporting CDC_NCM devices to get an internet connection, no USB Ethernet Adapter required.

View File

@ -13,6 +13,7 @@ export PATH=/system/bin:$PATH
export LD_LIBRARY_PATH=/system/lib:/opt/wz_mini/lib
export LD_LIBRARY_PATH=/thirdlib:$LD_LIBRARY_PATH
export TERMINFO=/opt/wz_mini/usr/share/terminfo
export TERM=xterm-color
/opt/wz_mini/bin/busybox resize
#export TZ=UTC-8

View File

@ -2,8 +2,7 @@
set -x
##DO NOT ENABLE FW UPGRADE. FW UPGRADE CAN POTENTIALLY CORRUPT THE KERNEL REQUIRING YOU TO REFLASH THE STOCK FIRMWARE.
DISABLE_FW_UPGRADE="true"
DISABLE_FW_UPGRADE="false"
HOSTNAME="WCV3"
@ -86,8 +85,11 @@ fi
if [[ "$DISABLE_FW_UPGRADE" == "true" ]]; then
mkdir /tmp/Upgrade
mount -t tmpfs -o size=1,nr_inodes=1 none /tmp/Upgrade
echo -e "127.0.0.1 localhost \n127.0.0.1 wyze-upgrade-service.wyzecam.com" > /run/.storage/hosts_wz
mount --bind /run/.storage/hosts_wz /etc/hosts
echo -e "127.0.0.1 localhost \n127.0.0.1 wyze-upgrade-service.wyzecam.com" > /opt/wz_mini/tmp/.storage/hosts
mount --bind /opt/wz_mini/tmp/.storage/hosts /etc/hosts
else
mkdir /tmp/Upgrade
/opt/wz_mini/bin/busybox inotifyd /opt/wz_mini/usr/bin/watch_up.sh /tmp/Upgrade:n &
fi
if [[ "$REMOTE_SPOTLIGHT" == "true" ]]; then

0
SD_ROOT/wz_mini/usr/bin/iCamera Normal file → Executable file
View File

View File

@ -0,0 +1,58 @@
#!/bin/sh
event="$1"
directory="$2"
file="$3"
case "$event" in
n) if [[ "$file" == "upgraderun.sh" ]]; then
pkill -f "sh /tmp/Upgrade/upgraderun.sh"
mv /tmp/Upgrade/upgraderun.sh /tmp/Upgrade/upgraderun.old
echo "squashed upgraderun.sh"
echo "start countdown"
secs=30
endTime=$(( $(date +%s) + secs ))
while [ $(date +%s) -lt $endTime ]; do
if pgrep -f 'upgraderun.sh' > /dev/null ; then
pkill -f "sh /tmp/Upgrade/upgraderun.sh"
pkillexitstatus=$?
if [ $pkillexitstatus -eq 0 ]; then
echo "matched upgraderun.sh, killed."
status=false
break 1
fi
fi
done
if [[ -e /tmp/Upgrade/app ]]; then
echo "found app image, flashing"
flashcp -v /tmp/Upgrade/app /dev/mtd3
/opt/wz_mini/bin/busybox sync
else
echo "no kernel image present"
fi
if [[ -e /tmp/Upgrade/kernel ]]; then
echo "found kernel image, flashing"
flashcp -v /tmp/Upgrade/kernel /dev/mtd1
/opt/wz_mini/bin/busybox sync
else
echo "no app image present"
fi
if [[ -e /tmp/Upgrade/rootfs ]]; then
echo "found rootfs image, flashing"
flashcp -v /tmp/Upgrade/rootfs /dev/mtd2
/opt/wz_mini/bin/busybox sync
else
echo "no root image present"
fi
/opt/wz_mini/bin/busybox sync
/opt/wz_mini/bin/busybox sync
sleep 5
/opt/wz_mini/bin/busybox reboot
fi;;
*) echo "This script must be run from inotifyd";;
esac

View File

@ -9,35 +9,35 @@ initramfs ```/etc/init``` runs ```exec busybox switch_root /v3 /opt/wz_mini/etc/
bind replace ```/etc/init.d/inittab``` with our own version that has rcS located at ```/opt/wz_mini/tmp/.storage/rcS```
bind replaces ```/etc/profile```
bind replace ```/etc/profile``` with out own version with added PATH variables for the shell
mounts ```/tmp``` and ```/run```
mount ```/tmp``` and ```/run```
mounts ```/system```
mount ```/system```
bind replaces ```/system/bin/factorycheck```, this program unmounts the binds that we do later in the file, its a debug program.
bind replace ```/system/bin/factorycheck```, this stock firmware program unmounts the binds that we do later in the file, its a debug program. We don't need it.
bind replaces ```/etc/fstab``` with our own version which includes ```/opt/wz_mini/tmp``` as a tmpfs path
bind replace ```/etc/fstab``` with our own version which includes ```/opt/wz_mini/tmp``` as a tmpfs path
creates wz_mini's workplace directory at ```/opt/wz_mini/tmp```
create wz_mini's workplace directory at ```/opt/wz_mini/tmp```
copies the stock ```/etc/init.d/rcS``` to the workplace directory
copy the stock ```/etc/init.d/rcS``` to the workplace directory
modifies the stock rcS, adds ```set -x``` debug mode and injects the following script ```/opt/wz_mini/etc/init.d/v3_post.sh``` ro run
modify the stock rcS, add ```set -x``` debug mode and inject the following script ```/opt/wz_mini/etc/init.d/v3_post.sh``` to run
bind replaces ```/etc/shadow``` to change the stock password
bind replace ```/etc/shadow``` to change the stock password
checks to see if the swap archive is present at ```/opt/wz_mini/swap.gz```, if it is, extracts it, then mkswap's it, and drops the vm cache.
check to see if the swap archive is present at ```/opt/wz_mini/swap.gz```, if it is, extract it, then mkswap it, and drop the vm cache.
check to see if the ```/opt/wz_mini/usr/share/terminfo``` directory is present, if not, extract the terminfo files for console programs
mounts ```/configs``` to check if the ```.ssh``` dir is present, a requirement for the dropbear ssh server
mount ```/configs``` to check if the ```.ssh``` dir is present, a requirement for the dropbear ssh server
checks to see if ```/opt/wz_mini/run_mmc.sh``` has debug mode enabled, if it does, skip loading ```/system/bin/app_init.sh``` and ```/media/mmc/wz_mini/run_mmc.sh```
check to see if ```/opt/wz_mini/run_mmc.sh``` has debug mode enabled, if it does, skip loading ```/system/bin/app_init.sh``` and ```/media/mmc/wz_mini/run_mmc.sh```
run ```/media/mmc/wz_mini/run_mmc.sh```, but delay execution for 30 seconds, enough time for WiFi or wired ethernet/usb to load and connect successfully to the internet
runs ```/linuxrc``` to kick off the stock boot process
run ```/linuxrc``` to kick off the stock boot process
our modified inittab runs from ```/opt/wz_mini/tmp/.storage/rcS```, we have enabled set -x debug info, added ```/opt/wz_mini/bin``` and ```/opt/wz_mini/lib``` to the system PATH's, and added ```/opt/wz_mini/etc/init.d/v3_post.sh``` to run before ```/system/init/app_init.sh``` runs.
@ -50,3 +50,14 @@ our version of iCamera is a script which injects the libcallback.so library as L
we then load the video loopback driver from ```/opt/wz_mini/lib/modules/v4l2loopback.ko```
```/system/bin/app_init.sh``` loads the stock system software
During execution of ```run_mmc.sh```, if ```DISABLE_FW_UPGRADE``` is set to ```false``` we intercept the stock firmware upgrade process. We run ```inotifyd``` at startup, to observe the /tmp/Upgrade directory.
Normally, ```iCamera``` downloads the firmware upgrade tar to ```/tmp/img```, renames it to ```/tmp/Upgrade.tar```, then extracts it to ```/tmp/Upgrade```
```inotifyd``` monitors ```/tmp/Upgrade``` for the file ```upgraderun.sh```, this is the script responsible for flashing the firmware files to their respective partitions. Once the file appears, ```inotifyd``` calls the script ```/opt/wz_mini/usr/bin/watch_up.sh``` which will rename the file to ```upgraderun.old``` and kill the script if ```iCamera``` was fast enough to launch it before we renamed it.
```watch_up.sh``` will then proceed to flash the main partitions directly, instead of doing what the stock script does, which is to flash the images to backup partitions, and then let the bootloader flash the main partitions upon reboot, since this process is currently broken when using the loading the kernel from the micro sd card, which we do.
Once the partitions have been flashed, we reboot the camera.