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

SB5101 Script BCM3349 JTAG

Status
Not open for further replies.

D3m0n

Administrator
Staff member
# JTAG script file for BCM3349 (SB5101) - ID 334917F

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

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

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,70)
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)

CreateEvent(ReadBoot) #This reads the bootloader
Status("Reading the SB5101 Bootloader")
Tab(t1).ButtonDisable()
MyData = Memory(CFGFLASH).Read(0,BootSize,False)
Prompt = "Choose filename to save bootloader"
SaveFile(MyData,Prompt,"SB5101.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 SB5101'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
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 SB5101'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 location not found"
goto ExitWriteFwErr
endif
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

  • SB5101_JTAG.bcs
    3.9 KB · Views: 244
Status
Not open for further replies.
Back
Top