begin:
cls
/////////////////////////////////////////////
//    SB5100 Script
/////////////////////////////////////////////
echo 1. Backup whole flash.
echo 2. Restore whole flash
echo 3. Debrick the modem (3.3V)
echo 4. Exit
option 1 backup 2 restore 3 debrick 4 end
backup:
echo backup begins
detect
if IDCODE != 0334817F
echo This is not BCM3348 CPU. 
goto end
endif
if IMPCODE != 00800908
echo IMPCODE error
goto end
endif
getram 9fc00000 200000
save 9fc00000 200000
goto continue
restore:
echo restore begins
detect
if IDCODE != 0334817F
echo This is not BCM3348 CPU. 
goto end
endif
if IMPCODE != 00800908
echo IMPCODE error
goto end
endif
ldram 9fc00000
checkmdw 9fc00000
if MEMORY != 0BF00004
echo the boot does not seems to be right. Check and try again!!
goto continue
endif
flashchk 9fc00000
if FLASHSET == 0
echo flash not defigned
goto continue
endif
peek 80000000
if PEEK == 3C1A8029
program 9fc00000 200000
else
erase boot
sprogram boot
wait 300
cmpram boot
echo Please power off on the modem
pause
detect
program cfg
program image0
program image1
program log
endif
wait 1000
cmpram 9fc00000 200000
goto continue
debrick:
echo please hold the 3.3V to CE and power on the modem
pause
detect
wait 1500
tap c
tap a ffffffff
wait 1500
if DEBUG != 1
echo Try again
goto continue
goto debrickbegin
endif
debrickbegin:
echo Remove the 3.3V
pause
detect
if FLASHSET == 0
echo flash not defigned. Try again
goto continue
endif
erase boot
ldram boot
echo Please power off on the modem
pause
detect
wait 500
erase boot
wait 500
sprogram boot
wait 300
cmpram boot
echo Please power off on the modem
pause
detect
program cfg
program image0
program image1
program log
wait 1000
cmpram 9fc00000 200000

continue:
pause
goto begin
end:

