• 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

SB5100 Script BCM3348 JTAG

Status
Not open for further replies.

D3m0n

Administrator
Staff member
# Script file for BCM3349 (SB5100) - 334817F
# This script is automatically executed when BlackcatUSB
# reads the CPU ID that the SB5100 uses. Which is 0x334817F.

MyDevice = "Motorola SB5100" #Name of device
BootSize = 32768 #Size of bootloader (in bytes)
ImgFile = "images\Motorola.gif" #Location of the logo

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

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

JTAG.BigEndian #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()


Legacy.SetFlash(CFGFLASH)
MYFIRMNAME = Legacy.GetFwName()

t1 = Tab.Create(MyDevice)
Tab(t1).AddGroup("Bootloader",10,10,420,54)
Tab(t1).AddGroup("Firmware",10,70,420,80)
Tab(t1).AddText("MSG1","This changes the default bootloader",20,36)
Tab(t1).AddButton("ReadBoot","Read",250,30)
Tab(t1).AddButton("WriteBoot","Write",340,30)
Tab(t1).AddText("FWTITLE","Currently installed:",18,92)
Tab(t1).AddText("FW",MYFIRMNAME,18,106)
Tab(t1).AddButton("SaveFirmware","Save",250,98)
Tab(t1).AddButton("WriteFirmware","Change",340,98)
Tab(t1).AddImage("LOGO",ImgFile,45,200)
Tab(t1).AddProgress(20,270,404) #Adds a progress bar (updates automatically from any function)

CreateEvent(ReadBoot) #This reads the bootloader
Status("Reading the SB5100 Bootloader")
Tab(t1).ButtonDisable()
MyData = Memory(CFGFLASH).Read(0,BootSize,False)
Prompt = "Choose filename to save bootloader"
SaveFile(MyData,Prompt,"SB5100.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 bootloader")
goto WriteBootExit
endif
Memory(CFGFLASH).Write(MyData,0,BootSize)
Status("New bootloader successfully written")
WriteBootExit:
Tab(t1).ButtonEnable()
EndEvent

CreateEvent(SaveFirmware)
Status("Saving the SB5100's Firmware")
Tab(t1).ButtonDisable()
FwStart = Legacy.GetFwLocation()
FwLen = Legacy.GetFwLen()
FwLen += 92 #Need to add 92 bytes to cover the fw header
MyData = Memory(CFGFLASH).ReadVerify(FwStart,FwLen) #ReadFlashVerify
if (MyData = Nothing)
Status("Error: data read was corrupted")
Tab(t1).ButtonEnable()
Exit Event
endif
Prompt = "Choose filename to save the firmware"
SaveFile(MyData,Prompt,MYFIRMNAME)
Status("Successfully read firmware from Flash")
Tab(t1).ButtonEnable()
EndEvent

CreateEvent(WriteFirmware)
Status("Programming the SB5100's 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) + 7 #increases Headlen by 7
NewLen = Len(MyData) - HeadLen
Resize(MyData,HeadLen,NewLen) #Removes the p7 header
endif
FwLen = Len(MyData)
FwStart = Legacy.GetFwLocation()
If (FwStart = 0)
WriteErr = "Error: Firmware destination not found"
goto ExitWriteFwErr
endif
If (FwLen > 600000)
goto BeginWrite
endif
If not Ask("File is smaller than a typical firmware. Write Anyways?")
WriteErr = "Cancelled firmware update"
goto ExitWriteFwErr
endif
BeginWrite:
Memory(CFGFLASH).Write(MyData,FwStart,FwLen)
Status("New firmware successfully installed")
MYFIRMNAME = Legacy.GetFwName()
Tab(t1).SetText("FW",MYFIRMNAME)
Tab(t1).ButtonEnable()
Exit
ExitWriteFwErr:
Status(WriteErr)
Tab(t1).ButtonEnable()
EndEvent
 

Attachments

Status
Not open for further replies.
Top