• 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

TM802G Script SPI

Status
Not open for further replies.

D3m0n

Administrator
Staff member
#This is a script for SPI mode
MyDevice = "Arris TM802G"

FwBase = 0x40000
FwSize = 8060928
Fw1Base = 0x3F0000
Fw1Size = 8060928
U-BootBase = 0x0
U-BootSize = 131072
NvBase = 0x7B0000
NvSize = 327680

t1 = Tab.Create(MyDevice)

Tab(t1).AddGroup("U-Boot",10,10,100,150)
Tab(t1).AddGroup("Firmware",110,10,100,150)
Tab(t1).AddGroup("Firmware1",210,10,100,150)
Tab(t1).AddGroup("Nvram",310,10,100,150)
Tab(t1).AddButton("ReadU-Boot","Read",20,42)
Tab(t1).AddButton("WriteU-Boot","Write",20,102)
Tab(t1).AddButton("ReadFirmware","Read",120,42)
Tab(t1).AddButton("WriteFirmware","Write",120,102)
Tab(t1).AddButton("ReadFirmware1","Read",220,42)
Tab(t1).AddButton("WriteFirmware1","Write",220,102)
Tab(t1).AddButton("ReadNvram","Read",320,42)
Tab(t1).AddButton("WriteNvram","Write",320,102)

CreateEvent(ReadU-Boot)
Status("Reading the U-Boot")
Tab(t1).ButtonDisable()
MyData = Memory.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.Write(MyData,U-BootBase,U-BootSize)
Status("New U-Boot successfully written")
WriteU-BootExit:
Tab(t1).ButtonEnable()
EndEvent

CreateEvent(ReadFirmware)
Status("Saving the Arris tm802g'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,"tm802g.bin")
Status("Successfully read firmware from Flash")
Tab(t1).ButtonEnable()
EndEvent

CreateEvent(WriteFirmware)
Status("Programming the Arris tm802g'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

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

CreateEvent(WriteFirmware1)
Status("Programming the Arris tm802g'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,Fw1Base,FwLen)
Fw1Size = FwLen
Status("New firmware successfully installed")
Tab(t1).ButtonEnable()
Exit
ExitWriteFwErr:
Status(WriteErr)
Tab(t1).ButtonEnable()
EndEvent

CreateEvent(ReadNVRAM)
Status("Reading the NVRAM")
Tab(t1).ButtonDisable()
MyData = Memory.ReadVerify(NvBase,NvSize)
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,"NVRAM.bin")
Status("Successfully read NVRAM from Flash")
Tab(t1).ButtonEnable()
EndEvent

CreateEvent(WriteNVRAM)
Status("Programming the NVRAM")
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
NvLen = Len(MyData)
Memory.Write(MyData,NvBase,NvLen)
NvSize = NvLen
Status("New NVRAM successfully installed")
Tab(t1).ButtonEnable()
Exit
ExitWriteFwErr:
Status(WriteErr)
Tab(t1).ButtonEnable()

EndEvent
 

Attachments

Status
Not open for further replies.
Top