• Visit https://www.embeddedcomputers.net/ for Hardware; Software and all other things related to FlashcatUSB

SBV6220NEW

Spyrocheti

New Member
I updated the current sbv6220 script by modifying the preexisting dpc3000
now the script has way more options and its accurate as to its element's offsets/sizes

MAKE BACKUPS BEFORE USING, YOU BEEN WARNED :/

MyDevice = "SBV6220NEW" #Name of device
Imgfile = "images\Motorola.gif" #Name of image

FwBase = 0x40000
FwSize = 8060928
Fw1Base = 0x7F0000
Fw1Size = 8060928
U-BootBase = 0x0
U-BootSize = 131072
Env1Base = 0x20000
Env1Size = 65536
Env2Base = 0x30000
Env2Size = 65536
BlankBase = 0xFA0000
BlankSize = 65536
NvBase = 0xFB0000
NvSize = 327680
FdBase = 0x0
FdSize = 16777216

JTAG.MemoryType("SPI")
SPIFLASH = JTAG.MemoryInit()


t1 = Tab.Create(MyDevice)
t2 = Tab.Create(Imgfile)

Tab(t1).AddGroup("U-Boot",10,10,100,150)
Tab(t1).AddGroup("Env1",110,10,100,150)
Tab(t1).AddGroup("Env2",210,10,100,150)
Tab(t1).AddGroup("UBFI1",310,10,100,150)
Tab(t1).AddGroup("UBFI2",10,160,100,150)
Tab(t1).AddGroup("Blank",110,160,100,150)
Tab(t1).AddGroup("NVRAM",210,160,100,150)
Tab(t1).AddGroup("FullDump",310,160,100,150)
Tab(t1).AddButton("ReadU-Boot","Read",20,42)
Tab(t1).AddButton("WriteU-Boot","Write",20,102)
Tab(t1).AddButton("ReadEnv1","Read",120,42)
Tab(t1).AddButton("WriteEnv1","Write",120,102)
Tab(t1).AddButton("ReadEnv2","Read",220,42)
Tab(t1).AddButton("WriteEnv2","Write",220,102)
Tab(t1).AddButton("ReadUBFI1","Read",320,42)
Tab(t1).AddButton("WriteUBFI1","Write",320,102)
Tab(t1).AddButton("ReadUBFI2","Read",20,192)
Tab(t1).AddButton("WriteUBFI2","Write",20,252)
Tab(t1).AddButton("ReadBlank","Read",120,192)
Tab(t1).AddButton("WriteBlank","Write",120,252)
Tab(t1).AddButton("ReadNVRAM","Read",220,192)
Tab(t1).AddButton("WriteNVRAM","Write",220,252)
Tab(t1).AddButton("ReadFullDump","Read",320,192)
Tab(t1).AddButton("WriteFullDump","Write",320,252)
Tab(t2).AddImage("LOGO",ImgFile,120,10)

CreateEvent(ReadU-Boot)
Status("Reading the U-Boot")
Tab(t1).ButtonDisable()
MyData = Memory(SPIFLASH).ReadVerify(U-BootBase,U-BootSize)
if (MyData = Nothing)
Status("Error: data read back failed")
Tab(t1).ButtonEnable()
Exit Event
endif
Prompt = "Choose filename to save the firmware"
SaveFile(MyData,Prompt,"U-Boot.bin")
Status("Successfully read U-Boot from Flash")
Tab(t1).ButtonEnable()
EndEvent


CreateEvent(WriteU-Boot)
Tab(t1).ButtonDisable()
Prompt = "Choose a U-Boot to write into Flash"
MyData = OpenFile(Prompt,"U-Boot files (*.bin)|*.bin")
if (MyData = Nothing)
goto WriteU-BootExit
endif
if not (Len(MyData) = U-BootSize)
Status("Error: File is not the size of the U-Boot")
goto WriteU-BootExit
endif
Memory(SPIFLASH).Write(MyData,U-BootBase,U-BootSize)
Status("New U-Boot successfully written")
WriteU-BootExit:
Tab(t1).ButtonEnable()
EndEvent

CreateEvent(ReadEnv1)
Status("Reading the Env1")
Tab(t1).ButtonDisable()
MyData = Memory(SPIFLASH).ReadVerify(Env1Base,Env1Size)
if (MyData = Nothing)
Status("Error: data read back failed")
Tab(t1).ButtonEnable()
Exit Event
endif
Prompt = "Choose filename to save the firmware"
SaveFile(MyData,Prompt,"Env1.bin")
Status("Successfully read Env1 from Flash")
Tab(t1).ButtonEnable()
EndEvent


