platform.sh 1021 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #
  2. # Copyright (C) 2016 OpenWrt.org
  3. #
  4. platform_do_upgrade() {
  5. local tar_file="$1"
  6. local board="$(cat /tmp/sysinfo/board_name)"
  7. echo "flashing kernel"
  8. tar xf $tar_file sysupgrade-$board/kernel -O | mtd write - kernel
  9. echo "flashing rootfs"
  10. tar xf $tar_file sysupgrade-$board/root -O | mtd write - rootfs
  11. return 0
  12. }
  13. platform_check_image() {
  14. local tar_file="$1"
  15. local board=$(cat /tmp/sysinfo/board_name)
  16. case "$board" in
  17. NAND)
  18. nand_do_platform_check $board $1
  19. return $?
  20. ;;
  21. eMMC)
  22. local kernel_length=`(tar xf $tar_file sysupgrade-$board/kernel -O | wc -c) 2> /dev/null`
  23. local rootfs_length=`(tar xf $tar_file sysupgrade-$board/root -O | wc -c) 2> /dev/null`
  24. ;;
  25. *)
  26. echo "Sysupgrade is not supported on your board yet."
  27. return 1
  28. ;;
  29. esac
  30. [ "$kernel_length" = 0 -o "$rootfs_length" = 0 ] && {
  31. echo "The upgarde image is corrupt."
  32. return 1
  33. }
  34. return 0
  35. }
  36. platform_pre_upgrade() {
  37. local board=$(cat /tmp/sysinfo/board_name)
  38. case "$board" in
  39. NAND)
  40. nand_do_upgrade $1
  41. ;;
  42. esac
  43. }