#!/bin/sh

nmt_ver=`cat /proc/syabas/fw_version`
[ -z "$nmt_ver" ] && nmt_ver="unknown_fw"

dir_dst="/share/backup_nand/$nmt_ver"
mkdir -p "$dir_dst"

# sigminfo
cat /proc/sigminfo > "$dir_dst/sigminfo"

# zxenv2+zboot
echo "backup /dev/sigmblocka"
dd if=/dev/sigmblocka of="$dir_dst/sigmblocka.bin" bs=131072 count=4

# all sigmablocks
for i in b c d e f g h i j k l m n o ; do
	echo "backup /dev/sigmblock${i}"
	cat /dev/sigmblock${i} > "$dir_dst/sigmblock${i}.bin"
done

export EM8XXX_SERVER=":0"

# lrrw xenv2
echo "backup lrrw xenv2"
gbus_read_bin_to_file 0x61a00 0x274 "$dir_dst/lrrw.xenv"

# lrro xenv2
echo "backup lrro xenv2"
gbus_read_bin_to_file 0x61d00 0x274 "$dir_dst/lrro.xenv"
