"
45 |
46 | inherit update-rc.d systemd
47 |
48 | S = "${WORKDIR}/git"
49 | COMPATIBLE_MACHINE = "^$"
50 | COMPATIBLE_MACHINE:zynqmp = "${MACHINE}"
51 |
52 | INITSCRIPT_NAME = "raft-startup"
53 | INITSCRIPT_PARAMS = "start 99 S ."
54 |
55 | SYSTEMD_PACKAGES = "${PN}"
56 | SYSTEMD_SERVICE:${PN} = "raft-startup.service"
57 | SYSTEMD_AUTO_ENABLE:${PN}="enable"
58 |
59 | DEPENDS += "libmetal"
60 |
61 | RDEPENDS:${PN} += "python3 \
62 | python3-pyro4 \
63 | python3-cffi \
64 | python3-async \
65 | python3-serpent \
66 | bash \
67 | "
68 |
69 | PACKAGECONFIG[raftnotebooks] = "enabled,disabled,,packagegroup-petalinux-jupyter"
70 | PACKAGECONFIG[raftstartup] = "enabled,disabled,,rfdc rfclk libmetal"
71 | PACKAGECONFIG[raftstartupsc] = "enabled,disabled,,python3-psutil python3-periphery"
72 |
73 | do_install() {
74 | if ${@bb.utils.contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then
75 | SYSCONFDIR=${D}${sysconfdir}/init.d/
76 | else
77 | SYSCONFDIR=''
78 | fi
79 | oe_runmake install DESTDIR=${D}\
80 | NOTEBOOKS=${@bb.utils.contains('PACKAGECONFIG','raftnotebooks','enabled','', d)}\
81 | STARTUPSC=${@bb.utils.contains('PACKAGECONFIG','raftstartupsc','enabled','',d)}\
82 | STARTUP=${@bb.utils.contains('PACKAGECONFIG','raftstartup','enabled','',d)}\
83 | BINDIR=${D}${bindir}\
84 | SYSTEM_UNIT_DIR=${D}${systemd_system_unitdir}\
85 | SYSCONF_DIR=${SYSCONFDIR}
86 | }
87 |
88 | PACKAGECONFIG:append:zcu208-zynqmp = "raftnotebooks raftstartup"
89 | PACKAGECONFIG:append:zcu216-zynqmp = "raftnotebooks raftstartup"
90 | PACKAGECONFIG:append:system-controller = "raftstartupsc"
91 |
92 | FILES:${PN} += " \
93 | ${datadir}/raft/* \
94 | ${libdir}/libaximemmap.so.* \
95 | ${libdir}/libxhelper.so.* \
96 | ${libdir}/libXI2c.so.* \
97 | ${libdir}/libXSysmon.so.* \
98 | ${datadir}/notebooks \
99 | ${@bb.utils.contains('DISTRO_FEATURES','sysvinit','${sysconfdir}/*', '', d)} \
100 | "
101 | ============================================================================
102 |
103 | Step 4: Config rootfs
104 | petalinux-config -c rootfs --silentconfig
105 |
106 | Step 5: Build
107 | petalinux-build
108 |
109 | For boot options please refer UG1444.
110 |
--------------------------------------------------------------------------------
/docs/instructions_for_adding_new_library.txt:
--------------------------------------------------------------------------------
1 | Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved.
2 | SPDX-License-Identifier: BSD-3-Clause
3 |
4 | Follow the below steps to add a new library to RAFT
5 |
6 | Step 1: Compile the C code as a linux shared object.
7 | - Avoid external dependencies in the library.
8 | - libmetal library support is available in the RAFT framework.
9 | - For more details check the link - https://cffi.readthedocs.io/en/latest/cdef.html#loading-libraries
10 |
11 | Step 2: Keep all the APIs that need to be exposed to python in one header file.
12 | - Ensure the header file is compatible with ffi cdef https://cffi.readthedocs.io/en/latest/cdef.html#ffi-cdef-limitations
13 |
14 | Step 3: Add the header file to RAFT
15 | - At location xserver/xcffi/drv_header/ under a directory related to the library
16 |
17 | Step 4: Prepare a server file
18 | - At location xserver/xcffi/drv_api/ in a directory with the same name as in Step 3.
19 | - Use the CCF server file as example. xserver/xcffi/drv_api/dfe/ccf_server.py
20 | - open_c_library() function in utils/utils.py can be used for opening the shared object with the header
21 | - A class need to be present with the module name as class name
22 | - All server class constructors in RAFT should be maintained in the same way.
23 | - Log handling should be done in the same way in all RAFT servers
24 | - Add dictionary equivalent of all enums
25 | - Function name begin with "GetEnum_", and follow by enum name as in header file.
26 | - The dictionary is supposed to be a key value pair with key as the string equivalent of enum members and the its numerical representations as value.
27 | - Add dictionary equivalent of all structures
28 | - Function name begin with "GetStruct_", and follow by structure name as in header file.
29 | - The dictionary is supposed to be a key value pair with key as the string equivalent of structure member and 0 as its value.
30 | - All python APIs should carry the same name as corresponding C function.
31 | - The naming convention of variable names passed to functions should also be same as in C header file.
32 | - For other variables pep8 standard should be used.
33 | - InstanceInit API should support multiple instances in all server files.
34 | - InstanceInit should keep the instance pointers in a dictionary as shown in xserver/xcffi/drv_api/dfe/ccf_server.py
35 | - InstanceClose API should delete the dictionary created in InstanceInit
36 | - Refer xserver/xcffi/drv_api/dfe/ccf_server.py for example
37 | - The required support function can be exported from utils/utils.py for conversion from python to C
38 | - Logs at Debug level should be added in all functions.
39 |
40 | Step 5: Add server class name to the init script
41 | - Different project can be added in xserver/init/ directory
42 | - Create a new project or add to the existing project according to the requirement
43 | - Always keep all the projects in the same way
44 | - Use xserver/init/xpyro-prj1/__init__.py for reference
45 |
46 | Step 6: Prepare a client file
47 | - At location xclient/ in a directory with the same name as in Step 3.
48 | - Use CCF client file as example xclient/dfe/ccf_client.py
49 | - A class need to be present with the module name followed by "_Client" as suffix
50 | - All client class constructors in RAFT should be maintained in the same way.
51 | - Log handling should be done in the same way in all RAFT clients
52 | - There should be a SetIpAndPort() function which creates the Pyro object as shown in xclient/dfe/ccf_client.py
53 | - There should be an equivalent API in client for all server APIs as in xclient/dfe/ccf_client.py
54 | - An object of the class should be available in the client file.
55 |
56 | Step 7: Create a python usage file
57 | - All python usage files in RAFT should carry a common format of taking arguments
58 | - Use examples/python/usage/python_usage_ccf.py as an example
59 | - Sample usage of all APIs in client/server should be shown in python usage script.
60 |
61 | Step 8: Create a MATLAB usage file
62 | - All MATLAB usage files in RAFT should carry a common format
63 | - Use examples/matlab/matlab_ccf_usage.m as an example
64 | - Sample usage of all APIs in client/server should be shown in MATLAB usage script.
--------------------------------------------------------------------------------
/docs/raft_usage.txt:
--------------------------------------------------------------------------------
1 | Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved.
2 | SPDX-License-Identifier: BSD-3-Clause
3 |
4 | The steps to build and run RAFT at startup of the board is available at build_petalinux_with_raft.txt
5 | This document illustrates the usage options of RAFT at server and client
6 |
7 | RAFT can be used in three modes
8 | xclient - At host PC or at board communicating to server with xclient
9 | xcffi - At board directly communicating with xcffi without pyro
10 | xpyro - At host PC or at board communicating with pyro server
11 |
12 | The usage of all three modes are described in the README.md at examples/python/usage folder.
13 |
14 | RAFT usage at board
15 | ===================
16 | Copy xserver, xclient and examples in RAFT repository to /usr/share/raft folder. This can be done through recipe method as mentioned in build_petalinux_with_raft.txt
17 | Projects are created in xserver/init/ directory. The desired server items are grouped together in the sub-directories.
18 | Change to the desired project directory.
19 | cd xserver/init/xpyro-prj1
20 | sudo python3 __init__.py
21 | Note: By default __init__.py will take the ipaddress of eth0 and port number 9090. If another IP address and port is required, it can be passed over commandline. Usage: __init__.py ipaddress portnumber
22 |
23 | RAFT usage at client
24 | ===================
25 | Each item in xclient client folder can communicate with the corresponding server independently.
26 | The client can be accessed with any tool that can work with python (MATLAB, LabView, GNU Radio etc.).
27 | The IP address of the server can be set at client side using a client API SetIpAndPort(ipaddr, port).
28 |
--------------------------------------------------------------------------------
/examples/matlab/matlab_axi_memmap_usage.m:
--------------------------------------------------------------------------------
1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 | % Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
3 | % SPDX-License-Identifier: BSD-3-Clause
4 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5 |
6 | %Put the path of the python module here. It can be in any drive
7 | current_folder = pwd
8 | if count(py.sys.path,current_folder) == 0
9 | %Put the path of the python module here. It can be in any drive
10 | insert(py.sys.path,uint32(0),current_folder);
11 | end
12 |
13 | %Import the python module in matlab
14 | %rehash toolboxcache
15 | AXI_MEMMAP=py.importlib.import_module('axi_memmap_client');
16 | AXI_MEMMAP=py.importlib.reload(AXI_MEMMAP);
17 |
18 | %%%%%% SetIPAndPort
19 | %Input Arguments:
20 | % arg1: ipaddress of server
21 | % arg2: port number at server for pyro communication
22 | %Return: None
23 | AXI_MEMMAP.axi_memmap.SetIpAndPort("169.254.10.2", "9090")
24 |
25 | %%%%%% axi_write_words
26 | %Input Arguments:
27 | % arg1: address
28 | % arg2: number of words
29 | % arg3: buffer to wirte
30 | % arg4: network_order
31 | %Return:
32 | % value1: Success or failure
33 | address = uint32(0xa7c0000)
34 | num_words = uint32(5)
35 | network_order = uint32(0)
36 | buf = py.list({int32(4), int32(5), int32(6), int32(7), int32(8)})
37 | ret = AXI_MEMMAP.axi_memmap.axi_write_words(address, num_words, buf, network_order)
38 |
39 | %%%%%% axi_read_words
40 | % arg1: address
41 | % arg2: number of words
42 | % arg3: network_order
43 | %Return:
44 | % value1: Success or failure
45 | % value2: read buffer
46 | address = uint32(0xa7c0000)
47 | num_words = uint32(5)
48 | network_order = uint32(0)
49 | ret = AXI_MEMMAP.axi_memmap.axi_read_words(address, num_words, network_order)
50 | S= cell(ret)
51 | retval = ret{1}
52 | readbuf = ret{2}
53 |
--------------------------------------------------------------------------------
/examples/matlab/matlab_rfclk_usage.m:
--------------------------------------------------------------------------------
1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 | % Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
3 | % SPDX-License-Identifier: BSD-3-Clause
4 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5 | %Put the path of the python module here. It can be in any drive
6 | current_folder = pwd;
7 | if count(py.sys.path,current_folder) == 0
8 | %Put the path of the python module here. It can be in any drive
9 | insert(py.sys.path,uint32(0),current_folder);
10 | end
11 |
12 | %Import the python module in matlab
13 | RFCLK=py.importlib.import_module('rfclk_client');
14 | RFCLK=py.importlib.reload(RFCLK);
15 |
16 | % SetIpAndPort
17 | RFCLK.rfclk.SetIpAndPort("169.254.10.2", "9090")
18 |
19 | %GetPythonLogLevels
20 | PythonLogLevels = RFCLK.rfclk.GetPythonLogLevels()
21 |
22 | %SetClientLogLevel
23 | RFCLK.rfclk.SetClientLogLevel(PythonLogLevels{'DEBUG'})
24 |
25 | %SetServerLogLevel
26 | RFCLK.rfclk.SetServerLogLevel(PythonLogLevels{'DEBUG'})
27 |
28 | %SetMetalLogLevel
29 | metal_log_level = RFCLK.rfclk.GetEnum_metal_log_level()
30 | RFCLK.rfclk.SetMetalLogLevel(metal_log_level{'METAL_LOG_EMERGENCY'})
31 |
32 | % XRFClk_Init
33 | ret = RFCLK.rfclk.XRFClk_Init(uint32(486))
34 |
35 | % XRFClk_ResetChip
36 | ret = RFCLK.rfclk.XRFClk_ResetChip(uint32(0))
37 |
38 | % XRFClk_SetConfigOnOneChipFromConfigId
39 | ret = RFCLK.rfclk.XRFClk_SetConfigOnOneChipFromConfigId(uint32(0), uint32(0))
40 |
41 | % XRFClk_GetConfigFromOneChip
42 | ret = RFCLK.rfclk.XRFClk_GetConfigFromOneChip(uint32(0))
43 |
44 | % XRFClk_SetConfigOnAllChipsFromConfigId
45 | ret = RFCLK.rfclk.XRFClk_SetConfigOnAllChipsFromConfigId(uint32(0), uint32(0), uint32(0))
46 |
47 | % XRFClk_WriteReg
48 | ret = RFCLK.rfclk.XRFClk_WriteReg(uint32(0), uint32(0))
49 |
50 | % XRFClk_ReadReg
51 | DataVal = RFCLK.rfclk.XRFClk_ReadReg(uint32(0))
52 |
--------------------------------------------------------------------------------
/examples/python/rftool/README.md:
--------------------------------------------------------------------------------
1 | Usage Description of rftool
2 |
3 | Rftool class inherits RFDC, RFCLK and AXI_MEMMAP client classes. Also, it have functionalities required for the configuration and getting data from STIM and CAP modules of ZCU208 and ZCU216 board reference xsa (The xsa in the released bsp - https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/embedded-design-tools/2022-2.html). The file rftool.py is a pythonic implementation of 'Rftool' application mentioned in ug1433 (https://www.xilinx.com/support/documents/boards_and_kits/zcu216/ug1433-zcu216-rfsoc-eval-tool.pdf), Chapter 4, Software Design and Build secton. The data transfer support is implemented only for BRAM mode. Data transfer support over DDR is not added at the moment.
4 |
5 | mixer.py is a sample application written over rftool.py. For more details please refer pg269 document (https://docs.xilinx.com/v/u/2.4-English/pg269-rf-data-converter). mixer.ipynb is the jupyter notebook equivalent of mixer.py.
6 |
7 | Petalinux Build
8 |
9 | For steps to prepare the petalinux build required for running mixer.py, follow the same steps for building petalinux with raft. In the raft recipe, (Step 6: Create raft library recipe) change xpyro-prj1 to xpyro-prj2
10 | For preparing the build for running the jupyter notebook example (mixer.ipynb), follow the steps mentioned in RAFT/docs/build_petalinux_jupyternb_raft.txt
11 |
12 | Hardware setup
13 |
14 | Setup as mentioned in https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/246153525/RF+DC+Evaluation+Tool+for+ZCU216+board+-+Quick+start. Connect CLK0104 and XM655/616B as shown in the diagram. Instead of RF Data Converter Evaluation User Interface, this application can be used.
15 |
16 | Usage
17 | The Rftool class runs at the host (Windows or Linux) PC
18 | At the board project inside xserver/init/xpyro-prj2 folder is used
19 | At Board
20 | In the serial console of the board give the following commands
21 | cd /usr/share/raft/xserver/init/xpyro-prj2
22 |
23 | Note: No need to run this, if it is already present in the starup-script.
24 | At Host
25 | Clone the github repository
26 | git clone https://github.com/Xilinx/RAFT
27 | Change directory to the rftool folder
28 | cd RAFT/xserver/examples/python/rftool
29 | Run the test application.
30 |
31 | If jupyter notebook is enabled as per RAFT/docs/build_petalinux_jupyternb_raft.txt, enter the link to jupyter notebook in the browser.
32 | Eg: http://169.254.10.2:8888/
33 |
34 | Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved.
35 | SPDX-License-Identifier: BSD-3-Clause
36 |
37 |
--------------------------------------------------------------------------------
/examples/python/rftool/mixer.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": null,
6 | "metadata": {},
7 | "outputs": [],
8 | "source": [
9 | "# Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.\n",
10 | "# SPDX-License-Identifier: BSD-3-Clause\n",
11 | "from rftool import Rftool\n",
12 | "import numpy as np\n",
13 | "from numpy import fft\n",
14 | "from bokeh.resources import INLINE\n",
15 | "import bokeh.io\n",
16 | "from bokeh.plotting import figure, show\n",
17 | "from bokeh import *"
18 | ]
19 | },
20 | {
21 | "cell_type": "code",
22 | "execution_count": null,
23 | "metadata": {},
24 | "outputs": [],
25 | "source": [
26 | "rftool_handle = Rftool()\n",
27 | "# SetBoardName\n",
28 | "board_name = \"zcu216\"\n",
29 | "rftool_handle.SetBoardName(board_name)\n",
30 | "# SetIpAndPort\n",
31 | "rftool_handle.SetIpAndPort(\"127.0.0.1\", \"9090\")\n",
32 | "# SetMetalLogLevel\n",
33 | "metal_log_level = rftool_handle.GetEnum_metal_log_level()\n",
34 | "rftool_handle.SetMetalLogLevel(metal_log_level[\"METAL_LOG_DEBUG\"])\n",
35 | "# GetPythonLogLevels\n",
36 | "PythonLogLevels = rftool_handle.GetPythonLogLevels()\n",
37 | "# SetClientLogLevel\n",
38 | "rftool_handle.SetClientLogLevel(PythonLogLevels[\"ERROR\"])\n",
39 | "\n",
40 | "ret, inst_id = rftool_handle.Initialize()"
41 | ]
42 | },
43 | {
44 | "cell_type": "code",
45 | "execution_count": null,
46 | "metadata": {},
47 | "outputs": [],
48 | "source": [
49 | "# setup clocking\n",
50 | "DistributionSettings = rftool_handle.GetStruct_XRFdc_Distribution_Settings()\n",
51 | "if board_name == \"zcu208\":\n",
52 | " DistributionSettings[\"SourceTileId\"] = 0\n",
53 | "else:\n",
54 | " DistributionSettings[\"SourceTileId\"] = 2\n",
55 | "DistributionSettings[\"SourceType\"] = 1\n",
56 | "DistributionSettings[\"EdgeTypes\"] = [0,1]\n",
57 | "DistributionSettings[\"EdgeTileIds\"] = [0,3]\n",
58 | "DistributionSettings[\"DistRefClkFreq\"] = 245.76\n",
59 | "DistributionSettings[\"DistributedClock\"] = 1\n",
60 | "DistributionSettings[\"SampleRates\"] = [[2211.86, 2211.86, 2211.86, 2211.86], [2211.86, 2211.86, 2211.86, 2211.86]]\n",
61 | "ret = rftool_handle.XRFdc_SetClkDistribution(inst_id, DistributionSettings)\n"
62 | ]
63 | },
64 | {
65 | "cell_type": "code",
66 | "execution_count": null,
67 | "metadata": {},
68 | "outputs": [],
69 | "source": [
70 | "tile_id = 0\n",
71 | "dac_block_id = 0\n",
72 | "if board_name == \"zcu208\":\n",
73 | " if dac_block_id == 2:\n",
74 | " adc_block_id = 1\n",
75 | " else:\n",
76 | " adc_block_id = 0\n",
77 | "else:\n",
78 | " adc_block_id = dac_block_id\n",
79 | "\n",
80 | "N = 2048 # number of 16bit samples\n",
81 | "f = 602.560\n",
82 | "FS = 2211.86\n",
83 | "FS_DAC = 2211.86"
84 | ]
85 | },
86 | {
87 | "cell_type": "code",
88 | "execution_count": null,
89 | "metadata": {},
90 | "outputs": [],
91 | "source": [
92 | "T = 1/FS_DAC\n",
93 | "t = np.arange(0, (N * T), T)\n",
94 | "sig = 0x1fff * np.cos(2 * np.pi * f * t)"
95 | ]
96 | },
97 | {
98 | "cell_type": "code",
99 | "execution_count": null,
100 | "metadata": {},
101 | "outputs": [],
102 | "source": [
103 | "MixerSettingsADC = {\n",
104 | " \"Freq\": 0.0,\n",
105 | " \"PhaseOffset\": 0.0,\n",
106 | " \"EventSource\": 2,\n",
107 | " \"CoarseMixFreq\": 0x10,\n",
108 | " \"MixerMode\": 4,\n",
109 | " \"FineMixerScale\": 0,\n",
110 | " \"MixerType\": 1,\n",
111 | "}\n",
112 | "\n",
113 | "ret, MixerSettingsADC = rftool_handle.XRFdc_SetMixerSettings(inst_id, 0, tile_id, adc_block_id, MixerSettingsADC)\n",
114 | "print(\"rftool_handle.XRFdc_SetMixerSettings ret = \", ret)\n",
115 | "\n",
116 | "ret = rftool_handle.XRFdc_UpdateEvent(inst_id, 0, tile_id, adc_block_id, 1)\n",
117 | "print(\"rftool_handle.XRFdc_UpdateEvent ret = \", ret)\n",
118 | "\n",
119 | "ret, df = rftool_handle.XRFdc_GetDecimationFactor(inst_id, tile_id, adc_block_id)\n",
120 | "print(f\"rftool_handle.XRFdc_GetDecimationFactor ret = {ret} Decimation factor = {df}\")\n",
121 | "\n",
122 | "ret = rftool_handle.SetMMCM(inst_id, 1, 0)\n",
123 | "print(\"rftool_handle.SetMMCM ret = \", ret)\n",
124 | "\n",
125 | "ret = rftool_handle.SetMMCM(inst_id, 1, 1)\n",
126 | "print(\"rftool_handle.SetMMCM ret = \", ret)\n",
127 | "\n",
128 | "ret = rftool_handle.SetMMCM(inst_id, 1, 2)\n",
129 | "print(\"rftool_handle.SetMMCM ret = \", ret)\n",
130 | "\n",
131 | "ret = rftool_handle.SetMMCM(inst_id, 1, 3)\n",
132 | "print(\"rftool_handle.SetMMCM ret = \", ret)\n",
133 | "\n",
134 | "ret = rftool_handle.SetMMCM(inst_id, 0, 0)\n",
135 | "print(\"rftool_handle.SetMMCM ret = \", ret)\n",
136 | "\n",
137 | "ret = rftool_handle.SetMMCM(inst_id, 0, 1)\n",
138 | "print(\"rftool_handle.SetMMCM ret = \", ret)\n",
139 | "\n",
140 | "ret = rftool_handle.SetMMCM(inst_id, 0, 2)\n",
141 | "print(\"rftool_handle.SetMMCM ret = \", ret)\n",
142 | "\n",
143 | "ret = rftool_handle.SetMMCM(inst_id, 0, 3)\n",
144 | "print(\"rftool_handle.SetMMCM ret = \", ret)"
145 | ]
146 | },
147 | {
148 | "cell_type": "code",
149 | "execution_count": null,
150 | "metadata": {},
151 | "outputs": [],
152 | "source": [
153 | "# Ensure Channels Enabled\n",
154 | "#First Tiles must be disabled (see pg269)\n",
155 | "rftool_handle.lmem_wr32(0xb000000c, 0x0)\n",
156 | "rftool_handle.lmem_wr32(0xb040000c, 0x0)\n",
157 | "#Channels can now be enabled\n",
158 | "rftool_handle.lmem_wr32(0xb0000008, 0xffff)\n",
159 | "rftool_handle.lmem_wr32(0xb0400008, 0xffff)\n",
160 | "#Enable all Tiles\n",
161 | "rftool_handle.lmem_wr32(0xb000000c, 0xf)\n",
162 | "rftool_handle.lmem_wr32(0xb040000c, 0xf)"
163 | ]
164 | },
165 | {
166 | "cell_type": "code",
167 | "execution_count": null,
168 | "metadata": {},
169 | "outputs": [],
170 | "source": [
171 | "rftool_handle.WriteDataToMemory(tile_id, dac_block_id, sig)\n",
172 | "rftool_handle.SetLocalMemSample(1, tile_id, dac_block_id, N)\n",
173 | "rftool_handle.LocalMemTrigger(1)\n",
174 | "\n",
175 | "rftool_handle.SetLocalMemSample(0, tile_id, adc_block_id, N)\n",
176 | "rftool_handle.LocalMemTrigger(0)\n",
177 | "SigOut = rftool_handle.ReadDataFromMemory(tile_id, adc_block_id, N, 0)\n"
178 | ]
179 | },
180 | {
181 | "cell_type": "code",
182 | "execution_count": null,
183 | "metadata": {},
184 | "outputs": [],
185 | "source": [
186 | "bokeh.io.output_notebook(INLINE)\n",
187 | "p = figure()\n",
188 | "dft = np.abs(fft.fft(SigOut[0]))\n",
189 | "fstp = FS/N\n",
190 | "fx = np.arange(0, FS, fstp)\n",
191 | "p.line(fx, dft)\n",
192 | "show(p)"
193 | ]
194 | },
195 | {
196 | "cell_type": "code",
197 | "execution_count": null,
198 | "metadata": {},
199 | "outputs": [],
200 | "source": []
201 | }
202 | ],
203 | "metadata": {
204 | "kernelspec": {
205 | "display_name": "Python 3",
206 | "language": "python",
207 | "name": "python3"
208 | },
209 | "language_info": {
210 | "codemirror_mode": {
211 | "name": "ipython",
212 | "version": 3
213 | },
214 | "file_extension": ".py",
215 | "mimetype": "text/x-python",
216 | "name": "python",
217 | "nbconvert_exporter": "python",
218 | "pygments_lexer": "ipython3",
219 | "version": "3.8.5"
220 | }
221 | },
222 | "nbformat": 4,
223 | "nbformat_minor": 4
224 | }
225 |
--------------------------------------------------------------------------------
/examples/python/rftool/mixer.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | __author__ = "Anish Kadamathikuttiyil Karthikeyan Pillai"
5 | __copyright__ = "Copyright 2021, Xilinx"
6 |
7 | from rftool import Rftool
8 | import matplotlib.pyplot as plt
9 | import numpy as np
10 | from scipy import fft
11 |
12 | rftool_handle = Rftool()
13 | # SetBoardName
14 | board_name = "zcu208"
15 | rftool_handle.SetBoardName(board_name)
16 | # SetIpAndPort
17 | rftool_handle.SetIpAndPort("169.254.10.2", "9090")
18 | # SetMetalLogLevel
19 | metal_log_level = rftool_handle.GetEnum_metal_log_level()
20 | rftool_handle.SetMetalLogLevel(metal_log_level["METAL_LOG_DEBUG"])
21 | # GetPythonLogLevels
22 | PythonLogLevels = rftool_handle.GetPythonLogLevels()
23 | # SetClientLogLevel
24 | rftool_handle.SetClientLogLevel(PythonLogLevels["ERROR"])
25 |
26 | ret, inst_id = rftool_handle.Initialize()
27 | # setup clocking
28 | DistributionSettings = rftool_handle.GetStruct_XRFdc_Distribution_Settings()
29 | if board_name == "zcu208":
30 | DistributionSettings["SourceTileId"] = 0
31 | else:
32 | DistributionSettings["SourceTileId"] = 2
33 | DistributionSettings["SourceType"] = 1
34 | DistributionSettings["EdgeTypes"] = [0,1]
35 | DistributionSettings["EdgeTileIds"] = [0,3]
36 | DistributionSettings["DistRefClkFreq"] = 245.76
37 | DistributionSettings["DistributedClock"] = 1
38 | DistributionSettings["SampleRates"] = [[2211.86, 2211.86, 2211.86, 2211.86], [2211.86, 2211.86, 2211.86, 2211.86]]
39 | ret = rftool_handle.XRFdc_SetClkDistribution(inst_id, DistributionSettings)
40 |
41 | MixerSettingsADC = {
42 | "Freq": 0.0,
43 | "PhaseOffset": 0.0,
44 | "EventSource": 2,
45 | "CoarseMixFreq": 0x10,
46 | "MixerMode": 4,
47 | "FineMixerScale": 0,
48 | "MixerType": 1,
49 | }
50 | tile_id = 0
51 | dac_block_id = 0
52 | if board_name == "zcu208":
53 | if dac_block_id == 2:
54 | adc_block_id = 1
55 | else:
56 | adc_block_id = 0
57 | else:
58 | adc_block_id = dac_block_id
59 |
60 | N = 2048 # number of 16bit samples
61 | f = 502.560
62 | FS = 2211.86
63 | FS_DAC = 2211.86
64 | T = 1/FS_DAC
65 | t = np.arange(0, (N * T), T)
66 | sig = 0x1fff * np.cos(2 * np.pi * f * t)
67 |
68 | ret, MixerSettingsADC = rftool_handle.XRFdc_SetMixerSettings(inst_id, 0, tile_id, adc_block_id, MixerSettingsADC)
69 | print("rftool_handle.XRFdc_SetMixerSettings ret = ", ret)
70 |
71 | ret = rftool_handle.XRFdc_UpdateEvent(inst_id, 0, tile_id, adc_block_id, 1)
72 | print("rftool_handle.XRFdc_UpdateEvent ret = ", ret)
73 |
74 | ret, df = rftool_handle.XRFdc_GetDecimationFactor(inst_id, tile_id, adc_block_id)
75 | print(f"rftool_handle.XRFdc_GetDecimationFactor ret = {ret} Decimation factor = {df}")
76 |
77 | ret = rftool_handle.SetMMCM(inst_id, 1, 0)
78 | print("rftool_handle.SetMMCM ret = ", ret)
79 |
80 | ret = rftool_handle.SetMMCM(inst_id, 1, 1)
81 | print("rftool_handle.SetMMCM ret = ", ret)
82 |
83 | ret = rftool_handle.SetMMCM(inst_id, 1, 2)
84 | print("rftool_handle.SetMMCM ret = ", ret)
85 |
86 | ret = rftool_handle.SetMMCM(inst_id, 1, 3)
87 | print("rftool_handle.SetMMCM ret = ", ret)
88 |
89 | ret = rftool_handle.SetMMCM(inst_id, 0, 0)
90 | print("rftool_handle.SetMMCM ret = ", ret)
91 |
92 | ret = rftool_handle.SetMMCM(inst_id, 0, 1)
93 | print("rftool_handle.SetMMCM ret = ", ret)
94 |
95 | ret = rftool_handle.SetMMCM(inst_id, 0, 2)
96 | print("rftool_handle.SetMMCM ret = ", ret)
97 |
98 | ret = rftool_handle.SetMMCM(inst_id, 0, 3)
99 | print("rftool_handle.SetMMCM ret = ", ret)
100 |
101 |
102 | # Ensure Channels Enabled
103 | #First Tiles must be disabled (see pg269)
104 | rftool_handle.lmem_wr32(0xb000000c, 0x0)
105 | rftool_handle.lmem_wr32(0xb040000c, 0x0)
106 | #Channels can now be enabled
107 | rftool_handle.lmem_wr32(0xb0000008, 0xffff)
108 | rftool_handle.lmem_wr32(0xb0400008, 0xffff)
109 | #Enable all Tiles
110 | rftool_handle.lmem_wr32(0xb000000c, 0xf)
111 | rftool_handle.lmem_wr32(0xb040000c, 0xf)
112 |
113 | rftool_handle.WriteDataToMemory(tile_id, dac_block_id, sig)
114 | rftool_handle.SetLocalMemSample(1, tile_id, dac_block_id, N)
115 | rftool_handle.LocalMemTrigger(1)
116 |
117 | rftool_handle.SetLocalMemSample(0, tile_id, adc_block_id, N)
118 | rftool_handle.LocalMemTrigger(0)
119 | SigOut = rftool_handle.ReadDataFromMemory(tile_id, adc_block_id, N, 0)
120 |
121 | rftool_handle.SetLocalMemSample(0, tile_id, adc_block_id, N)
122 | rftool_handle.LocalMemTrigger(0)
123 | SigOut = rftool_handle.ReadDataFromMemory(tile_id, adc_block_id, N, 0)
124 |
125 | dft = np.abs(fft.fft(SigOut[0]))
126 | fstp = FS/N
127 | fx = np.arange(0, FS, fstp)
128 | plt.plot(fx, dft)
129 | plt.show()
130 |
--------------------------------------------------------------------------------
/examples/python/usage/README.md:
--------------------------------------------------------------------------------
1 | Usage Description of python examples
2 |
3 |
4 | Python usage scripts run in three modes.
5 | xclient - Runs at host (Windows or Linux) PC or at board communicating with xclient
6 | xcffi - Runs at board directly communicating with xcffi without pyro
7 | xpyro - Runs at host (Windows or Linux) PC or at board communicating with pyro server
8 | To run the xclient at host, Python 3.7 or higher with Pyro4 package is required.
9 |
Package installation command for Pyro4 is given below
10 | pip install Pyro4
11 |
12 | Mode - xclient
13 |
14 |
Runs at host (Windows or Linux) PC or at board communicating with xclient
15 | To run at host (Windows or Linux) PC
16 | Run the python script,
17 | python3 script_name xclient host ip_address port
18 | To run at board
19 | In the serial console of the board give the following commands
20 | cd /usr/share/examples/python
21 | sudo python3 script_name xclient board ip_address port
22 |
23 | Mode - xcffi
24 |
25 | Runs at board directly communicating with xcffi
26 |
27 | In the serial console of the board give the following commands
28 | cd /usr/share/examples/python
29 | sudo python3 script_name xcffi
30 |
31 | Mode - xpyro
32 |
33 | Runs at host (Windows or Linux) PC or at board communicating with pyro server
34 | To run at host (Windows or Linux) PC
35 | Run the python script,
36 | python3 script_name xpyro host ip_address port
37 | To run at board
38 | In the serial console of the board give the following commands
39 | cd /usr/share/examples/python
40 | python3 script_name xpyro board ip_address port
41 |
42 | Copyright (C) 2022 - 2023 Advanced Micro Devices, Inc. All rights reserved.
43 | SPDX-License-Identifier: BSD-3-Clause
--------------------------------------------------------------------------------
/examples/python/usage/python_usage_axi_memmap.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | __author__ = "Anish Kadamathikuttiyil Karthikeyan Pillai"
5 | __copyright__ = "Copyright 2021, Xilinx"
6 |
7 | import sys
8 | import datetime
9 | import serpent
10 | import sys
11 | def usage():
12 | # sys.argv[0] - usage python file name
13 | # sys.argv[1] - xclient/xcffi/xpyro
14 | # sys.argv[2] - host/board
15 | # sys.argv[3] - ip_address
16 | # sys.argv[4] - port
17 | print(f"Usage: The application work in three modes xclient, xcffi and xpyro\n"
18 | f"python3 {sys.argv[0]} xclient host/board ip_address port => Runs at host or board with xclient\n"
19 | f"sudo python3 {sys.argv[0]} xcffi => Runs at board with xcffi\n"
20 | f"python3 {sys.argv[0]} xpyro host/board ip_address port => Runs at host or board with xpyro\n"
21 | f"Example: python3 {sys.argv[0]} xclient host 169.254.10.2 9090")
22 |
23 | # 'xcffi' option will run only in the board
24 | if (len(sys.argv) == 2):
25 | if (sys.argv[1] != 'xcffi'):
26 | usage()
27 | sys.exit()
28 |
29 | elif (len(sys.argv) != 5):
30 | usage()
31 | sys.exit()
32 |
33 | # The 'xclient' option will run both in host and board
34 | if (sys.argv[1] == 'xclient'):
35 | # For 'xclient' option the path of the xclient is required
36 | # The relative path in the host is given for host case
37 | if (sys.argv[2] == 'host'):
38 | sys.path.append('../../../xclient/data_stream/data_transfer_no_dma/')
39 | # The location of xclient in the filesystem is given for the board case
40 | elif (sys.argv[2] == 'board'):
41 | sys.path.append('/usr/share/raft/xclient/data_stream/data_transfer_no_dma/')
42 | else:
43 | usage()
44 | sys.exit()
45 | import axi_memmap_client
46 | handle = axi_memmap_client.axi_memmap
47 | ip_address = sys.argv[3]
48 | port = sys.argv[4]
49 |
50 | elif (sys.argv[1] == 'xcffi'):
51 | # For 'xcffi' option the path of the cffi python code is required
52 | sys.path.append('/usr/share/raft/xserver/xcffi/drv_api/data_stream/data_transfer_no_dma/')
53 | from axi_memmap_c import AXI_MEMMAP_C
54 | handle = AXI_MEMMAP_C()
55 |
56 | # The 'xpyro' option will run both in host and board
57 | elif (sys.argv[1] == 'xpyro'):
58 | ip_address = sys.argv[3]
59 | port = sys.argv[4]
60 | import Pyro4
61 | # Prepare the uri needed for pyro communication
62 | uri = f"PYRO:AXI_MEMMAP@{ip_address}:{port}"
63 | handle = Pyro4.Proxy(uri)
64 | else:
65 | usage()
66 | sys.exit()
67 |
68 | if (sys.argv[1] == 'xclient'):
69 | #SetIpAndPort
70 | handle.SetIpAndPort(ip_address, port)
71 |
72 | def convert_to_list(data):
73 | k = []
74 | for i in range(int(len(data)/4)):
75 | k.append(int.from_bytes(data[(i*4):(((i+1)*4))], byteorder='little'))
76 | return k
77 |
78 | def convert_to_bytearray(data):
79 | b = bytearray()
80 | for i in range(len(data)):
81 | c = data[i].to_bytes(4, byteorder='little', signed=False)
82 | b.extend(c)
83 | return b
84 |
85 | def test_axi_write_read():
86 | buf = [0xABCDEF12, 0x34567890, 0x567890AB, 0x7890ABCD, 0x342ABC12]
87 | address = 0xa7c0000
88 | num_words = 5
89 | network_order = 0
90 | if (sys.argv[1] == 'xpyro'):
91 | buf = convert_to_bytearray(buf)
92 | ret = handle.axi_write_words(address, num_words, buf, network_order)
93 | assert ret == 0
94 | ret, buf = handle.axi_read_words(address, num_words, network_order)
95 | #This conversion is done in xpyro client
96 | if (sys.argv[1] == 'xpyro'):
97 | buf = serpent.tobytes(buf)
98 | buf = convert_to_list(buf)
99 | assert ret == 0
100 | assert buf[0] == 0xABCDEF12
101 | assert buf[1] == 0x34567890
102 | assert buf[2] == 0x567890AB
103 | assert buf[3] == 0x7890ABCD
104 | assert buf[4] == 0x342ABC12
105 |
106 | def test_axi_write_read_bulk():
107 | buf = []
108 | num_words_write = 1024*2
109 | num_words = num_words_write
110 | for i in range (num_words):
111 | buf.append(0xFFFFFFFF - i)
112 | address = 0xa7c0000
113 | network_order = 0
114 | print("num_words at client test = ", num_words)
115 | a = datetime.datetime.now()
116 | if (sys.argv[1] == 'xpyro'):
117 | buf = convert_to_bytearray(buf)
118 | ret = handle.axi_write_words(address, num_words, buf, network_order)
119 | b = datetime.datetime.now()
120 | c = b-a
121 | print("Time taken for writing ", num_words * 4, "bytes = ", c.total_seconds(), " seconds")
122 | print("Write Throughput = ", round((num_words*4)/c.total_seconds()/1000000, 4), "Mega bytes per second")
123 | assert ret == 0
124 | num_words = 1024*1000
125 | a = datetime.datetime.now()
126 | ret, buf = handle.axi_read_words(address, num_words, network_order)
127 | #This conversion is done in xpyro client
128 | if (sys.argv[1] == 'xpyro'):
129 | buf = serpent.tobytes(buf)
130 | buf = convert_to_list(buf)
131 | b = datetime.datetime.now()
132 | c = b-a
133 | print("Time taken for reading ", num_words * 4, "bytes = ", c.total_seconds(), " seconds")
134 | print("Read Throughput = ", round((num_words*4)/c.total_seconds()/1000000,4), "Mega bytes per second")
135 | for i in range (num_words_write):
136 | assert buf[i] == (0xFFFFFFFF - i)
137 |
138 | test_axi_write_read()
139 | test_axi_write_read_bulk()
140 |
--------------------------------------------------------------------------------
/examples/python/usage/python_usage_console.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | __author__ = "Anish Kadamathikuttiyil Karthikeyan Pillai"
5 | __copyright__ = "Copyright 2021, Xilinx"
6 |
7 | import sys
8 | def usage():
9 | # sys.argv[0] - usage python file name
10 | # sys.argv[1] - xclient/xcffi/xpyro
11 | # sys.argv[2] - host/board
12 | # sys.argv[3] - ip_address
13 | # sys.argv[4] - port
14 | print(f"Usage: The application work in three modes xclient, xcffi and xpyro\n"
15 | f"python3 {sys.argv[0]} xclient host/board ip_address port => Runs at host or board with xclient\n"
16 | f"sudo python3 {sys.argv[0]} xcffi => Runs at board with xcffi\n"
17 | f"python3 {sys.argv[0]} xpyro host/board ip_address port => Runs at host or board with xpyro\n"
18 | f"Example: python3 {sys.argv[0]} xclient host 169.254.10.2 9090")
19 |
20 | # 'xcffi' option will run only in the board
21 | if (len(sys.argv) == 2):
22 | if (sys.argv[1] != 'xcffi'):
23 | usage()
24 | sys.exit()
25 |
26 | elif (len(sys.argv) != 5):
27 | usage()
28 | sys.exit()
29 |
30 | # The 'xclient' option will run both in host and board
31 | if (sys.argv[1] == 'xclient'):
32 | # For 'xclient' option the path of the xclient is required
33 | # The relative path in the host is given for host case
34 | if (sys.argv[2] == 'host'):
35 | sys.path.append('../../../xclient/raft_services')
36 | # The location of xclient in the filesystem is given for the board case
37 | elif (sys.argv[2] == 'board'):
38 | sys.path.append('/usr/share/raft/xclient/raft_services')
39 | else:
40 | usage()
41 | sys.exit()
42 | import console_client
43 | handle = console_client.console
44 | ip_address = sys.argv[3]
45 | port = sys.argv[4]
46 |
47 | elif (sys.argv[1] == 'xcffi'):
48 | # For 'xcffi' option the path of the cffi python code is required
49 | sys.path.append('/usr/share/raft/xserver/raft_services')
50 | from console_server import CONSOLE
51 | handle = CONSOLE()
52 |
53 | # The 'xpyro' option will run both in host and board
54 | elif (sys.argv[1] == 'xpyro'):
55 | ip_address = sys.argv[3]
56 | port = sys.argv[4]
57 | import Pyro4
58 | # Prepare the uri needed for pyro communication
59 | uri = f"PYRO:CONSOLE@{ip_address}:{port}"
60 | handle = Pyro4.Proxy(uri)
61 | else:
62 | usage()
63 | sys.exit()
64 |
65 | if (sys.argv[1] == 'xclient'):
66 | #SetIpAndPort
67 | handle.SetIpAndPort(ip_address, port)
68 | #GetPythonLogLevels
69 | PythonLogLevels = handle.GetPythonLogLevels()
70 | #SetClientLogLevel
71 | handle.SetClientLogLevel(PythonLogLevels["DEBUG"])
72 |
73 | #GetPythonLogLevels
74 | PythonLogLevels = handle.GetPythonLogLevels()
75 |
76 | #SetServerLogLevel
77 | handle.SetServerLogLevel(PythonLogLevels["DEBUG"])
78 |
79 | #RaftConsole
80 | cmd = 'cat /sys/bus/iio/devices/iio\:device0/in_temp160_temp_input'
81 | status, str_cmd_ret = handle.RaftConsole(cmd)
82 | print(cmd)
83 | print(f"status: {status}")
84 | print(f"str_cmd_ret: {str_cmd_ret}")
85 |
86 | #RaftConsole
87 | cmd = 'ls -all'
88 | status, str_cmd_ret = handle.RaftConsole(cmd)
89 | print(cmd)
90 | print(f"status: {status}")
91 | print(f"str_cmd_ret: {str_cmd_ret}")
92 |
--------------------------------------------------------------------------------
/examples/python/usage/python_usage_pm.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | __author__ = "Salih Erim"
5 | __copyright__ = "Copyright 2023-2025, Advanced Micro Devices, Inc."
6 |
7 | import sys
8 | import json
9 | import sys
10 | def usage():
11 | # sys.argv[0] - usage python file name
12 | # sys.argv[1] - xclient/xpyro
13 | # sys.argv[2] - host/board
14 | # sys.argv[3] - ip_address
15 | # sys.argv[4] - port
16 | print(f"Usage: The application work in three modes xclient and xpyro\n"
17 | f"python3 {sys.argv[0]} xclient host/board ip_address port => Runs at host or board with xclient\n"
18 | f"python3 {sys.argv[0]} xpyro host/board ip_address port => Runs at host or board with xpyro\n"
19 | f"Example: python3 {sys.argv[0]} xclient host 127.0.0.1 9090")
20 |
21 | if (len(sys.argv) != 5):
22 | usage()
23 | sys.exit()
24 |
25 | # The 'xclient' option will run both in host and board
26 | if (sys.argv[1] == 'xclient'):
27 | # For 'xclient' option the path of the xclient is required
28 | # The relative path in the host is given for host case
29 | if (sys.argv[2] == 'host'):
30 | sys.path.append('../../../xclient/raft_services')
31 | # The location of xclient in the filesystem is given for the board case
32 | elif (sys.argv[2] == 'board'):
33 | sys.path.append('/usr/share/raft/xclient/raft_services')
34 | else:
35 | usage()
36 | sys.exit()
37 | import pm_client
38 | handle = pm_client.pm
39 | ip_address = sys.argv[3]
40 | port = sys.argv[4]
41 |
42 | # The 'xpyro' option will run both in host and board
43 | elif (sys.argv[1] == 'xpyro'):
44 | ip_address = sys.argv[3]
45 | port = sys.argv[4]
46 | import Pyro4
47 | # Prepare the uri needed for pyro communication
48 | uri = f"PYRO:PM@{ip_address}:{port}"
49 | handle = Pyro4.Proxy(uri)
50 | else:
51 | usage()
52 | sys.exit()
53 |
54 | if (sys.argv[1] == 'xclient'):
55 | #SetIpAndPort
56 | handle.SetIpAndPort(ip_address, port)
57 | #GetPythonLogLevels
58 | PythonLogLevels = handle.GetPythonLogLevels()
59 | #SetClientLogLevel
60 | #handle.SetClientLogLevel(PythonLogLevels["DEBUG"])
61 |
62 |
63 | def print_response(response):
64 | if ret['status'] == 'success':
65 | print(json.dumps(ret['data'], indent=2))
66 | else:
67 | print(json.dumps(ret['message'], indent=2))
68 |
69 | def print_header(section_name):
70 | print(f'\n######## {section_name} ########')
71 |
72 | print_header("GET BOARD INFO")
73 | #Description:
74 | # Gets Board info.
75 | #Input Arguments:
76 | #
77 | #Return:
78 | # ret:BoardInfo in dict format.
79 | ret = handle.getboardinfo()
80 | print(json.dumps(ret, indent=2))
81 |
82 | print_header("LIST OF FEATURES")
83 | #Description:
84 | # Lists feature info.
85 | #Input Arguments:
86 | #
87 | #Return:
88 | # ret:Features in list format.
89 | list_features = handle.listfeature()
90 | print(json.dumps(list_features, indent=2))
91 |
92 | if 'powerdomain' in list_features['data']:
93 | print_header("LIST OF DOMAINS")
94 | #Description:
95 | # Lists Power domains.
96 | #Input Arguments:
97 | # None
98 | #Return:
99 | # ret: Power Domains List.
100 | list_domains = handle.listpowerdomain()
101 | print(json.dumps(list_domains, indent=2))
102 |
103 | if list_domains['data']:
104 | print_header(f'LIST OF "{list_domains['data'][0]}" RAILS')
105 | #Description:
106 | # Gets Rail list of asked domain
107 | #Input Arguments:
108 | # domain_name: Domain Name
109 | #Return:
110 | # ret: List of rails for asked domain.
111 | list_rails = handle.listrailsofdomain(list_domains['data'][0])
112 | print(json.dumps(list_rails, indent=2))
113 |
114 | if list_rails['data']:
115 | print_header(f'VALUES OF "{list_rails['data'][0]}" RAIL')
116 | #Description:
117 | # Gets power/sensor values of a rail.
118 | #Input Arguments:
119 | # rail_name: Rail Name
120 | #Return:
121 | # ret: List of rails for asked domain.
122 | ret = handle.getvalueofrail(list_rails['data'][0])
123 | print(json.dumps(ret, indent=2))
124 |
125 | print_header(f'######## VALUES OF "{list_domains['data'][0]}" DOMAIN ########')
126 | #Description:
127 | # Gets power/sensor values of a domain.
128 | #Input Arguments:
129 | # rail_name: Domain Name
130 | #Return:
131 | # ret: List of rails for asked domain.
132 | ret = handle.getvalueofdomain(list_domains['data'][0])
133 | print(json.dumps(ret, indent=2))
134 |
135 | print_header(f'######## GET ALL DOMAINS POWER VALUES AT ONCE ##########')
136 | #Description:
137 | # Gets domains and total power values of the board.
138 | #Input Arguments:
139 | # None
140 | #Return:
141 | # ret: List of power values of the board.
142 | ret = handle.getpowerall()
143 | print(json.dumps(ret, indent=2))
144 |
145 | print_header(f'######## GET ALL DOMAINS VALUES AT ONCE ##########')
146 | #Description:
147 | # Gets power/sensor values of the board.
148 | #Input Arguments:
149 | # None
150 | #Return:
151 | # ret: List of rails for asked domain.
152 | ret = handle.getvalueall()
153 | print(json.dumps(ret, indent=2))
154 |
155 | if 'power' in list_features['data']:
156 | print_header(f'######## LIST POWER SENSORS ##########')
157 | #Description:
158 | # List of power sensors
159 | #Input Arguments:
160 | # None
161 | #Return:
162 | # ret: list of power sensors
163 | list_power = handle.listpower()
164 | print(json.dumps(list_power, indent=2))
165 |
166 |
167 | if list_power['data']:
168 | # Get first power sensor name from list of power sensors
169 | power_sensor = [key for key in list_power['data'][0]][0]
170 | print_header(f'######## GET "{power_sensor}" POWER SENSOR ##########')
171 | #Description:
172 | # Gets power sensor values.
173 | #Input Arguments:
174 | # Power sensor name
175 | #Return:
176 | # ret: Power sensor values
177 | ret = handle.getpower(power_sensor)
178 | print(json.dumps(ret, indent=2))
179 |
180 | if 'voltage' in list_features['data']:
181 | print_header(f'######## LIST VOLTAGES ##########')
182 | #Description:
183 | # List of voltages.
184 | #Input Arguments:
185 | # None
186 | #Return:
187 | # ret: list of voltages
188 | list_voltage = handle.listvoltage()
189 | print(json.dumps(list_voltage, indent=2))
190 |
191 |
192 | if list_voltage['data']:
193 | # Get first voltage name from list of voltages
194 | voltage = [key for key in list_voltage['data'][0]][0]
195 | print_header(f'######## GET {voltage} VOLTAGE ##########')
196 | #Description:
197 | # Gets voltage value.
198 | #Input Arguments:
199 | # Voltage regulator name
200 | #Return:
201 | # ret: Voltage value
202 | ret = handle.getvoltage(voltage)
203 | print(json.dumps(ret, indent=2))
204 |
205 | print_header(f'######## GET "{voltage}" REGULATOR ##########')
206 | #Description:
207 | # Gets voltage regulator telemetry values.
208 | #Input Arguments:
209 | # Voltage regulator name
210 | #Return:
211 | # ret: voltage regulator telemetry values
212 | ret = handle.getregulator(voltage)
213 | print(json.dumps(ret, indent=2))
214 |
215 | if 'temp' in list_features['data']:
216 | print_header(f'######## LIST TEMPERATURES ##########')
217 | #Description:
218 | # List of temperature names.
219 | #Input Arguments:
220 | # None
221 | #Return:
222 | # ret: List Temperature devices
223 | list_temp = handle.listtemperature()
224 | print(json.dumps(list_temp, indent=2))
225 |
226 | if list_temp['data']:
227 | print_header(f'######## GET TEMPERATURE of {list_temp['data'][0]} ##########')
228 | #Description:
229 | # Gets sysmon temperature values of Versal.
230 | #Input Arguments:
231 | # None
232 | #Return:
233 | # ret: Versal's Temperature values
234 | ret = handle.gettemperature(list_temp['data'][0])
235 | print(json.dumps(ret, indent=2))
--------------------------------------------------------------------------------
/examples/python/usage/python_usage_rfclk.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2021-2024 Xilinx, Inc. All rights reserved.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | __author__ = "Gerard Thomas Colman"
5 | __copyright__ = "Copyright 2021, Xilinx"
6 |
7 | import sys
8 | def usage():
9 | # sys.argv[0] - usage python file name
10 | # sys.argv[1] - xclient/xcffi/xpyro
11 | # sys.argv[2] - host/board
12 | # sys.argv[3] - ip_address
13 | # sys.argv[4] - port
14 | print(f"Usage: The application work in three modes xclient, xcffi and xpyro\n"
15 | f"python3 {sys.argv[0]} xclient host/board ip_address port => Runs at host or board with xclient\n"
16 | f"sudo python3 {sys.argv[0]} xcffi => Runs at board with xcffi\n"
17 | f"python3 {sys.argv[0]} xpyro host/board ip_address port => Runs at host or board with xpyro\n"
18 | f"Example: python3 {sys.argv[0]} xclient host 169.254.10.2 9090")
19 |
20 | # # 'xcffi' option will run only in the board
21 | if (len(sys.argv) == 2):
22 | if (sys.argv[1] != 'xcffi'):
23 | usage()
24 | sys.exit()
25 |
26 | elif (len(sys.argv) != 5):
27 | print("here")
28 | usage()
29 | sys.exit()
30 |
31 | # The 'xclient' option will run both in host and board
32 | if (sys.argv[1] == 'xclient'):
33 | # For 'xclient' option the path of the xclient is required
34 | # The relative path in the host is given for host case
35 | if (sys.argv[2] == 'host'):
36 | sys.path.append('../../../xclient/rfdc')
37 | # The location of xclient in the filesystem is given for the board case
38 | elif (sys.argv[2] == 'board'):
39 | sys.path.append('/usr/share/raft/xclient/rfdc')
40 | else:
41 | usage()
42 | sys.exit()
43 | import rfclk_client
44 | handle = rfclk_client.rfclk
45 | ip_address = sys.argv[3]
46 | port = sys.argv[4]
47 |
48 | elif (sys.argv[1] == 'xcffi'):
49 | # For 'xcffi' option the path of the cffi python code is required
50 | sys.path.append('/usr/share/raft/xserver/xcffi/drv_api/rfdc')
51 | from rfclk_server import RFCLK
52 | handle = RFCLK()
53 |
54 | # The 'xpyro' option will run both in host and board
55 | elif (sys.argv[1] == 'xpyro'):
56 | ip_address = sys.argv[3]
57 | port = sys.argv[4]
58 | import Pyro4
59 | # Prepare the uri needed for pyro communication
60 | uri = f"PYRO:RFCLK@{ip_address}:{port}"
61 | handle = Pyro4.Proxy(uri)
62 | else:
63 | usage()
64 | sys.exit()
65 |
66 | if (sys.argv[1] == 'xclient'):
67 | #SetIpAndPort
68 | handle.SetIpAndPort(ip_address, port)
69 | #GetPythonLogLevels
70 | PythonLogLevels = handle.GetPythonLogLevels()
71 | #SetClientLogLevel
72 | handle.SetClientLogLevel(PythonLogLevels["DEBUG"])
73 |
74 | #GetPythonLogLevels
75 | PythonLogLevels = handle.GetPythonLogLevels()
76 |
77 | #SetServerLogLevel
78 | handle.SetServerLogLevel(PythonLogLevels["DEBUG"])
79 |
80 | #SetMetalLogLevel
81 | metal_log_level = handle.GetEnum_metal_log_level()
82 | handle.SetMetalLogLevel(metal_log_level["METAL_LOG_EMERGENCY"])
83 |
84 | #GetRfclkMacro
85 | rfclk_macro = handle.GetRfclkMacro()
86 | print(rfclk_macro["XST_SUCCESS"])
87 | print(rfclk_macro["XST_FAILURE"])
88 | print(rfclk_macro["RFCLK_LMX2594_1"])
89 | print(rfclk_macro["RFCLK_LMX2594_2"])
90 | print(rfclk_macro["RFCLK_LMK"])
91 | print(rfclk_macro["RFCLK_CHIP_NUM"])
92 | print(rfclk_macro["LMK_COUNT"])
93 | print(rfclk_macro["LMK_FREQ_NUM"])
94 | print(rfclk_macro["LMX_ADC_NUM"])
95 | print(rfclk_macro["LMX_DAC_NUM"])
96 | print(rfclk_macro["LMX2594_COUNT"])
97 | print(rfclk_macro["FREQ_LIST_STR_SIZE"])
98 |
99 | #XRFClk_Init
100 | ret = handle.XRFClk_Init(486)
101 | print(ret)
102 |
103 | #XRFClk_ResetChip
104 | ret = handle.XRFClk_ResetChip(0)
105 | print(ret)
106 |
107 | #XRFClk_SetConfigOnOneChipFromConfigId
108 | ret = handle.XRFClk_SetConfigOnOneChipFromConfigId(0,0)
109 | print(ret)
110 |
111 | #XRFClk_GetConfigFromOneChip
112 | ret = handle.XRFClk_GetConfigFromOneChip(0)
113 | print(ret)
114 |
115 | #XRFClk_SetConfigOnAllChipsFromConfigId
116 | ret = handle.XRFClk_SetConfigOnAllChipsFromConfigId(0,0,0)
117 | print(ret)
118 |
119 | #XRFClk_WriteReg
120 | ret = handle.XRFClk_WriteReg(0,0)
121 | print(ret)
122 |
123 | #XRFClk_ReadReg
124 | DataVal = handle.XRFClk_ReadReg(0)
125 | print(DataVal)
126 |
--------------------------------------------------------------------------------
/xclient/data_stream/data_transfer_no_dma/axi_memmap_client.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | __author__ = "Anish Kadamathikuttiyil Karthikeyan Pillai"
5 | __copyright__ = "Copyright 2021, Xilinx"
6 |
7 | import Pyro4
8 | import serpent
9 | import logging
10 |
11 | def convert_to_bytearray(data):
12 | b = bytearray()
13 | for i in range(len(data)):
14 | c = data[i].to_bytes(4, byteorder='little', signed=False)
15 | b.extend(c)
16 | return b
17 |
18 | def convert_to_list(data):
19 | k = []
20 | for i in range(int(len(data)/4)):
21 | k.append(int.from_bytes(data[(i*4):(((i+1)*4))], byteorder='little'))
22 | return k
23 |
24 |
25 | class AXI_MEMMAP_Client(object):
26 | AXI_MEMMAP = None
27 |
28 | def __init__(self):
29 | logging.info("Inside AXI_MEMMAP Pyro Client Constructor")
30 | pass
31 |
32 | def SetIpAndPort(self, ipaddr, port):
33 | """
34 | API to inform AXI_MEMMAP Client the IP address and port number of AXI_MEMMAP Server.
35 |
36 | :param ipaddr: IP Address string
37 | :param port: Port number string
38 | :return: None
39 |
40 | """
41 | uri = f"PYRO:AXI_MEMMAP@{ipaddr}:{port}"
42 | logging.debug(f"SetIpAndPort({ipaddr}, {port})\n uri = {uri}")
43 | self.AXI_MEMMAP = Pyro4.Proxy(uri)
44 | pass
45 |
46 | def axi_read_words(self, address, num_words, network_order):
47 | """
48 | Read num_words from address.
49 |
50 | :param address: address to read from
51 | :param num_words: number of words to read
52 | :param network_order: Apply network byte ordering if network_order!=0
53 | :return: ret: whether success or failure
54 | buf: the read data
55 |
56 | """
57 | logging.debug("axi_read_words({address}, {num_words}, {network_order})")
58 | ret, buf = self.AXI_MEMMAP.axi_read_words(address, num_words, network_order)
59 | logging.debug(f"ret = {ret}")
60 | buf = serpent.tobytes(buf)
61 | buf = convert_to_list(buf)
62 | return ret, buf
63 |
64 | def axi_write_words(self, address, num_words, buf, network_order):
65 | """
66 | Write num_words to address.
67 |
68 | :param address: address to write
69 | :param num_words: number of words to write
70 | :param buffer: data to write
71 | :param network_order: Apply network byte ordering if network_order!=0
72 | :return: ret: whether success or failure
73 |
74 | """
75 | buf = convert_to_bytearray(buf)
76 | logging.debug("axi_write_words({address}, {num_words}, {network_order})")
77 | ret = self.AXI_MEMMAP.axi_write_words(address, num_words, buf, network_order)
78 | logging.debug(f"ret = {ret}")
79 | return ret
80 |
81 | axi_memmap = AXI_MEMMAP_Client()
82 |
--------------------------------------------------------------------------------
/xclient/pat/i2c_client.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | __author__ = "Hugh Maguire"
5 | __copyright__ = "Copyright 2021, Xilinx"
6 |
7 | import Pyro4
8 | import logging
9 | import base64
10 |
11 | logging.basicConfig(level=logging.ERROR)
12 |
13 | class I2C_Client(object):
14 | I2C = None
15 |
16 | def __init__(self):
17 | logging.info("Inside CCF_Client Constructor")
18 | pass
19 |
20 | def SetIpAndPort(self, ipaddr, port):
21 | """
22 | API to inform I2C Client the IP address and port number of I2C Server.
23 |
24 | :param ipaddr: IP Address string
25 | :param port: Port number string
26 | :return: None
27 |
28 | """
29 | logging.debug("ipaddr = " + str(ipaddr))
30 | logging.debug("port = " + str(port))
31 | uri = "PYRO:I2C@" + str(ipaddr) + ":" + str(port)
32 | logging.debug("uri = " + uri)
33 | self.I2C = Pyro4.Proxy(uri)
34 | pass
35 |
36 | def XI2c_Initialize(self, device):
37 | """
38 | I2C driver one time initialisation.
39 |
40 | :param device_id: id of the opened device
41 | :return: ret_code
42 | """
43 | logging.debug(
44 | "XDfeCcf_Initialize(" + str(device) + ")"
45 | )
46 | ret = self.I2C.XI2c_Initialize(device)
47 | logging.debug("The return value Init = " + str(ret))
48 | return ret
49 |
50 | def XI2c_ReadINA226Reg(self, addr, reg):
51 | """
52 | I2C driver read a register
53 |
54 | :param addr: address of INA226 device
55 | :param reg: register to be read
56 | :return: ret_code, value of register
57 | """
58 | ret, val = self.I2C.XI2c_ReadINA226Reg(addr, reg)
59 | return ret, val
60 |
61 | def XI2c_WriteINA226Reg(self, addr, reg, val):
62 | """
63 | I2C driver write a register
64 |
65 | :param addr: address of INA226 device
66 | :param reg: register to be written
67 | :param val: value to be written
68 | :return: ret_code
69 | """
70 | ret = self.I2C.XI2c_WriteINA226Reg(addr, reg, val)
71 | return ret
72 |
73 | def XI2c_Release(self):
74 | """
75 | I2C driver Release instance
76 | :return: none
77 | """
78 | self.I2C.XI2c_Release()
79 |
80 | def __del__(self):
81 | logging.info("Inside I2C Destructor")
82 |
83 | i2c = I2C_Client()
84 |
--------------------------------------------------------------------------------
/xclient/pat/sysmon_client.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | __author__ = "Hugh Maguire"
5 | __copyright__ = "Copyright 2021, Xilinx"
6 |
7 | import Pyro4
8 | import logging
9 | #import base64
10 |
11 | logging.basicConfig(level=logging.ERROR)
12 |
13 | class Sysmon_Client(object):
14 | Sysmon = None
15 |
16 | def __init__(self):
17 | logging.info("Inside Sysmon_Client Constructor")
18 | pass
19 |
20 | def SetIpAndPort(self, ipaddr, port):
21 | """
22 | API to inform Sysmon Client the IP address and port number of I2C Server.
23 |
24 | :param ipaddr: IP Address string
25 | :param port: Port number string
26 | :return: None
27 |
28 | """
29 | logging.debug("ipaddr = " + str(ipaddr))
30 | logging.debug("port = " + str(port))
31 | uri = "PYRO:SYSMON@" + str(ipaddr) + ":" + str(port)
32 | logging.debug("uri = " + uri)
33 | self.Sysmon = Pyro4.Proxy(uri)
34 | pass
35 |
36 |
37 | def XSysmon_ReadValue(self, idStr):
38 | """
39 | I2C driver read a register
40 |
41 | :param addr: address of INA226 device
42 | :param reg: register to be read
43 | :return: ret_code, value of register
44 | """
45 | ret, val = self.Sysmon.XSysmon_ReadValue(idStr)
46 | return ret, val
47 |
48 | def __del__(self):
49 | logging.info("Inside Sysmon Destructor")
50 |
51 | sysmon = Sysmon_Client()
52 |
--------------------------------------------------------------------------------
/xclient/raft_services/console_client.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | __author__ = "Dragan Cvetic"
5 | __copyright__ = "Copyright 2022, Xilinx"
6 |
7 | import Pyro4
8 | import logging
9 | import base64
10 | import json
11 | import sys
12 |
13 |
14 | class CONSOLE_Client(object):
15 | CONSOLE = None
16 | logger = None
17 | LogLevelsDict = {
18 | "DEBUG": 4,
19 | "INFO": 3,
20 | "WARNING": 2,
21 | "ERROR": 1,
22 | "CRITICAL": 0
23 | }
24 |
25 | def __init__(self):
26 | self.logger = self.GetLogger()
27 | self.logger.info("Inside CONSOLE Pyro Client Constructor")
28 | return
29 |
30 | @staticmethod
31 | def GetLogger():
32 | """
33 | Static method to get the logger for the class.
34 | Default loglevel is set inside this class
35 |
36 | :return: logger
37 |
38 | """
39 | log_level = logging.ERROR
40 | logging.basicConfig(format="%(levelname)s:%(message)s")
41 | logger = logging.getLogger(__name__)
42 | try:
43 | handler_set_check = getattr(logger, 'handler_set')
44 | except AttributeError:
45 | handler_set_check = False
46 | if not handler_set_check:
47 | logger.setLevel(log_level)
48 | handler = logging.StreamHandler(sys.stdout)
49 | logger.addHandler(handler)
50 | logger.handler_set = True
51 | logger.disabled = False
52 | return logger
53 |
54 | def SetIpAndPort(self, ipaddr, port):
55 | """
56 | API to inform CONSOLE Client the IP address and port number of CONSOLE Server.
57 |
58 | :param ipaddr: IP Address string
59 | :param port: Port number string
60 | :return: None
61 |
62 | """
63 | uri = f"PYRO:CONSOLE@{ipaddr}:{port}"
64 | self.logger.debug(f"SetIpAndPort({ipaddr}, {port})\n uri = {uri}")
65 | self.CONSOLE = Pyro4.Proxy(uri)
66 | pass
67 |
68 | def GetPythonLogLevels(self):
69 | """
70 | Return the logging levels supported by logging library in python
71 |
72 | :param : None
73 | :return: Dictionary showing the log levels supported by logging library
74 | """
75 | self.logger.debug("GetPythonLogLevels()")
76 | PythonLogLevel = self.CONSOLE.GetPythonLogLevels()
77 | self.logger.debug(f"PythonLogLevel = {json.dumps(PythonLogLevel, indent=2)}")
78 | return PythonLogLevel
79 |
80 | def SetServerLogLevel(self, PythonLogLevel):
81 | """
82 | Set the python log level to the given level
83 |
84 | :param : Log level to set
85 | :return: None
86 | """
87 | self.logger.debug(f"SetServerLogLevel({PythonLogLevel})")
88 | self.CONSOLE.SetServerLogLevel(PythonLogLevel)
89 | return
90 |
91 | def SetClientLogLevel(self, PythonLogLevel):
92 | """
93 | Set the python log level to the given level
94 |
95 | :param : Log level to set
96 | :return: None
97 | """
98 |
99 | if PythonLogLevel == self.LogLevelsDict["DEBUG"]:
100 | self.logger.setLevel(logging.DEBUG)
101 | elif PythonLogLevel == self.LogLevelsDict["INFO"]:
102 | self.logger.setLevel(logging.INFO)
103 | elif PythonLogLevel == self.LogLevelsDict["WARNING"]:
104 | self.logger.setLevel(logging.WARNING)
105 | elif PythonLogLevel == self.LogLevelsDict["ERROR"]:
106 | self.logger.setLevel(logging.ERROR)
107 | else:
108 | self.logger.setLevel(logging.CRITICAL)
109 | return
110 |
111 | def SetMetalLogLevel(self, MetalLogLevel):
112 | """
113 | Set the metal log level to the given level
114 |
115 | :param : Log level to set
116 | :return: None
117 | """
118 | self.logger.debug(f"SetMetalLogLevel({MetalLogLevel})")
119 | self.CONSOLE.SetMetalLogLevel(MetalLogLevel)
120 | return
121 |
122 | def RaftConsole(self, strCmd):
123 | """
124 | API console command.
125 |
126 | :param : string as a "cat" command argument
127 | :return: outStr output from cat command
128 | """
129 | self.logger.debug(f"execute: " + strCmd)
130 | status, strCmdRet = self.CONSOLE.RaftConsole(strCmd)
131 | self.logger.debug(f"return: ststus: {status}, command output: {strCmdRet}")
132 | return status, strCmdRet
133 |
134 | console = CONSOLE_Client()
135 |
--------------------------------------------------------------------------------
/xclient/raft_services/pm_client.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | __author__ = "Salih Erim"
5 | __copyright__ = "Copyright 2023-2025, Advanced Micro Devices, Inc."
6 |
7 | import Pyro4
8 | import Pyro4.utils
9 | import logging
10 | import base64
11 | import json
12 | import sys
13 |
14 | sys.excepthook = Pyro4.util.excepthook
15 |
16 | class PM_Client(object):
17 | PM = None
18 | logger = None
19 | LogLevelsDict = {
20 | "DEBUG": 4,
21 | "INFO": 3,
22 | "WARNING": 2,
23 | "ERROR": 1,
24 | "CRITICAL": 0
25 | }
26 |
27 | def __init__(self):
28 | self.logger = self.GetLogger()
29 | self.logger.info("Inside Raft-PM Client Constructor")
30 | self.SetIpAndPort("127.0.0.1", "9090")
31 | return
32 |
33 | @staticmethod
34 | def GetLogger():
35 | """
36 | Static method to get the logger for the class.
37 | Default loglevel is set inside this class
38 |
39 | :return: logger
40 | """
41 | log_level = logging.ERROR
42 | logging.basicConfig(format="%(levelname)s:%(message)s")
43 | logger = logging.getLogger(__name__)
44 | try:
45 | handler_set_check = getattr(logger, 'handler_set')
46 | except AttributeError:
47 | handler_set_check = False
48 | if not handler_set_check:
49 | logger.setLevel(log_level)
50 | handler = logging.StreamHandler(sys.stdout)
51 | logger.addHandler(handler)
52 | logger.handler_set = True
53 | logger.disabled = False
54 | return logger
55 |
56 | def SetIpAndPort(self, ipaddr, port):
57 | """
58 | API to inform PM Client the IP address and port number of PM Server.
59 |
60 | :param ipaddr: IP Address string
61 | :param port: Port number string
62 | :return: None
63 | """
64 | uri = f"PYRO:PM@{ipaddr}:{port}"
65 | self.logger.debug(f"SetIpAndPort({ipaddr}, {port})\n uri = {uri}")
66 | self.PM = Pyro4.Proxy(uri)
67 | pass
68 |
69 | def GetPythonLogLevels(self):
70 | """
71 | Return the logging levels supported by logging library in python
72 |
73 | :return: Dictionary showing the log levels supported by logging library
74 | """
75 | self.logger.debug("GetPythonLogLevels()")
76 | PythonLogLevel = self.PM.GetPythonLogLevels()
77 | self.logger.debug(f"PythonLogLevel = {json.dumps(PythonLogLevel, indent=2)}")
78 | return PythonLogLevel
79 |
80 | def SetServerLogLevel(self, PythonLogLevel):
81 | """
82 | Set the python log level to the given level
83 |
84 | :param PythonLogLevel: Log level to set
85 | :return: None
86 | """
87 | self.logger.debug(f"SetServerLogLevel({PythonLogLevel})")
88 | self.PM.SetServerLogLevel(PythonLogLevel)
89 | return
90 |
91 | def SetClientLogLevel(self, PythonLogLevel):
92 | """
93 | Set the python log level to the given level
94 |
95 | :param PythonLogLevel: Log level to set
96 | :return: None
97 | """
98 | if PythonLogLevel == self.LogLevelsDict["DEBUG"]:
99 | self.logger.setLevel(logging.DEBUG)
100 | elif PythonLogLevel == self.LogLevelsDict["INFO"]:
101 | self.logger.setLevel(logging.INFO)
102 | elif PythonLogLevel == self.LogLevelsDict["WARNING"]:
103 | self.logger.setLevel(logging.WARNING)
104 | elif PythonLogLevel == self.LogLevelsDict["ERROR"]:
105 | self.logger.setLevel(logging.ERROR)
106 | else:
107 | self.logger.setLevel(logging.CRITICAL)
108 | return
109 |
110 | def getboardinfo(self):
111 | """
112 | Gets Board's Info
113 |
114 | :param : None
115 | :return: Board Info
116 | """
117 | self.logger.debug("getboardinfo()")
118 | return self.PM.GetBoardInfo()
119 |
120 | def listfeature(self):
121 | """
122 | Gets feature list
123 |
124 | :param : None
125 | :return: Feature List
126 | """
127 | self.logger.debug("listfeature()")
128 | return self.PM.ListFeature()
129 |
130 | def listpowerdomain(self):
131 | """
132 | Gets list of Power Domains.
133 |
134 | :param : None
135 | :return: Domains
136 | """
137 | self.logger.debug("listpowerdomain()")
138 | return self.PM.ListPowerDomains()
139 |
140 | def listrailsofdomain(self, domainname):
141 | """
142 | Gets list of Rails given domain name.
143 |
144 | :param domainname: string of a "domainname"
145 | :return: Rails name list
146 | """
147 | self.logger.debug("listrailsofdomain()")
148 | return self.PM.ListRailsOfDomain(domainname)
149 |
150 | def getvalueofrail(self, railname):
151 | """
152 | Gets list of the rail's sensor values given rail name.
153 |
154 | :param railname: string of a "railname"
155 | :return: Sensor values of the Rail
156 | """
157 | self.logger.debug(f"getvalueofrail({railname})")
158 | return self.PM.GetPowerSensor(railname)
159 |
160 | def getvalueofdomain(self, domainname):
161 | """
162 | Gets the domain's all rail sensor values given domain name.
163 |
164 | :param : string of a "domainname"
165 | :return: The domain's all rails sensor values of the Rail
166 | """
167 | self.logger.debug("getvalueofdomain({domainname})")
168 | return self.PM.GetValueOfDomain(domainname)
169 |
170 | def getpowerall(self):
171 | """
172 | Gets the boards's all domain's and total power values
173 |
174 | :param : None
175 | :return: The boards's all domain's and total power values
176 | """
177 | self.logger.debug("getpowerall()")
178 | return self.PM.GetPowersAll()
179 |
180 | def getvalueall(self):
181 | """
182 | Gets the boards's all domain's rails sensor values
183 |
184 | :param : None
185 | :return: The board's all rails sensor values of the Rail
186 | """
187 | self.logger.debug("getvalueall()")
188 | return self.PM.GetValuesAll()
189 |
190 | def listtemperature(self):
191 | """
192 | Gets the Sysmon temperature values
193 |
194 | :param : None
195 | :return: The sysmon temperature values
196 | """
197 | self.logger.debug("listtemperature()")
198 | return self.PM.ListTemperatures()
199 |
200 | def gettemperature(self, name):
201 | """
202 | Gets the Sysmon temperature values
203 |
204 | :param : None
205 | :return: The sysmon temperature values
206 | """
207 | self.logger.debug("GetSysmonTemperatures()")
208 | return self.PM.GetTemperature(name)
209 |
210 | def listpower(self):
211 | self.logger.debug("ListPowerSensors()")
212 | return self.PM.ListPowerSensors()
213 |
214 | def getpower(self, name):
215 | self.logger.debug("GetPowerSensor()")
216 | return self.PM.GetPowerSensor(name)
217 |
218 | def getcalpower(self, name):
219 | self.logger.debug("GetCalPowerSensor()")
220 | return self.PM.GetCalPowerSensor(name)
221 |
222 | def getpowerconf(self, name):
223 | self.logger.debug("GetPowerSensorConf()")
224 | return self.PM.GetPowerSensorConf(name)
225 |
226 | def setpowerconf(self, name, conf):
227 | self.logger.debug("SetPowerSensorConf()")
228 | return self.PM.SetPowerSensorConf(name, conf)
229 |
230 | def listvoltage(self):
231 | self.logger.debug("ListVoltages()")
232 | return self.PM.ListVoltages()
233 |
234 | def enablevoltage(self, name):
235 | self.logger.debug("EnableVoltage()")
236 | return self.PM.EnableVoltage(name)
237 |
238 | def disablevoltage(self, name):
239 | self.logger.debug("DisableVoltage()")
240 | return self.PM.DisableVoltage(name)
241 |
242 | def getregulator(self, name):
243 | self.logger.debug("GetRegulator()")
244 | return self.PM.GetRegulator(name)
245 |
246 | def getvoltage(self, name):
247 | self.logger.debug("GetVoltage()")
248 | return self.PM.GetVoltage(name)
249 |
250 | def setvoltage(self, name, value):
251 | self.logger.debug("SetVoltage()")
252 | return self.PM.SetVoltage(name, value)
253 |
254 | def setbootvoltage(self, name, value):
255 | """
256 | Set boot voltage for the regulator.
257 |
258 | :name : voltage regulator name
259 | :value : voltage value in volt
260 | :return: Success mesage
261 | """
262 | self.logger.debug("SetBootVoltage()")
263 | return self.PM.SetBootVoltage(name, value)
264 |
265 | def restorevoltage(self, name):
266 | """
267 | Reset to typical voltage.
268 |
269 | :name : voltage output name
270 | :return: Success mesage
271 | """
272 | self.logger.debug("RestoreVoltage()")
273 | return self.PM.RestoreVoltage(name)
274 |
275 | def listunit(self):
276 | self.logger.debug("ListUnits()")
277 | return self.PM.ListUnits()
278 |
279 | def getunit(self, quantity):
280 | self.logger.debug("GetUnit()")
281 | return self.PM.GetUnit(quantity)
282 |
283 | def setscale(self, quantity, scale):
284 | self.logger.debug("SetScale()")
285 | return self.PM.SetScale(quantity, scale)
286 |
287 | def listscale(self, quantity):
288 | self.logger.debug("ListAvailableScales()")
289 | return self.PM.ListAvailableScales(quantity)
290 |
291 | pm = PM_Client()
--------------------------------------------------------------------------------
/xclient/rfdc/rfclk_client.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
2 | # Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All Rights Reserved.
3 | # SPDX-License-Identifier: BSD-3-Clause
4 |
5 | __author__ = "Gerard Thomas Colman"
6 | __copyright__ = "Copyright 2021, Xilinx"
7 |
8 | import Pyro4
9 | import logging
10 | import json
11 | import sys
12 |
13 |
14 | class RFCLK_CLIENT(object):
15 | RFCLK = None
16 | logger = None
17 | LogLevelsDict = {
18 | "DEBUG": 4,
19 | "INFO": 3,
20 | "WARNING": 2,
21 | "ERROR": 1,
22 | "CRITICAL": 0
23 | }
24 |
25 | def __init__(self):
26 | self.logger = self.GetLogger()
27 | self.logger.info("Inside RFCLK Pyro Client Constructor")
28 | return
29 |
30 | @staticmethod
31 | def GetLogger():
32 | """
33 | Static method to get the logger for the class.
34 | Default loglevel is set inside this class
35 |
36 | :return: logger
37 |
38 | """
39 | log_level = logging.ERROR
40 | logging.basicConfig(format="%(levelname)s:%(message)s")
41 | logger = logging.getLogger(__name__)
42 | try:
43 | handler_set_check = getattr(logger, 'handler_set')
44 | except AttributeError:
45 | handler_set_check = False
46 | if not handler_set_check:
47 | logger.setLevel(log_level)
48 | handler = logging.StreamHandler(sys.stdout)
49 | logger.addHandler(handler)
50 | logger.handler_set = True
51 | logger.disabled = False
52 | return logger
53 |
54 | def SetIpAndPort(self, ipaddr, port):
55 | """
56 | API to inform RFCLK Client the IP address and port number of RFCLK Server.
57 |
58 | :param ipaddr: IP Address string
59 | :param port: Port number string
60 | :return: None
61 |
62 | """
63 | uri = f"PYRO:RFCLK@{ipaddr}:{port}"
64 | self.logger.debug(f"SetIpAndPort({ipaddr}, {port})\n uri = {uri}")
65 | self.RFCLK = Pyro4.Proxy(uri)
66 | pass
67 |
68 | def GetPythonLogLevels(self):
69 | """
70 | Return the logging levels supported by logging library in python
71 |
72 | :param : None
73 | :return: Dictionary showing the log levels supported by logging library
74 | """
75 | self.logger.debug("GetPythonLogLevels()")
76 | PythonLogLevel = self.RFCLK.GetPythonLogLevels()
77 | self.logger.debug(f"PythonLogLevel = {json.dumps(PythonLogLevel, indent=2)}")
78 | return PythonLogLevel
79 |
80 | def SetServerLogLevel(self, PythonLogLevel):
81 | """
82 | Set the python log level to the given level
83 |
84 | :param : Log level to set
85 | :return: None
86 | """
87 | self.logger.debug(f"SetServerLogLevel({PythonLogLevel})")
88 | self.RFCLK.SetServerLogLevel(PythonLogLevel)
89 | return
90 |
91 | def SetClientLogLevel(self, PythonLogLevel):
92 | """
93 | Set the python log level to the given level
94 |
95 | :param : Log level to set
96 | :return: None
97 | """
98 |
99 | if PythonLogLevel == self.LogLevelsDict["DEBUG"]:
100 | self.logger.setLevel(logging.DEBUG)
101 | elif PythonLogLevel == self.LogLevelsDict["INFO"]:
102 | self.logger.setLevel(logging.INFO)
103 | elif PythonLogLevel == self.LogLevelsDict["WARNING"]:
104 | self.logger.setLevel(logging.WARNING)
105 | elif PythonLogLevel == self.LogLevelsDict["ERROR"]:
106 | self.logger.setLevel(logging.ERROR)
107 | else:
108 | self.logger.setLevel(logging.CRITICAL)
109 | return
110 |
111 | def SetMetalLogLevel(self, MetalLogLevel):
112 | """
113 | Set the metal log level to the given level
114 |
115 | :param : Log level to set
116 | :return: None
117 | """
118 | self.logger.debug(f"SetMetalLogLevel({MetalLogLevel})")
119 | self.RFCLK.SetMetalLogLevel(MetalLogLevel)
120 | return
121 |
122 | def GetRfclkMacro(self):
123 | """
124 | Return Dictionary with all RFCLK macros in the rfclk header file
125 |
126 | :param : None
127 | :return: Dictionary with all RFCLK macros in the rfclk header file
128 | """
129 | self.logger.debug("GetRfclkMacro()")
130 | rfclk_macro = self.RFCLK.GetRfclkMacro()
131 | self.logger.debug(f"rfclk_macro = {json.dumps(rfclk_macro, indent=2)}")
132 | return rfclk_macro
133 |
134 | def GetEnum_metal_log_level(self):
135 | """
136 | Return Dictionary equivalent of enum metal_log_level
137 |
138 | :param : None
139 | :return: Dictionary equivalent of enum metal_log_level
140 | """
141 | self.logger.debug("GetEnum_metal_log_level()")
142 | metal_log_level = self.RFCLK.GetEnum_metal_log_level()
143 | self.logger.debug(f"metal_log_level = {json.dumps(metal_log_level, indent=2)}")
144 | return metal_log_level
145 |
146 | def XRFClk_Init(self, GpioId):
147 | self.logger.debug(f"XRFClk_Init({GpioId})")
148 | ret = self.RFCLK.XRFClk_Init(GpioId)
149 | self.logger.debug(f"ret = {ret}")
150 | return ret
151 |
152 | def XRFClk_ResetChip(self, ChipId):
153 | self.logger.debug(f"XRFClk_ResetChip({ChipId})")
154 | ret = self.RFCLK.XRFClk_ResetChip(ChipId)
155 | self.logger.debug(f"ret = {ret}")
156 | return ret
157 |
158 | def XRFClk_SetConfigOnOneChipFromConfigId(self, ChipId, ConfigId):
159 | self.logger.debug(f"XRFClk_SetConfigOnOneChipFromConfigId({ChipId}, {ConfigId})")
160 | ret = self.RFCLK.XRFClk_SetConfigOnOneChipFromConfigId(ChipId, ConfigId)
161 | self.logger.debug(f"ret = {ret}")
162 | return ret
163 |
164 | def XRFClk_GetConfigFromOneChip(self, ChipId):
165 | self.logger.debug(f"XRFClk_GetConfigFromOneChip({ChipId})")
166 | CfgData = self.RFCLK.XRFClk_GetConfigFromOneChip(ChipId)
167 | self.logger.debug(f"CfgData = {CfgData}")
168 | return CfgData
169 |
170 | def XRFClk_SetConfigOnAllChipsFromConfigId(self, ConfigId_LMK, ConfigId_1, ConfigId_2):
171 | self.logger.debug(f"XRFClk_SetConfigOnAllChipsFromConfigId({ConfigId_LMK}, {ConfigId_1}, {ConfigId_2})")
172 | ret = self.RFCLK.XRFClk_SetConfigOnAllChipsFromConfigId(ConfigId_LMK, ConfigId_1, ConfigId_2)
173 | self.logger.debug(f"ret = {ret}")
174 | return ret
175 |
176 | def XRFClk_WriteReg(self, ChipId, Data):
177 | self.logger.debug(f"XRFClk_WriteReg({ChipId}, {Data})")
178 | ret = self.RFCLK.XRFClk_WriteReg(ChipId, Data)
179 | self.logger.debug(f"ret = {ret}")
180 | return ret
181 |
182 | def XRFClk_ReadReg(self, ChipId):
183 | self.logger.debug(f"XRFClk_ReadReg({ChipId})")
184 | DataVal = self.RFCLK.XRFClk_ReadReg(ChipId)
185 | self.logger.debug(f"DataVal = {DataVal}")
186 | return DataVal
187 |
188 | def __del__(self):
189 | self.logger.info("Inside RFCLK Destructor")
190 |
191 | rfclk = RFCLK_CLIENT()
192 |
--------------------------------------------------------------------------------
/xserver/init/startup/raftjupyter-startup/raft-startup:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # APP Start-Up Script
4 | #
5 | # Applications inteded to start with RAFT can be initialized here
6 | #
7 |
8 | start ()
9 | {
10 | sudo ifconfig -a | grep eth0
11 | RESULT=$?
12 | if [ $RESULT -eq 0 ]; then
13 | sudo ifconfig eth0 169.254.10.2 up
14 | sudo ifconfig -a | grep lo
15 | if [ $RESULT -eq 0 ]; then
16 | cd /usr/share/raft/xserver/init/xpyro-prj2/
17 | /usr/bin/python3 __init__.py 127.0.0.1 &
18 | cd /usr/share/notebooks/
19 | jupyter nbextension enable --py widgetsnbextension
20 | #jupyter nbextension enable --py --sys-prefix bqplot
21 | export PYTHONPATH=.:/usr/share/raft/xclient/pat:$PYTHONPATH
22 | echo "c.NotebookApp.token = ''" >> /etc/jupyter/jupyter_notebook_config.py
23 | echo "c.NotebookApp.password = ''" >> /etc/jupyter/jupyter_notebook_config.py
24 | echo "c.NotebookApp.disable_check_xsrf = True" >> /etc/jupyter/jupyter_notebook_config.py
25 | jupyter notebook --ip=0.0.0.0 --no-browser --notebook-dir=/usr/share/notebooks --allow-root
26 | fi
27 | fi
28 |
29 | }
30 |
31 | stop ()
32 | {
33 | echo "Stopping Applications"
34 | }
35 |
36 | restart()
37 | {
38 | stop
39 | start
40 | }
41 |
42 |
43 | case "$1" in
44 | start)
45 | start; ;;
46 | stop)
47 | stop; ;;
48 | restart)
49 | restart; ;;
50 | *)
51 | echo "Usage: $0 {start|stop|restart}"
52 | exit 1
53 | esac
54 |
55 | exit $?
56 |
57 |
--------------------------------------------------------------------------------
/xserver/init/startup/raftjupyter-startup/raft-startup.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=raft-startup
3 |
4 | [Service]
5 | Type=oneshot
6 | StandardOutput=journal+console
7 | ExecStart=/usr/bin/raft-startup start
8 | RemainAfterExit=yes
9 |
10 | [Install]
11 | WantedBy=multi-user.target
12 |
--------------------------------------------------------------------------------
/xserver/init/startup/system-controller/raft-startup:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | cd /usr/share/raft/xserver/init/xpyro-prj6/
4 | python3 __init__.py 0.0.0.0 9090
5 |
--------------------------------------------------------------------------------
/xserver/init/startup/system-controller/raft-startup.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=raft-startup
3 | After=systemd-networkd.service
4 | Requires=systemd-networkd.service
5 | StartLimitBurst=3
6 | StartLimitIntervalSec=infinity
7 |
8 | [Service]
9 | ExecStartPre=/bin/sleep 3
10 | ExecStart=/usr/bin/raft-startup
11 | StandardOutput=journal+console
12 | Restart=always
13 | RestartSec=3
14 |
15 | [Install]
16 | WantedBy=multi-user.target
17 |
--------------------------------------------------------------------------------
/xserver/init/xpyro-prj1/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
2 | # Copyright (C) 2022-2023 Advanced Micro Devices, Inc. All Rights Reserved.
3 | # SPDX-License-Identifier: BSD-3-Clause
4 |
5 | __author__ = "Anish Kadamathikuttiyil Karthikeyan Pillai"
6 | __copyright__ = "Copyright 2021, Xilinx"
7 |
8 | import sys
9 | sys.path.append('../../utils')
10 | sys.path.append('../../xcffi/drv_api/dfe')
11 | sys.path.append('../../xcffi/drv_api/rfdc')
12 | sys.path.append('../../xcffi/drv_api/data_stream/data_transfer_no_dma')
13 | sys.path.append('../../xpyro/data_stream/data_transfer_no_dma')
14 | import Pyro4
15 | from rfdc_server import RFDC
16 | from rfclk_server import RFCLK
17 | from mix_server import MIX
18 | from ccf_server import CCF
19 | from equ_server import EQU
20 | from prach_server import PRACH
21 | from ofdm_server import OFDM
22 | from axi_memmap import AXI_MEMMAP
23 | from utils import get_ip_and_port
24 |
25 | IPADDR, PORT = get_ip_and_port()
26 | if len(IPADDR) == 0:
27 | print("RAFT ERROR: Unable to Run Pyro Server.\n"
28 | "No network interface present.\n"
29 | "Please pass the ipaddress to __init__.py and retry.\n"
30 | "Usage:python3 __init__.py \n")
31 | sys.exit()
32 | else:
33 | print("RAFT Pyro Server run successfully\n")
34 |
35 | RFDC = Pyro4.expose(RFDC)
36 | RFCLK = Pyro4.expose(RFCLK)
37 | MIX = Pyro4.expose(MIX)
38 | CCF = Pyro4.expose(CCF)
39 | EQU = Pyro4.expose(EQU)
40 | PRACH = Pyro4.expose(PRACH)
41 | OFDM = Pyro4.expose(OFDM)
42 | AXI_MEMMAP = Pyro4.expose(AXI_MEMMAP)
43 |
44 | Pyro4.Daemon.serveSimple(
45 | {
46 | RFDC: "RFDC",
47 | RFCLK: "RFCLK",
48 | MIX: "MIX",
49 | CCF: "CCF",
50 | EQU: "EQU",
51 | PRACH: "PRACH",
52 | OFDM: "OFDM",
53 | AXI_MEMMAP: "AXI_MEMMAP",
54 | },
55 | host=IPADDR,
56 | port=PORT,
57 | ns=False,
58 | verbose=True,
59 | )
60 |
--------------------------------------------------------------------------------
/xserver/init/xpyro-prj2/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
2 | # Copyright (C) 2022-2023 Advanced Micro Devices, Inc. All Rights Reserved.
3 | # SPDX-License-Identifier: BSD-3-Clause
4 |
5 | __author__ = "Anish Kadamathikuttiyil Karthikeyan Pillai"
6 | __copyright__ = "Copyright 2021, Xilinx"
7 |
8 | import sys
9 | sys.path.append('../../utils')
10 | sys.path.append('../../xcffi/drv_api/rfdc')
11 | sys.path.append('../../xcffi/drv_api/data_stream/data_transfer_no_dma')
12 | sys.path.append('../../xpyro/data_stream/data_transfer_no_dma')
13 | sys.path.append('../../xcffi/drv_api/pat')
14 | import Pyro4
15 | from rfdc_server import RFDC
16 | from rfclk_server import RFCLK
17 | from axi_memmap import AXI_MEMMAP
18 | from i2c_server import I2C
19 | from sysmon_server import SYSMON
20 | from utils import get_ip_and_port
21 |
22 | IPADDR, PORT = get_ip_and_port()
23 | if len(IPADDR) == 0:
24 | print("RAFT ERROR: Unable to Run Pyro Server.\n"
25 | "No network interface present.\n"
26 | "Please pass the ipaddress to __init__.py and retry.\n"
27 | "Usage:python3 __init__.py \n")
28 | sys.exit()
29 | else:
30 | print("RAFT Pyro Server run successfully\n")
31 |
32 | RFDC = Pyro4.expose(RFDC)
33 | RFCLK = Pyro4.expose(RFCLK)
34 | AXI_MEMMAP = Pyro4.expose(AXI_MEMMAP)
35 | SYSMON = Pyro4.expose(SYSMON)
36 | I2C = Pyro4.expose(I2C)
37 |
38 | Pyro4.Daemon.serveSimple(
39 | {
40 | RFDC: "RFDC",
41 | RFCLK: "RFCLK",
42 | AXI_MEMMAP: "AXI_MEMMAP",
43 | SYSMON: "SYSMON",
44 | I2C: "I2C"
45 | },
46 | host=IPADDR,
47 | port=PORT,
48 | ns=False,
49 | verbose=True,
50 | )
51 |
--------------------------------------------------------------------------------
/xserver/init/xpyro-prj3/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
2 | # Copyright (C) 2022-2023 Advanced Micro Devices, Inc. All Rights Reserved.
3 | # SPDX-License-Identifier: BSD-3-Clause
4 |
5 | __author__ = "Hugh Maguire"
6 | __copyright__ = "Copyright 2021, Xilinx"
7 |
8 | import sys
9 | sys.path.append('../../utils')
10 | sys.path.append('../../xcffi/drv_api/rfdc')
11 | import Pyro4
12 | from rfdc_server import RFDC
13 | from utils import get_ip_and_port
14 |
15 | IPADDR, PORT = get_ip_and_port()
16 | if len(IPADDR) == 0:
17 | print("RAFT ERROR: Unable to Run Pyro Server.\n"
18 | "No network interface present.\n"
19 | "Please pass the ipaddress to __init__.py and retry.\n"
20 | "Usage:python3 __init__.py \n")
21 | sys.exit()
22 | else:
23 | print("RAFT Pyro Server run successfully\n")
24 |
25 | RFDC = Pyro4.expose(RFDC)
26 |
27 | Pyro4.Daemon.serveSimple(
28 | {
29 | RFDC: "RFDC"
30 | },
31 | host=IPADDR,
32 | port=PORT,
33 | ns=False,
34 | verbose=True,
35 | )
36 |
--------------------------------------------------------------------------------
/xserver/init/xpyro-prj4/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
2 | # Copyright (C) 2022-2023 Advanced Micro Devices, Inc. All Rights Reserved.
3 | # SPDX-License-Identifier: BSD-3-Clause
4 |
5 | __author__ = "Anish Kadamathikuttiyil Karthikeyan Pillai"
6 | __copyright__ = "Copyright 2021, Xilinx"
7 |
8 | import sys
9 | sys.path.append('../../utils')
10 | sys.path.append('../../xcffi/drv_api/dfe')
11 | sys.path.append('../../xcffi/drv_api/rfdc')
12 | sys.path.append('../../xcffi/drv_api/data_stream/data_transfer_no_dma')
13 | sys.path.append('../../xpyro/data_stream/data_transfer_no_dma')
14 | import Pyro4
15 | from rfdc_server import RFDC
16 | from rfclk_server import RFCLK
17 | from mix_server import MIX
18 | from ccf_server import CCF
19 | from equ_server import EQU
20 | from prach_server import PRACH
21 | from axi_memmap import AXI_MEMMAP
22 | from utils import get_ip_and_port
23 |
24 | IPADDR, PORT = get_ip_and_port()
25 | if len(IPADDR) == 0:
26 | print("RAFT ERROR: Unable to Run Pyro Server.\n"
27 | "No network interface present.\n"
28 | "Please pass the ipaddress to __init__.py and retry.\n"
29 | "Usage:python3 __init__.py \n")
30 | sys.exit()
31 | else:
32 | print("RAFT Pyro Server run successfully\n")
33 |
34 | RFDC = Pyro4.expose(RFDC)
35 | RFCLK = Pyro4.expose(RFCLK)
36 | MIX = Pyro4.expose(MIX)
37 | CCF = Pyro4.expose(CCF)
38 | EQU = Pyro4.expose(EQU)
39 | PRACH = Pyro4.expose(PRACH)
40 | AXI_MEMMAP = Pyro4.expose(AXI_MEMMAP)
41 |
42 | Pyro4.Daemon.serveSimple(
43 | {
44 | RFDC: "RFDC",
45 | RFCLK: "RFCLK",
46 | MIX: "MIX",
47 | CCF: "CCF",
48 | EQU: "EQU",
49 | PRACH: "PRACH",
50 | AXI_MEMMAP: "AXI_MEMMAP",
51 | },
52 | host=IPADDR,
53 | port=PORT,
54 | ns=False,
55 | verbose=True,
56 | )
57 |
--------------------------------------------------------------------------------
/xserver/init/xpyro-prj5/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
2 | # Copyright (C) 2022-2023 Advanced Micro Devices, Inc. All Rights Reserved.
3 | # SPDX-License-Identifier: BSD-3-Clause
4 |
5 | __author__ = "Dragan Cvetic"
6 | __copyright__ = "Copyright 2022, Xilinx"
7 |
8 | import sys
9 | sys.path.append('../../utils')
10 | sys.path.append('../../raft_services')
11 | import Pyro4
12 | from console_server import CONSOLE
13 | from utils import get_ip_and_port
14 |
15 | IPADDR, PORT = get_ip_and_port()
16 | if len(IPADDR) == 0:
17 | print("RAFT ERROR: Unable to Run Pyro Server.\n"
18 | "No network interface present.\n"
19 | "Please pass the ipaddress to __init__.py and retry.\n"
20 | "Usage:python3 __init__.py \n")
21 | sys.exit()
22 | else:
23 | print("RAFT Pyro Server run successfully\n")
24 |
25 | CONSOLE = Pyro4.expose(CONSOLE)
26 |
27 | Pyro4.Daemon.serveSimple(
28 | {
29 | CONSOLE: "CONSOLE",
30 | },
31 | host=IPADDR,
32 | port=PORT,
33 | ns=False,
34 | verbose=True,
35 | )
36 |
--------------------------------------------------------------------------------
/xserver/init/xpyro-prj6/__init__.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | __author__ = "Salih Erim"
5 | __copyright__ = "Copyright 2023-2025, Advanced Micro Devices, Inc."
6 |
7 | import os
8 | import sys
9 | import json
10 | import logging
11 | sys.path.append('../../utils')
12 | sys.path.append('../../raft_services')
13 | sys.path.append('../../raft_services/power_management')
14 | import Pyro4
15 | from periphery import I2C
16 | from pm import PM
17 | from utils import get_ip_and_port
18 |
19 | RAFT_DIR = '/usr/share/raft/'
20 |
21 | logging.basicConfig(level=logging.ERROR)
22 |
23 | IPADDR, PORT = get_ip_and_port()
24 | if len(IPADDR) == 0:
25 | print("CRITITCAL ERROR: Unable to Run Pyro Server.\n"
26 | "No eth0 network interface present.\n"
27 | "Please pass the ipaddress to __init__.py and retry.\n"
28 | "Usage:python3 __init__.py \n")
29 | sys.exit(1)
30 | else:
31 | print("RAFT Pyro Server run successfully\n")
32 |
33 | def exit_program():
34 | logging.error("CRITICAL ERROR: Unable to Run Raft-PM Server.")
35 | sys.exit(1)
36 |
37 | def is_valid_json_file(file_path):
38 | if not os.path.isfile(file_path):
39 | logging.error("ERROR:root:Board Identification Json is not in Path : {file_path}")
40 | return False
41 | try:
42 | with open(file_path, 'r') as file:
43 | data = json.load(file)
44 | return True
45 | except json.JSONDecodeError:
46 | logging.error("ERROR:root:{file} Board Identification is not a JSON")
47 | return False
48 |
49 | class board_eeprom:
50 | Name = ""
51 | I2C_Bus = ""
52 | I2C_Addr = ""
53 |
54 | onboard = board_eeprom()
55 |
56 | def parse_json_file(json_file):
57 | with open(json_file, 'r') as f:
58 | json_data = json.load(f)
59 | #print(json.dumps(json_data, indent=2))
60 | return json_data
61 |
62 | def find_i2c_device_by_name(target_name):
63 | sys_i2c_path = "/sys/bus/i2c/devices/"
64 |
65 | for device in os.listdir(sys_i2c_path):
66 | name_path = os.path.join(sys_i2c_path, device, "name")
67 |
68 | if os.path.isfile(name_path):
69 | try:
70 | with open(name_path, "r") as f:
71 | device_name = f.read().strip()
72 |
73 | if device_name == target_name:
74 | bus_number, address = device.split("-")
75 | bus_number = bus_number.replace("i2c", "")
76 | dev_path = f"/dev/i2c-{bus_number}"
77 | logging.debug(f"Found {target_name} at {dev_path}, address 0x{address}")
78 | return dev_path, int(address, 16)
79 | except IOError:
80 | continue
81 |
82 | logging.debug(f"Device {target_name} not found")
83 | return None, None
84 |
85 | def get_eeprom_data():
86 | result = False
87 | i2c = None
88 | onboard.Name = "Common"
89 | onboard.I2C_Bus = "/dev/i2c-1"
90 | onboard.I2C_Addr = 0x54
91 | data = bytearray(256)
92 | try:
93 | i2c = I2C(onboard.I2C_Bus)
94 | msgs = [I2C.Message([0x0, 0x0]), I2C.Message(data, read=True)]
95 | i2c.transfer(onboard.I2C_Addr, msgs)
96 | eeprom_data = msgs[1].data
97 | result = True
98 | i2c.close()
99 | except:
100 | logging.debug(f"Onboard {onboard.Name} Eeprom read failed!")
101 |
102 | if result is False:
103 | onboard.Name = "Legacy"
104 | onboard.I2C_Bus = "/dev/i2c-11"
105 | onboard.I2C_Addr = 0x54
106 | data = bytearray(256)
107 | try:
108 | i2c = I2C(onboard.I2C_Bus)
109 | msgs = [I2C.Message([0x0, 0x0]), I2C.Message(data, read=True)]
110 | i2c.transfer(onboard.I2C_Addr, msgs)
111 | eeprom_data = msgs[1].data
112 | result = True
113 | i2c.close()
114 | except:
115 | logging.debug(f"Onboard {onboard.Name} Eeprom read failed!")
116 |
117 | if result is False:
118 | device_path, device_address = find_i2c_device_by_name("24c128")
119 | if device_path is not None:
120 | onboard.Name = "Custom"
121 | onboard.I2C_Bus = device_path
122 | onboard.I2C_Addr = device_address
123 | data = bytearray(256)
124 | try:
125 | i2c = I2C(onboard.I2C_Bus)
126 | msgs = [I2C.Message([0x0, 0x0]), I2C.Message(data, read=True)]
127 | i2c.transfer(onboard.I2C_Addr, msgs)
128 | eeprom_data = msgs[1].data
129 | result = True
130 | i2c.close()
131 | except:
132 | logging.debug(f"Onboard {onboard.Name} Eeprom read failed!")
133 |
134 | if result is False:
135 | logging.error("Board Eeprom Identification Failed.")
136 | exit_program()
137 |
138 | return eeprom_data
139 |
140 | def get_product_name():
141 | eeprom_data = get_eeprom_data()
142 | offset = 0x15
143 | length = int.from_bytes(eeprom_data[offset:offset+1], "big") & 0x3f
144 | name = eeprom_data[offset+1:(offset+1 + length)].decode("utf-8").strip('\x00')
145 | return name
146 |
147 | json_file = os.path.join(RAFT_DIR, 'xserver/raft_services/power_management/board', '.'.join((get_product_name(), 'json')))
148 |
149 | if is_valid_json_file(json_file):
150 | json_data = parse_json_file(json_file)
151 | board_name = os.path.splitext(os.path.basename(json_file))
152 | else:
153 | exit_program()
154 |
155 | PM = Pyro4.expose(PM)
156 |
157 | Pyro4.Daemon.serveSimple(
158 | {
159 | PM(json_data, board_name[0], onboard): "PM",
160 | },
161 | host=IPADDR,
162 | port=PORT,
163 | ns=False,
164 | verbose=True,
165 | )
166 |
--------------------------------------------------------------------------------
/xserver/raft_services/console_server.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | __author__ = "Dragan Cvetic"
5 | __copyright__ = "Copyright 2022, Xilinx"
6 |
7 | import sys
8 | import subprocess
9 | RAFT_DIR = '/usr/share/raft/'
10 | sys.path.append(RAFT_DIR + 'xserver/utils')
11 | import logging
12 | from utils import xhelper_handle
13 | from utils import get_python_log_levels
14 |
15 |
16 | class CONSOLE(object):
17 | device_id = 0
18 | logger = None
19 |
20 | def __init__(self):
21 | self.logger = self.GetLogger()
22 | ret = xhelper_handle.XHelper_MetalInit(xhelper_handle.METAL_LOG_ERROR)
23 | if 0 != ret:
24 | self.logger.error(f"CONSOLE: XHelper_MetalInit failed. ret = {ret}")
25 | self.logger.info("Inside CONSOLE Constructor")
26 | pass
27 |
28 | @staticmethod
29 | def GetLogger():
30 | """
31 | Static method to get the logger for the class.
32 | Default loglevel is set inside this class
33 |
34 | :return: logger
35 |
36 | """
37 | log_level = logging.ERROR
38 | logging.basicConfig(format="%(levelname)s:%(message)s")
39 | logger = logging.getLogger(__name__)
40 | try:
41 | handler_set_check = getattr(logger, 'handler_set')
42 | except AttributeError:
43 | handler_set_check = False
44 | if not handler_set_check:
45 | logger.setLevel(log_level)
46 | logger.handler_set = True
47 | logger.disabled = False
48 | return logger
49 |
50 | # Log level
51 | def GetPythonLogLevels(self):
52 | """
53 | Return the logging levels supported by logging library in python
54 |
55 | :param : None
56 | :return: Dictionary showing the log levels supported by logging library
57 | """
58 | return get_python_log_levels()
59 |
60 | def SetServerLogLevel(self, PythonLogLevel):
61 | """
62 | Set the python log level to the given level
63 |
64 | :param : Log level to set
65 | :return: None
66 | """
67 | self.logger.debug(f"PythonLogLevel = {PythonLogLevel}")
68 | LogLevelsDict = get_python_log_levels()
69 | if PythonLogLevel == LogLevelsDict["DEBUG"]:
70 | self.logger.setLevel(logging.DEBUG)
71 | elif PythonLogLevel == LogLevelsDict["INFO"]:
72 | self.logger.setLevel(logging.INFO)
73 | elif PythonLogLevel == LogLevelsDict["WARNING"]:
74 | self.logger.setLevel(logging.WARNING)
75 | elif PythonLogLevel == LogLevelsDict["ERROR"]:
76 | self.logger.setLevel(logging.ERROR)
77 | else:
78 | self.logger.setLevel(logging.CRITICAL)
79 | return
80 |
81 | def RaftConsole(self, str_cmd):
82 | """
83 | API console command.
84 |
85 | :param : string as a "cat" command argument
86 | :return: outStr output from cat command
87 | """
88 | self.logger.debug(f"execute: " + str_cmd)
89 | ret = subprocess.getstatusoutput(str_cmd)
90 | status = ret[0]
91 | str_cmd_ret = ret[1]
92 | self.logger.debug(f"return: status: {status}, command output: {str_cmd_ret}")
93 | return status, str_cmd_ret
94 |
95 | def __del__(self):
96 | self.logger.info("Inside CONSOLE Destructor")
97 |
--------------------------------------------------------------------------------
/xserver/raft_services/power_management/board/VE-X-A2112-00.json:
--------------------------------------------------------------------------------
1 | {
2 | "License" : "Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved. SPDX-License-Identifier: MIT",
3 |
4 | "VE-X-A2112-00" : {
5 | "FEATURE" : {
6 | "List" : ["voltage", "temp", "power", "powerdomain"]
7 | },
8 | "POWER_SENSORS" : {
9 | "VR_LPD_0V8" : {
10 | "Name" : "VR_LPD_0V8",
11 | "Part_Name" : "INA226",
12 | "I2C_Bus" : "/dev/i2c-0",
13 | "I2C_Address" : "0x40",
14 | "Shunt_Resistor" : 1000,
15 | "Maximum_Current" : 5000,
16 | "Phase_Multiplier" : 1
17 | },
18 | "VCC_FPD" : {
19 | "Name" : "VCC_FPD",
20 | "Part_Name" : "INA226",
21 | "I2C_Bus" : "/dev/i2c-0",
22 | "I2C_Address" : "0x41",
23 | "Shunt_Resistor" : 1000,
24 | "Maximum_Current" : 25000,
25 | "Phase_Multiplier" : 1
26 | }
27 | },
28 | "POWER DOMAIN" : {
29 | "PD_FPD" : {
30 | "Name" : "FPD",
31 | "Rails" : ["VCC_FPD"]
32 | },
33 | "PD_LPD" : {
34 | "Name" : "LPD",
35 | "Rails" : ["VR_LPD_0V8"]
36 | }
37 | },
38 | "VOLTAGE" : {
39 | "VCCINT" : {
40 | "Name" : "VCCINT",
41 | "Part_Name" : "TPS53681",
42 | "Maximum_Volt" : 0.88,
43 | "Typical_Volt" : 0.8,
44 | "Minimum_Volt" : 0.72,
45 | "I2C_Bus" : "/dev/i2c-0",
46 | "I2C_Address" : "0x60",
47 | "PMBus_VOUT_MODE" : 1,
48 | "Page_Select" : 0.0,
49 | "Phase" : 4
50 | },
51 | "VCC_FPD" : {
52 | "Name" : "VCC_FPD",
53 | "Part_Name" : "TPS53681",
54 | "Maximum_Volt" : 0.88,
55 | "Typical_Volt" : 0.8,
56 | "Minimum_Volt" : 0.72,
57 | "I2C_Bus" : "/dev/i2c-0",
58 | "I2C_Address" : "0x60",
59 | "PMBus_VOUT_MODE" : 1,
60 | "Page_Select" : 1
61 | },
62 | "VCC_AIE" : {
63 | "Name" : "VCC_AIE",
64 | "Part_Name" : "TPS53681",
65 | "Maximum_Volt" : 0.88,
66 | "Typical_Volt" : 0.8,
67 | "Minimum_Volt" : 0.72,
68 | "I2C_Bus" : "/dev/i2c-0",
69 | "I2C_Address" : "0x61",
70 | "PMBus_VOUT_MODE" : 1,
71 | "Page_Select" : 0
72 | },
73 | "VCC_IO_SOC" : {
74 | "Name" : "VCC_IO_SOC",
75 | "Part_Name" : "TPS53681",
76 | "Maximum_Volt" : 0.88,
77 | "Typical_Volt" : 0.8,
78 | "Minimum_Volt" : 0.72,
79 | "I2C_Bus" : "/dev/i2c-0",
80 | "I2C_Address" : "0x61",
81 | "PMBus_VOUT_MODE" : 1,
82 | "Page_Select" : 1
83 | },
84 | "VR_RAM_0V8" : {
85 | "Name" : "VR_RAM_0V8",
86 | "Part_Name" : "TPS546B24A",
87 | "Maximum_Volt" : 0.88,
88 | "Typical_Volt" : 0.8,
89 | "Minimum_Volt" : 0.72,
90 | "I2C_Bus" : "/dev/i2c-0",
91 | "I2C_Address" : "0x19",
92 | "PMBus_VOUT_MODE" : 1,
93 | "Page_Select" : -1
94 | },
95 | "VR_MIO_1V8" : {
96 | "Name" : "VR_MIO_1V8",
97 | "Part_Name" : "TPS546B24A",
98 | "Maximum_Volt" : 1.98,
99 | "Typical_Volt" : 1.8,
100 | "Minimum_Volt" : 1.62,
101 | "I2C_Bus" : "/dev/i2c-0",
102 | "I2C_Address" : "0x1D",
103 | "PMBus_VOUT_MODE" : 1,
104 | "Page_Select" : -1
105 | },
106 | "VR_LPD_0V8": {
107 | "Name" : "VR_LPD_0V8",
108 | "Part_Name" : "TPS546B24A",
109 | "Maximum_Volt" : 0.88,
110 | "Typical_Volt" : 0.8,
111 | "Minimum_Volt" : 0.72,
112 | "I2C_Bus" : "/dev/i2c-0",
113 | "I2C_Address" : "0x10",
114 | "PMBus_VOUT_MODE" : 1,
115 | "Page_Select" : -1
116 | },
117 | "VR_AUX_LPD_1V5" : {
118 | "Name" : "VR_AUX_LPD_1V5",
119 | "Part_Name" : "TPS546B24A",
120 | "Maximum_Volt" : 1.65,
121 | "Typical_Volt" : 1.5,
122 | "Minimum_Volt" : 1.35,
123 | "I2C_Bus" : "/dev/i2c-0",
124 | "I2C_Address" : "0x13",
125 | "PMBus_VOUT_MODE" : 1,
126 | "Page_Select" : -1
127 | },
128 | "VR_MIPI_1V2" : {
129 | "Name" : "VR_MIPI_1V2",
130 | "Part_Name" : "TPS546B24A",
131 | "Maximum_Volt" : 1.32,
132 | "Typical_Volt" : 1.2,
133 | "Minimum_Volt" : 1.08,
134 | "I2C_Bus" : "/dev/i2c-0",
135 | "I2C_Address" : "0x1F",
136 | "PMBus_VOUT_MODE" : 1,
137 | "Page_Select" : -1
138 | },
139 | "VR_VCC_USB2_0V8" : {
140 | "Name" : "VR_VCC_USB2_0V8",
141 | "Part_Name" : "TPS546B24A",
142 | "Maximum_Volt" : 0.88,
143 | "Typical_Volt" : 0.8,
144 | "Minimum_Volt" : 0.72,
145 | "I2C_Bus" : "/dev/i2c-0",
146 | "I2C_Address" : "0x24",
147 | "PMBus_VOUT_MODE" : 1,
148 | "Page_Select" : -1
149 | },
150 | "VR_VCC_PAUX_USB3_0V8" : {
151 | "Name" : "VR_VCC_PAUX_USB3_0V8",
152 | "Part_Name" : "TPS546B24A",
153 | "Maximum_Volt" : 0.88,
154 | "Typical_Volt" : 0.8,
155 | "Minimum_Volt" : 0.72,
156 | "I2C_Bus" : "/dev/i2c-0",
157 | "I2C_Address" : "0x25",
158 | "PMBus_VOUT_MODE" : 1,
159 | "Page_Select" : -1
160 | },
161 | "VR_VCCIO_REG_USB2_3V3" : {
162 | "Name" : "VR_VCCIO_REG_USB2_3V3",
163 | "Part_Name" : "TPS546B24A",
164 | "Maximum_Volt" : 3.6,
165 | "Typical_Volt" : 3.3,
166 | "Minimum_Volt" : 3,
167 | "I2C_Bus" : "/dev/i2c-0",
168 | "I2C_Address" : "0x26",
169 | "PMBus_VOUT_MODE" : 1,
170 | "Page_Select" : -1
171 | },
172 | "VR_VCCIO_PAUX_1V8" : {
173 | "Name" : "VR_VCCIO_PAUX_1V8",
174 | "Part_Name" : "TPS546B24A",
175 | "Maximum_Volt" : 1.98,
176 | "Typical_Volt" : 1.8,
177 | "Minimum_Volt" : 1.62,
178 | "I2C_Bus" : "/dev/i2c-0",
179 | "I2C_Address" : "0x27",
180 | "PMBus_VOUT_MODE" : 1,
181 | "Page_Select" : -1
182 | },
183 | "VR_UTIL_1V8" : {
184 | "Name" : "VR_UTIL_1V8",
185 | "Part_Name" : "TPS546B24A",
186 | "Maximum_Volt" : 1.98,
187 | "Typical_Volt" : 1.8,
188 | "Minimum_Volt" : 1.62,
189 | "I2C_Bus" : "/dev/i2c-0",
190 | "I2C_Address" : "0x11",
191 | "PMBus_VOUT_MODE" : 1,
192 | "Page_Select" : -1
193 | },
194 | "VR_UTIL_3V3" : {
195 | "Name" : "VR_UTIL_3V3",
196 | "Part_Name" : "TPS546B24A",
197 | "Maximum_Volt" : 3.6,
198 | "Typical_Volt" : 3.3,
199 | "Minimum_Volt" : 3,
200 | "I2C_Bus" : "/dev/i2c-0",
201 | "I2C_Address" : "0x17",
202 | "PMBus_VOUT_MODE" : 1,
203 | "Page_Select" : -1
204 | },
205 | "VR_VCCIO_USB3_1V2" : {
206 | "Name" : "VR_VCCIO_USB3_1V2",
207 | "Part_Name" : "TPS546B24A",
208 | "Maximum_Volt" : 1.32,
209 | "Typical_Volt" : 1.2,
210 | "Minimum_Volt" : 1,
211 | "I2C_Bus" : "/dev/i2c-0",
212 | "I2C_Address" : "0x14",
213 | "PMBus_VOUT_MODE" : 1,
214 | "Page_Select" : -1
215 | },
216 | "VR_AUX_1V5" : {
217 | "Name" : "VR_AUX_1V5",
218 | "Part_Name" : "TPS546B24A",
219 | "Maximum_Volt" : 1.65,
220 | "Typical_Volt" : 1.5,
221 | "Minimum_Volt" : 1.35,
222 | "I2C_Bus" : "/dev/i2c-0",
223 | "I2C_Address" : "0x15",
224 | "PMBus_VOUT_MODE" : 1,
225 | "Page_Select" : -1
226 | },
227 | "VR_MMD_0V8" : {
228 | "Name" : "VR_MMD_0V8",
229 | "Part_Name" : "TPS546B24A",
230 | "Maximum_Volt" : 0.88,
231 | "Typical_Volt" : 0.8,
232 | "Minimum_Volt" : 0.72,
233 | "I2C_Bus" : "/dev/i2c-0",
234 | "I2C_Address" : "0x18",
235 | "PMBus_VOUT_MODE" : 1,
236 | "Page_Select" : -1
237 | },
238 | "VR_LP5_1V0" : {
239 | "Name" : "VR_LP5_1V0",
240 | "Part_Name" : "TPS546B24A",
241 | "Maximum_Volt" : 1.1,
242 | "Typical_Volt" : 1.0,
243 | "Minimum_Volt" : 0.9,
244 | "I2C_Bus" : "/dev/i2c-0",
245 | "I2C_Address" : "0x20",
246 | "PMBus_VOUT_MODE" : 1,
247 | "Page_Select" : -1
248 | },
249 | "VR_LP5_VDD2_1V05" : {
250 | "Name" : "VR_LP5_VDD2_1V05",
251 | "Part_Name" : "TPS546B24A",
252 | "Maximum_Volt" : 1.1,
253 | "Typical_Volt" : 1.05,
254 | "Minimum_Volt" : 0.9,
255 | "I2C_Bus" : "/dev/i2c-0",
256 | "I2C_Address" : "0x21",
257 | "PMBus_VOUT_MODE" : 1,
258 | "Page_Select" : -1
259 | },
260 | "VR_LP5_VDDQ_0V5" : {
261 | "Name" : "VR_LP5_VDDQ_0V5",
262 | "Part_Name" : "TPS546B24A",
263 | "Maximum_Volt" : 0.55,
264 | "Typical_Volt" : 0.5,
265 | "Minimum_Volt" : 0.45,
266 | "I2C_Bus" : "/dev/i2c-0",
267 | "I2C_Address" : "0x22",
268 | "PMBus_VOUT_MODE" : 1,
269 | "Page_Select" : -1
270 | },
271 | "VR_HDIO_3V3" : {
272 | "Name" : "VR_HDIO_3V3",
273 | "Part_Name" : "TPS546B24A",
274 | "Maximum_Volt" : 3.6,
275 | "Typical_Volt" : 3.3,
276 | "Minimum_Volt" : 3,
277 | "I2C_Bus" : "/dev/i2c-0",
278 | "I2C_Address" : "0x23",
279 | "PMBus_VOUT_MODE" : 1,
280 | "Page_Select" : -1
281 | },
282 | "VR_GTYP_MMI_AVCC_0V92" : {
283 | "Name" : "VR_GTYP_MMI_AVCC_0V92",
284 | "Part_Name" : "TPS546B24A",
285 | "Maximum_Volt" : 1,
286 | "Typical_Volt" : 0.92,
287 | "Minimum_Volt" : 0.8,
288 | "I2C_Bus" : "/dev/i2c-0",
289 | "I2C_Address" : "0x29",
290 | "PMBus_VOUT_MODE" : 1,
291 | "Page_Select" : -1
292 | },
293 | "VR_GTYP_MMI_AVTT_1V2" : {
294 | "Name" : "VR_GTYP_MMI_AVTT_1V2",
295 | "Part_Name" : "TPS546B24A",
296 | "Maximum_Volt" : 1.32,
297 | "Typical_Volt" : 1.2,
298 | "Minimum_Volt" : 1.08,
299 | "I2C_Bus" : "/dev/i2c-0",
300 | "I2C_Address" : "0x2A",
301 | "PMBus_VOUT_MODE" : 1,
302 | "Page_Select" : -1
303 | },
304 | "VR_GTYP_MMI_AVCCAUX_1V5" : {
305 | "Name" : "VR_GTYP_MMI_AVCCAUX_1V5",
306 | "Part_Name" : "TPS546B24A",
307 | "Maximum_Volt" : 1.65,
308 | "Typical_Volt" : 1.5,
309 | "Minimum_Volt" : 1.35,
310 | "I2C_Bus" : "/dev/i2c-0",
311 | "I2C_Address" : "0x2B",
312 | "PMBus_VOUT_MODE" : 1,
313 | "Page_Select" : -1
314 | },
315 | "VR_UTIL_5V0" : {
316 | "Name" : "VR_UTIL_5V0",
317 | "Part_Name" : "TPS546B24A",
318 | "Maximum_Volt" : 5.5,
319 | "Typical_Volt" : 5.0,
320 | "Minimum_Volt" : 4.5,
321 | "I2C_Bus" : "/dev/i2c-0",
322 | "I2C_Address" : "0x16",
323 | "PMBus_VOUT_MODE" : 1,
324 | "Page_Select" : -1
325 | }
326 | },
327 | "Temperature": {
328 | "Name": "Versal-AIEPG2",
329 | "Sensor": "versal-isa-0000"
330 | }
331 | }
332 | }
333 |
--------------------------------------------------------------------------------
/xserver/raft_services/power_management/board/VMK180.json:
--------------------------------------------------------------------------------
1 | {
2 | "License" : "Copyright (c) 2021 - 2022 Xilinx, Inc. All rights reserved. SPDX-License-Identifier: MIT",
3 | "License" : "Copyright (c) 2022 - 2025 Advanced Micro Devices, Inc. All rights reserved. SPDX-License-Identifier: MIT",
4 |
5 | "VMK180" : {
6 | "FEATURE" : {
7 | "List" : ["power", "powerdomain"]
8 | },
9 | "POWER_SENSORS" : {
10 | "VCCINT" : {
11 | "Name" : "VCCINT",
12 | "Part_Name" : "INA226",
13 | "I2C_Bus" : "/dev/i2c-4",
14 | "I2C_Address" : "0x40",
15 | "Shunt_Resistor" : 500,
16 | "Maximum_Current" : 192000,
17 | "Phase_Multiplier" : 6
18 | },
19 | "VCC_SOC" : {
20 | "Name" : "VCC_SOC",
21 | "Part_Name" : "INA226",
22 | "I2C_Bus" : "/dev/i2c-4",
23 | "I2C_Address" : "0x41",
24 | "Shunt_Resistor" : 500,
25 | "Maximum_Current" : 18000,
26 | "Phase_Multiplier" : 1
27 | },
28 | "VCC_PMC" : {
29 | "Name" : "VCC_PMC",
30 | "Part_Name" : "INA226",
31 | "I2C_Bus" : "/dev/i2c-4",
32 | "I2C_Address" : "0x42",
33 | "Shunt_Resistor" : 5000,
34 | "Maximum_Current" : 500,
35 | "Phase_Multiplier" : 1
36 | },
37 | "VCCINT_RAM" : {
38 | "Name" : "VCC_RAM",
39 | "Part_Name" : "INA226",
40 | "I2C_Bus" : "/dev/i2c-4",
41 | "I2C_Address" : "0x43",
42 | "Shunt_Resistor" : 5000,
43 | "Maximum_Current" : 4000,
44 | "Phase_Multiplier" : 1
45 | },
46 | "VCCINT_PSLP" : {
47 | "Name" : "VCCINT_PSLP",
48 | "Part_Name" : "INA226",
49 | "I2C_Bus" : "/dev/i2c-4",
50 | "I2C_Address" : "0x44",
51 | "Shunt_Resistor" : 5000,
52 | "Maximum_Current" : 1000,
53 | "Phase_Multiplier" : 1
54 | },
55 | "VCCINT_PSFP" : {
56 | "Name" : "VCCINT_PSFP",
57 | "Part_Name" : "INA226",
58 | "I2C_Bus" : "/dev/i2c-4",
59 | "I2C_Address" : "0x45",
60 | "Shunt_Resistor" : 5000,
61 | "Maximum_Current" : 2000,
62 | "Phase_Multiplier" : 1
63 | },
64 | "VCCAUX" : {
65 | "Name" : "VCCAUX",
66 | "Part_Name" : "INA226",
67 | "I2C_Bus" : "/dev/i2c-6",
68 | "I2C_Address" : "0x40",
69 | "Shunt_Resistor" : 5000,
70 | "Maximum_Current" : 3000,
71 | "Phase_Multiplier" : 1
72 | },
73 | "VCCAUX_PMC" : {
74 | "Name" : "VCCAUX_PMC",
75 | "Part_Name" : "INA226",
76 | "I2C_Bus" : "/dev/i2c-6",
77 | "I2C_Address" : "0x41",
78 | "Shunt_Resistor" : 5000,
79 | "Maximum_Current" : 500,
80 | "Phase_Multiplier" : 1
81 | },
82 | "VCC_MIO" : {
83 | "Name" : "VCC_MIO",
84 | "Part_Name" : "INA226",
85 | "I2C_Bus" : "/dev/i2c-6",
86 | "I2C_Address" : "0x45",
87 | "Shunt_Resistor" : 5000,
88 | "Maximum_Current" : 2000,
89 | "Phase_Multiplier" : 1
90 | },
91 | "VCC1V8" : {
92 | "Name" : "VCC1V8",
93 | "Part_Name" : "INA226",
94 | "I2C_Bus" : "/dev/i2c-6",
95 | "I2C_Address" : "0x46",
96 | "Shunt_Resistor" : 5000,
97 | "Maximum_Current" : 6000,
98 | "Phase_Multiplier" : 1
99 | },
100 | "VCC3V3" : {
101 | "Name" : "VCC3V3",
102 | "Part_Name" : "INA226",
103 | "I2C_Bus" : "/dev/i2c-6",
104 | "I2C_Address" : "0x47",
105 | "Shunt_Resistor" : 5000,
106 | "Maximum_Current" : 500,
107 | "Phase_Multiplier" : 1
108 | },
109 | "VCC1V2_DDR4" : {
110 | "Name" : "VCC_DDR4",
111 | "Part_Name" : "INA226",
112 | "I2C_Bus" : "/dev/i2c-6",
113 | "I2C_Address" : "0x48",
114 | "Shunt_Resistor" : 5000,
115 | "Maximum_Current" : 4000,
116 | "Phase_Multiplier" : 1
117 | },
118 | "VCC1V1_LP4" : {
119 | "Name" : "VCC1V1_LP4",
120 | "Part_Name" : "INA226",
121 | "I2C_Bus" : "/dev/i2c-6",
122 | "I2C_Address" : "0x49",
123 | "Shunt_Resistor" : 5000,
124 | "Maximum_Current" : 4000,
125 | "Phase_Multiplier" : 1
126 | },
127 | "VADJ_FMC" : {
128 | "Name" : "VADJ_FMC",
129 | "Part_Name" : "INA226",
130 | "I2C_Bus" : "/dev/i2c-6",
131 | "I2C_Address" : "0x4A",
132 | "Shunt_Resistor" : 2000,
133 | "Maximum_Current" : 10000,
134 | "Phase_Multiplier" : 1
135 | },
136 | "MGTYAVCC" : {
137 | "Name" : "MGTYAVCC",
138 | "Part_Name" : "INA226",
139 | "I2C_Bus" : "/dev/i2c-6",
140 | "I2C_Address" : "0x48",
141 | "Shunt_Resistor" : 2000,
142 | "Maximum_Current" : 6000,
143 | "Phase_Multiplier" : 1
144 | },
145 | "MGTYAVTT" : {
146 | "Name" : "MGTYAVTT",
147 | "Part_Name" : "INA226",
148 | "I2C_Bus" : "/dev/i2c-6",
149 | "I2C_Address" : "0x4C",
150 | "Shunt_Resistor" : 2000,
151 | "Maximum_Current" : 10000,
152 | "Phase_Multiplier" : 1
153 | },
154 | "MGTYVCCAUX" : {
155 | "Name" : "MGTYVCCAUX",
156 | "Part_Name" : "INA226",
157 | "I2C_Bus" : "/dev/i2c-6",
158 | "I2C_Address" : "0x4D",
159 | "Shunt_Resistor" : 5000,
160 | "Maximum_Current" : 500,
161 | "Phase_Multiplier" : 1
162 | }
163 | },
164 | "POWER DOMAIN" : {
165 | "PD_FPD" : {
166 | "Name" : "FPD",
167 | "Rails" : ["VCCINT_PSFP"]
168 | },
169 | "PD_LPD" : {
170 | "Name" : "LPD",
171 | "Rails" : ["VCCINT_PSLP"]
172 | },
173 | "PD_PLD" : {
174 | "Name" : "PLD",
175 | "Rails" : ["VCCINT", "VCC1V8", "VCC3V3",
176 | "VCC1V2_DDR4", "VCC1V1_LP4",
177 | "VCCINT_RAM", "VCCAUX"]
178 | },
179 | "PD_PMC" : {
180 | "Name" : "PMC",
181 | "Rails" : ["VCC_PMC", "VCC_MIO", "VCCAUX_PMC"]
182 | },
183 | "PD_GTY" : {
184 | "Name" : "GTY",
185 | "Rails" : ["MGTYAVCC", "MGTYAVTT", "MGTYVCCAUX"]
186 | },
187 | "PD_FMC" : {
188 | "Name" : "FMC",
189 | "Rails" : ["VADJ_FMC"]
190 | },
191 | "PD_SYSTEM" : {
192 | "Name" : "system",
193 | "Rails" : ["VCC_SOC"]
194 | }
195 | },
196 | "VOLTAGE" : {
197 | "VOLTAGE_VCCINT" : {
198 | "Name" : "VCCINT",
199 | "Part_Name" : "IR35215",
200 | "Maximum_Volt" : 0.88,
201 | "Typical_Volt" : 0.8,
202 | "Minimum_Volt" : 0.7,
203 | "I2C_Bus" : "/dev/i2c-3",
204 | "I2C_Address" : "0x46",
205 | "PMBus_VOUT_MODE" : 1,
206 | "Page_Select" : 0.0
207 | },
208 | "VOLTAGE_VCCINT_SOC" : {
209 | "Name" : "VCCINT_SOC",
210 | "Part_Name" : "IR35215",
211 | "Maximum_Volt" : 0.83,
212 | "Typical_Volt" : 0.8,
213 | "Minimum_Volt" : 0.77,
214 | "I2C_Bus" : "/dev/i2c-3",
215 | "I2C_Address" : "0x46",
216 | "PMBus_VOUT_MODE" : 1,
217 | "Page_Select" : 1
218 | },
219 | "VOLTAGE_VCCINT_PSLP" : {
220 | "Name" : "VCCINT_PSLP",
221 | "Part_Name" : "IRPS5401",
222 | "Maximum_Volt" : 0.83,
223 | "Typical_Volt" : 0.8,
224 | "Minimum_Volt" : 0.77,
225 | "I2C_Bus" : "/dev/i2c-3",
226 | "I2C_Address" : "0x47",
227 | "PMBus_VOUT_MODE" : 1,
228 | "Page_Select" : 0.0
229 | },
230 | "VOLTAGE_VCCINT_PSFP" : {
231 | "Name" : "VCCINT_PSFP",
232 | "Part_Name" : "IRPS5401",
233 | "Maximum_Volt" : 0.83,
234 | "Typical_Volt" : 0.8,
235 | "Minimum_Volt" : 0.77,
236 | "I2C_Bus" : "/dev/i2c-3",
237 | "I2C_Address" : "0x47",
238 | "PMBus_VOUT_MODE" : 1,
239 | "Page_Select" : 1
240 | },
241 | "VOLTAGE_VCCAUX" : {
242 | "Name" : "VCCAUX",
243 | "Part_Name" : "IRPS5401",
244 | "Maximum_Volt" : 1.55,
245 | "Typical_Volt" : 1.5,
246 | "Minimum_Volt" : 1.45,
247 | "I2C_Bus" : "/dev/i2c-3",
248 | "I2C_Address" : "0x47",
249 | "PMBus_VOUT_MODE" : 1,
250 | "Page_Select" : 2
251 | },
252 | "VOLTAGE_VCC_RAM" : {
253 | "Name" : "VCC_RAM",
254 | "Part_Name" : "IRPS5401",
255 | "Maximum_Volt" : 0.83,
256 | "Typical_Volt" : 0.8,
257 | "Minimum_Volt" : 0.0,
258 | "I2C_Bus" : "/dev/i2c-3",
259 | "I2C_Address" : "0x47",
260 | "PMBus_VOUT_MODE" : 1,
261 | "Page_Select" : 3
262 | },
263 | "VOLTAGE_VCC_PMC" : {
264 | "Name" : "VCC_PMC",
265 | "Part_Name" : "IRPS5401",
266 | "Maximum_Volt" : 0.83,
267 | "Typical_Volt" : 0.8,
268 | "Minimum_Volt" : 0.77,
269 | "I2C_Bus" : "/dev/i2c-3",
270 | "I2C_Address" : "0x47",
271 | "PMBus_VOUT_MODE" : 1,
272 | "Page_Select" : 4
273 | },
274 | "VOLTAGE_VCCO_MIO" : {
275 | "Name" : "VCCO_MIO",
276 | "Part_Name" : "IRPS5401",
277 | "Maximum_Volt" : 1.86,
278 | "Typical_Volt" : 1.8,
279 | "Minimum_Volt" : 1.74,
280 | "I2C_Bus" : "/dev/i2c-3",
281 | "I2C_Address" : "0x4C",
282 | "PMBus_VOUT_MODE" : 1,
283 | "Page_Select" : 0.0
284 | },
285 | "VOLTAGE_VCC3V3" : {
286 | "Name" : "VCC3V3",
287 | "Part_Name" : "IRPS5401",
288 | "Maximum_Volt" : 3.4,
289 | "Typical_Volt" : 3.3,
290 | "Minimum_Volt" : 3.2,
291 | "I2C_Bus" : "/dev/i2c-3",
292 | "I2C_Address" : "0x4C",
293 | "PMBus_VOUT_MODE" : 1,
294 | "Page_Select" : 1
295 | },
296 | "VOLTAGE_VCC1V8" : {
297 | "Name" : "VCC1V8",
298 | "Part_Name" : "IRPS5401",
299 | "Maximum_Volt" : 1.86,
300 | "Typical_Volt" : 1.8,
301 | "Minimum_Volt" : 1.74,
302 | "I2C_Bus" : "/dev/i2c-3",
303 | "I2C_Address" : "0x4C",
304 | "PMBus_VOUT_MODE" : 1,
305 | "Page_Select" : 2
306 | },
307 | "VOLTAGE_VCCAUX_PMC" : {
308 | "Name" : "VCCAUX_PMC",
309 | "Part_Name" : "IRPS5401",
310 | "Maximum_Volt" : 1.55,
311 | "Typical_Volt" : 1.5,
312 | "Minimum_Volt" : 1.45,
313 | "I2C_Bus" : "/dev/i2c-3",
314 | "I2C_Address" : "0x4C",
315 | "PMBus_VOUT_MODE" : 1,
316 | "Page_Select" : 4
317 | },
318 | "VOLTAGE_MGTYAVTT" : {
319 | "Name" : "MGTYAVTT",
320 | "Part_Name" : "IR38164",
321 | "Maximum_Volt" : 1.24,
322 | "Typical_Volt" : 1.2,
323 | "Minimum_Volt" : 1.16,
324 | "I2C_Bus" : "/dev/i2c-3",
325 | "I2C_Address" : "0x50",
326 | "PMBus_VOUT_MODE" : 0,
327 | "Page_Select" : -1
328 | },
329 | "VOLTAGE_VADJ_FMC" : {
330 | "Name" : "VADJ_FMC",
331 | "Part_Name" : "IR38164",
332 | "Maximum_Volt" : 1.55,
333 | "Typical_Volt" : 1.5,
334 | "Minimum_Volt" : 0.0,
335 | "I2C_Bus" : "/dev/i2c-3",
336 | "I2C_Address" : "0x4E",
337 | "PMBus_VOUT_MODE" : 0,
338 | "Page_Select" : -1
339 | },
340 | "VOLTAGE_MGTYAVCC" : {
341 | "Name" : "MGTYAVCC",
342 | "Part_Name" : "IR38164",
343 | "Maximum_Volt" : 0.91,
344 | "Typical_Volt" : 0.88,
345 | "Minimum_Volt" : 0.85,
346 | "I2C_Bus" : "/dev/i2c-3",
347 | "I2C_Address" : "0x4F",
348 | "PMBus_VOUT_MODE" : 0,
349 | "Page_Select" : -1
350 | },
351 | "VOLTAGE_UTIL_1V13" : {
352 | "Name" : "UTIL_1V13",
353 | "Part_Name" : "IRPS5401",
354 | "Maximum_Volt" : 1.17,
355 | "Typical_Volt" : 1.13,
356 | "Minimum_Volt" : 1.09,
357 | "I2C_Bus" : "/dev/i2c-3",
358 | "I2C_Address" : "0x4D",
359 | "PMBus_VOUT_MODE" : 1,
360 | "Page_Select" : 0.0
361 | },
362 | "VOLTAGE_UTIL_2V5" : {
363 | "Name" : "UTIL_2V5",
364 | "Part_Name" : "IRPS5401",
365 | "Maximum_Volt" : 2.58,
366 | "Typical_Volt" : 2.5,
367 | "Minimum_Volt" : 2.42,
368 | "I2C_Bus" : "/dev/i2c-3",
369 | "I2C_Address" : "0x4D",
370 | "PMBus_VOUT_MODE" : 1,
371 | "Page_Select" : 1
372 | },
373 | "VOLTAGE_VCC1V2_DDR4" : {
374 | "Name" : "VCC1V2_DDR4",
375 | "Part_Name" : "IRPS5401",
376 | "Maximum_Volt" : 1.24,
377 | "Typical_Volt" : 1.2,
378 | "Minimum_Volt" : 1.16,
379 | "I2C_Bus" : "/dev/i2c-3",
380 | "I2C_Address" : "0x4D",
381 | "PMBus_VOUT_MODE" : 1,
382 | "Page_Select" : 2
383 | },
384 | "VOLTAGE_VCC1V1_LP4" : {
385 | "Name" : "VCC1V1_LP4",
386 | "Part_Name" : "IRPS5401",
387 | "Maximum_Volt" : 1.14,
388 | "Typical_Volt" : 1.1,
389 | "Minimum_Volt" : 1.06,
390 | "I2C_Bus" : "/dev/i2c-3",
391 | "I2C_Address" : "0x4D",
392 | "PMBus_VOUT_MODE" : 1,
393 | "Page_Select" : 3
394 | }
395 | }
396 | }
397 | }
398 |
--------------------------------------------------------------------------------
/xserver/raft_services/power_management/board/VR-R-A2488-00.json:
--------------------------------------------------------------------------------
1 | {
2 | "License" : "Copyright (c) 2024 - 2025 Advanced Micro Devices, Inc. All rights reserved. SPDX-License-Identifier: MIT",
3 |
4 | "VR-R-A2488-00" : {
5 | "FEATURE" : {
6 | "List" : ["voltage", "power", "powerdomain"]
7 | },
8 | "POWER_SENSORS" : {
9 | "DAC_AVCCAUX" : {
10 | "Name" : "DAC_AVCCAUX",
11 | "Part_Name" : "INA226",
12 | "I2C_Bus" : "/dev/i2c-1",
13 | "I2C_Address" : "0x40",
14 | "Shunt_Resistor" : 1000,
15 | "Maximum_Current" : 1600,
16 | "Phase_Multiplier" : 1
17 | },
18 | "DAC_AVTT" : {
19 | "Name" : "DAC_AVTT",
20 | "Part_Name" : "INA226",
21 | "I2C_Bus" : "/dev/i2c-1",
22 | "I2C_Address" : "0x41",
23 | "Shunt_Resistor" : 1000,
24 | "Maximum_Current" : 1000,
25 | "Phase_Multiplier" : 1
26 | },
27 | "ADC_AVCC" : {
28 | "Name" : "ADC_AVCC",
29 | "Part_Name" : "INA226",
30 | "I2C_Bus" : "/dev/i2c-1",
31 | "I2C_Address" : "0x42",
32 | "Shunt_Resistor" : 1000,
33 | "Maximum_Current" : 7500,
34 | "Phase_Multiplier" : 1
35 | },
36 | "ADC_AVCCAUX" : {
37 | "Name" : "ADC_AVCCAUX",
38 | "Part_Name" : "INA226",
39 | "I2C_Bus" : "/dev/i2c-1",
40 | "I2C_Address" : "0x43",
41 | "Shunt_Resistor" : 1000,
42 | "Maximum_Current" : 3500,
43 | "Phase_Multiplier" : 1
44 | },
45 | "DAC_AVCC" : {
46 | "Name" : "DAC_AVCC",
47 | "Part_Name" : "INA226",
48 | "I2C_Bus" : "/dev/i2c-1",
49 | "I2C_Address" : "0x48",
50 | "Shunt_Resistor" : 1000,
51 | "Maximum_Current" : 8000,
52 | "Phase_Multiplier" : 1
53 | }
54 | },
55 | "POWER DOMAIN" : {
56 | "PD_DAC" : {
57 | "Name" : "DAC",
58 | "Rails" : ["DAC_AVCCAUX", "DAC_AVTT", "DAC_AVCC"]
59 | },
60 | "PD_ADC" : {
61 | "Name" : "ADC",
62 | "Rails" : ["ADC_AVCC", "ADC_AVCCAUX"]
63 | }
64 | },
65 | "VOLTAGE" : {
66 | "VCCINT" : {
67 | "Name" : "VCCINT",
68 | "Part_Name" : "TPS53681",
69 | "Maximum_Volt" : 0.975,
70 | "Typical_Volt" : 0.8,
71 | "Minimum_Volt" : 0.5,
72 | "I2C_Bus" : "/dev/i2c-1",
73 | "I2C_Address" : "0x60",
74 | "PMBus_VOUT_MODE" : 1,
75 | "Page_Select" : 0.0,
76 | "Phase" : 4
77 | },
78 | "VCC_SOC" : {
79 | "Name" : "VCC_SOC",
80 | "Part_Name" : "TPS53681",
81 | "Maximum_Volt" : 0.97,
82 | "Typical_Volt" : 0.8,
83 | "Minimum_Volt" : 0.5,
84 | "I2C_Bus" : "/dev/i2c-1",
85 | "I2C_Address" : "0x60",
86 | "PMBus_VOUT_MODE" : 1,
87 | "Page_Select" : 1,
88 | "Phase" : 2
89 | },
90 | "VCC_IO" : {
91 | "Name" : "VCC_IO",
92 | "Part_Name" : "TPS546B24A",
93 | "Maximum_Volt" : 1.5,
94 | "Typical_Volt" : 0.8,
95 | "Minimum_Volt" : 0.5,
96 | "I2C_Bus" : "/dev/i2c-1",
97 | "I2C_Address" : "0x1B",
98 | "PMBus_VOUT_MODE" : 1,
99 | "Page_Select" : -1
100 | },
101 | "VCCINT_GT" : {
102 | "Name" : "VCCINT_GT",
103 | "Part_Name" : "TPS546B24A",
104 | "Maximum_Volt" : 1.5,
105 | "Typical_Volt" : 0.8,
106 | "Minimum_Volt" : 0.5,
107 | "I2C_Bus" : "/dev/i2c-1",
108 | "I2C_Address" : "0x10",
109 | "PMBus_VOUT_MODE" : 1,
110 | "Page_Select" : -1
111 | },
112 | "VCC_RAM" : {
113 | "Name" : "VCC_RAM",
114 | "Part_Name" : "TPS546B24A",
115 | "Maximum_Volt" : 1.5,
116 | "Typical_Volt" : 0.8,
117 | "Minimum_Volt" : 0.5,
118 | "I2C_Bus" : "/dev/i2c-1",
119 | "I2C_Address" : "0x11",
120 | "PMBus_VOUT_MODE" : 1,
121 | "Page_Select" : -1
122 | },
123 | "UTIL_1V8" : {
124 | "Name" : "UTIL_1V8",
125 | "Part_Name" : "TPS546B24A",
126 | "Maximum_Volt" : 3,
127 | "Typical_Volt" : 1.8,
128 | "Minimum_Volt" : 1,
129 | "I2C_Bus" : "/dev/i2c-1",
130 | "I2C_Address" : "0x1A",
131 | "PMBus_VOUT_MODE" : 1,
132 | "Page_Select" : -1
133 | },
134 | "VCC_PMC" : {
135 | "Name" : "VCC_PMC",
136 | "Part_Name" : "TPS546B24A",
137 | "Maximum_Volt" : 1.5,
138 | "Typical_Volt" : 0.8,
139 | "Minimum_Volt" : 0.5,
140 | "I2C_Bus" : "/dev/i2c-1",
141 | "I2C_Address" : "0x29",
142 | "PMBus_VOUT_MODE" : 1,
143 | "Page_Select" : -1
144 | },
145 | "VCC_PSFP" : {
146 | "Name" : "VCC_PSFP",
147 | "Part_Name" : "TPS546B24A",
148 | "Maximum_Volt" : 1.5,
149 | "Typical_Volt" : 0.8,
150 | "Minimum_Volt" : 0.5,
151 | "I2C_Bus" : "/dev/i2c-1",
152 | "I2C_Address" : "0x13",
153 | "PMBus_VOUT_MODE" : 1,
154 | "Page_Select" : -1
155 | },
156 | "VCC_PSLP" : {
157 | "Name" : "VCC_PSLP",
158 | "Part_Name" : "TPS546B24A",
159 | "Maximum_Volt" : 1.5,
160 | "Typical_Volt" : 0.8,
161 | "Minimum_Volt" : 0.5,
162 | "I2C_Bus" : "/dev/i2c-1",
163 | "I2C_Address" : "0x14",
164 | "PMBus_VOUT_MODE" : 1,
165 | "Page_Select" : -1
166 | },
167 | "VCCO_MIO" : {
168 | "Name" : "VCCO_MIO",
169 | "Part_Name" : "TPS546B24A",
170 | "Maximum_Volt" : 3,
171 | "Typical_Volt" : 0.8,
172 | "Minimum_Volt" : 1,
173 | "I2C_Bus" : "/dev/i2c-1",
174 | "I2C_Address" : "0x16",
175 | "PMBus_VOUT_MODE" : 1,
176 | "Page_Select" : -1
177 | },
178 | "VCCAUX" : {
179 | "Name" : "VCCAUX",
180 | "Part_Name" : "TPS546B24A",
181 | "Maximum_Volt" : 3,
182 | "Typical_Volt" : 1.2,
183 | "Minimum_Volt" : 1,
184 | "I2C_Bus" : "/dev/i2c-1",
185 | "I2C_Address" : "0x23",
186 | "PMBus_VOUT_MODE" : 1,
187 | "Page_Select" : -1
188 | },
189 | "VCCO_X5IO" : {
190 | "Name" : "VCCO_X5IO",
191 | "Part_Name" : "TPS546B24A",
192 | "Maximum_Volt" : 3,
193 | "Typical_Volt" : 1.2,
194 | "Minimum_Volt" : 1,
195 | "I2C_Bus" : "/dev/i2c-1",
196 | "I2C_Address" : "0x18",
197 | "PMBus_VOUT_MODE" : 1,
198 | "Page_Select" : -1
199 | },
200 | "VCCO_700" : {
201 | "Name" : "VCCO_700",
202 | "Part_Name" : "TPS546B24A",
203 | "Maximum_Volt" : 3,
204 | "Typical_Volt" : 1.2,
205 | "Minimum_Volt" : 1,
206 | "I2C_Bus" : "/dev/i2c-1",
207 | "I2C_Address" : "0x19",
208 | "PMBus_VOUT_MODE" : 1,
209 | "Page_Select" : -1
210 | },
211 | "LP5_VDD1_1V8" : {
212 | "Name" : "LP5_VDD1_1V8",
213 | "Part_Name" : "TPS544B25",
214 | "Maximum_Volt" : 3,
215 | "Typical_Volt" : 1.8,
216 | "Minimum_Volt" : 1,
217 | "I2C_Bus" : "/dev/i2c-1",
218 | "I2C_Address" : "0x0E",
219 | "PMBus_VOUT_MODE" : 1,
220 | "Page_Select" : -1
221 | },
222 | "LP5_VDD2_1V05" : {
223 | "Name" : "LP5_VDD2_1V05",
224 | "Part_Name" : "TPS544B25",
225 | "Maximum_Volt" : 1.5,
226 | "Typical_Volt" : 1.05,
227 | "Minimum_Volt" : 0.5,
228 | "I2C_Bus" : "/dev/i2c-1",
229 | "I2C_Address" : "0x0F",
230 | "PMBus_VOUT_MODE" : 1,
231 | "Page_Select" : -1
232 | },
233 | "LP5_VCCO_1V0" : {
234 | "Name" : "LP5_VCCO_1V0",
235 | "Part_Name" : "TPS544B25",
236 | "Maximum_Volt" : 3,
237 | "Typical_Volt" : 1.0,
238 | "Minimum_Volt" : 1,
239 | "I2C_Bus" : "/dev/i2c-1",
240 | "I2C_Address" : "0x15",
241 | "PMBus_VOUT_MODE" : 1,
242 | "Page_Select" : -1
243 | },
244 | "LP5_VDDQ_0V5" : {
245 | "Name" : "LP5_VDDQ_0V5",
246 | "Part_Name" : "TPS546B24A",
247 | "Maximum_Volt" : 1.5,
248 | "Typical_Volt" : 0.5,
249 | "Minimum_Volt" : 0.5,
250 | "I2C_Bus" : "/dev/i2c-1",
251 | "I2C_Address" : "0x22",
252 | "PMBus_VOUT_MODE" : 1,
253 | "Page_Select" : -1
254 | },
255 | "GTYP_AVCC" : {
256 | "Name" : "GTYP_AVCC",
257 | "Part_Name" : "TPS546B24A",
258 | "Maximum_Volt" : 1.5,
259 | "Typical_Volt" : 0.92,
260 | "Minimum_Volt" : 0.5,
261 | "I2C_Bus" : "/dev/i2c-1",
262 | "I2C_Address" : "0x27",
263 | "PMBus_VOUT_MODE" : 1,
264 | "Page_Select" : -1
265 | },
266 | "GTYP_AVTT" : {
267 | "Name" : "GTYP_AVTT",
268 | "Part_Name" : "TPS546B24A",
269 | "Maximum_Volt" : 3,
270 | "Typical_Volt" : 1.2,
271 | "Minimum_Volt" : 1,
272 | "I2C_Bus" : "/dev/i2c-1",
273 | "I2C_Address" : "0x25",
274 | "PMBus_VOUT_MODE" : 1,
275 | "Page_Select" : -1
276 | },
277 | "GTYP_AVCCAUX" : {
278 | "Name" : "GTYP_AVCCAUX",
279 | "Part_Name" : "TPS546B24A",
280 | "Maximum_Volt" : 3,
281 | "Typical_Volt" : 1.5,
282 | "Minimum_Volt" : 1,
283 | "I2C_Bus" : "/dev/i2c-1",
284 | "I2C_Address" : "0x20",
285 | "PMBus_VOUT_MODE" : 1,
286 | "Page_Select" : -1
287 | },
288 | "GTM_AVCC" : {
289 | "Name" : "GTM_AVCC",
290 | "Part_Name" : "TPS546B24A",
291 | "Maximum_Volt" : 1.5,
292 | "Typical_Volt" : 0.92,
293 | "Minimum_Volt" : 0.5,
294 | "I2C_Bus" : "/dev/i2c-1",
295 | "I2C_Address" : "0x24",
296 | "PMBus_VOUT_MODE" : 1,
297 | "Page_Select" : -1
298 | },
299 | "GTM_AVTT" : {
300 | "Name" : "GTM_AVTT",
301 | "Part_Name" : "TPS546B24A",
302 | "Maximum_Volt" : 3,
303 | "Typical_Volt" : 1.2,
304 | "Minimum_Volt" : 1,
305 | "I2C_Bus" : "/dev/i2c-1",
306 | "I2C_Address" : "0x1C",
307 | "PMBus_VOUT_MODE" : 1,
308 | "Page_Select" : -1
309 | },
310 | "GTM_AVCCAUX" : {
311 | "Name" : "GTM_AVCCAUX",
312 | "Part_Name" : "TPS546B24A",
313 | "Maximum_Volt" : 3,
314 | "Typical_Volt" : 1.5,
315 | "Minimum_Volt" : 1,
316 | "I2C_Bus" : "/dev/i2c-1",
317 | "I2C_Address" : "0x21",
318 | "PMBus_VOUT_MODE" : 1,
319 | "Page_Select" : -1
320 | },
321 | "ADC_AVCC" : {
322 | "Name" : "ADC_AVCC",
323 | "Part_Name" : "MPM54522",
324 | "Maximum_Volt" : 1,
325 | "Typical_Volt" : 0.9,
326 | "Minimum_Volt" : 0.8,
327 | "I2C_Bus" : "/dev/i2c-1",
328 | "I2C_Address" : "0x61",
329 | "Page_Select" : -1,
330 | "FB_Ratio" : 0.6667
331 | },
332 | "DAC_AVCC" : {
333 | "Name" : "DAC_AVCC",
334 | "Part_Name" : "MPM54522",
335 | "Maximum_Volt" : 1,
336 | "Typical_Volt" : 0.9,
337 | "Minimum_Volt" : 0.8,
338 | "I2C_Bus" : "/dev/i2c-1",
339 | "I2C_Address" : "0x62",
340 | "Page_Select" : -1,
341 | "FB_Ratio" : 0.6667
342 | },
343 | "ADC_AVCCAUX" : {
344 | "Name" : "ADC_AVCCAUX",
345 | "Part_Name" : "MPM54322",
346 | "Maximum_Volt" : 2,
347 | "Typical_Volt" : 1.8,
348 | "Minimum_Volt" : 1.5,
349 | "I2C_Bus" : "/dev/i2c-1",
350 | "I2C_Address" : "0x63",
351 | "Page_Select" : -1,
352 | "FB_Ratio" : 1.5
353 | },
354 | "DAC_AVCCAUX" : {
355 | "Name" : "DAC_AVCCAUX",
356 | "Part_Name" : "MPM54322",
357 | "Maximum_Volt" : 2,
358 | "Typical_Volt" : 1.8,
359 | "Minimum_Volt" : 1.5,
360 | "I2C_Bus" : "/dev/i2c-1",
361 | "I2C_Address" : "0x64",
362 | "Page_Select" : 0.0,
363 | "FB_Ratio" : 1.5
364 | },
365 | "DAC_AVTT" : {
366 | "Name" : "DAC_AVTT",
367 | "Part_Name" : "MPM54322",
368 | "Maximum_Volt" : 3,
369 | "Typical_Volt" : 2.85,
370 | "Minimum_Volt" : 2.5,
371 | "I2C_Bus" : "/dev/i2c-1",
372 | "I2C_Address" : "0x64",
373 | "Page_Select" : 1,
374 | "FB_Ratio" : 0.2126
375 | }
376 | }
377 | }
378 | }
379 |
--------------------------------------------------------------------------------
/xserver/raft_services/power_management/devices/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Xilinx/RAFT/2e228b13372c829d75043dad8f9e6658ed736d82/xserver/raft_services/power_management/devices/__init__.py
--------------------------------------------------------------------------------
/xserver/raft_services/power_management/devices/sysmon.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | __author__ = "Salih Erim"
5 | __copyright__ = "Copyright 2023-2025, Advanced Micro Devices, Inc."
6 |
7 | import os
8 | import sys
9 | import logging
10 | import subprocess
11 | from periphery import I2C
12 |
13 | RAFT_DIR = '/usr/share/raft/'
14 | sys.path.append(RAFT_DIR + 'xserver/utils')
15 | sys.path.append(RAFT_DIR + 'xserver/raft_services/power_management/devices')
16 | from pm_types import *
17 |
18 | logging.basicConfig(level=logging.ERROR)
19 |
20 | class Sysmon(object):
21 | def __init__(self, address, devicepath, devicetype):
22 | logging.info("Inside SysmonI2C Constructor")
23 | self._address = None
24 | self._bus = None
25 | self._min = 0
26 | self._min_min = 0
27 | self._max_max = 0
28 | self._temp = 0
29 | self._device_type = devicetype
30 | self._device_path = devicepath
31 |
32 | if self._device_type is Sysmon_Device_Type.I2C:
33 | self._address = int(address, 0)
34 | self._bus = I2C(self._device_path)
35 | try:
36 | msgs = [I2C.Message([0xc6, 0xd7, 0xe8, 0xf9, 0x03, 0x00, 0x08, 0x00])]
37 | self._bus.transfer(self._address, msgs)
38 | except IOError:
39 | logging.error("Sysmon I2C device init failed.")
40 | raise Exception("Sysmon I2C device init failed")
41 |
42 | elif self._device_type is Sysmon_Device_Type.PMBUS:
43 | self._address = int(address, 0)
44 | self._bus = I2C(self._device_path)
45 | try:
46 | msgs = [I2C.Message([0xc6, 0xd7, 0xe8, 0xf9, 0x03, 0x00, 0x08, 0x00])]
47 | self._bus.transfer(self._address, msgs)
48 | except IOError:
49 | logging.error("Sysmon Pmbus device init failed.")
50 | raise Exception("Sysmon Pmbus device init failed")
51 |
52 | elif self._device_type is Sysmon_Device_Type.SYSFS:
53 | for root, subdirs, files in os.walk("/sys/bus/iio/devices/"):
54 | for subdir in subdirs:
55 | filepath = os.path.join(root, subdir, "name")
56 | if os.path.isfile(filepath):
57 | with open(filepath, 'r') as f:
58 | file_content = f.read()
59 | if 'xlnx,versal-sysmon' in file_content:
60 | temp_path = os.path.join(root, subdir)
61 | device_path = os.path.abspath(temp_path)
62 | self._device_path = device_path
63 | if self._device_path is None:
64 | logging.error("Sysmon Sysfs device init failed.")
65 | raise Exception("Sysmon Sysfs device init failed.")
66 | else:
67 | logging.error("Unknown Sysmon device type.")
68 | raise Exception("Unknown Sysmon device type.")
69 |
70 | @staticmethod
71 | def twos_comp(val, bits):
72 | if (val & (1 << (bits - 1))) != 0:
73 | val = val - (1 << bits)
74 | return val
75 |
76 | @staticmethod
77 | def ConvertRawtoProcessed(first_byte, second_byte):
78 | val1 = (second_byte << 8) + first_byte
79 | if (val1 & 0x8000) == 0x8000:
80 | val1 = Sysmon.twos_comp(val1, 16)
81 | val2 = 128
82 | return float(val1)/float(val2)
83 |
84 | def ReadSysmonTemperatures(self):
85 | """
86 | Read Processing System Temperature Values
87 |
88 | :return: values of temp, min, max_max and min_min
89 | """
90 | if self._device_type == Sysmon_Device_Type.SYSFS:
91 | if self._device_path is not None:
92 | cmd = 'cat ' + os.path.join(self._device_path, 'in_temp160_temp_input')
93 | ret, val = subprocess.getstatusoutput(cmd)
94 | if ret == 0:
95 | self._temp = round(int(val)/1000, 3)
96 |
97 | cmd = 'cat ' + os.path.join(self._device_path, 'in_temp161_min_input')
98 | ret, val = subprocess.getstatusoutput(cmd)
99 | if ret == 0:
100 | self._min = round(int(val)/1000, 3)
101 |
102 | cmd = 'cat ' + os.path.join(self._device_path, 'in_temp162_max_max_input')
103 | ret, val = subprocess.getstatusoutput(cmd)
104 | if ret == 0:
105 | self._max_max = round(int(val)/1000, 3)
106 |
107 | cmd = 'cat ' + os.path.join(self._device_path, 'in_temp163_min_min_input')
108 | ret, val = subprocess.getstatusoutput(cmd)
109 | if ret == 0:
110 | self._min_min = round(int(val)/1000, 3)
111 | else:
112 | logging.error("Sysmon device path is None.")
113 |
114 | elif self._device_type == Sysmon_Device_Type.I2C:
115 | try:
116 | msgs = [I2C.Message([0xc6, 0xd7, 0xe8, 0xf9, 0x03, 0x00, 0x08, 0x00])]
117 | self._bus.transfer(self._address, msgs)
118 |
119 | msgs = [I2C.Message([0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x04, 0x00]), I2C.Message([0x00, 0x00, 0x00, 0x00], read=True)]
120 | self._bus.transfer(self._address, msgs)
121 | logging.debug("{0}: 0x{1:02x}{2:02x}{2:02x}{3:02x}".format(self._address, msgs[1].data[0], msgs[1].data[1], msgs[1].data[2], msgs[1].data[3]))
122 |
123 | msgs = [I2C.Message([0x00, 0x00, 0x00, 0x00, 0x0c, 0x04, 0x04, 0x00]), I2C.Message([0x00, 0x00, 0x00, 0x00], read=True)]
124 | self._bus.transfer(self._address, msgs)
125 | logging.debug("{0}: 0x{1:02x}{2:02x}{2:02x}{3:02x}".format(self._address, msgs[1].data[0], msgs[1].data[1], msgs[1].data[2], msgs[1].data[3]))
126 |
127 | self._min = round(self.ConvertRawtoProcessed(msgs[1].data[0], msgs[1].data[1]), 3)
128 |
129 | msgs = [I2C.Message([0x00, 0x00, 0x00, 0x00, 0x0d, 0x04, 0x04, 0x00]), I2C.Message([0x00, 0x00, 0x00, 0x00], read=True)]
130 | self._bus.transfer(self._address, msgs)
131 | logging.debug("{0}: 0x{1:02x}{2:02x}{2:02x}{3:02x}".format(self._address, msgs[1].data[0], msgs[1].data[1], msgs[1].data[2], msgs[1].data[3]))
132 |
133 | self._temp = round(self.ConvertRawtoProcessed(msgs[1].data[0], msgs[1].data[1]), 3)
134 |
135 | msgs = [I2C.Message([0x00, 0x00, 0x00, 0x00, 0xe3, 0x07, 0x04, 0x00]), I2C.Message([0x00, 0x00, 0x00, 0x00], read=True)]
136 | self._bus.transfer(self._address, msgs)
137 | logging.debug("{0}: 0x{1:02x}{2:02x}{2:02x}{3:02x}".format(self._address, msgs[1].data[0], msgs[1].data[1], msgs[1].data[2], msgs[1].data[3]))
138 |
139 | self._min_min = round(self.ConvertRawtoProcessed(msgs[1].data[0], msgs[1].data[1]), 3)
140 |
141 | msgs = [I2C.Message([0x00, 0x00, 0x00, 0x00, 0xe4, 0x07, 0x04, 0x00]), I2C.Message([0x00, 0x00, 0x00, 0x00], read=True)]
142 | self._bus.transfer(self._address, msgs)
143 | logging.debug("{0}: 0x{1:02x}{2:02x}{2:02x}{3:02x}".format(self._address, msgs[1].data[0], msgs[1].data[1], msgs[1].data[2], msgs[1].data[3]))
144 |
145 | self._max_max = round(self.ConvertRawtoProcessed(msgs[1].data[0], msgs[1].data[1]), 3)
146 |
147 | except IOError:
148 | logging.error("Read Sysmon failed.")
149 |
150 | elif self._device_type == Sysmon_Device_Type.PMBUS:
151 | try:
152 | msgs = [I2C.Message([0xc6, 0xd7, 0xe8, 0xf9, 0x03, 0x00, 0x08, 0x00])]
153 | self._bus.transfer(self._address, msgs)
154 |
155 | msgs = [I2C.Message([0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x04, 0x00]), I2C.Message([0x00, 0x00, 0x00, 0x00], read=True)]
156 | self._bus.transfer(self._address, msgs)
157 | logging.debug("{0}: 0x{1:02x}{2:02x}{2:02x}{3:02x}".format(self._address, msgs[1].data[0], msgs[1].data[1], msgs[1].data[2], msgs[1].data[3]))
158 |
159 | msgs = [I2C.Message([0x00, 0x00, 0x00, 0x00, 0x0c, 0x04, 0x04, 0x00]), I2C.Message([0x00, 0x00, 0x00, 0x00], read=True)]
160 | self._bus.transfer(self._address, msgs)
161 | logging.debug("{0}: 0x{1:02x}{2:02x}{2:02x}{3:02x}".format(self._address, msgs[1].data[0], msgs[1].data[1], msgs[1].data[2], msgs[1].data[3]))
162 |
163 | self._min = round(self.ConvertRawtoProcessed(msgs[1].data[0], msgs[1].data[1]), 3)
164 |
165 | msgs = [I2C.Message([0x00, 0x00, 0x00, 0x00, 0x0d, 0x04, 0x04, 0x00]), I2C.Message([0x00, 0x00, 0x00, 0x00], read=True)]
166 | self._bus.transfer(self._address, msgs)
167 | logging.debug("{0}: 0x{1:02x}{2:02x}{2:02x}{3:02x}".format(self._address, msgs[1].data[0], msgs[1].data[1], msgs[1].data[2], msgs[1].data[3]))
168 |
169 | self._temp = round(self.ConvertRawtoProcessed(msgs[1].data[0], msgs[1].data[1]), 3)
170 |
171 | msgs = [I2C.Message([0x00, 0x00, 0x00, 0x00, 0xe3, 0x07, 0x04, 0x00]), I2C.Message([0x00, 0x00, 0x00, 0x00], read=True)]
172 | self._bus.transfer(self._address, msgs)
173 | logging.debug("{0}: 0x{1:02x}{2:02x}{2:02x}{3:02x}".format(self._address, msgs[1].data[0], msgs[1].data[1], msgs[1].data[2], msgs[1].data[3]))
174 |
175 | self._min_min = round(self.ConvertRawtoProcessed(msgs[1].data[0], msgs[1].data[1]), 3)
176 |
177 | msgs = [I2C.Message([0x00, 0x00, 0x00, 0x00, 0xe4, 0x07, 0x04, 0x00]), I2C.Message([0x00, 0x00, 0x00, 0x00], read=True)]
178 | self._bus.transfer(self._address, msgs)
179 | logging.debug("{0}: 0x{1:02x}{2:02x}{2:02x}{3:02x}".format(self._address, msgs[1].data[0], msgs[1].data[1], msgs[1].data[2], msgs[1].data[3]))
180 |
181 | self._max_max = round(self.ConvertRawtoProcessed(msgs[1].data[0], msgs[1].data[1]), 3)
182 |
183 | except IOError:
184 | logging.error("Read Sysmon failed.")
185 | else:
186 | ps_path = os.path.join(self._device_path, self._address)
187 | ret, val = subprocess.getstatusoutput(["cat", ps_path])
188 | if ret == 0:
189 | self._temp = int(val)
190 |
191 | return self._temp, self._min, self._max_max, self._min_min
192 |
193 | def __del__(self):
194 | logging.info("Inside Sysmon Destructor")
195 |
--------------------------------------------------------------------------------
/xserver/raft_services/power_management/pm_types.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | __author__ = "Salih Erim"
5 | __copyright__ = "Copyright 2024-2025, Advanced Micro Devices, Inc."
6 |
7 | import json
8 | from enum import IntEnum
9 |
10 | class Sysmon_Device_Type(IntEnum):
11 | I2C = 0
12 | PMBUS = 1
13 | SYSFS = 2
14 |
15 | class Rails:
16 | def __init__(self, Name, Part_Name, I2C_Bus, I2C_Address,
17 | Shunt_Resistor=None, Maximum_Current=None, Phase_Multiplier=None,
18 | Maximum_Volt=None, Typical_Volt=None, Minimum_Volt=None,
19 | PMBus_VOUT_MODE=-1, Page_Select=-1, Phase=-1, FB_Ratio=1.0, Voltage_Multiplier=-1):
20 | self.name = Name
21 | self.part_name = Part_Name
22 | self.i2c_bus = I2C_Bus
23 | self.i2c_address = I2C_Address
24 | self.shunt_resistor = Shunt_Resistor
25 | self.maximum_current = Maximum_Current
26 | self.phase_multiplier = Phase_Multiplier
27 | self.maximum_volt = Maximum_Volt
28 | self.typical_volt = Typical_Volt
29 | self.minimum_volt = Minimum_Volt
30 | self.pmbus_vout_mode = int(PMBus_VOUT_MODE)
31 | self.page_select = int(Page_Select)
32 | self.phase = int(Phase)
33 | self.fb_ratio = float(FB_Ratio)
34 | self.voltage_multiplier = int(Voltage_Multiplier)
35 |
36 | self._sensor = None
37 | self._output = None
38 |
39 | def __str__(self):
40 | str_info = {
41 | k: v
42 | for k, v in self.__dict__.items()
43 | if k and v is not None
44 | }
45 | return str(str_info)
46 |
47 | def toJSON(self):
48 | return json.dumps(self, default=lambda o: o.__dict__,
49 | sort_keys=True, indent=4)
50 |
51 | class Domain:
52 | def __init__(self, Name, Rails):
53 | self.name = Name
54 | self.railnames = Rails
55 |
56 | def __str__(self):
57 | str_info = {
58 | k: v
59 | for k, v in self.__dict__.items()
60 | if k and v
61 | }
62 | return str(str_info)
63 |
64 | def toJSON(self):
65 | return json.dumps(self, default=lambda o: o.__dict__,
66 | sort_keys=True, indent=4)
67 |
68 | class Unit:
69 | def __init__(self, base_unit, available_scales):
70 | self.base_unit = base_unit
71 | self.available_scales = available_scales
72 | self.current_unit = None
73 | self.quantity = None
74 |
75 | def __str__(self):
76 | str_info = {
77 | k: v
78 | for k, v in self.__dict__.items()
79 | if k and v
80 | }
81 | return str(str_info)
--------------------------------------------------------------------------------
/xserver/raft_services/power_management/pmic.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | __author__ = "Salih Erim"
5 | __copyright__ = "Copyright 2023-2025, Advanced Micro Devices, Inc."
6 |
7 | import os
8 | import sys
9 | import datetime
10 | import logging
11 | import dbm.dumb
12 | from periphery import I2C
13 | from utils import get_python_log_levels
14 |
15 | RAFT_DIR = '/usr/share/raft/'
16 | sys.path.append(RAFT_DIR + 'xserver/utils')
17 | sys.path.append(RAFT_DIR + 'xserver/raft_services/power_management/devices')
18 |
19 | from pm_types import *
20 | from devices.sensors import *
21 | from devices.regulators import *
22 | class PMIC(object):
23 | logger = None
24 | domains = []
25 | voltages = []
26 | power_sensors = []
27 |
28 | def __init__(self, pm_domains, pm_powersensor, pm_voltages):
29 | self.logger = self.GetLogger()
30 | self.domains = pm_domains
31 |
32 | for ps in pm_powersensor:
33 | match ps.part_name:
34 | case 'INA226':
35 | ps._sensor = INA226(ps.i2c_address, ps.i2c_bus)
36 | case 'INA700':
37 | ps._sensor = INA700(ps.i2c_address, ps.i2c_bus)
38 | case 'INA745A' | 'INA745B':
39 | ps._sensor = INA745x(ps.i2c_address, ps.i2c_bus)
40 | case _:
41 | ps._sensor = None
42 |
43 | if ps._sensor is None:
44 | self.logger.error(f"Sensor({ps.name}) device initialization is Failed.")
45 | else:
46 | if ps._sensor.initSensor(ps.maximum_current, ps.shunt_resistor, ps.phase_multiplier):
47 | self.power_sensors.append(ps)
48 | self.logger.debug(f"Sensor({ps.name}) device initialization Successfully.")
49 | else:
50 | self.logger.error(f"Sensor({ps.name}) device is not found !")
51 |
52 | directory = os.path.dirname(RAFT_DIR + '.raft/')
53 | if directory and not os.path.exists(directory):
54 | os.makedirs(directory)
55 | bootvoltage_path = os.path.join(directory, 'bootvoltage')
56 |
57 | db = dbm.dumb.open(bootvoltage_path, 'c')
58 | for v in pm_voltages:
59 | v._output = None
60 | match v.part_name:
61 | case 'IR35215'| 'IRPS5401' | 'IR38164' | 'IR38064' | 'IR38060'\
62 | | 'TPS53681' | 'TPS546B24A' | 'TPS546D24A' | 'TPS544B25'\
63 | | 'MPQ2283' | 'MPQ2285' | 'MPQ72963':
64 | v._output = PMBusRegulator(device_name=v.part_name, device_path=v.i2c_bus, device_address=v.i2c_address, page=v.page_select, pmbus_vout_mode=v.pmbus_vout_mode, phase=v.phase)
65 | case 'MPM54322' | 'MPM54522':
66 | v._output = MPSRegulator(device_path=v.i2c_bus, device_address=v.i2c_address, page=v.page_select, phase=v.phase, fb_ratio=v.fb_ratio)
67 | case _:
68 | v._output = None #DefaultRegulator(device_path=v.i2c_bus, device_address=v.i2c_address)
69 | if v._output is None:
70 | self.logger.error(f"Voltage regulator for {v.name} is not defined.")
71 | else:
72 | self.voltages.append(v)
73 | self.logger.debug(f"Regulator Output({v.name}) device initialization Successfully.")
74 | for key, value in db.items():
75 | voltage_name = key.decode('utf-8')
76 | if voltage_name == v.name:
77 | self.SetVoltage(v._output, float(value))
78 | db.close()
79 | self.logger.info("Inside PMIC Constructor")
80 |
81 | @staticmethod
82 | def GetLogger():
83 | log_level = logging.ERROR
84 | logging.basicConfig(format="%(levelname)s:%(message)s")
85 | logger = logging.getLogger(__name__)
86 | try:
87 | handler_set_check = getattr(logger, 'handler_set')
88 | except AttributeError:
89 | handler_set_check = False
90 | if not handler_set_check:
91 | logger.setLevel(log_level)
92 | logger.handler_set = True
93 | logger.disabled = False
94 | return logger
95 |
96 | def GetPythonLogLevels(self):
97 | return get_python_log_levels()
98 |
99 | def SetServerLogLevel(self, PythonLogLevel):
100 | self.logger.debug(f"PythonLogLevel = {PythonLogLevel}")
101 | LogLevelsDict = get_python_log_levels()
102 | if PythonLogLevel == LogLevelsDict["DEBUG"]:
103 | self.logger.setLevel(logging.DEBUG)
104 | elif PythonLogLevel == LogLevelsDict["INFO"]:
105 | self.logger.setLevel(logging.INFO)
106 | elif PythonLogLevel == LogLevelsDict["WARNING"]:
107 | self.logger.setLevel(logging.WARNING)
108 | elif PythonLogLevel == LogLevelsDict["ERROR"]:
109 | self.logger.setLevel(logging.ERROR)
110 | else:
111 | self.logger.setLevel(logging.CRITICAL)
112 | return
113 |
114 | def GetBoardInfo(self, eeprom, has_pdi):
115 | boardinfo = {}
116 | i2c = I2C(eeprom.I2C_Bus)
117 | bytes = bytearray(256)
118 | try:
119 | msgs = [I2C.Message([0x0, 0x0]), I2C.Message(bytes, read=True)]
120 | i2c.transfer(eeprom.I2C_Addr, msgs)
121 | eeprom_data = msgs[1].data
122 | #print(''.join('{:02x} '.format(x) for x in eeprom_data))
123 | offset = 0xA
124 | boardinfo["Language"] = eeprom_data[offset]
125 |
126 | if has_pdi is not None:
127 | boardinfo["Silicon Revision"] = "PROD"
128 | else:
129 | boardinfo["Silicon Revision"] = ""
130 |
131 | build_date = datetime.datetime(1996, 1, 1)
132 | minutes = (eeprom_data[0xd] << 16 | eeprom_data[0xc] << 8 | eeprom_data[0xb])
133 | time_delta = datetime.timedelta(minutes=minutes)
134 | build_date += time_delta
135 | time_string = build_date.strftime('%c')
136 | boardinfo['Manufacturing Date'] = time_string
137 |
138 | offset = 0xe
139 | length = int.from_bytes(eeprom_data[offset:offset+1], "big")
140 | length &= 0x3f
141 | boardinfo["Manufacturer"] = eeprom_data[(offset+1):((offset+1) + length)].decode("utf-8").strip('\x00')
142 |
143 | offset = offset + length + 1
144 | length = int.from_bytes(eeprom_data[offset:offset+1], "big")
145 | length &= 0x3f
146 | boardinfo["Product Name"] = eeprom_data[(offset+1):((offset+1) + length)].decode("utf-8").strip('\x00')
147 |
148 | offset = offset + length + 1
149 | length = int.from_bytes(eeprom_data[offset:offset+1], "big")
150 | length &= 0x3f
151 | boardinfo["Board Serial Number"] = eeprom_data[(offset+1):((offset+1) + length)].decode("utf-8").strip('\x00')
152 |
153 | offset = offset + length + 1
154 | length = int.from_bytes(eeprom_data[offset:offset+1], "big")
155 | length &= 0x3f
156 | boardinfo["Board Part Number"] = eeprom_data[(offset+1):((offset+1) + length)].decode("utf-8").strip('\x00')
157 |
158 | offset = offset + length + 1
159 | length = int.from_bytes(eeprom_data[offset:offset+1], "big")
160 | length &= 0x3f
161 | #/* Skip FRU File ID */
162 | offset = offset + length + 1
163 | length = int.from_bytes(eeprom_data[offset:offset+1], "big")
164 | length &= 0x3f
165 | boardinfo["Board Revision"] = eeprom_data[(offset+1):((offset+1) + length)].decode("utf-8").strip('\x00')
166 | except IOError:
167 | logging.error(f"Onboard {eeprom.Name} Eeprom read failed!")
168 | finally:
169 | i2c.close()
170 | return boardinfo
171 |
172 | def EnableVoltage(self, o):
173 | self.logger.debug(f"EnableVoltage({o.addr}@{o.i2c.devpath})")
174 | o.enable_output()
175 |
176 | def DisableVoltage(self, o):
177 | self.logger.debug(f"DisableVoltage({o.addr}@{o.i2c.devpath})")
178 | o.shutdown_output()
179 |
180 | def GetRegulator(self, o):
181 | self.logger.debug(f"GetRegulator({o.addr}@{o.i2c.devpath})")
182 | return o.read_telemetry_all()
183 |
184 | def GetVoltage(self, o):
185 | self.logger.debug("GetVoltage(0x{0:02x}@{1})".format(o.addr, o.i2c.devpath))
186 | return o.read_voltage()
187 |
188 | def SetVoltage(self, o, val):
189 | self.logger.debug("SetVoltage(0x{0:02x}@{1}, {2})".format(o.addr, o.i2c.devpath, val))
190 | o.set_voltage(val)
191 |
192 | def GetPowerSensorConf(self, s):
193 | self.logger.debug("GetPowerSensorConf(0x{0:02x}@{1})".format(s.addr, s.i2c.devpath))
194 | return s.readRegisterValues()
195 |
196 | def SetPowerSensorConf(self, s, data):
197 | self.logger.debug("SetPowerSensorConf(0x{0:02x}@{1})".format(s.addr, s.i2c.devpath))
198 | s.writeRegisterValues(data)
199 |
200 | def GetSensorValues(self, s):
201 | self.logger.debug("GetSensorValues(0x{0:02x}@{1})".format(s.addr, s.i2c.devpath))
202 | vbus = round(s.getBusVoltage(), 4)
203 | current = round(s.getCurrent(), 4)
204 | power = round(s.getPower(), 4)
205 | return vbus, current, power
206 |
207 | def __del__(self):
208 | self.logger.info("Inside PMIC Destructor")
209 |
--------------------------------------------------------------------------------
/xserver/utils/utils.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | __author__ = "Dragan Cvetic"
5 | __copyright__ = "Copyright 2021, Xilinx"
6 |
7 | import logging
8 | import base64
9 | from cffi import FFI
10 | import os
11 | import sys
12 | import subprocess
13 | import re
14 |
15 | RAFT_DIR = '/usr/share/raft/'
16 | DEFAULT_PORT_NUMBER=9090
17 |
18 | ffi = FFI()
19 |
20 |
21 | def open_c_library(c_libhdr, c_lib):
22 | file_data = None
23 | lib_handle = None
24 | hdr = None
25 | try:
26 | hdr = open(c_libhdr, "r")
27 | file_data = hdr.read()
28 | ffi.cdef(file_data)
29 | hdr.close()
30 | except FileNotFoundError:
31 | logging.error("[xserver]: Unable to find '%s'" % c_libhdr)
32 | pass
33 | except IOError:
34 | logging.error("[xserver]: Unable to open '%s'" % c_libhdr)
35 | pass
36 | try:
37 | lib_handle = ffi.dlopen(c_lib)
38 | except IOError:
39 | logging.error("[xserver]: Unable to open '%s'" % c_lib)
40 | pass
41 | return lib_handle
42 |
43 | def open_packed_c_library(c_libhdr, c_lib):
44 | file_data = None
45 | lib_handle = None
46 | hdr = None
47 | try:
48 | hdr = open(c_libhdr, "r")
49 | file_data = hdr.read()
50 | ffi.cdef(file_data, pack=1)
51 | hdr.close()
52 | except FileNotFoundError:
53 | logging.error("[xserver]: Unable to find '%s'" % c_libhdr)
54 | pass
55 | except IOError:
56 | logging.error("[xserver]: Unable to open '%s'" % c_libhdr)
57 | pass
58 | try:
59 | lib_handle = ffi.dlopen(c_lib)
60 | except IOError:
61 | logging.error("[xserver]: Unable to open '%s'" % c_lib)
62 | pass
63 | return lib_handle
64 |
65 |
66 | def struct_to_py(CdataPtr, TypeFields):
67 | for Fld, FldType in TypeFields:
68 | if FldType.type.kind == 'primitive' or FldType.type.kind == 'enum':
69 | yield (Fld, getattr(CdataPtr, Fld))
70 | else:
71 | yield (Fld, cdata_to_py(getattr(CdataPtr, Fld)))
72 |
73 |
74 | def array_to_py(CdataPtr):
75 | Type = ffi.typeof(CdataPtr)
76 | if Type.item.kind == 'primitive':
77 | if Type.item.cname == 'wchar_t' or Type.item.cname == 'char':
78 | return ffi.string(CdataPtr)
79 | else:
80 | return [CdataPtr[m] for m in range(Type.length)]
81 | else:
82 | return [cdata_to_py(CdataPtr[m]) for m in range(Type.length)]
83 |
84 |
85 | def cdata_to_py(CdataPtr):
86 | Type = ffi.typeof(CdataPtr)
87 | if Type.kind == 'struct':
88 | return dict(struct_to_py(CdataPtr, Type.fields))
89 | elif Type.kind == 'primitive':
90 | return int(CdataPtr)
91 | elif Type.kind == 'array':
92 | return array_to_py(CdataPtr)
93 |
94 | def cptr_to_pylist(CdataPtr, len):
95 | List = []
96 | for i in range(len):
97 | List.append(CdataPtr[i])
98 | return List
99 |
100 | def cdata_string_to_py(CdataPtr):
101 | return ffi.string(CdataPtr)
102 |
103 | def extract_b64_encoded_string(var):
104 | # if it is b64 encoded, extract the data
105 | if isinstance(var, dict):
106 | b64_data = var['data']
107 | b64_bytes_data = b64_data.encode('ascii')
108 | msg_bytes_data = base64.b64decode(b64_bytes_data)
109 | data = msg_bytes_data.decode('ascii')
110 | # otherwise, consider it as a string and return it
111 | else:
112 | data = var
113 | data = bytes(data, 'utf-8')
114 | return data
115 |
116 | def get_ip_and_port():
117 | if (len(sys.argv) > 1):
118 | ipaddr = sys.argv[1]
119 | else:
120 | ip_end0 = subprocess.run(['ip', 'addr', 'show', 'end0'], capture_output=True, text=True)
121 | ip_stdout = ip_end0.stdout
122 |
123 | found = re.search(r'inet (\d+\.\d+\.\d+\.\d+)', ip_stdout)
124 | if found:
125 | ipaddr = found.group(1)
126 | else:
127 | ipaddr = "0.0.0.0"
128 |
129 | if (len(sys.argv) > 2):
130 | port = int(sys.argv[2])
131 | else:
132 | port = DEFAULT_PORT_NUMBER
133 |
134 | return ipaddr, port
135 |
136 | def convert_to_bytearray(data):
137 | bb = bytearray()
138 | for i in range(len(data)):
139 | c = data[i].to_bytes(4, byteorder='little', signed=False)
140 | bb.extend(c)
141 | return bb
142 |
143 | def convert_to_list(data):
144 | k = []
145 | for i in range(int(len(data)/4)):
146 | k.append(int.from_bytes(data[(i*4):(((i+1)*4))], byteorder='little'))
147 | return k
148 |
149 | def get_python_log_levels():
150 | python_log_level = {
151 | "DEBUG": 4,
152 | "INFO": 3,
153 | "WARNING": 2,
154 | "ERROR": 1,
155 | "CRITICAL": 0
156 | }
157 | return python_log_level
158 |
159 | def getkey_from_listbeginvalue(dictionary, value):
160 | found = 0
161 | key = 0
162 | for key, listvalue in dictionary.items():
163 | if listvalue[0] == value:
164 | found = 1
165 | break
166 | return found, key
167 |
168 | xhelper_handle = open_c_library(RAFT_DIR + "xserver/xcffi/drv_header/board_common/xhelper.h", "/usr/lib/libxhelper.so.1")
169 |
--------------------------------------------------------------------------------
/xserver/xcffi/drv_api/data_stream/data_transfer_no_dma/axi_memmap_c.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | __author__ = "Anish Kadamathikuttiyil Karthikeyan Pillai"
5 | __copyright__ = "Copyright 2021, Xilinx"
6 |
7 | import sys
8 | RAFT_DIR = '/usr/share/raft/'
9 | sys.path.append(RAFT_DIR + 'xserver/utils')
10 | import logging
11 | from utils import ffi, open_c_library
12 | import logging
13 |
14 | axi_memmap_handle = open_c_library(
15 | RAFT_DIR + "xserver/xcffi/drv_header/data_stream/data_transfer_no_dma/axi_memmap.h",
16 | "/usr/lib/libaximemmap.so.1",
17 | )
18 |
19 |
20 | class AXI_MEMMAP_C(object):
21 | def __init__(self):
22 | logging.info("Inside AXI_MEMMAP_C Constructor")
23 | pass
24 |
25 | def axi_read_words(self, address, num_words, network_order):
26 | """
27 | Read num_words from address.
28 |
29 | :param address: address to read from
30 | :param num_words: number of words to read
31 | :param network_order: Apply network byte ordering if network_order!=0
32 | :return: ret: whether success or failure
33 | buf: the read data
34 |
35 | """
36 | buf = ffi.new("unsigned int[]", num_words)
37 | ret = axi_memmap_handle.axi_read_words(address, num_words, buf, network_order)
38 | buf = [buf[k] for k in range(num_words)]
39 | if ret == 0:
40 | logging.info("axi_read_words returned success")
41 | else:
42 | logging.info("axi_read_words returned failure ret = ", ret)
43 | return ret, buf
44 |
45 | def axi_write_words(self, address, num_words, buf, network_order):
46 | """
47 | Write num_words to address.
48 |
49 | :param address: address to write
50 | :param num_words: number of words to write
51 | :param buffer: data to write
52 | :param network_order: Apply network byte ordering if network_order!=0
53 | :return: ret: whether success or failure
54 |
55 | """
56 | buf_in = ffi.new("unsigned int[]", buf)
57 | ret = axi_memmap_handle.axi_write_words(
58 | address, num_words, buf_in, network_order
59 | )
60 | if ret == 0:
61 | logging.info("axi_write_words returned success")
62 | else:
63 | logging.info("axi_write_words returned failure ret = ", ret)
64 | return ret
65 |
66 | def __del__(self):
67 | logging.info("Inside AXI_MEMMAP_C Destructor")
68 |
--------------------------------------------------------------------------------
/xserver/xcffi/drv_api/pat/i2c_server.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | __author__ = "Hugh Maguire"
5 | __copyright__ = "Copyright 2021, Xilinx"
6 |
7 | import sys
8 | RAFT_DIR = '/usr/share/raft/'
9 | sys.path.append(RAFT_DIR + 'xserver/utils')
10 | import Pyro4
11 | import logging
12 | import base64
13 | from cffi import FFI
14 | from utils import ffi, xhelper_handle, open_c_library, cdata_to_py
15 | from utils import extract_b64_encoded_string, cdata_string_to_py
16 |
17 | i2c_handle = open_c_library(RAFT_DIR+"xserver/xcffi/drv_header/pat/xi2c_python.h", "/usr/lib/libXI2c.so.1")
18 |
19 | @Pyro4.expose
20 | class I2C(object):
21 | i2c_dict = {}
22 |
23 | def __init__(self):
24 | ret = xhelper_handle.XHelper_MetalInit(xhelper_handle.METAL_LOG_ERROR)
25 | if 0 != ret:
26 | logging.error("I2C: XHelper_MetalInit failed. ret = ", ret)
27 | logging.info("Inside I2C Constructor")
28 | pass
29 |
30 | # System initialization API
31 | def XI2c_Initialize(self, device):
32 | """
33 | API Initialise one instance of an I2c driver.
34 |
35 | :param device: contains the number of the i2c device
36 | :return: pointer to instance if successful, NULL on error.
37 |
38 | """
39 | logging.debug("XI2c_Initialize(Init)")
40 | Inst_ptr = ffi.new("XI2c *")
41 | ret = i2c_handle.XI2c_Initialize(Inst_ptr, device)
42 | Inst = cdata_to_py(Inst_ptr[0])
43 | self.i2c_dict[0] = Inst_ptr
44 | return ret
45 |
46 | def XI2c_ReadINA226Reg(self, addr, reg):
47 | """
48 | API Read a INA226 register.
49 |
50 | :param addr: addr of INA226 device
51 | :param reg: register to be read
52 | :return: ret_code, pointer unsigned short
53 |
54 | """
55 |
56 | Inst_ptr = self.i2c_dict[0];
57 | Val_ptr = ffi.new("unsigned short *")
58 |
59 | ret = i2c_handle.XI2c_ReadINA226Reg(Inst_ptr, addr, reg, Val_ptr)
60 | return ret, Val_ptr[0]
61 |
62 | def XI2c_WriteINA226Reg(self, addr, reg, val):
63 |
64 | """
65 | API Write an INA266 register
66 |
67 | :param addr: addr of INA226 device
68 | :param reg: register to be read
69 | :param val: value to be written
70 | :return: ret_code
71 |
72 | """
73 | Inst_ptr = self.i2c_dict[0];
74 |
75 | ret = i2c_handle.XI2c_WriteINA226Reg(Inst_ptr, addr, reg, val)
76 | return ret
77 |
78 | # System initialization API
79 | def XI2c_Release(self):
80 | """
81 | API Release an Instance of I2c driver
82 | """
83 | Inst_ptr = self.i2c_dict[0]
84 | logging.debug("XI2c_Release()")
85 | i2c_handle.XI2c_Release(Inst_ptr)
86 | return
87 |
88 | def __del__(self):
89 | logging.info("Inside I2C Destructor")
90 |
91 | """
92 | Some quick test code
93 | """
94 |
95 | #if __name__ == "__main__" :
96 | # I2c = I2C()
97 | # I2c.XI2c_Initialize(2)
98 | # Inst_ptr = I2c.i2c_dict[0]
99 | # Inst = cdata_to_py(Inst_ptr[0])
100 | # ret, val_ptr = I2c.XI2c_ReadINA226Reg(0x43, 0x5)
101 | # print(hex(val_ptr[0]))
102 | # ret = I2c.XI2c_WriteINA226Reg(0x43, 0x5, 0x1234)
103 | # ret, val_ptr = I2c.XI2c_ReadINA226Reg(0x43, 0x5)
104 | # print(hex(val_ptr[0]))
105 | # pass
106 |
--------------------------------------------------------------------------------
/xserver/xcffi/drv_api/pat/sysmon_server.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | __author__ = "Hugh Maguire"
5 | __copyright__ = "Copyright 2021, Xilinx"
6 |
7 | import sys
8 | RAFT_DIR = '/usr/share/raft/'
9 | sys.path.append(RAFT_DIR + 'xserver/utils')
10 | import Pyro4
11 | import logging
12 | import base64
13 | from cffi import FFI
14 | from utils import ffi, xhelper_handle, open_c_library, cdata_to_py
15 | from utils import extract_b64_encoded_string, cdata_string_to_py
16 |
17 | sysmon_handle = open_c_library(RAFT_DIR+"xserver/xcffi/drv_header/pat/xsysmon_python.h", "/usr/lib/libXSysmon.so.1")
18 |
19 | @Pyro4.expose
20 | class SYSMON(object):
21 |
22 | def __init__(self):
23 | ret = xhelper_handle.XHelper_MetalInit(xhelper_handle.METAL_LOG_ERROR)
24 | if 0 != ret:
25 | logging.error("SYSMON: XHelper_MetalInit failed. ret = ", ret)
26 | logging.info("Inside Sysmon Constructor")
27 | pass
28 |
29 | def XSysmon_ReadValue(self, idStr):
30 | """
31 | API Read a INA226 register.
32 |
33 | :param addr: addr of INA226 device
34 | :param reg: register to be read
35 | :return: ret_code, pointer unsigned short
36 |
37 | """
38 | logging.info("Inside XSysmon_ReadValue")
39 | idStr = idStr.encode('ascii')
40 |
41 | Val_ptr = ffi.new("float *")
42 |
43 | ret = sysmon_handle.XSysmon_ReadValue(idStr, Val_ptr)
44 | return ret, Val_ptr[0]
45 |
46 |
47 |
48 | def __del__(self):
49 | logging.info("Inside Sysmon Destructor")
50 |
51 | #if __name__ == "__main__" :
52 | # Sysmon = SYSMON()
53 | # ret, val = Sysmon.XSysmon_ReadValue("in_temp0_ps_temp")
54 |
--------------------------------------------------------------------------------
/xserver/xcffi/drv_api/rfdc/rfclk_server.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
2 | # Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All Rights Reserved.
3 | # SPDX-License-Identifier: BSD-3-Clause
4 |
5 | __author__ = "Anish Kadamathikuttiyil Karthikeyan Pillai"
6 | __copyright__ = "Copyright 2021, Xilinx"
7 |
8 | import sys
9 | RAFT_DIR = '/usr/share/raft/'
10 | sys.path.append(RAFT_DIR + 'xserver/utils')
11 | import logging
12 | import json
13 | from utils import ffi, open_c_library, cdata_to_py, xhelper_handle
14 | from utils import get_python_log_levels
15 |
16 | rfclk_handle = open_c_library(RAFT_DIR + "xserver/xcffi/drv_header/rfdc/xrfclk_h_python.h", "/usr/lib/librfclk.so.1")
17 |
18 |
19 | class RFCLK(object):
20 | MAX_DATA_SIZE_LMK = 128
21 | MAX_DATA_SIZE_LMX = 116
22 | RFCLK_LMX2594_1 = 0
23 | RFCLK_LMX2594_2 = 1
24 | RFCLK_LMK = 2
25 | max_size = 0
26 | logger = None
27 |
28 | def __init__(self):
29 | self.logger = self.GetLogger()
30 | ret = xhelper_handle.XHelper_MetalInit(xhelper_handle.METAL_LOG_ERROR)
31 | if 0 != ret:
32 | self.logger.error("RFCLK: XHelper_MetalInit failed. ret = ", ret)
33 | self.logger.info(f"Inside RFCLK Constructor")
34 | pass
35 |
36 | @staticmethod
37 | def GetLogger():
38 | """
39 | Static method to get the logger for the class.
40 | Default loglevel is set inside this class
41 |
42 | :return: logger
43 |
44 | """
45 | log_level = logging.ERROR
46 | logging.basicConfig(format="%(levelname)s:%(message)s")
47 | logger = logging.getLogger(__name__)
48 | try:
49 | handler_set_check = getattr(logger, 'handler_set')
50 | except AttributeError:
51 | handler_set_check = False
52 | if not handler_set_check:
53 | logger.setLevel(log_level)
54 | logger.handler_set = True
55 | logger.disabled = False
56 | return logger
57 |
58 | def GetPythonLogLevels(self):
59 | """
60 | Return the logging levels supported by logging library in python
61 |
62 | :param : None
63 | :return: Dictionary showing the log levels supported by logging library
64 | """
65 | return get_python_log_levels()
66 |
67 | def SetServerLogLevel(self, PythonLogLevel):
68 | """
69 | Set the python log level to the given level
70 |
71 | :param : Log level to set
72 | :return: None
73 | """
74 | self.logger.debug(f"PythonLogLevel = {PythonLogLevel}")
75 | LogLevelsDict = get_python_log_levels()
76 | if PythonLogLevel == LogLevelsDict["DEBUG"]:
77 | self.logger.setLevel(logging.DEBUG)
78 | elif PythonLogLevel == LogLevelsDict["INFO"]:
79 | self.logger.setLevel(logging.INFO)
80 | elif PythonLogLevel == LogLevelsDict["WARNING"]:
81 | self.logger.setLevel(logging.WARNING)
82 | elif PythonLogLevel == LogLevelsDict["ERROR"]:
83 | self.logger.setLevel(logging.ERROR)
84 | else:
85 | self.logger.setLevel(logging.CRITICAL)
86 | return
87 |
88 | def SetMetalLogLevel(self, MetalLogLevel):
89 | """
90 | Set the metal log level to the given level
91 |
92 | :param : Log level to set
93 | :return: None
94 | """
95 | self.logger.debug(f"SetMetalLogLevel({MetalLogLevel})")
96 | metal_log_level = ffi.typeof("enum metal_log_level").relements
97 | if MetalLogLevel == metal_log_level["METAL_LOG_DEBUG"]:
98 | xhelper_handle.XHelper_MetalSetLogLevel(xhelper_handle.METAL_LOG_DEBUG)
99 | elif MetalLogLevel == metal_log_level["METAL_LOG_INFO"]:
100 | xhelper_handle.XHelper_MetalSetLogLevel(xhelper_handle.METAL_LOG_INFO)
101 | elif MetalLogLevel == metal_log_level["METAL_LOG_NOTICE"]:
102 | xhelper_handle.XHelper_MetalSetLogLevel(xhelper_handle.METAL_LOG_NOTICE)
103 | elif MetalLogLevel == metal_log_level["METAL_LOG_WARNING"]:
104 | xhelper_handle.XHelper_MetalSetLogLevel(xhelper_handle.METAL_LOG_WARNING)
105 | elif MetalLogLevel == metal_log_level["METAL_LOG_ERROR"]:
106 | xhelper_handle.XHelper_MetalSetLogLevel(xhelper_handle.METAL_LOG_ERROR)
107 | elif MetalLogLevel == metal_log_level["METAL_LOG_CRITICAL"]:
108 | xhelper_handle.XHelper_MetalSetLogLevel(xhelper_handle.METAL_LOG_CRITICAL)
109 | elif MetalLogLevel == metal_log_level["METAL_LOG_ALERT"]:
110 | xhelper_handle.XHelper_MetalSetLogLevel(xhelper_handle.METAL_LOG_ALERT)
111 | else:
112 | xhelper_handle.XHelper_MetalSetLogLevel(xhelper_handle.METAL_LOG_EMERGENCY)
113 | return
114 |
115 | def GetRfclkMacro(self):
116 | """
117 | Return Dictionary with all RFCLK macros in the rfclk header file
118 |
119 | :param : None
120 | :return: Dictionary with all RFCLK macros in the rfclk header file
121 | """
122 | rfclk_macro = {}
123 | rfclk_macro["XST_SUCCESS"] = rfclk_handle.XST_SUCCESS
124 | rfclk_macro["XST_FAILURE"] = rfclk_handle.XST_FAILURE
125 | rfclk_macro["RFCLK_LMX2594_1"] = rfclk_handle.RFCLK_LMX2594_1
126 | rfclk_macro["RFCLK_LMX2594_2"] = rfclk_handle.RFCLK_LMX2594_2
127 | rfclk_macro["RFCLK_LMK"] = rfclk_handle.RFCLK_LMK
128 | rfclk_macro["RFCLK_CHIP_NUM"] = rfclk_handle.RFCLK_CHIP_NUM
129 | rfclk_macro["LMK_COUNT"] = rfclk_handle.LMK_COUNT
130 | rfclk_macro["LMK_FREQ_NUM"] = rfclk_handle.LMK_FREQ_NUM
131 | rfclk_macro["LMX_ADC_NUM"] = rfclk_handle.LMX_ADC_NUM
132 | rfclk_macro["LMX_DAC_NUM"] = rfclk_handle.LMX_DAC_NUM
133 | rfclk_macro["LMX2594_COUNT"] = rfclk_handle.LMX2594_COUNT
134 | rfclk_macro["FREQ_LIST_STR_SIZE"] = rfclk_handle.FREQ_LIST_STR_SIZE
135 | return rfclk_macro
136 |
137 | def GetEnum_metal_log_level(self):
138 | """
139 | Return Dictionary equivalent of enum metal_log_level
140 |
141 | :param : None
142 | :return: Dictionary equivalent of enum metal_log_level
143 | """
144 | metal_log_level = ffi.typeof("enum metal_log_level").relements
145 | self.logger.debug(f"metal_log_level = {json.dumps(metal_log_level, indent=2)}")
146 | return metal_log_level
147 |
148 | def XRFClk_Init(self, GpioId):
149 | ret = rfclk_handle.XRFClk_Init(GpioId)
150 | self.logger.debug(f"\nret = XRFClk_Init({GpioId})")
151 | self.logger.debug(f"The return value is: {ret}")
152 | return ret
153 |
154 | def XRFClk_ResetChip(self, ChipId):
155 | self.logger.debug(f"\nret = XRFClk_ResetChip({ChipId})")
156 | ret = rfclk_handle.XRFClk_ResetChip(ChipId)
157 | self.logger.debug(f"The return value is: {ret}")
158 | return ret
159 |
160 | def XRFClk_SetConfigOnOneChipFromConfigId(self, ChipId, ConfigId):
161 | self.logger.debug(
162 | f"\nret = XRFClk_SetConfigOnOneChipFromConfigId({ChipId}, {ConfigId})"
163 | )
164 | ret = rfclk_handle.XRFClk_SetConfigOnOneChipFromConfigId(ChipId, ConfigId)
165 | self.logger.debug(f"The return value is: {ret}")
166 | return ret
167 |
168 | def XRFClk_GetConfigFromOneChip(self, ChipId):
169 | if ChipId == self.RFCLK_LMK:
170 | self.max_size = self.MAX_DATA_SIZE_LMK
171 | else:
172 | self.max_size = self.MAX_DATA_SIZE_LMX
173 | CfgData = ffi.new("unsigned int a[]", self.max_size)
174 | self.logger.debug(f"\nret = XRFClk_GetConfigFromOneChip({ChipId}, {CfgData})")
175 | ret = rfclk_handle.XRFClk_GetConfigFromOneChip(ChipId, CfgData)
176 | self.logger.debug(f"The return value is {ret}")
177 | self.logger.debug(f"The Configuration data is the following:")
178 | print("[{}]".format(", ".join(hex(x) for x in CfgData)))
179 | return list(CfgData)
180 |
181 | def XRFClk_SetConfigOnAllChipsFromConfigId(
182 | self, ConfigId_LMK, ConfigId_1, ConfigId_2
183 | ):
184 | self.logger.debug(
185 | f"\nret = XRFClk_SetConfigOnAllChipsFromConfigId({ConfigId_LMK}, {ConfigId_1}, {ConfigId_2}"
186 | )
187 | ret = rfclk_handle.XRFClk_SetConfigOnAllChipsFromConfigId(
188 | ConfigId_LMK, ConfigId_1, ConfigId_2
189 | )
190 | self.logger.debug(f"The return value is: {ret}")
191 | return ret
192 |
193 | def XRFClk_WriteReg(self, ChipId, Data):
194 | self.logger.debug(f"\nret = XRFClk_WriteReg({ChipId}, {hex(Data)})")
195 | ret = rfclk_handle.XRFClk_WriteReg(ChipId, Data)
196 | self.logger.debug(f"The return value is: {ret}")
197 | return ret
198 |
199 | def XRFClk_ReadReg(self, ChipId):
200 | self.logger.debug(f"\nret = XRFClk_ReadReg({ChipId})")
201 | DataPtr = ffi.new("u32 *")
202 | ret = rfclk_handle.XRFClk_ReadReg(ChipId, DataPtr)
203 | Data = DataPtr[0]
204 | self.logger.debug(f"The return value is {ret} and Data is {Data}")
205 | return Data
206 |
207 | def __del__(self):
208 | self.logger.info("Inside RFCLK Destructor")
209 |
--------------------------------------------------------------------------------
/xserver/xcffi/drv_header/board_common/xhelper.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
3 | * SPDX-License-Identifier: MIT
4 | ******************************************************************************/
5 |
6 | /*****************************************************************************/
7 | /**
8 | *
9 | * @file xhelper.h
10 | * @addtogroup xhelper_v1_0
11 | * @{
12 | *
13 | * Contains the APIs for DFE Mixer component.
14 | *
15 | *
16 | * MODIFICATION HISTORY:
17 | *
18 | * Ver Who Date Changes
19 | * ----- --- -------- -----------------------------------------------
20 | * 1.0 akk 03/29/21 Initial version
21 | *
22 | *
23 | ******************************************************************************/
24 | typedef enum metal_log_level {
25 | METAL_LOG_EMERGENCY = 0, /**< system is unusable. */
26 | METAL_LOG_ALERT, /**< action must be taken immediately. */
27 | METAL_LOG_CRITICAL, /**< critical conditions. */
28 | METAL_LOG_ERROR, /**< error conditions. */
29 | METAL_LOG_WARNING, /**< warning conditions. */
30 | METAL_LOG_NOTICE, /**< normal but significant condition. */
31 | METAL_LOG_INFO, /**< informational messages. */
32 | METAL_LOG_DEBUG, /**< debug-level messages. */
33 | }metal_log_level;
34 | int XHelper_MetalInit(enum metal_log_level loglevel);
35 | void XHelper_MetalSetLogLevel(enum metal_log_level loglevel);
36 |
--------------------------------------------------------------------------------
/xserver/xcffi/drv_header/data_stream/data_transfer_no_dma/axi_memmap.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
3 | * SPDX-License-Identifier: MIT
4 | ******************************************************************************/
5 |
6 | int axi_read_words(uint64_t address, unsigned int num_words, unsigned int *buf,
7 | int network_order);
8 | int axi_write_words(uint64_t address, unsigned int num_words, unsigned int *buf,
9 | int network_order);
10 |
--------------------------------------------------------------------------------
/xserver/xcffi/drv_header/pat/xi2c_python.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
3 | * SPDX-License-Identifier: MIT
4 | ******************************************************************************/
5 |
6 | typedef struct {
7 | int dev;
8 | int i2c_fd;
9 | int IsReady;
10 | } XI2c;
11 |
12 | #define XST_OPEN_DEVICE_FAILED 3
13 |
14 | int XI2c_Initialize(XI2c *InstancePtr, int dev);
15 | int XI2c_Release(XI2c *InstancePtr);
16 | int XI2c_ReadINA226Reg(XI2c *InstancePtr, int addr, unsigned char reg,
17 | unsigned short *val);
18 | int XI2c_WriteINA226Reg(XI2c *InstancePtr, int addr, unsigned char reg,
19 | unsigned short wr_reg);
20 |
21 | #define I2C_SLEEP_US 200 /* I2C sleep period */
22 |
--------------------------------------------------------------------------------
/xserver/xcffi/drv_header/pat/xsysmon_python.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
3 | * SPDX-License-Identifier: MIT
4 | ******************************************************************************/
5 |
6 | int XSysmon_ReadValue(char *strId, float *value);
7 |
--------------------------------------------------------------------------------
/xserver/xcffi/drv_header/rfdc/xrfclk_h_python.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright (C) 2017 - 2021 Xilinx, Inc. All rights reserved.
3 | * SPDX-License-Identifier: MIT
4 | ******************************************************************************/
5 |
6 | /*****************************************************************************/
7 | /**
8 | *
9 | * @file xrfclk.h
10 | * @addtogroup xrfclk
11 | * @{
12 | *
13 | * Contains the API of the XRFclk middleware.
14 | *
15 | *
16 | * MODIFICATION HISTORY:
17 | *
18 | * Ver Who Date Changes
19 | * ----- --- -------- -----------------------------------------------
20 | * 1.0 dc 07/21/19 Initial version
21 | * 1.1 dc 11/21/19 Remove xil dependencies from linux build
22 | * dc 11/25/19 update LMX and LMK configs
23 | * dc 12/05/19 adjust LMX and LMK configs to a rftool needs
24 | * 1.2 dc 22/01/20 add version and list of LMK frequencies
25 | * dc 03/05/20 add protection for shared i2c1 MUX
26 | * 1.3 dc 03/10/20 update LMK/LMX config for MTS
27 | * 1.4 dc 03/30/20 new LMX config suppressing RF noise on dual output
28 | *
29 | *
30 | ******************************************************************************/
31 |
32 | typedef unsigned char u8;
33 | typedef unsigned int u32;
34 | typedef int s32;
35 | #define XST_SUCCESS 0L
36 | #define XST_FAILURE 1L
37 |
38 | #define RFCLK_LMX2594_1 0 /* I0 on MUX and SS3 on Bridge */
39 | #define RFCLK_LMX2594_2 1 /* I1 on MUX and SS2 on Bridge */
40 | #define RFCLK_LMK 2 /* I2 on MUX and SS1 on Bridge */
41 | #define RFCLK_CHIP_NUM 3
42 | #define LMK_COUNT 128
43 | #define LMK_FREQ_NUM 2 /* Number of LMK freq. configs */
44 | #define LMX_ADC_NUM 8 /* Number of LMX ADC configs */
45 | #define LMX_DAC_NUM 24 /* Number of LMX DAC configs */
46 |
47 | #define LMX2594_COUNT 116
48 | #define FREQ_LIST_STR_SIZE 50 /* Frequency string size */
49 |
50 | u32 XRFClk_WriteReg(u32 ChipId, u32 Data);
51 | u32 XRFClk_ReadReg(u32 ChipId, u32 *Data);
52 | u32 XRFClk_Init(int GpioId);
53 | void XRFClk_Close();
54 | u32 XRFClk_ResetChip(u32 ChipId);
55 | u32 XRFClk_SetConfigOnOneChipFromConfigId(u32 ChipId, u32 ConfigId);
56 | u32 XRFClk_SetConfigOnOneChip(u32 ChipId, u32 *cfgData, u32 len);
57 | u32 XRFClk_GetConfigFromOneChip(u32 ChipId, u32 *cfgData);
58 | u32 XRFClk_SetConfigOnAllChipsFromConfigId(u32 ConfigId_LMK, u32 ConfigId_RF1,
59 | u32 ConfigId_RF2);
60 | u32 XRFClk_ControlOutputPortLMK(u32 PortId, u32 state);
61 | u32 XRFClk_ConfigOutputDividerAndMUXOnLMK(u32 PortId, u32 DCLKoutX_DIV,
62 | u32 DCLKoutX_MUX, u32 SDCLKoutY_MUX,
63 | u32 SYSREF_DIV);
64 |
65 | /** @} */
66 |
--------------------------------------------------------------------------------
/xserver/xpyro/data_stream/data_transfer_no_dma/axi_memmap.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2021-2022 Xilinx, Inc. All rights reserved.
2 | # SPDX-License-Identifier: BSD-3-Clause
3 |
4 | __author__ = "Anish Kadamathikuttiyil Karthikeyan Pillai"
5 | __copyright__ = "Copyright 2021, Xilinx"
6 |
7 | import Pyro4
8 | import logging
9 | import base64
10 | from utils import convert_to_bytearray, convert_to_list
11 | import serpent
12 | from axi_memmap_c import AXI_MEMMAP_C
13 |
14 |
15 | class AXI_MEMMAP(object):
16 | memmap_c = None
17 | def __init__(self):
18 | self.memmap_c = AXI_MEMMAP_C()
19 | logging.info("Inside AXI MEMMAP Constructor")
20 | pass
21 |
22 | def axi_read_words(self, address, num_words, network_order):
23 | """
24 | Read num_words from address.
25 |
26 | :param address: address to read from
27 | :param num_words: number of words to read
28 | :param network_order: Apply network byte ordering if network_order!=0
29 | :return: ret: whether success or failure
30 | buf: the read data
31 |
32 | """
33 | ret, buf = self.memmap_c.axi_read_words(address, num_words, network_order)
34 | buf = convert_to_bytearray(buf)
35 | if ret == 0:
36 | logging.info("axi_memmap_c.axi_read_words returned success")
37 | else:
38 | logging.info("axi_memmap_c.axi_read_words returned failure ret = ", ret)
39 | return ret, buf
40 |
41 | def axi_write_words(self, address, num_words, buf, network_order):
42 | """
43 | Write num_words to address.
44 |
45 | :param address: address to write
46 | :param num_words: number of words to write
47 | :param buffer: data to write
48 | :param network_order: Apply network byte ordering if network_order!=0
49 | :return: ret: whether success or failure
50 |
51 | """
52 | if Pyro4.config.SERIALIZER == "serpent" and type(buf) is dict:
53 | buf = serpent.tobytes(buf) # in case of serpent encoded bytes
54 | buf = convert_to_list(buf[0:num_words*4])
55 | ret = self.memmap_c.axi_write_words(address, num_words, buf, network_order)
56 | if ret == 0:
57 | logging.info("axi_memmap_c.axi_write_words returned success")
58 | else:
59 | logging.info("axi_memmap_c.axi_write_words returned failure ret = ", ret)
60 | return ret
61 |
62 | def __del__(self):
63 | logging.info("Inside AXI MEMMAP Destructor")
64 |
65 |
--------------------------------------------------------------------------------