• 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

SBG900 Script BCM3348 JTAG

Status
Not open for further replies.

D3m0n

Administrator
Staff member
# Script file for BCM3348 (SBG900) -334817F

MyDevice = "SBG900" #Name of device

SetParam(1,50) #Sets the Intel flash delay
SetParam(2,150) #Sets the AMD flash delay
SetParam(3,50) #Sets the DMA read delay

JTAG.BigEndian #Sets the device endian

JTAG.MemoryAddress(0x0)
JTAG.MemoryType("RAM")
JTAG.MemorySize(0x800000)
CFGMEM = JTAG.MemoryInit()
JTAG.MemoryAddress(0x1f400000)
JTAG.MemoryType("CFI")
CFGFLASH = JTAG.MemoryInit()

JTAG.Poke(0xfffe0224,0x0)
JTAG.Poke(0xfffe2300,0x1a)
JTAG.Poke(0xfffe2304,0x0)
JTAG.Poke(0xfffe2308,0x8040)
JTAG.Poke(0xfffe230C,0x3)
JTAG.Poke(0xfffe2310,0x4824)



FWBase = 0x20000
FWSize = 3932160
FW1Base = 0x400000
FW1Size = 3932160
BootBase = 0x0
BootSize = 131072
CfgBase = 0x3E0000
CfgSize = 131072
LogBase = 0x7C0000
LogSize = 262144


t1 = Tab.Create(MyDevice)
Tab(t1).AddGroup("Bootloader",10,10,95,100)
Tab(t1).AddGroup("Firmware",110,10,95,100)
Tab(t1).AddGroup("Firmware2",110,120,95,100)
Tab(t1).AddGroup("Cfg",210,10,95,100)
Tab(t1).AddGroup("Log",310,10,95,100)
Tab(t1).AddButton("ReadBoot","Read",15,30)
Tab(t1).AddButton("WriteBoot","Write",15,60)
Tab(t1).AddButton("ReadFirmware","Read",115,30)
Tab(t1).AddButton("WriteFirmware","Write",115,60)
Tab(t1).AddButton("ReadCfg","Read",215,30)
Tab(t1).AddButton("WriteCfg","Write",215,60)
Tab(t1).AddButton("ReadLog","Read",315,30)
Tab(t1).AddButton("WriteLog","Write",315,60)
Tab(t1).AddButton("ReadFirmware2","Read",115,140)
Tab(t1).AddButton("WriteFirmware2","Write",115,170)

CreateEvent(ReadBoot)
Status("Reading the Bootloader")
Tab(t1).ButtonDisable()
MyData = Memory(CFGFLASH).ReadVerify(BootBase,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,"Bootloader.bin")
Status("Successfully read Bootloader from Flash")
Tab(t1).ButtonEnable()
EndEvent


CreateEvent(WriteBoot)
Tab(t1).ButtonDisable()
Prompt = "Choose a Bootloader to write into Flash"
MyData = OpenFile(Prompt,"Bootloader files (*.bin)|*.bin")
if (MyData = Nothing)
goto WriteBootExit
endif
if not (Len(MyData) = BootSize)
Status("Error: File is not the size of the boot")
goto WriteBootExit
endif
Memory(CFGFLASH).Write(MyData,BootBase,BootSize)
Status("New Bootloader successfully written")
Tab(t1).ButtonEnable()
Exit
ExitWriteFwErr:
Status(WriteErr)
Tab(t1).ButtonEnable()
EndEvent

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

CreateEvent(WriteFirmware)
Status("Programming the 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(CFGFLASH).Write(MyData,FwBase,FwLen)
FwSize = FwLen
Status("New Firmware successfully installed")
Tab(t1).ButtonEnable()
Exit
ExitWriteFwErr:
Status(WriteErr)
Tab(t1).ButtonEnable()
EndEvent

CreateEvent(ReadFirmware2)
Status("Reading the Firmware")
Tab(t1).ButtonDisable()
MyData = Memory(CFGFLASH).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,"Firmware2.bin")
Status("Successfully read Firmware from Flash")
Tab(t1).ButtonEnable()
EndEvent

CreateEvent(WriteFirmware2)
Status("Programming the 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(CFGFLASH).Write(MyData,Fw1Base,FwLen)
Fw1Size = FwLen
Status("New Firmware successfully installed")
Tab(t1).ButtonEnable()
Exit
ExitWriteFwErr:
Status(WriteErr)
Tab(t1).ButtonEnable()
EndEvent

CreateEvent(ReadCfg)
Status("Reading the Config")
Tab(t1).ButtonDisable()
MyData = Memory(CFGFLASH).ReadVerify(CfgBase,CfgSize)
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,"Config.bin")
Status("Successfully read Config from Flash")
Tab(t1).ButtonEnable()
EndEvent


CreateEvent(WriteCfg)
Tab(t1).ButtonDisable()
Prompt = "Choose a Config to write into Flash"
MyData = OpenFile(Prompt,"Config files (*.bin)|*.bin")
if (MyData = Nothing)
goto WriteCfgExit
endif
if not (Len(MyData) = CfgSize)
Status("Error: File is not the size of the Cfg")
goto WriteCfgExit
endif
Memory(CFGFLASH).Write(MyData,CfgBase,CfgSize)
Status("New Config successfully written")
Tab(t1).ButtonEnable()
Exit
ExitWriteFwErr:
Status(WriteErr)
Tab(t1).ButtonEnable()
EndEvent

CreateEvent(ReadLog)
Status("Reading the Log")
Tab(t1).ButtonDisable()
MyData = Memory(CFGFLASH).ReadVerify(LogBase,LogSize)
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,"Log.bin")
Status("Successfully read Log from Flash")
Tab(t1).ButtonEnable()
EndEvent


CreateEvent(WriteLog)
Tab(t1).ButtonDisable()
Prompt = "Choose a Log to write into Flash"
MyData = OpenFile(Prompt,"Log files (*.bin)|*.bin")
if (MyData = Nothing)
goto WriteLogExit
endif
if not (Len(MyData) = LogSize)
Status("Error: File is not the size of the Log")
goto WriteLogExit
endif
Memory(CFGFLASH).Write(MyData,LogBase,LogSize)
Status("New Log successfully written")
Tab(t1).ButtonEnable()
Exit
ExitWriteFwErr:
Status(WriteErr)
Tab(t1).ButtonEnable()
EndEvent
 

Attachments

Status
Not open for further replies.
Top