• Seems like hotmail /outlook is blocking emails from here so please refrain from using one of these accounts as you may not receive your authorization email.. many thanks

SB6120 Script Puma5-TI SPI

Status
Not open for further replies.

D3m0n

Administrator
Staff member
MyDevice = "Motorola SB6120" #Name of device
ImgFile = "images\Motorola.gif"
FwBase = 0x40000

if not (Memory.Exist)
Writeline("Error in script: Flash not connected")
exit script
endif

ObjTxt = Memory.ReadString(0x40020)
if (ObjTxt = Nothing)
Writeline("Flash data does not contain proper firmware format")
exit script
endif
if not (ObjTxt = "Boot Script File")
Writeline("Flash data does not contain proper firmware format")
exit script
endif

FwFileOffset = Memory.Read(0x4000E,2,true)
FwFileOffsetInt = HWord(FwFileOffset,0)
ReadOffset = FwFileOffsetInt + FwBase + 76
FwFileOffset = Memory.Read(ReadOffset,4,true)
FwSize = Word(FwFileOffset,0) + FwFileOffsetInt + 128

t1 = Tab.Create(MyDevice)

Tab(t1).AddGroup("Firmware",10,10,420,75)
Tab(t1).AddButton("ReadFirmware","Read",120,42)
Tab(t1).AddButton("WriteFirmware","Write",270,42)
Tab(t1).AddImage("LOGO",ImgFile,45,240)

CreateEvent(ReadFirmware)
Status("Saving the SB6120's Firmware")
Tab(t1).ButtonDisable()
MyData = Memory.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,"SB6120.bin")
Status("Successfully read firmware from Flash")
Tab(t1).ButtonEnable()
EndEvent

CreateEvent(WriteFirmware)
Status("Programming the SB6120'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
If not (HWORD(MyData,0) = 0x2705)
Status("Error: File does not appear to be compatible firmware")
exit event
endif
FwLen = Len(MyData)
Memory.Write(MyData,FwBase,FwLen)
FwSize = FwLen
Status("New firmware successfully installed")
Tab(t1).ButtonEnable()
Exit
ExitWriteFwErr:
Status(WriteErr)
Tab(t1).ButtonEnable()
EndEvent
 

Attachments

Status
Not open for further replies.
Top