CreateEvent(WriteEnv1)
Tab(t1).ButtonDisable()
Prompt = "Choose an Env1 to write into Flash"
MyData = OpenFile(Prompt,"Env1 files (*.bin)|*.bin")
if (MyData = Nothing)
goto WriteEnv1Exit
endif
if not (Len(MyData) = Env1Size)
Status("Error: File is not the size of the Env1")
goto WriteEnv1Exit
endif
Memory(SPIFLASH).Write(MyData,Env1Base,Env1Size)
Status("New Env1 successfully written")
WriteEnv1Exit:
Tab(t1).ButtonEnable()
EndEvent

CreateEvent(ReadEnv2)
Status("Reading the Env2")
Tab(t1).ButtonDisable()
MyData = Memory(SPIFLASH).ReadVerify(Env2Base,Env2Size)
if (MyData = Nothing)
Status("Error: data read back failed")
Tab(t1).ButtonEnable()
Exit Event
endif
Prompt = "Choose filename to save the firmware"
SaveFile(MyData,Prompt,"Env2.bin")
Status("Successfully read Env2 from Flash")
Tab(t1).ButtonEnable()
EndEvent


CreateEvent(WriteEnv2)
Tab(t1).ButtonDisable()
Prompt = "Choose an Env2 to write into Flash"
MyData = OpenFile(Prompt,"Env2 files (*.bin)|*.bin")
if (MyData = Nothing)
goto WriteEnv2Exit
endif
if not (Len(MyData) = Env2Size)
Status("Error: File is not the size of the Env2")
goto WriteEnv2Exit
endif
Memory(SPIFLASH).Write(MyData,Env2Base,Env2Size)
Status("New Env2 successfully written")
WriteEnv2Exit:
Tab(t1).ButtonEnable()
EndEvent

CreateEvent(ReadUBFI1)
Status("Saving the SBV6220's Firmware")
Tab(t1).ButtonDisable()
MyData = Memory(SPIFLASH).ReadVerify(FwBase,FwSize)
if (MyData = Nothing)
Status("Error: data read back failed")
Tab(t1).ButtonEnable()
Exit Event
endif
Prompt = "Choose filename to save the firmware"
SaveFile(MyData,Prompt,"UBFI1.bin")
Status("Successfully read UBFI1 from Flash")
Tab(t1).ButtonEnable()
EndEvent

CreateEvent(WriteUBFI1)
Status("Programming the SBV6220's Firmware")
Tab(t1).ButtonDisable()
Prompt = "Choose a firmware to install"
MyData = OpenFile(Prompt,"Firmware files (*.bin,*.p7)|*.bin;*.p7")
if (MyData = Nothing)
WriteErr = "User cancelled opperation"
goto ExitWriteFwErr
endif
If (HWORD(MyData,0) = 12418) #Remove header if .p7 fw
Writeline("Removing .p7 firmware header")
HeadLen = HWORD(MyData,2) + 52 #increases Headlen by 7
NewLen = Len(MyData) - HeadLen
Resize(MyData,HeadLen,NewLen) #Removes the p7 header
endif
FwLen = Len(MyData)
Memory(SPIFLASH).Write(MyData,FwBase,FwLen)
FwSize = FwLen
Status("New firmware successfully installed")
Tab(t1).ButtonEnable()
Exit
ExitWriteFwErr:
Status(WriteErr)
Tab(t1).ButtonEnable()
EndEvent

CreateEvent(ReadUBFI2)
Status("Saving the SBV6220's Firmware")
Tab(t1).ButtonDisable()
MyData = Memory(SPIFLASH).ReadVerify(Fw1Base,Fw1Size)
if (MyData = Nothing)
Status("Error: data read back failed")
Tab(t1).ButtonEnable()
Exit Event
endif
Prompt = "Choose filename to save the firmware"
SaveFile(MyData,Prompt,"UBFI2.bin")
Status("Successfully read UBFI2 from Flash")
Tab(t1).ButtonEnable()
EndEvent

