######################## Program Executive Info ########################
pe_address = 0xa0000900
pe_len = 0x1050
######################## Device Info ########################
devInf = DeviceInfo()
devInf.deviceName = "PIC32MX695F512L"
devInf.programmerType = "PIC32MX_SSM"
devInf.family = "32-bit MCUs (PIC32)"
devInf.subFamily = "PIC32"
devInf.useRowEraseIfVoltageIsLow = False
devInf.voltageBelowWhichUseRowErase = 0
devInf.Vpp = 3300
devInf.deviceIDMask = 0xff000
devInf.deviceID = 0x4341053
memTypeInfo = []
memInf = MemInfo()
memInf.type = "Pgm"
memInf.exists = True
memInf.startAddr = 0x1d000000
memInf.endAddr = 0x1d07ffff
memInf.rowSize = 0x1000
memInf.rowEraseSize = 0x1000
memInf.addrInc = 0x4
memInf.widthProgram = 0x4
memInf.mask = 0xffffffff
memTypeInfo.append(memInf)
memInf = MemInfo()
memInf.type = "Cfg"
memInf.exists = True
memInf.startAddr = 0x1fc02ff0
memInf.endAddr = 0x1fc02fff
memInf.rowSize = 0x0
memInf.rowEraseSize = 0x0
memInf.addrInc = 0x4
memInf.widthProgram = 0x4
memInf.mask = 0xffffffff
memTypeInfo.append(memInf)
memInf = MemInfo()
memInf.type = "BootFlash"
memInf.exists = True
memInf.startAddr = 0x0
memInf.endAddr = 0x0
memInf.rowSize = 0x1000
memInf.rowEraseSize = 0x0
memInf.addrInc = 0x4
memInf.widthProgram = 0x4
memInf.mask = 0x0
memTypeInfo.append(memInf)
memInf = MemInfo()
memInf.type = "EEData"
memInf.exists = False
memTypeInfo.append(memInf)
memInf = MemInfo()
memInf.type = "UserID"
memInf.exists = False
memTypeInfo.append(memInf)
memInf = MemInfo()
memInf.type = "Test"
memInf.exists = False
memTypeInfo.append(memInf)
memInf = MemInfo()
memInf.type = "FileRegs"
memInf.exists = False
memTypeInfo.append(memInf)
memInf = MemInfo()
memInf.type = "Periph"
memInf.exists = True
memInf.startAddr = 0x1f800000
memInf.endAddr = 0x1f88cfff
memInf.rowSize = 0x0
memInf.rowEraseSize = 0x0
memInf.addrInc = 0x4
memInf.widthProgram = 0x4
memInf.mask = 0xffffffff
memTypeInfo.append(memInf)
memInf = MemInfo()
memInf.type = "DataFlash"
memInf.exists = False
memTypeInfo.append(memInf)
memInf = MemInfo()
memInf.type = "FlashData"
memInf.exists = False
memTypeInfo.append(memInf)
memInf = MemInfo()
memInf.type = "Emulation"
memInf.exists = False
memTypeInfo.append(memInf)
memInf = MemInfo()
memInf.type = "NMMR"
memInf.exists = False
memTypeInfo.append(memInf)
memInf = MemInfo()
memInf.type = "InstructionRam"
memInf.exists = False
memTypeInfo.append(memInf)
memInf = MemInfo()
memInf.type = "UserOTP"
memInf.exists = False
memTypeInfo.append(memInf)
memInf = MemInfo()
memInf.type = "FBoot"
memInf.exists = False
memTypeInfo.append(memInf)
memInf = MemInfo()
memInf.type = "EDS"
memInf.exists = False
memTypeInfo.append(memInf)
memInf = MemInfo()
memInf.type = "DevID"
memInf.exists = True
memInf.startAddr = 0xffffffff
memInf.endAddr = 0xfffffffe
memInf.rowSize = 0x1
memInf.rowEraseSize = 0x0
memInf.addrInc = 0x1
memInf.widthProgram = 0x1
memInf.mask = 0x7fffffff
memTypeInfo.append(memInf)
memInf = MemInfo()
memInf.type = "Calibration"
memInf.exists = False
memTypeInfo.append(memInf)
memInf = MemInfo()
memInf.type = "DCI"
memInf.exists = False
memTypeInfo.append(memInf)
memInf = MemInfo()
memInf.type = "DIA"
memInf.exists = False
memTypeInfo.append(memInf)
memInf = MemInfo()
memInf.type = "RWW"
memInf.exists = False
memTypeInfo.append(memInf)
memInf = MemInfo()
memInf.type = "OTPConfig"
memInf.exists = False
memTypeInfo.append(memInf)
memInf = MemInfo()
memInf.type = "UDID"
memInf.exists = False
memTypeInfo.append(memInf)
devInf.setMemInfo(memTypeInfo)

