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

Sagem F@st 2504 BCM6348 JTAG

Status
Not open for further replies.

D3m0n

Administrator
Staff member
# Script file for BCM6348 (Sagem F@st 2504) - 634817F
# This script is automatically executed when BlackcatUSB

MyDevice = "Sagem F@st 2504" #Name of device

FwBase = 0x10000
FwSize = 3866624
CFEBase = 0x0
CFESize = 65536
NvBase = 0x3C0000
NvSize = 262144

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

JTAG.MemoryAddress(0x1FC00000)
JTAG.MemoryType("CFI")
CFGFLASH = JTAG.MemoryInit()

SetParam(1,100) #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

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

  • Sagem_F@st_2504_JTAG.bcs
    4.2 KB · Views: 30
Status
Not open for further replies.
Back
Top