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

WGR614 v9 Script JTAG

Status
Not open for further replies.

D3m0n

Administrator
Staff member
# Script file for Netgear WGR-614 v9 - 535417F
# Processor is a Broadcom BCM5350

MyDevice = "Netgear WGR614v9" #Name of device

FwBase = 0x20000
FwSize = 1900544
CFEBase = 0x0
CFESize = 131072
NvBase = 0xDF0000
NvSize = 65536

SetParam(3,100) #Sets the DMA read delay to 20 clock cycles

JTAG.LittleEndian

JTAG.Debug(false) #Incase we were already in debug mode

JTAG.MemoryType("SPI") #SPI over JTAG support? YES!
CFGFLASH = JTAG.MemoryInit()

JTAG.Debug(true) #Turn on debug mode to ensure proper read/write


t2 = Tab.Create(MyDevice)
Tab(t2).AddGroup("CFE",10,10,420,54)
Tab(t2).AddButton("ReadCFE","Read",130,30)
Tab(t2).AddButton("WriteCFE","Write",220,30)

Tab(t2).AddGroup("Kernel",10,90,420,54)
Tab(t2).AddButton("ReadKernel","Read",130,110)
Tab(t2).AddButton("WriteKernel","Write",220,110)

Tab(t2).AddGroup("NVRAM",10,170,420,54)
Tab(t2).AddButton("ReadNVRAM","Read",130,192)
Tab(t2).AddButton("WriteNVRAM","Write",220,192)



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


CreateEvent(WriteCFE)
Tab(t1).ButtonDisable()
Prompt = "Choose a CFE to write into Flash"
MyData = OpenFile(Prompt,"CFE files (*.bin)|*.bin")
if (MyData = Nothing)
goto WriteCFEExit
endif
if not (Len(MyData) = CFESize)
Status("Error: File is not the size of the CFE")
goto WriteCFEExit
endif
Memory(CFGFLASH).Write(MyData,CFEBase,CFESize)
Status("New CFE successfully written")
WriteCFEExit:
Tab(t1).ButtonEnable()
EndEvent

CreateEvent(ReadKernel)
Status("Reading the Kernel")
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,"Kernel.bin")
Status("Successfully read Kernel from Flash")
Tab(t1).ButtonEnable()
EndEvent

CreateEvent(WriteKernel)
Status("Programming the Kernel")
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 Kernel successfully installed")
Tab(t1).ButtonEnable()
Exit
ExitWriteFwErr:
Status(WriteErr)
Tab(t1).ButtonEnable()
EndEvent

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

EndEvent
 

Attachments

  • WGR614v9_JTAG.bcs
    4.1 KB · Views: 28
Status
Not open for further replies.
Back
Top