1#!/bin/sh 2ARTMTD=$(grep \"ART\" /proc/mtd | awk -F ':' '{print $1}') 3BAKMTD=$(grep \"ART.bak\" /proc/mtd | awk -F ':' '{print $1}') 4validlen=65536 5hwid_len=34 6 7is_valid_board_parameter() 8{ 9 [ "$(dd if=$1 bs=1 count=$hwid_len skip=41 2>/dev/null | cat)" != "$(cat /hw_id)" ] && return 255 10 # add other check here if necessary 11 return 0 12 # Note: return 0 means true, return other value means false 13} 14 15if [ "x$BAKMTD" = "x" ]; then 16 echo "Not find ART.bak mtd partition" 17 exit 18fi 19 20nanddump /dev/$ARTMTD -l $validlen -f /tmp/$ARTMTD 2>/dev/null 21nanddump /dev/$BAKMTD -l $validlen -f /tmp/$BAKMTD 2>/dev/null 22if is_valid_board_parameter /tmp/$ARTMTD 23then 24 if diff -q /tmp/$ARTMTD /tmp/$BAKMTD > /dev/null 25 then 26 echo "board parameter in $ARTMTD and $BAKMTD partition are same and valid" 27 else 28 echo "backup board parameter from $ARTMTD to $BAKMTD partition" 29 nandwrite -p -m -q /dev/$BAKMTD /tmp/$ARTMTD 30 fi 31else 32 if is_valid_board_parameter /tmp/$BAKMTD 33 then 34 echo "restore board parameter from $BAKMTD to $ARTMTD partition" 35 nandwrite -p -m -q /dev/$ARTMTD /tmp/$BAKMTD 36 else 37 echo "!!! board parameter in $ARTMTD and $BAKMTD partition both are invalid" 38 fi 39fi 40rm -f /tmp/$ARTMTD /tmp/$BAKMTD 41