This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[FAQ] AM243x: How to plot graph for OSPI Phy Tuning Algorithm?

Part Number: PROCESSOR-SDK-AM62A

Tool/software:

Explanation:

While running the OSPI Phy Tuning algorithm we tend to compute the Optimal Tuning Point(OTP).

Under the file ospi_phy.c, we come across the API: OSPI_phyTuneGrapher

The API OSPI_phyTuneGrapher scans through all possible combinations of rdDelay(0 till 4), txDLL(0 till 127) and rxDLL(0 till 127).

A value of 1 is recorded if a particular combination is successful in reading the 128 bytes of pre flashed data else a value of 0 is recorded.

This value is recorded in an array named phyTuningArray(a 3D array [rdDelay][txDLL][rxDLL] having dimensions [5][128][128]).

To represent this array in a graph, we can perform the following steps:

  1. Run the following piece of attached code, which saves the graph in a binary format to a custom local directory.
  2. Once the graph is saved as "graph_data_temperature_testing.bin", run the attached python script as follows: "python graph.py graph_data_temperature_testing.bin".

The graph plots can be used to see the variation across different temperatures.

  • Code that can be run on TI EVM AM243x directly on the MCU R5F core: ospi_flash_io.zip

    Python Script to plot the graph: 

    import os
    import sys
    import matplotlib.pyplot as plt
    
    col0 = "red"
    col1 = "blue"
    col2 = "green"
    col3 = "pink"
    
    f_name = sys.argv[1]
    f_size = os.path.getsize(f_name)
    
    f = open(f_name, "rb")
    
    data0 = f.read(int(f_size/5))
    data1 = f.read(int(f_size/5))
    data2 = f.read(int(f_size/5))
    data3 = f.read(int(f_size/5))
    data4 = f.read(int(f_size/5))
    
    x0 = []
    y0 = []
    
    
    for tx in range(0, 128):
    	for rx in range(0, 128):
    		idx = 128*tx + rx
    		if(int(data0[idx]) == 1):
    			x0.append(tx)
    			y0.append(rx)
    
    x1 = []
    y1 = []
    
    for tx in range(0, 128):
    	for rx in range(0, 128):
    		idx = 128*tx + rx
    		if(int(data1[idx]) == 1):
    			x1.append(tx)
    			y1.append(rx)
    
    
    x2 = []
    y2 = []
    
    for tx in range(0, 128):
    	for rx in range(0, 128):
    		idx = 128*tx + rx
    		if(int(data2[idx]) == 1):
    			x2.append(tx)
    			y2.append(rx)
    
    
    x3 = []
    y3 = []
    
    for tx in range(0, 128):
    	for rx in range(0, 128):
    		idx = 128*tx + rx
    		if(int(data3[idx]) == 1):
    			x3.append(tx)
    			y3.append(rx)
    			
    x4 = []
    y4 = []
    
    for tx in range(0, 128):
    	for rx in range(0, 128):
    		idx = 128*tx + rx
    		if(int(data4[idx]) == 1):
    			x4.append(tx)
    			y4.append(rx)
    
    plt.xlim(0,128)
    plt.ylim(0,128)
    
    plt.scatter(x0,y0,c=col0,linewidths=2)
    plt.scatter(x1,y1,c=col1,linewidths=2)
    
    
    plt.xlabel("TX")
    plt.ylabel("RX")
    
    plt.show()