diff options
Diffstat (limited to 'target/linux/ar71xx/base-files/lib/upgrade/merakinand.sh')
-rw-r--r-- | target/linux/ar71xx/base-files/lib/upgrade/merakinand.sh | 61 |
1 files changed, 45 insertions, 16 deletions
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/merakinand.sh b/target/linux/ar71xx/base-files/lib/upgrade/merakinand.sh index cc7a86c..78cde20 100644 --- a/target/linux/ar71xx/base-files/lib/upgrade/merakinand.sh +++ b/target/linux/ar71xx/base-files/lib/upgrade/merakinand.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (C) 2015 Chris Blake <chrisrblake93@gmail.com> +# Copyright (C) 2015-2016 Chris Blake <chrisrblake93@gmail.com> # # Custom upgrade script for Meraki NAND devices (ex. MR18) # Based on dir825.sh and stock nand functions @@ -14,34 +14,52 @@ get_magic_at() { dd bs=1 count=2 skip=$pos if=$mtddev 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"' } -mr18_is_caldata_valid() { - local mtddev=$1 +meraki_is_caldata_valid() { + local board=$1 + local mtddev=$2 local magic - magic=$(get_magic_at $mtddev 4096) - [ "$magic" != "0202" ] && return 0 + case "$board" in + "mr18") + magic=$(get_magic_at $mtddev 4096) + [ "$magic" != "0202" ] && return 0 + + magic=$(get_magic_at $mtddev 20480) + [ "$magic" != "0202" ] && return 0 - magic=$(get_magic_at $mtddev 20480) - [ "$magic" != "0202" ] && return 0 + magic=$(get_magic_at $mtddev 36864) + [ "$magic" != "0202" ] && return 0 + + return 1 + ;; + "z1") + magic=$(get_magic_at $mtddev 4096) + [ "$magic" != "0202" ] && return 0 - magic=$(get_magic_at $mtddev 36864) - [ "$magic" != "0202" ] && return 0 + magic=$(get_magic_at $mtddev 86016) + [ "$magic" != "a55a" ] && return 0 - return 1 + return 1 + ;; + *) + return 1 + ;; + esac } merakinand_copy_caldata() { local cal_src=$1 local cal_dst=$2 - local ubidev=$( nand_find_ubi $CI_UBIPART ) + local ubidev="$(nand_find_ubi $CI_UBIPART)" local board_name="$(cat /tmp/sysinfo/board_name)" local rootfs_size="$(ubinfo /dev/ubi0 -N rootfs_data | grep "Size" | awk '{ print $6 }')" # Setup partitions using board name, in case of future platforms case "$board_name" in - "mr18") + "mr18"|\ + "z1") # Src is MTD - mtd_src=$(find_mtd_chardev $cal_src) + mtd_src="$(find_mtd_chardev $cal_src)" [ -n "$mtd_src" ] || { echo "no mtd device found for partition $cal_src" exit 1 @@ -56,12 +74,12 @@ merakinand_copy_caldata() { exit 1 } - mr18_is_caldata_valid "$mtd_src" && { + meraki_is_caldata_valid "$board_name" "$mtd_src" && { echo "no valid calibration data found in $cal_src" exit 1 } - mr18_is_caldata_valid "/dev/$mtd_dst" && { + meraki_is_caldata_valid "$board_name" "/dev/$mtd_dst" && { echo "Copying calibration data from $cal_src to $cal_dst..." dd if="$mtd_src" of=/tmp/caldata.tmp 2>/dev/null ubiupdatevol "/dev/$mtd_dst" /tmp/caldata.tmp @@ -89,6 +107,11 @@ merakinand_do_kernel_check() { echo "pass" && return 0 } ;; + "z1") + [ "$image_magic_word" == "4d495053" ] && { + echo "pass" && return 0 + } + ;; esac exit 1 @@ -102,7 +125,8 @@ merakinand_do_platform_check() { local kernel_magic="$(merakinand_do_kernel_check $1 $2)" case "$board_name" in - "mr18") + "mr18"|\ + "z1") [ "$control_length" = 0 -o "$file_type" != "squashfs" -o "$kernel_magic" != "pass" ] && { echo "Invalid sysupgrade file for $board_name" return 1 @@ -128,6 +152,11 @@ merakinand_do_upgrade() { merakinand_copy_caldata "odm-caldata" "caldata" nand_do_upgrade $1 ;; + "z1") + # Check and create UBI caldata if it's invalid + merakinand_copy_caldata "origcaldata" "caldata" + nand_do_upgrade $1 + ;; *) echo "Unsupported device $board_name"; exit 1 |