developer | 0e0b0ce | 2022-07-20 14:30:33 +0800 | [diff] [blame] | 1 | |
| 2 | board_name=`cat /proc/device-tree/compatible` |
| 3 | . /lib/upgrade/nand.sh |
developer | e499f14 | 2023-02-13 17:54:38 +0800 | [diff] [blame] | 4 | . /lib/upgrade/mmc.sh |
developer | 0e0b0ce | 2022-07-20 14:30:33 +0800 | [diff] [blame] | 5 | |
| 6 | platform_do_upgrade() { |
| 7 | local board=$board_name |
| 8 | echo " board=$board_name ." |
| 9 | case "$board" in |
| 10 | *snand*) |
| 11 | ubi_do_upgrade "$1" |
| 12 | ;; |
| 13 | *emmc*) |
| 14 | mtk_mmc_do_upgrade "$1" |
| 15 | ;; |
| 16 | *) |
| 17 | default_do_upgrade "$1" |
| 18 | ;; |
| 19 | esac |
| 20 | } |
| 21 | |
| 22 | PART_NAME=firmware |
| 23 | |
| 24 | platform_check_image() { |
| 25 | local board=$board_name |
| 26 | local magic="$(get_magic_long "$1")" |
| 27 | |
| 28 | [ "$#" -gt 1 ] && return 1 |
| 29 | |
| 30 | case "$board" in |
| 31 | *snand* |\ |
| 32 | *emmc*) |
| 33 | # tar magic `ustar` |
| 34 | magic="$(dd if="$1" bs=1 skip=257 count=5 2>/dev/null)" |
| 35 | |
| 36 | [ "$magic" != "ustar" ] && { |
| 37 | echo "Invalid image type." |
| 38 | return 1 |
| 39 | } |
| 40 | |
| 41 | return 0 |
| 42 | ;; |
| 43 | *) |
| 44 | [ "$magic" != "d00dfeed" ] && { |
| 45 | echo "Invalid image type." |
| 46 | return 1 |
| 47 | } |
| 48 | return 0 |
| 49 | ;; |
| 50 | esac |
| 51 | |
| 52 | return 0 |
| 53 | } |