fastboot $* getvar product 2>&1 | grep "^product: *kate$"
if [ $? -ne 0 ] ; then echo "Missmatching image and device"; exit 1; fi
fastboot $* flash tz `dirname $0`/images/tz.mbn
fastboot $* flash sbl1 `dirname $0`/images/sbl1.mbn
fastboot $* flash rpm `dirname $0`/images/rpm.mbn
fastboot $* flash aboot `dirname $0`/images/emmc_appsboot.mbn
fastboot $* flash hyp `dirname $0`/images/hyp.mbn
fastboot $* flash keymaster `dirname $0`/images/keymaster.mbn
fastboot $* flash cmnlib `dirname $0`/images/cmnlib.mbn

fastboot $* flash tzbak `dirname $0`/images/tz.mbn
fastboot $* flash sbl1bak `dirname $0`/images/sbl1.mbn
fastboot $* flash rpmbak `dirname $0`/images/rpm.mbn
fastboot $* flash abootbak `dirname $0`/images/emmc_appsboot.mbn
fastboot $* flash hypbak `dirname $0`/images/hyp.mbn
fastboot $* flash keymasterbak `dirname $0`/images/keymaster.mbn
fastboot $* flash cmnlibbak `dirname $0`/images/cmnlib.mbn

fastboot $* erase boot
fastboot $* flash modem `dirname $0`/images/NON-HLOS.bin
fastboot $* flash system `dirname $0`/images/system.img
fastboot $* flash cache `dirname $0`/images/cache.img
fastboot $* flash userdata `dirname $0`/images/userdata.img
fastboot $* flash recovery `dirname $0`/images/recovery.img
fastboot $* flash boot `dirname $0`/images/boot.img
fastboot $* flash cust `dirname $0`/images/cust.img

fastboot $* flash sec `dirname $0`/images/sec.dat
fastboot $* flash dsp `dirname $0`/images/adspso.bin
fastboot $* flash mdtp `dirname $0`/images/mdtp.img
fastboot $* erase splash
fastboot $* flash splash `dirname $0`/images/splash.img
fastboot $* erase DDR

fastboot $* oem lock
fastboot $* reboot
