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

WRT54G 2M/4M/8M Script JTAG

Status
Not open for further replies.

D3m0n

Administrator
Staff member
# Script file for BCM5352 (Linksys) - 535217F
# This script is automatically executed when BlackcatUSB

MyDevice = "Linksys WRT54GS 2M" #Name of device

FwBase = 0x40000
FwSize = 1769472
CFEBase = 0x0
CFESize = 262144
NvBase = 0xDF0000
NvSize = 65536

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

JTAG.LittleEndian #Sets the device endian

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

t1 = Tab.Create(MyDevice)

Tab(t1).AddGroup("CFE",10,10,420,54)
Tab(t1).AddButton("ReadCFE","Read",130,30)
Tab(t1).AddButton("WriteCFE","Write",220,30)

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

Tab(t1).AddGroup("NVRAM",10,170,420,54)
Tab(t1).AddButton("ReadNVRAM","Read",130,192)
Tab(t1).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

  • WRT54G_4M_JTAG.bcs
    4.2 KB · Views: 46
  • WRT54G_8M_JTAG.bcs
    4.2 KB · Views: 41
  • WRT54GS_2M_JTAG.bcs
    4.2 KB · Views: 41
Status
Not open for further replies.
Back
Top