Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MyDevice = "SB6141" #Name of device
- FlBase = 0x0
- FLSize = 0x7FFFFF
- FwBase = 0x40000
- FwSize = 3866624
- Fw1Base = 0x3F0000
- Fw1Size = 3866624
- BootBase = 0x0
- BootSize = 131072
- Env1Base = 0x20000
- Env1Size = 131072
- BlankBase = 0x7A0000
- BlankSize = 196608
- LogBase = 0x7D0000
- LogSize = 131072
- CfgBase = 0x7F0000
- CfgSize = 65536
- #JTAG.MemoryType("SPI")
- SPIFLASH = JTAG.MemoryInit("SPI", 1)
- t1 = Tab.Create(MyDevice)
- Tab(t1).AddGroup("U-Boot",10,10,100,150)
- Tab(t1).AddGroup("BootParam",110,10,100,150)
- Tab(t1).AddGroup("UBFI1",210,10,100,150)
- Tab(t1).AddGroup("UBFI2",310,10,100,150)
- Tab(t1).AddGroup("Blank",10,160,100,150)
- Tab(t1).AddGroup("Log",110,160,100,150)
- Tab(t1).AddGroup("Cfg",210,160,100,150)
- Tab(t1).AddGroup("FullFlash",310,160,100,150)
- Tab(t1).AddButton("ReadU-Boot","Read",20,42)
- Tab(t1).AddButton("WriteU-Boot","Write",20,102)
- Tab(t1).AddButton("ReadBootParam","Read",120,42)
- Tab(t1).AddButton("WriteBootParam","Write",120,102)
- Tab(t1).AddButton("ReadUBFI1","Read",220,42)
- Tab(t1).AddButton("WriteUBFI1","Write",220,102)
- Tab(t1).AddButton("ReadUBFI2","Read",320,42)
- Tab(t1).AddButton("WriteUBFI2","Write",320,102)
- Tab(t1).AddButton("ReadBlank","Read",20,192)
- Tab(t1).AddButton("WriteBlank","Write",20,252)
- Tab(t1).AddButton("ReadLog","Read",120,192)
- Tab(t1).AddButton("WriteLog","Write",120,252)
- Tab(t1).AddButton("ReadCfg","Read",220,192)
- Tab(t1).AddButton("WriteCfg","Write",220,252)
- Tab(t1).AddButton("ReadFullFlash","Read",320,192)
- Tab(t1).AddButton("WriteFullFlash","Write",320,252)
- CreateEvent(ReadU-Boot)
- Status("Reading U-Boot")
- Tab(t1).ButtonDisable()
- MyData = Memory(SPIFLASH).ReadVerify(BootBase,BootSize)
- if (MyData == Nothing)
- Status("Error: data read back failed")
- Tab(t1).ButtonEnable()
- Exit Event
- endif
- Prompt = "Choose filename for U-Boot"
- IO.Save(MyData,Prompt,"U-Boot.bin")
- #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 U-Boot to write to Flash"
- #MyData = OpenFile(Prompt,"U-Boot files (*.bin)|*.bin")
- MyData = IO.Open(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(SPIFLASH).Write(MyData,BootBase,BootSize)
- Status("New U-Boot successfully written!")
- WriteU-BootExit:
- Tab(t1).ButtonEnable()
- EndEvent
- CreateEvent(ReadBootParam)
- Status("Reading BootParams")
- Tab(t1).ButtonDisable()
- MyData = Memory(SPIFLASH).ReadVerify(Env1Base,Env1Size)
- 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,"BootParam.bin")
- IO.Save(MyData,Prompt,"BootParam.bin")
- Status("Successfully read BootParam from Flash")
- Tab(t1).ButtonEnable()
- EndEvent
- CreateEvent(WriteBootParam)
- Tab(t1).ButtonDisable()
- Prompt = "Choose BootParams to write to Flash"
- #MyData = OpenFile(Prompt,"BootParam files (*.bin)|*.bin")
- MyData = IO.Open(Prompt, "BootParam files (*.bin)|*.bin")
- if (MyData == Nothing)
- goto WriteEnv1Exit
- endif
- if not (Data.Length(MyData) == Env1Size)
- Status("Error: File is not the size of the BootParam")
- goto WriteEnv1Exit
- endif
- Memory(SPIFLASH).Write(MyData,Env1Base,Env1Size)
- Status("New BootParam successfully written")
- WriteEnv1Exit:
- Tab(t1).ButtonEnable()
- EndEvent
- CreateEvent(ReadUBFI1)
- Status("Saving the SB6141's UBFI1")
- Tab(t1).ButtonDisable()
- MyData = Memory(SPIFLASH).ReadVerify(FwBase,FwSize)
- if (MyData == Nothing)
- Status("Error: data read back failed")
- Tab(t1).ButtonEnable()
- Exit Event
- endif
- Prompt = "Choose filename for UBFI1"
- #SaveFile(MyData,Prompt,"UBFI1.bin")
- IO.Save(MyData,Prompt,"UBFI1.bin")
- Status("Successfully read UBFI1 from Flash")
- Tab(t1).ButtonEnable()
- EndEvent
- CreateEvent(WriteUBFI1)
- Status("Programming the SB6141's UBFI1")
- Tab(t1).ButtonDisable()
- Prompt = "Choose a firmware to install"
- #MyData = OpenFile(Prompt,"Firmware files (*.bin,*.p7)|*.bin;*.p7")
- MyData = IO.Open(Prompt,"Firmware files (*.bin,*.p7)|*.bin;*.p7")
- if (MyData == Nothing)
- WriteErr = "User cancelled operation"
- goto ExitWriteFwErr
- endif
- If (Data.Hword(MyData,0) == 12418) #Remove header if .p7 fw
- Writeline("Removing .p7 firmware header")
- HeadLen = Data.Hword(MyData,2) + 52 #increases Headlen by 7
- NewLen = Data.Length(MyData) - HeadLen
- Data.Resize(MyData,HeadLen,NewLen) #Removes the p7 header
- endif
- FwLen = Data.Length(MyData)
- Memory(SPIFLASH).Write(MyData,FwBase,FwLen)
- FwSize = FwLen
- Status("New firmware successfully installed")
- Tab(t1).ButtonEnable()
- Exit
- ExitWriteFwErr:
- Status(WriteErr)
- Tab(t1).ButtonEnable()
- EndEvent
- CreateEvent(ReadUBFI2)
- Status("Saving the SB6141's UBFI2")
- Tab(t1).ButtonDisable()
- MyData = Memory(SPIFLASH).ReadVerify(Fw1Base,Fw1Size)
- if (MyData == Nothing)
- Status("Error: data read back failed")
- Tab(t1).ButtonEnable()
- Exit Event
- endif
- Prompt = "Choose filename for UBFI2"
- #SaveFile(MyData,Prompt,"UBFI2.bin")
- IO.Save(MyData,Prompt,"UBFI2.bin")
- Status("Successfully read UBFI2 from Flash")
- Tab(t1).ButtonEnable()
- EndEvent
- CreateEvent(WriteUBFI2)
- Status("Programming the SB6141's UBFI2")
- Tab(t1).ButtonDisable()
- Prompt = "Choose a firmware to install"
- #MyData = OpenFile(Prompt,"Firmware files (*.bin,*.p7)|*.bin;*.p7")
- MyData = IO.Open(Prompt,"Firmware files (*.bin,*.p7)|*.bin;*.p7")
- if (MyData == Nothing)
- WriteErr = "User cancelled operation"
- goto ExitWriteFwErr
- endif
- If (Data.Hword(MyData,0) == 12418) #Remove header if .p7 fw
- Writeline("Removing .p7 firmware header")
- HeadLen = Data.Hword(MyData,2) + 52 #increases Headlen by 7
- NewLen = Data.Length(MyData) - HeadLen
- Data.Resize(MyData,HeadLen,NewLen) #Removes the p7 header
- endif
- FwLen = Data.Length(MyData)
- Memory(SPIFLASH).Write(MyData,Fw1Base,FwLen)
- Fw1Size = FwLen
- Status("New firmware successfully installed")
- Tab(t1).ButtonEnable()
- Exit
- ExitWriteFwErr:
- Status(WriteErr)
- Tab(t1).ButtonEnable()
- EndEvent
- CreateEvent(ReadBlank)
- Status("Saving 'Blank' area")
- Tab(t1).ButtonDisable()
- MyData = Memory(SPIFLASH).ReadVerify(BlankBase,BlankSize)
- if (MyData == Nothing)
- Status("Error: data read back failed")
- Tab(t1).ButtonEnable()
- Exit Event
- endif
- Prompt = "Choose filename to save Blank"
- #SaveFile(MyData,Prompt,"Blank.bin")
- IO.Save(MyData,Prompt,"Blank.bin")
- Status("Successfully read Blank from Flash")
- Tab(t1).ButtonEnable()
- EndEvent
- CreateEvent(WriteBlank)
- Tab(t1).ButtonDisable()
- Prompt = "Choose a Blank to write to Flash"
- #MyData = OpenFile(Prompt,"Blank files (*.bin)|*.bin")
- MyData = IO.Open(Prompt,"Blank files (*.bin)|*.bin")
- if (MyData == Nothing)
- goto WriteBlankExit
- endif
- if not (Data.Length(MyData) == BlankSize)
- Status("Error: File is not the size of the Blank")
- goto WriteBlankExit
- endif
- Memory(SPIFLASH).Write(MyData,BlankBase,BlankSize)
- Status("New Blank successfully written")
- WriteBlankExit:
- Tab(t1).ButtonEnable()
- EndEvent
- CreateEvent(ReadLog)
- Status("Reading the Log")
- Tab(t1).ButtonDisable()
- MyData = Memory(SPIFLASH).ReadVerify(LogBase,LogSize)
- if (MyData == Nothing)
- Status("Error: data read back failed")
- Tab(t1).ButtonEnable()
- Exit Event
- endif
- Prompt = "Choose filename to save Log"
- #SaveFile(MyData,Prompt,"Log.bin")
- IO.Save(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 to Flash"
- #MyData = OpenFile(Prompt,"Log files (*.bin)|*.bin")
- MyData = IO.Open(Prompt,"Log files (*.bin)|*.bin")
- if (MyData == Nothing)
- goto WriteLogExit
- endif
- if not (Data.Length(MyData) == LogSize)
- Status("Error: File is not the size of the Log")
- goto WriteLogExit
- endif
- Memory(SPIFLASH).Write(MyData,LogBase,LogSize)
- Status("New Log successfully written")
- WriteLogExit:
- Tab(t1).ButtonEnable()
- EndEvent
- CreateEvent(ReadCfg)
- Status("Reading the Cfg")
- Tab(t1).ButtonDisable()
- MyData = Memory(SPIFLASH).ReadVerify(CfgBase,CfgSize)
- if (MyData == Nothing)
- Status("Error: data read back failed")
- Tab(t1).ButtonEnable()
- Exit Event
- endif
- Prompt = "Choose filename to save Cfg"
- #SaveFile(MyData,Prompt,"Cfg.bin")
- IO.Save(MyData,Prompt,"Cfg.bin")
- Status("Successfully read Cfg from Flash")
- Tab(t1).ButtonEnable()
- EndEvent
- CreateEvent(WriteCfg)
- Tab(t1).ButtonDisable()
- Prompt = "Choose a Cfg to write to Flash"
- #MyData = OpenFile(Prompt,"Cfg files (*.bin)|*.bin")
- MyData = IO.Open(Prompt,"Cfg files (*.bin)|*.bin")
- if (MyData == Nothing)
- goto WriteCfgExit
- endif
- if not (Data.Length(MyData) == CfgSize)
- Status("Error: File is not the size of the Cfg")
- goto WriteCfgExit
- endif
- Memory(SPIFLASH).Write(MyData,CfgBase,CfgSize)
- Status("New Cfg successfully written")
- WriteCfgExit:
- Tab(t1).ButtonEnable()
- EndEvent
- CreateEvent(ReadFullFlash)
- Status("Saving the SB6141's Full Flash")
- Tab(t1).ButtonDisable()
- MyData = Memory(SPIFLASH).ReadVerify(FlBase,FlSize)
- if (MyData == Nothing)
- Status("Error: data read back failed")
- Tab(t1).ButtonEnable()
- Exit Event
- endif
- Prompt = "Choose filename to save Full Flash"
- #SaveFile(MyData,Prompt,"FullFlash.bin")
- IO.Save(MyData,Prompt,"FullFlash.bin")
- Status("Successfully read Full Flash!")
- Tab(t1).ButtonEnable()
- EndEvent
- CreateEvent(WriteFullFlash)
- Status("Programming the SB6141's Full Flash")
- Tab(t1).ButtonDisable()
- Prompt = "Choose a firmware to install"
- #MyData = OpenFile(Prompt,"Full Flash files (*.bin)|*.bin")
- MyData = IO.Open(Prompt,"Full Flash files (*.bin)|*.bin")
- if (MyData == Nothing)
- WriteErr = "User cancelled operation"
- goto ExitWriteFwErr
- endif
- FlLen = Data.Length(MyData)
- Memory(SPIFLASH).Write(MyData,FlBase,FlLen)
- FlSize = FlLen
- Status("Full Flash successful!")
- Tab(t1).ButtonEnable()
- Exit
- ExitWriteFwErr:
- Status(WriteErr)
- Tab(t1).ButtonEnable()
- EndEvent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement