| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- #!/bin/sh
- ### BEGIN INIT INFO
- # Provides:
- # Short-Description: Stock Firmware Detection and Upgrade
- # Description: Detect the firmware version of the stock firmware and process upgrades, based off atomcam_tools S32fwupdate.
- ### END INIT INFO
- . /opt/wz_mini/wz_mini.conf
- flash_copy() {
- size=`awk '{ if($1 == MTD ":") print ("0x" $2)/1024; }' MTD=${1##*/} /proc/mtd`
- echo "flash_copy $1 $2 ${size}"
- dd if=$1 of=/tmp/mtd bs=1k count=${size}
- [ $? != 0 ] && return
- flash_eraseall $2
- [ $? != 0 ] && return
- flashcp -v /tmp/mtd $2
- [ $? != 0 ] && return
- rm -f /tmp/mtd
- }
- flash_update() {
- FWGRADEUP=`awk '/FWGRADEUP=/ { gsub(/^.*=/, ""); print $0; }' /dev/mtd7`
- if [ "${FWGRADEUP}" = "kernel+app" ] ; then
- flash_copy /dev/mtd4 /dev/mtd1
- [ $? != 0 ] && return
- flash_copy /dev/mtd5 /dev/mtd3
- [ $? != 0 ] && return
- flash_eraseall /dev/mtd7
- fi
- if [ "${FWGRADEUP}" = "kernel+rootfs" ] ; then
- flash_copy /dev/mtd4 /dev/mtd1
- [ $? != 0 ] && return
- flash_copy /dev/mtd5 /dev/mtd2
- [ $? != 0 ] && return
- flash_eraseall /dev/mtd7
- fi
- if [ "${FWGRADEUP}" = "kernel" ] ; then
- flash_copy /dev/mtd4 /dev/mtd1
- [ $? != 0 ] && return
- flash_eraseall /dev/mtd7
- fi
- if [ "${FWGRADEUP}" = "rootfs" ] ; then
- flash_copy /dev/mtd5 /dev/mtd2
- [ $? != 0 ] && return
- flash_eraseall /dev/mtd7
- fi
- if [ "${FWGRADEUP}" = "app" ] ; then
- flash_copy /dev/mtd5 /dev/mtd3
- [ $? != 0 ] && return
- flash_eraseall /dev/mtd7
- fi
- }
- case "$1" in
- start)
- echo "#####$(basename "$0")#####"
- if [ -f /system/bin/app.ver ]; then
- echo "Current stock firmware version:"
- cat /system/bin/app.ver
- else
- echo "/system/bin/app.ver not found"
- fi
- ;;
- *)
- echo "Usage: $0 {start}"
- exit 1
- ;;
- esac
|