S15fwupdate 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:
  4. # Short-Description: Stock Firmware Detection and Upgrade
  5. # Description: Detect the firmware version of the stock firmware and process upgrades, based off atomcam_tools S32fwupdate.
  6. ### END INIT INFO
  7. . /opt/wz_mini/wz_mini.conf
  8. flash_copy() {
  9. size=`awk '{ if($1 == MTD ":") print ("0x" $2)/1024; }' MTD=${1##*/} /proc/mtd`
  10. echo "flash_copy $1 $2 ${size}"
  11. dd if=$1 of=/tmp/mtd bs=1k count=${size}
  12. [ $? != 0 ] && return
  13. flash_eraseall $2
  14. [ $? != 0 ] && return
  15. flashcp -v /tmp/mtd $2
  16. [ $? != 0 ] && return
  17. rm -f /tmp/mtd
  18. }
  19. flash_update() {
  20. FWGRADEUP=`awk '/FWGRADEUP=/ { gsub(/^.*=/, ""); print $0; }' /dev/mtd7`
  21. if [ "${FWGRADEUP}" = "kernel+app" ] ; then
  22. flash_copy /dev/mtd4 /dev/mtd1
  23. [ $? != 0 ] && return
  24. flash_copy /dev/mtd5 /dev/mtd3
  25. [ $? != 0 ] && return
  26. flash_eraseall /dev/mtd7
  27. fi
  28. if [ "${FWGRADEUP}" = "kernel+rootfs" ] ; then
  29. flash_copy /dev/mtd4 /dev/mtd1
  30. [ $? != 0 ] && return
  31. flash_copy /dev/mtd5 /dev/mtd2
  32. [ $? != 0 ] && return
  33. flash_eraseall /dev/mtd7
  34. fi
  35. if [ "${FWGRADEUP}" = "kernel" ] ; then
  36. flash_copy /dev/mtd4 /dev/mtd1
  37. [ $? != 0 ] && return
  38. flash_eraseall /dev/mtd7
  39. fi
  40. if [ "${FWGRADEUP}" = "rootfs" ] ; then
  41. flash_copy /dev/mtd5 /dev/mtd2
  42. [ $? != 0 ] && return
  43. flash_eraseall /dev/mtd7
  44. fi
  45. if [ "${FWGRADEUP}" = "app" ] ; then
  46. flash_copy /dev/mtd5 /dev/mtd3
  47. [ $? != 0 ] && return
  48. flash_eraseall /dev/mtd7
  49. fi
  50. }
  51. case "$1" in
  52. start)
  53. echo "#####$(basename "$0")#####"
  54. if [ -f /system/bin/app.ver ]; then
  55. echo "Current stock firmware version:"
  56. cat /system/bin/app.ver
  57. else
  58. echo "/system/bin/app.ver not found"
  59. fi
  60. if [-f /system/bin/liveMediaServer ]; then
  61. echo "WARNING: Stock RTSP firmware detected."
  62. echo "WARNING: The stock RTSP firmware is old, unmaintained, and insecure."
  63. echo "WARNING: Compatability with wz_mini is NOT guaranteed, and not supported"
  64. fi
  65. ;;
  66. *)
  67. echo "Usage: $0 {start}"
  68. exit 1
  69. ;;
  70. esac