# Script file for Huawei HG556a
MyDevice = "NHuawei HG556a" #Name of device
SetParam(1,150) #Sets the Intel flash delay
SetParam(2,150) #Sets the AMD flash delay
SetParam(3,100) #Sets the DMA read delay
JTAG.BigEndian #Sets the device endian
JTAG.MemoryAddress(0x0)
JTAG.MemoryType("RAM")
JTAG.MemorySize(0x1f00000)
CFGMEM = JTAG.MemoryInit()
JTAG.MemoryAddress(0x1f000000)
JTAG.MemoryType("CFI")
CFGFLASH = JTAG.MemoryInit()
MacBase = 0x6A0
MacSize = 6
FirmBase = 0x2000
WpaBase = 0xFDE920
WpaSize = 14
SerialBase = 0x6A8
SerialSize = 15
SSIDBase = 0xFDE968
SSIDSize = 12
SSID2Base = 0xFE0403
SSID2Size = 12
SSID3Base = 0xFE072A
SSID3Size = 12
SSID4Base = 0xFFE968
SSID4Size = 12
SSID5Base = 0xFF0403
SSID5Size = 12
SSID6Base = 0xFF072A
SSID6Size = 12
t1 = Tab.Create(MyDevice)
Tab(t1).AddButton("ReadMac","Read Mac",15,30)
Tab(t1).AddButton("WriteMac","Write Mac",15,60)
Tab(t1).AddButton("ReadWpa","Read Wpa",150,30)
Tab(t1).AddButton("WriteWpa","Write Wpa",150,60)
Tab(t1).AddButton("ReadSSID","Read SSID",15,120)
Tab(t1).AddButton("WriteSSID","Write SSID",15,150)
Tab(t1).AddButton("ReadSerial","Read Serial",150,120)
Tab(t1).AddButton("WriteSerial","Write Serial",150,150)
Tab(t1).AddButton("EraseF","Erase Flash",15,210)
CreateEvent(EraseF)
Tab(t1).ButtonDisable()
Memory(CFGFLASH).EraseBulk()
Status("Erased")
Tab(t1).ButtonEnable()
Exit
EndEvent
CreateEvent(ReadMac)
Status("Reading the Mac")
Tab(t1).ButtonDisable()
MyData = Memory(CFGFLASH).ReadVerify(MacBase,MacSize)
if (MyData = Nothing)
Status("Error: data read back failed")
Tab(t1).ButtonEnable()
Exit Event
endif
Prompt = "Choose filename to save the mac"
SaveFile(MyData,Prompt,"mac.bin")
Status("Successfully read Mac from Flash")
Tab(t1).ButtonEnable()
EndEvent
CreateEvent(WriteMac)
Tab(t1).ButtonDisable()
Prompt = "Choose a mac to write into Flash"
MyData = OpenFile(Prompt,"mac files (*.bin)|*.bin")
if (MyData = Nothing)
goto WriteMacExit
endif
if not (Len(MyData) = MacSize)
Status("Error: File is not the size of the mac")
goto WriteMacExit
endif
Memory(CFGFLASH).Write(MyData,MacBase,MacSize)
Status("New Mac successfully written")
Tab(t1).ButtonEnable()
Exit
ExitWriteFwErr:
Status(WriteErr)
Tab(t1).ButtonEnable()
EndEvent
CreateEvent(ReadWpa)
Status("Reading the Wpa")
Tab(t1).ButtonDisable()
MyData = Memory(CFGFLASH).ReadVerify(WpaBase,WpaSize)
if (MyData = Nothing)
Status("Error: data read back failed")
Tab(t1).ButtonEnable()
Exit Event
endif
Prompt = "Choose filename to save the Wpa"
SaveFile(MyData,Prompt,"wpa.bin")
Status("Successfully read Wpa from Flash")
Tab(t1).ButtonEnable()
EndEvent
CreateEvent(WriteWpa)
Tab(t1).ButtonDisable()
Prompt = "Choose a Wpa to write into Flash"
MyData = OpenFile(Prompt,"wpa files (*.bin)|*.bin")
if (MyData = Nothing)
goto WriteWpaExit
endif
if not (Len(MyData) = WpaSize)
Status("Error: File is not the size of the wpa")
goto WriteWpaExit
endif
Memory(CFGFLASH).Write(MyData,WpaBase,WpaSize)
Status("New Wpa successfully written")
Tab(t1).ButtonEnable()
Exit
ExitWriteFwErr:
Status(WriteErr)
Tab(t1).ButtonEnable()
EndEvent
CreateEvent(ReadSerial)
Status("Reading the Serial")
Tab(t1).ButtonDisable()
MyData = Memory(CFGFLASH).ReadVerify(SerialBase,SerialSize)
if (MyData = Nothing)
Status("Error: data read back failed")
Tab(t1).ButtonEnable()
Exit Event
endif
Prompt = "Choose filename to save the serial"
SaveFile(MyData,Prompt,"wpa.bin")
Status("Successfully read Serial from Flash")
Tab(t1).ButtonEnable()
EndEvent
CreateEvent(WriteWpa)
Tab(t1).ButtonDisable()
Prompt = "Choose a Serial to write into Flash"
MyData = OpenFile(Prompt,"serial files (*.bin)|*.bin")
if (MyData = Nothing)
goto WriteSerialExit
endif
if not (Len(MyData) = SerialSize)
Status("Error: File is not the size of the serial")
goto WriteSerialExit
endif
Memory(CFGFLASH).Write(MyData,SerialBase,SerialSize)
Status("New Serial successfully written")
Tab(t1).ButtonEnable()
Exit
ExitWriteFwErr:
Status(WriteErr)
Tab(t1).ButtonEnable()
EndEvent
CreateEvent(ReadSSID)
Status("Reading the SSID")
Tab(t1).ButtonDisable()
MyData = Memory(CFGFLASH).ReadVerify(SSIDBase,SSIDSize)
if (MyData = Nothing)
Status("Error: data read back failed")
Tab(t1).ButtonEnable()
Exit Event
endif
Prompt = "Choose filename to save the SSID"
SaveFile(MyData,Prompt,"SSID.bin")
Status("Successfully read SSID from Flash")
Tab(t1).ButtonEnable()
EndEvent
CreateEvent(WriteSSID)
Tab(t1).ButtonDisable()
Prompt = "Choose a SSID to write into Flash"
MyData = OpenFile(Prompt,"SSID files (*.bin)|*.bin")
if (MyData = Nothing)
goto WriteSSIDExit
endif
if not (Len(MyData) = SSIDSize)
Status("Error: File is not the size of the SSID")
goto WriteMSSIDExit
endif
Memory(CFGFLASH).Write(MyData,SSIDBase,SSIDSize)
Memory(CFGFLASH).Write(MyData,SSID2Base,SSID2Size)
Memory(CFGFLASH).Write(MyData,SSID3Base,SSID3Size)
Memory(CFGFLASH).Write(MyData,SSID4Base,SSID4Size)
Memory(CFGFLASH).Write(MyData,SSID5Base,SSID5Size)
Memory(CFGFLASH).Write(MyData,SSID6Base,SSID6Size)
Status("New SSID successfully written")
Tab(t1).ButtonEnable()
Exit
ExitWriteFwErr:
Status(WriteErr)
Tab(t1).ButtonEnable()
EndEvent
MyDevice = "NHuawei HG556a" #Name of device
SetParam(1,150) #Sets the Intel flash delay
SetParam(2,150) #Sets the AMD flash delay
SetParam(3,100) #Sets the DMA read delay
JTAG.BigEndian #Sets the device endian
JTAG.MemoryAddress(0x0)
JTAG.MemoryType("RAM")
JTAG.MemorySize(0x1f00000)
CFGMEM = JTAG.MemoryInit()
JTAG.MemoryAddress(0x1f000000)
JTAG.MemoryType("CFI")
CFGFLASH = JTAG.MemoryInit()
MacBase = 0x6A0
MacSize = 6
FirmBase = 0x2000
WpaBase = 0xFDE920
WpaSize = 14
SerialBase = 0x6A8
SerialSize = 15
SSIDBase = 0xFDE968
SSIDSize = 12
SSID2Base = 0xFE0403
SSID2Size = 12
SSID3Base = 0xFE072A
SSID3Size = 12
SSID4Base = 0xFFE968
SSID4Size = 12
SSID5Base = 0xFF0403
SSID5Size = 12
SSID6Base = 0xFF072A
SSID6Size = 12
t1 = Tab.Create(MyDevice)
Tab(t1).AddButton("ReadMac","Read Mac",15,30)
Tab(t1).AddButton("WriteMac","Write Mac",15,60)
Tab(t1).AddButton("ReadWpa","Read Wpa",150,30)
Tab(t1).AddButton("WriteWpa","Write Wpa",150,60)
Tab(t1).AddButton("ReadSSID","Read SSID",15,120)
Tab(t1).AddButton("WriteSSID","Write SSID",15,150)
Tab(t1).AddButton("ReadSerial","Read Serial",150,120)
Tab(t1).AddButton("WriteSerial","Write Serial",150,150)
Tab(t1).AddButton("EraseF","Erase Flash",15,210)
CreateEvent(EraseF)
Tab(t1).ButtonDisable()
Memory(CFGFLASH).EraseBulk()
Status("Erased")
Tab(t1).ButtonEnable()
Exit
EndEvent
CreateEvent(ReadMac)
Status("Reading the Mac")
Tab(t1).ButtonDisable()
MyData = Memory(CFGFLASH).ReadVerify(MacBase,MacSize)
if (MyData = Nothing)
Status("Error: data read back failed")
Tab(t1).ButtonEnable()
Exit Event
endif
Prompt = "Choose filename to save the mac"
SaveFile(MyData,Prompt,"mac.bin")
Status("Successfully read Mac from Flash")
Tab(t1).ButtonEnable()
EndEvent
CreateEvent(WriteMac)
Tab(t1).ButtonDisable()
Prompt = "Choose a mac to write into Flash"
MyData = OpenFile(Prompt,"mac files (*.bin)|*.bin")
if (MyData = Nothing)
goto WriteMacExit
endif
if not (Len(MyData) = MacSize)
Status("Error: File is not the size of the mac")
goto WriteMacExit
endif
Memory(CFGFLASH).Write(MyData,MacBase,MacSize)
Status("New Mac successfully written")
Tab(t1).ButtonEnable()
Exit
ExitWriteFwErr:
Status(WriteErr)
Tab(t1).ButtonEnable()
EndEvent
CreateEvent(ReadWpa)
Status("Reading the Wpa")
Tab(t1).ButtonDisable()
MyData = Memory(CFGFLASH).ReadVerify(WpaBase,WpaSize)
if (MyData = Nothing)
Status("Error: data read back failed")
Tab(t1).ButtonEnable()
Exit Event
endif
Prompt = "Choose filename to save the Wpa"
SaveFile(MyData,Prompt,"wpa.bin")
Status("Successfully read Wpa from Flash")
Tab(t1).ButtonEnable()
EndEvent
CreateEvent(WriteWpa)
Tab(t1).ButtonDisable()
Prompt = "Choose a Wpa to write into Flash"
MyData = OpenFile(Prompt,"wpa files (*.bin)|*.bin")
if (MyData = Nothing)
goto WriteWpaExit
endif
if not (Len(MyData) = WpaSize)
Status("Error: File is not the size of the wpa")
goto WriteWpaExit
endif
Memory(CFGFLASH).Write(MyData,WpaBase,WpaSize)
Status("New Wpa successfully written")
Tab(t1).ButtonEnable()
Exit
ExitWriteFwErr:
Status(WriteErr)
Tab(t1).ButtonEnable()
EndEvent
CreateEvent(ReadSerial)
Status("Reading the Serial")
Tab(t1).ButtonDisable()
MyData = Memory(CFGFLASH).ReadVerify(SerialBase,SerialSize)
if (MyData = Nothing)
Status("Error: data read back failed")
Tab(t1).ButtonEnable()
Exit Event
endif
Prompt = "Choose filename to save the serial"
SaveFile(MyData,Prompt,"wpa.bin")
Status("Successfully read Serial from Flash")
Tab(t1).ButtonEnable()
EndEvent
CreateEvent(WriteWpa)
Tab(t1).ButtonDisable()
Prompt = "Choose a Serial to write into Flash"
MyData = OpenFile(Prompt,"serial files (*.bin)|*.bin")
if (MyData = Nothing)
goto WriteSerialExit
endif
if not (Len(MyData) = SerialSize)
Status("Error: File is not the size of the serial")
goto WriteSerialExit
endif
Memory(CFGFLASH).Write(MyData,SerialBase,SerialSize)
Status("New Serial successfully written")
Tab(t1).ButtonEnable()
Exit
ExitWriteFwErr:
Status(WriteErr)
Tab(t1).ButtonEnable()
EndEvent
CreateEvent(ReadSSID)
Status("Reading the SSID")
Tab(t1).ButtonDisable()
MyData = Memory(CFGFLASH).ReadVerify(SSIDBase,SSIDSize)
if (MyData = Nothing)
Status("Error: data read back failed")
Tab(t1).ButtonEnable()
Exit Event
endif
Prompt = "Choose filename to save the SSID"
SaveFile(MyData,Prompt,"SSID.bin")
Status("Successfully read SSID from Flash")
Tab(t1).ButtonEnable()
EndEvent
CreateEvent(WriteSSID)
Tab(t1).ButtonDisable()
Prompt = "Choose a SSID to write into Flash"
MyData = OpenFile(Prompt,"SSID files (*.bin)|*.bin")
if (MyData = Nothing)
goto WriteSSIDExit
endif
if not (Len(MyData) = SSIDSize)
Status("Error: File is not the size of the SSID")
goto WriteMSSIDExit
endif
Memory(CFGFLASH).Write(MyData,SSIDBase,SSIDSize)
Memory(CFGFLASH).Write(MyData,SSID2Base,SSID2Size)
Memory(CFGFLASH).Write(MyData,SSID3Base,SSID3Size)
Memory(CFGFLASH).Write(MyData,SSID4Base,SSID4Size)
Memory(CFGFLASH).Write(MyData,SSID5Base,SSID5Size)
Memory(CFGFLASH).Write(MyData,SSID6Base,SSID6Size)
Status("New SSID successfully written")
Tab(t1).ButtonEnable()
Exit
ExitWriteFwErr:
Status(WriteErr)
Tab(t1).ButtonEnable()
EndEvent