JEDEC DDR5 SPD Hub Devices例程
为进一步方便程序开发,使用vscode开发程序,IntrospectESP_23.3.0软件调用运行,如图所示,双击UTILITY区域的PythonModule,自动生成一个py文件,可以给该模块重命名。例如重命名为SystemTestItem,在Procedure区域编辑代码SystemTestItem.run(),点击Run,即可运行SystemTestItem文件中的程序:
生成的py文件目录如下,此时就可以用其他python编辑器,例如vscode,进行代码开发:
使用vscode编辑代码,可能会出现警告信息,一般情况不需要处理,前提是保证自己的代码无误:
IntrospectESP API文档,IntrospectESP_23.3.0软件安装完成即可找到,快速打开方式如下:
IntrospectESP API文档如图所示,参考其进行程序开发即可:
所有例程,SV4E-I3C设备连接器件均为SPD5芯片,Reg表示MR寄存器,Mem表示NVM存储器
1、进入I3C工作模式
import dftm.svt as svt
sidebandBusController.enableLowBitRateMode()
status = sidebandBusController.doBroadcastWrite('SETAASA')
if status == True:
pass
else:
svt.printMsg('SETAASA CCC FAIL', 'red')
sidebandBusController.disableLowBitRateMode()
2、退出I3C工作模式
import dftm.svt as svt
status = sidebandBusController.doBroadcastWrite('RSTDAA')
if status == True:
pass
else:
svt.printMsg('RSTDAA CCC FAIL', 'red')
sidebandBusController.enableLowBitRateMode()
3、带PEC Byte退出I3C工作模式
import dftm.svt as svt
status = sidebandBusController.doBroadcastWrite('RSTDAA', cccDefiningBytes=[0x12])
if status == True:
pass
else:
svt.printMsg('RSTDAA CCC FAIL', 'red')
sidebandBusController.enableLowBitRateMode()
4、I3C工作模式SPD5写MR
DIMM_HUB_SPD5_ADDR是list(),包含多个的SPD5地址,MR_REGADDR是list(),表示MR地址,如下程序是i3c模式给不同的SPD5的MR20写0x02数据:
import dftm.svt as svt
sidebandBusController.enableLowBitRateMode()
status = sidebandBusController.doBroadcastWrite('SETAASA')
if status == True:
pass
else:
svt.printMsg('SETAASA CCC FAIL', 'red')
sidebandBusController.disableLowBitRateMode()
for hub in range(len(DIMM_HUB_SPD5_ADDR)):
status = sidebandBusController.spdWriteReg(DIMM_HUB_SPD5_ADDR[hub], MR_REGADDR[20], 0x02)
if status == True:
pass
else:
svt.printMsg('spdWriteReg FAIL', 'red')
print("DIMM_HUB_SPD5_ADDR: %s MR%d_REGADDR: 0x%02X MRBYTE: 0x%02X" % (
DIMM_HUB_SPD5_ADDR[hub], 20, MR_REGADDR[20], 0x02))
status = sidebandBusController.doBroadcastWrite('RSTDAA')
if status == True:
pass
else:
svt.printMsg('RSTDAA CCC FAIL', 'red')
5、I3C工作模式SPD5读MR
DIMM_HUB_SPD5_ADDR是list(),包含多个的SPD5地址,MR_REGADDR是list(),表示MR地址,如下程序是i3c模式读出不同的SPD5的MR28数据,并进行数据校验,校验值是0xFC:
import dftm.svt as svt
sidebandBusController.enableLowBitRateMode()
status = sidebandBusController.doBroadcastWrite('SETAASA')
if status == True:
pass
else:
svt.printMsg('SETAASA CCC FAIL', 'red')
sidebandBusController.disableLowBitRateMode()
for hub in range(len(DIMM_HUB_SPD5_ADDR)):
bytesFromTarget = sidebandBusController.spdReadReg(DIMM_HUB_SPD5_ADDR[hub], MR_REGADDR[28], numBytes=1)
if bytesFromTarget is not None and len(bytesFromTarget) > 0:
if bytesFromTarget[0] == 0xFC:
pass
else:
svt.printMsg('spdReadReg_verify FAIL', 'red')
print("DIMM_HUB_SPD5_ADDR: %s MR%d_REGADDR: 0x%02X MRBYTE: 0x%02X" % (
DIMM_HUB_SPD5_ADDR[hub], 28, MR_REGADDR[28], bytesFromTarget[0]))
else:
svt.printMsg('spdReadReg FAIL', 'red')
print("DIMM_HUB_SPD5_ADDR: %s MR%d_REGADDR: 0x%02X" % (
DIMM_HUB_SPD5_ADDR[hub], 28, MR_REGADDR[28]))
status = sidebandBusController.doBroadcastWrite('RSTDAA')
if status == True:
pass
else:
svt.printMsg('RSTDAA CCC FAIL', 'red')
6、I2C工作模式SPD5读MR
DIMM_HUB_SPD5_ADDR是list(),包含多个的SPD5地址,MR_REGADDR是list(),表示MR地址,如下程序是i2c模式读出不同的SPD5的MR52数据,并进行数据校验,校验值是0x01:
import dftm.svt as svt
sidebandBusController.enableLowBitRateMode()
for hub in range(len(DIMM_HUB_SPD5_ADDR)):
bytesFromTarget = sidebandBusController.spdLegacyReadReg(
DIMM_HUB_SPD5_ADDR[hub], MR_REGADDR[52], numBytes=1,twoByteAddressing=False)
if bytesFromTarget is not None and len(bytesFromTarget) > 0:
if bytesFromTarget[0] == 0x01:
pass
else:
svt.printMsg('spdLegacyReadReg_verify FAIL', 'red')
print("DIMM_HUB_SPD5_ADDR: %s MR%d_REGADDR: 0x%02X MRBYTE: 0x%02X" % (
DIMM_HUB_SPD5_ADDR[hub], 52, MR_REGADDR[52], bytesFromTarget[0]))
else:
svt.printMsg('spdLegacyReadReg FAIL', 'red')
print("DIMM_HUB_SPD5_ADDR: %s MR%d_REGADDR: 0x%02X" % (
DIMM_HUB_SPD5_ADDR[hub], 52, MR_REGADDR[52]))
7、I2C工作模式SPD5写MR
DIMM_HUB_SPD5_ADDR是list(),包含多个的SPD5地址,MR_REGADDR是list(),表示MR地址,如下程序是i2c模式给不同的SPD5的MR11写0x00数据:
import dftm.svt as svt
sidebandBusController.enableLowBitRateMode()
for hub in range(len(DIMM_HUB_SPD5_ADDR)):
status = sidebandBusController.spdLegacyWriteReg(DIMM_HUB_SPD5_ADDR[hub], MR_REGADDR[11], 0x00, twoByteAddressing=False)
if status == True:
pass
else:
svt.printMsg('spdLegacyWriteReg FAIL', 'red')
print("DIMM_HUB_SPD5_ADDR: %s MR%d_REGADDR: 0x%02X MRBYTE: 0x%02X" % (DIMM_HUB_SPD5_ADDR[hub], 11, MR_REGADDR[11], 0x00))
8、I3C工作模式SPD5写NVM
DIMM_HUB_SPD5_ADDR是list(),包含多个的SPD5地址,如下程序是i3c模式给不同的SPD5的NVM block0的0x00地址开始,写0x12,0x23,0x34,0x45数据:
import dftm.svt as svt
sidebandBusController.enableLowBitRateMode()
status = sidebandBusController.doBroadcastWrite('SETAASA')
if status == True:
pass
else:
svt.printMsg('SETAASA CCC FAIL', 'red')
sidebandBusController.disableLowBitRateMode()
for hub in range(len(DIMM_HUB_SPD5_ADDR)):
status = sidebandBusController.spdWriteMem(DIMM_HUB_SPD5_ADDR[hub],0x00,0x00, [0x12,0x23,0x34,0x45])
if status == True:
pass
else:
svt.printMsg('spdWriteMem FAIL', 'red')
print("DIMM_HUB_SPD5_ADDR: %s memBlock: 0x%02X memAddr: 0x%02X NVMBYTE: 0x%02X" % (DIMM_HUB_SPD5_ADDR[hub], 0, 0, 0x12))
status = sidebandBusController.doBroadcastWrite('RSTDAA')
if status == True:
pass
else:
svt.printMsg('RSTDAA CCC FAIL', 'red')
9、I3C工作模式SPD5读NVM
DIMM_HUB_SPD5_ADDR是list(),包含多个的SPD5地址,如下程序是i3c模式读不同的SPD5的NVM block0的0x00地址开始的4byte数据,并校验第一个数据是否为0x12:
import dftm.svt as svt
sidebandBusController.enableLowBitRateMode()
status = sidebandBusController.doBroadcastWrite('SETAASA')
if status == True:
pass
else:
svt.printMsg('SETAASA CCC FAIL', 'red')
sidebandBusController.disableLowBitRateMode()
for hub in range(len(DIMM_HUB_SPD5_ADDR)):
bytesFromTarget = sidebandBusController.spdReadMem(DIMM_HUB_SPD5_ADDR[hub],0x00,0x00, numBytes=4)
if bytesFromTarget is not None and len(bytesFromTarget) > 0:
if(bytesFromTarget[0] == 0x12):
pass
else:
svt.printMsg('spdReadMem_verify FAIL', 'red')
print("DIMM_HUB_SPD5_ADDR: %s memBlock: 0x%02X memAddr: 0x%02X NVMBYTE: 0x%02X" % (DIMM_HUB_SPD5_ADDR[hub], 0, 0, bytesFromTarget[0]))
else:
svt.printMsg('spdReadMem FAIL', 'red')
print("DIMM_HUB_SPD5_ADDR: %s memBlock: 0x%02X memAddr: 0x%02X" % (DIMM_HUB_SPD5_ADDR[hub], 0, 0))
status = sidebandBusController.doBroadcastWrite('RSTDAA')
if status == True:
pass
else:
svt.printMsg('RSTDAA CCC FAIL', 'red')
10、I3C工作模式SPD5写NVM,数据为随机数
DIMM_HUB_SPD5_ADDR是list(),包含多个的SPD5地址,如下程序是i3c模式给不同的SPD5的NVM block0的0x08地址开始,写4个随机数据:
import dftm.svt as svt
import random
def random_hex(start, stop):
'''
Command:
needs to be called
Function:
Generate random numbers
Args:
datas: (0,1) or (5,100) or ...
Returns:
random data
Examples:
>>> randomdata = random_hex(0, 63)
>>> randomdata = random_hex(0, 255)
Developer:
WHL
'''
random_number = random.randint(start, stop)
random_number = hex(random_number)
return int(random_number, 16)
sidebandBusController.enableLowBitRateMode()
status = sidebandBusController.doBroadcastWrite('SETAASA')
if status == True:
pass
else:
svt.printMsg('SETAASA CCC FAIL', 'red')
sidebandBusController.disableLowBitRateMode()
for hub in range(len(DIMM_HUB_SPD5_ADDR)):
NVMBYTE0_random = random_hex(0, 255)
NVMBYTE1_random = random_hex(0, 255)
NVMBYTE2_random = random_hex(0, 255)
NVMBYTE3_random = random_hex(0, 255)
status = sidebandBusController.spdWriteMem(DIMM_HUB_SPD5_ADDR[hub],0x00,0x08, [NVMBYTE0_random,NVMBYTE1_random,NVMBYTE2_random,NVMBYTE3_random])
if status == True:
pass
else:
svt.printMsg('spdWriteMem FAIL', 'red')
print("DIMM_HUB_SPD5_ADDR: %s memBlock: 0x%02X memAddr: 0x%02X NVMBYTE: 0x%02X" % (DIMM_HUB_SPD5_ADDR[hub], 0, 8, NVMBYTE0_random))
status = sidebandBusController.doBroadcastWrite('RSTDAA')
if status == True:
pass
else:
svt.printMsg('RSTDAA CCC FAIL', 'red')
本博文暂时分享到这里,后续博文将继续为大家呈现JEDEC DDR5 SPD Hub Devices例程
希望本文对大家有帮助,上文若有不妥之处,欢迎指正
分享决定高度,学习拉开差距