######################## Power Info ########################
power = PowerInfo()
power.shutDownSystem = False
power.isToolPower = False
power.useVPPfirst = False
power.useLowVoltageProgramming = True
power.useMaintainActivePower = False
power.voltage = 3250

######################## Tool Info ########################
tool = ToolInfo()
tool.speedLevel = 1
tool.PGCResistance = 4700
tool.PGDResistance = 4700
tool.PGCPullDir = 2
tool.PGDPullDir = 2
tool.ICSPSelected = 0
tool.communicationSpeed = 2000
tool.communicationInterface = "SWD"
tool.physicalActivation = "nohv"

######################## Operation Info ########################
o = Opinfo("erase",0x0)
oi.append(o)

######################## Operation Info ########################
o = Opinfo("write",0x0)
t = Tinfo()
t.start = 0x1d000000
t.end = 0x1d006fff
t.data = "write_Pgm_st_0x1d000000_op1_0.dat"
t.type = "Pgm"
t.mask = 0x0
t.aligned = True
t.crc = 0xeb52
o.addTI(t)
t = Tinfo()
t.start = 0x1d008000
t.end = 0x1d07efff
t.data = "write_Pgm_st_0x1d008000_op1_1.dat"
t.type = "Pgm"
t.mask = 0x0
t.aligned = True
t.crc = 0x35da
o.addTI(t)
t = Tinfo()
t.start = 0x1fc02ff0
t.end = 0x1fc02fff
t.data = "write_Cfg_st_0x1fc02ff0_op1_2.dat"
t.type = "Cfg"
t.mask = 0x0
o.addTI(t)
t = Tinfo()
t.start = 0x1fc00000
t.end = 0x1fc01fff
t.data = "write_BootFlash_st_0x1fc00000_op1_3.dat"
t.type = "BootFlash"
t.mask = 0x0
t.aligned = True
t.crc = 0x0
o.addTI(t)
oi.append(o)

######################## Operation Info ########################
o = Opinfo("releasefromreset",0x0)
oi.append(o)