CreateEvent(WriteUBFI2)
Status("Programming the SBV6220's Firmware")
Tab(t1).ButtonDisable()
Prompt = "Choose a firmware to install"
MyData = OpenFile(Prompt,"Firmware files (*.bin,*.p7)|*.bin;*.p7")
if (MyData = Nothing)
WriteErr = "User cancelled opperation"
goto ExitWriteFwErr
endif
If (HWORD(MyData,0) = 12418) #Remove header if .p7 fw
Writeline("Removing .p7 firmware header")
HeadLen = HWORD(MyData,2) + 52 #increases Headlen by 7
NewLen = Len(MyData) - HeadLen
Resize(MyData,HeadLen,NewLen) #Removes the p7 header
endif
FwLen = Len(MyData)
Memory(SPIFLASH).Write(MyData,Fw1Base,FwLen)
Fw1Size = FwLen
Status("New firmware successfully installed")
Tab(t1).ButtonEnable()
Exit
ExitWriteFwErr:
Status(WriteErr)
Tab(t1).ButtonEnable()
EndEvent

CreateEvent(ReadBlank)
Status("Reading the Blank")
Tab(t1).ButtonDisable()
MyData = Memory(SPIFLASH).ReadVerify(BlankBase,BlankSize)
if (MyData = Nothing)
Status("Error: data read back failed")
Tab(t1).ButtonEnable()
Exit Event
endif
Prompt = "Choose filename to save the firmware"
SaveFile(MyData,Prompt,"Blank.bin")
Status("Successfully read Blank from Flash")
Tab(t1).ButtonEnable()
EndEvent


CreateEvent(WriteBlank)
Tab(t1).ButtonDisable()
Prompt = "Choose a Blank to write into Flash"
MyData = OpenFile(Prompt,"Blank files (*.bin)|*.bin")
if (MyData = Nothing)
goto WriteBlankExit
endif
if not (Len(MyData) = BlankSize)
Status("Error: File is not the size of the Blank")
goto WriteBlankExit
endif
Memory(SPIFLASH).Write(MyData,BlankBase,BlankSize)
Status("New Blank successfully written")
WriteBlankExit:
Tab(t1).ButtonEnable()
EndEvent

CreateEvent(ReadNVRAM)
Status("Reading the NVRAM")
Tab(t1).ButtonDisable()
MyData = Memory(SPIFLASH).ReadVerify(NvBase,NvSize)
if (MyData = Nothing)
Status("Error: data read back failed")
Tab(t1).ButtonEnable()
Exit Event
endif
Prompt = "Choose filename to save the NVRAM"
SaveFile(MyData,Prompt,"NVRAM.bin")
Status("Successfully read NVRAM from Flash")
Tab(t1).ButtonEnable()
EndEvent


CreateEvent(WriteNVRAM)
Tab(t1).ButtonDisable()
Prompt = "Choose the NVRAM to write into Flash"
MyData = OpenFile(Prompt,"NVRAM files (*.bin)|*.bin")
if (MyData = Nothing)
goto WriteNVRAMExit
endif
if not (Len(MyData) = NvSize)
Status("Error: File is not the size of the NVRAM")
goto WriteNVRAMExit
endif
Memory(SPIFLASH).Write(MyData,NvBase,NvSize)
Status("New NVRAM successfully written")
WriteNVRAMExit:
Tab(t1).ButtonEnable()
EndEvent

CreateEvent(ReadFullDump)
Status("Reading the whole Flash")
Tab(t1).ButtonDisable()
MyData = Memory(SPIFLASH).ReadVerify(FdBase,FdSize)
if (MyData = Nothing)
Status("Error: data read back failed")
Tab(t1).ButtonEnable()
Exit Event
endif
Prompt = "Choose filename to save the Full Dump"
SaveFile(MyData,Prompt,"SBV6220.bin")
Status("Successfully read the whole Flash")
Tab(t1).ButtonEnable()
EndEvent


CreateEvent(WriteFullDump)
Tab(t1).ButtonDisable()
Prompt = "Choose a Full Dump to write into Flash"
MyData = OpenFile(Prompt,"SBV6220 files (*.bin)|*.bin")
if (MyData = Nothing)
goto WriteFullDumpExit
endif
if not (Len(MyData) = FdSize)
Status("Error: File is not the size of the SBV6220")
goto WriteFullDumpExit
endif
Memory(SPIFLASH).Write(MyData,FdBase,FdSize)
Status("New Full Dump successfully written")
WriteFullDumpExit:
Tab(t1).ButtonEnable()
EndEvent


Please test and leave some feedback....thanks
 

Attachments

  • SBV6220NEW_SPI.bcs
    9.7 KB · Views: 57
Nice work , hopefully people will leave some feedback for this , if you don't mind could you add this to the list of Target devices with some screenshots , would be greatly appreciated
 
Back
Top