######################## Scripts ########################
EnterTMOD_LV= b'\xb1\x94\x05\x00\xb2\x00\xa0\x14\x00\xb0\xa0\x0a\x00\xb1\xa0\x64\x00\xb4\xb2\xc2\x12\x0a\xa0\x64\x00\xb0\xa0\x0a\x00'
ExitTMOD= b'\xb2\x03\xb1\x94\x01\x00\xa0\x0a\x00'
InitJTAG= b'\xc0\x06\x1f\xc1\x04\xc1\x07\xa2\xc2\x00\xa5\x0c\x00\x00\x00\x08\x00\x00\x00\x00\x08'
GetDeviceID= b'\xc1\x04\xc1\x07\xc2\x00\xc1\x04\xc1\x01\x95\xc3\x00\x00\x00\x00'
EraseChip= b'\xc1\x04\xc1\x07\xc2\xfc\xa0\x10\x27\xa2\xc2\x00\xa5\x0c\x00\x00\x00\x08\x00\x00\x00\x00\x02'
CheckCodeProtect= b'\xc1\x04\xc1\x07\xc2\x00\xaa\x80\x00\x00\x00\x80\x00\x00\x00'
SetupSerialMode= b'\xc1\x04\xc1\x07\xc2\x00\xc1\x04\xc1\x07\xc2\x00\xc2\xd1\xc1\x05\xc0\x06\x1f\xc1\x0c\xc1\x04\xc1\x07\xc2\xd0\xc2\xfe\xc1\x05\xc0\x06\x1f\xc1\x01\xc3\x00\x00\x00\x00'
LoadLoader= b'\xc4\x88\xbf\x04\x3c\xc4\x00\x20\x84\x34\xc4\x1f\x00\x05\x3c\xc4\x40\x00\xa5\x34\xc4\x00\x00\x85\xac\xc4\x00\x08\x05\x34\xc4\x10\x00\x85\xac\xc4\x40\x00\x85\x8c\xc4\x20\x00\x85\xac\xc4\x30\x00\x85\xac\xc4\x00\xa0\x04\x3c\xc4\x00\x08\x84\x34\xca\xad\xde\x07\x3c\xca\x20\xff\x06\x3c\xca\x20\xff\x05\x3c\xca\x00\x00\xc4\x8c\xca\x00\x00\xc3\x8c\xca\x0b\x00\x67\x10\xca\x00\x00\x00\x00\xca\xfb\xff\x60\x10\xca\x00\x00\x00\x00\xca\x00\x00\xa2\x8c\xca\xff\xff\x63\x24\xca\x00\x00\x82\xac\xca\x04\x00\x84\x24\xca\xfb\xff\x60\x14\xca\x00\x00\x00\x00\xca\xf3\xff\x00\x10\xca\x00\x00\x00\x00\xca\x00\xa0\x02\x3c\xca\x00\x09\x42\x34\xca\x08\x00\x40\x00\xca\x00\x00\x00\x00\xc4\x00\xa0\x19\x3c\xc4\x00\x08\x39\x37\xc4\x08\x00\x20\x03\xc4\x00\x00\x00\x00'
DownloadPE= b'\x91\x00\x91\x01\x93\x01\x04\x00\xc1\x0e\xc9\x00\xc9\x01\xad\x01\xc8\xae\xc7\x00\x00\x00\x00\xc7\x00\x00\xad\xde'
TestPEConnect= b'\xc7\x01\x00\x07\x00\x95\xc7\x00\x00\x00\x00\xaa\x00\x00\x07\x00\x00\x00\xff\xff'
WriteProgmemPE= b'\x91\x00\x91\x01\xc7\x00\x00\x02\x00\xc9\x00\xc9\x01\x93\x01\x04\x00\xad\x01\xc8\xae\xc7\x00\x00\x00\x00\xa8\x00\x00\x00\x00'
P32PE_ProgramCluster= b'\x91\x00\x91\x01\xc7\x00\x00\x09\x00\xc9\x00\xc9\x01\x93\x01\x04\x00\xad\x01\xc8\xae\xc7\x00\x00\x00\x00\xa8\x00\x00\x09\x00'
WriteConfigmemPE= b'\x91\x00\x91\x01\xc7\x00\x00\x09\x00\xc9\x00\xc9\x01\x93\x01\x04\x00\xad\x01\xc8\xae\xc7\x00\x00\x00\x00\xa8\x00\x00\x09\x00'
ReadProgmemPE= b'\x91\x00\x91\x01\x93\x01\x04\x00\x60\x02\x01\x61\x02\x00\x00\x01\x00\xc9\x02\xc9\x00\xc7\x00\x00\x00\x00\xa8\x00\x00\x01\x00\x95\xad\x01\xc7\x00\x00\x00\x00\xae'
CalcCRC_PE= b'\x91\x00\x91\x01\xc7\x00\x00\x08\x00\xc9\x00\xc9\x01\xd7\x98\x3a\xc7\x00\x00\x00\x00\xa8\x00\x00\x08\x00\x95\xc7\x00\x00\x00\x00'
BlankProgmemRange= b'\x91\x00\x91\x01\xc7\x00\x00\x06\x00\xc9\x00\xc9\x01\xd7\x98\x3a\xc7\x00\x00\x00\x00\xa8\x00\x00\x06\x00'
WriteDebugVector= b'\xc7\x00\x00\x09\x00\xc7\x80\x04\xc0\x1f\xc7\x08\x00\x00\x00\xc7\x00\x08\xf0\x0b\xc7\x00\x00\x00\x00\xc7\x00\x00\x00\x00\xa8\x00\x00\x09\x00'
GetVersionDE= b'\x3a\x6c\x0f\x66\x0f\xff\x00\x00\x00\xfe\x0f\x01\x00\x00\x00\x1e\x00\x95\x21\x03\x00\x00\x00\x00\x00\x04\x00\xfb\x26\x00\x95\xd0\x00\x03\x00\x00\x00\x01'
ReadRAM= b'\x3a\x6c\x0f\x66\x0f\xff\x00\x00\x00\xfe\x0f\x01\x00\x00\x00\x22\x00\x91\x00\x91\x01\x66\x00\xff\xff\xff\x1f\x95\x24\x00\x01\xfb\x3a\x00\x91\x00\x91\x01\x90\x0b\xff\xff\xff\x7f\xfa\x00\x0b\x37\x00\x92\x00\x00\x00\x00\xa0\xd2\x00\x01'
WriteRAM= b'\x3a\x6c\x0f\x66\x0f\xff\x00\x00\x00\xfe\x0f\x01\x00\x00\x00\x21\x00\x91\x00\x91\x01\x66\x00\xff\xff\xff\x1f\x26\x00\x01\xfb\x39\x00\x91\x00\x91\x01\x90\x0b\xff\xff\xff\x7f\xfa\x00\x0b\x36\x00\x92\x00\x00\x00\x00\xa0\xd3\x00\x01'
ReadEmu= b'\x3a\x6c\x0f\x66\x0f\xff\x00\x00\x00\xfe\x0f\x01\x00\x00\x00\x1c\x00\x91\x00\x91\x01\x95\x2a\x00\x01\xfb\x34\x00\x91\x00\x91\x01\x90\x0b\xff\xff\xff\x7f\xfa\x00\x0b\x31\x00\x92\x00\x00\x00\x00\xa0\xd2\x00\x01'
WriteEmu= b'\x3a\x6c\x0f\x66\x0f\xff\x00\x00\x00\xfe\x0f\x01\x00\x00\x00\x1b\x00\x91\x00\x91\x01\x2b\x00\x01\xfb\x33\x00\x91\x00\x91\x01\x90\x0b\xff\xff\xff\x7f\xfa\x00\x0b\x30\x00\x92\x00\x00\x00\x00\xa0\xd3\x00\x01'
ReadDeviceParameters= b'\x9e\x00\x02\x00\x00\x97'
WriteProgmemDE= b'\x3a\x6c\x0f\x66\x0f\xff\x00\x00\x00\xfe\x0f\x01\x00\x00\x00\x5e\x00\x91\x00\x91\x01\x66\x00\xff\xff\xff\x1f\x93\x01\x00\x10\xad\x01\x64\x00\x04\x21\x07\x00\x00\x00\x04\x00\x04\x00\xa8\xaa\xaa\x07\x00\xac\x80\x00\x25\x50\x01\x00\x00\x20\x00\x00\x00\x64\x00\x04\x25\x90\x01\x00\x00\x04\x00\x00\x00\x21\x08\x00\x00\x00\x00\x00\x04\x00\x92\x00\x20\x00\x00\x00\xa4\xae\xfb\xa6\x00\x91\x00\x91\x01\x66\x00\xff\xff\xff\x1f\x93\x01\x00\x10\xad\x01\x64\x00\x04\xd0\x01\x07\x00\x00\x00\x01\xa8\xaa\xaa\x07\x00\xac\x80\x00\x90\x02\x50\x01\x00\xa0\x90\x03\x20\x00\x00\x00\xd3\x02\x03\x64\x00\x04\xd0\x01\x08\x00\x00\x00\x01\xa8\xaa\xaa\x08\x00\x92\x00\x20\x00\x00\x00\xa4\xae'
SetSpeedFromDevice= b'\xec\x64\x00\x00\x00'
EraseProgmemRangePE= b'\x91\x00\x91\x01\xf5\x01\x00\x10\x61\x01\x00\x00\x05\x00\xc9\x01\xc9\x00\xc7\x00\x00\x00\x00\xa8\x00\x00\x05\x00'

