Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python_test_scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
python_test_scripts
Commits
91bc850d
Commit
91bc850d
authored
4 years ago
by
Gijs Schoonderbeek
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup of UniBoard2_I2C.py
parent
8bdc20da
No related branches found
No related tags found
1 merge request
!2
Modified the scripts to run on Raspberry Pi.
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
UniBoard2_I2C.py
+62
-27
62 additions, 27 deletions
UniBoard2_I2C.py
rd_unb2c.py
+16
-23
16 additions, 23 deletions
rd_unb2c.py
with
78 additions
and
50 deletions
UniBoard2_I2C.py
+
62
−
27
View file @
91bc850d
#******************************************#
# I2C address, registers and ports for UNB2c
# Created: 2021-05-11
#******************************************#
EEPROM_I2C_ADDR
=
0x50
#"1010000"
###################################
# General, Point of load converters
###################################
LOC_POWER_CORE
=
0x01
LOC_POWER_ERAM
=
0x0D
LOC_POWER_TR_R
=
0x0E
LOC_POWER_TR_T
=
0x0F
LOC_POWER_BAT
=
0x10
LOC_POWER_IO
=
0x11
LOC_POWER_CORE
=
0x01
#"0000001" # 0x01
CTR_POWER_S_1V0
=
0x0E
LOC_POWER_ERAM
=
0x0D
#"0001101" # 0x0D
CTR_POWER_S_1V2
=
0x0F
LOC_POWER_TR_R
=
0x0E
#"0001110" # 0x0E
CTR_POWER_CLK
=
0x0D
LOC_POWER_TR_T
=
0x0F
#"0001111" # 0x0F
CTR_POWER_QSFP_01
=
0x01
LOC_POWER_BAT
=
0x10
#"0010000" # 0x10
CTR_POWER_QSFP_23
=
0x02
LOC_POWER_IO
=
0x11
#"0010001" # 0x11
SWI_POWER_CORE
=
0x0F
#"0001111" # 0x0F
SWI_POWER_IO
=
0x0E
#"0001110" # 0x0E
CLK_PWR
=
0x0D
#"000000D" # 0x00
QSFP_BOT_PWR
=
0x50
#"0000002" # 0x02
BRICK_PWR
=
0x2c
#"0000002" # 0x02
LP_VOUT_MODE
=
0x20
LP_VOUT_MODE
=
0x20
LP_VOUT
=
0x8B
#
LP_VOUT
=
0x8B
#
LP_temp
=
0x8D
#
LP_temp
=
0x8D
#
LP_IOUT
=
0x8C
LP_IOUT
=
0x8C
QSFP_I2C_ADDR
=
0x50
#"1010000"
###################################
QSFP_TEMP
=
0x16
#"00010110" # (Byte1*256+Byte2)/256
# Central I2C Devices
QSFP_VOLT
=
0x1A
#"00011010" # (Byte1*256+Byte2)*0.0001
###################################
EEPROM
=
0x50
################
# Main I2C switch
################
MAIN_I2C_SWITCH
=
0x071
NODE
=
[]
NODE
.
append
(
0x01
)
NODE
.
append
(
0x02
)
NODE
.
append
(
0x04
)
NODE
.
append
(
0x08
)
FRONT_LED
=
0x20
CTRL_POWER
=
0x10
ETH_TEMP_I2C_ADDR
=
0x4C
#"1001100" # 0x29
################
# Front panel LED
################
LED_DRIVER
=
0x41
LED_COLORS
=
{
"
red
"
:
0x01
,
"
blue
"
:
0x02
,
"
green
"
:
0x04
,
"
magenta
"
:
0x03
,
"
yellow
"
:
0x06
,
"
cyaan
"
:
0x05
}
ETH_LOC_TEMP
=
0x00
#"00000000"
################
ETH_TEMP
=
0x01
#"00000001"
# Node I2C switch
################
NODE_I2C_SWITCH
=
0x072
QSFP_PORT
=
[]
QSFP_PORT
.
append
(
0x08
)
QSFP_PORT
.
append
(
0x04
)
QSFP_PORT
.
append
(
0x02
)
QSFP_PORT
.
append
(
0x01
)
QSFP_PORT
.
append
(
0x40
)
QSFP_PORT
.
append
(
0x80
)
DDR4
=
0x10
LOC_POWER
=
0x20
###################################
# Node I2C Devices
###################################
QSFP_I2C_ADDR
=
0x50
QSFP_TEMP
=
0x16
QSFP_VOLT
=
0x1A
MB_I_TEMP_I2C_ADDR
=
0x18
MB_I_TEMP_I2C_ADDR
=
0x18
MB_II_TEMP_I2C_ADDR
=
0x19
MB_II_TEMP_I2C_ADDR
=
0x19
...
@@ -39,11 +79,6 @@ MB_DATE_bytes = 2
...
@@ -39,11 +79,6 @@ MB_DATE_bytes = 2
MB_TYPE_NR
=
0x149
MB_TYPE_NR
=
0x149
MB_TYPE_NR_bytes
=
20
MB_TYPE_NR_bytes
=
20
PWR_CLK_I2C_ADDR
=
"
0001101
"
# 0x0D
PWR_S3V3_I2C_ADDR
=
"
0001110
"
# 0x0E
PWR_S1V2_I2C_ADDR
=
"
0001111
"
# 0x0E
######################
######################
# Functions
# Functions
######################
######################
...
...
This diff is collapsed.
Click to expand it.
rd_unb2c.py
+
16
−
23
View file @
91bc850d
...
@@ -15,16 +15,9 @@ else:
...
@@ -15,16 +15,9 @@ else:
from
UniBoard2_I2C
import
*
from
UniBoard2_I2C
import
*
I2CBUSNR
=
3
I2CBUSNR
=
3
QSFP_PORT
=
[]
QSFP_PORT
.
append
(
0x08
)
QSFP_PORT
.
append
(
0x04
)
QSFP_PORT
.
append
(
0x02
)
QSFP_PORT
.
append
(
0x01
)
QSFP_PORT
.
append
(
0x40
)
QSFP_PORT
.
append
(
0x80
)
def
rw_eeprom
(
value
=
0xAB
):
def
rw_eeprom
(
value
=
0xAB
):
I2C_eeprom
=
I2C
(
0x53
)
I2C_eeprom
=
I2C
(
EEPROM
)
I2C_eeprom
.
bus
=
I2CBUSNR
I2C_eeprom
.
bus
=
I2CBUSNR
ret_ack
,
ret_value
=
I2C_eeprom
.
read_bytes
(
0
)
ret_ack
,
ret_value
=
I2C_eeprom
.
read_bytes
(
0
)
if
ret_ack
<
1
:
if
ret_ack
<
1
:
...
@@ -37,20 +30,20 @@ def rw_eeprom(value=0xAB):
...
@@ -37,20 +30,20 @@ def rw_eeprom(value=0xAB):
stri
=
"
Wrote to EEPROM: 0x{0:X}, Read from EEPROM: 0x{1}
"
.
format
(
value
,
ret_value
)
stri
=
"
Wrote to EEPROM: 0x{0:X}, Read from EEPROM: 0x{1}
"
.
format
(
value
,
ret_value
)
print
(
stri
)
print
(
stri
)
def
front_led
(
value
=
0xFF
):
def
front_led
(
collor
):
main_switch
=
I2C
(
0x71
)
main_switch
=
I2C
(
MAIN_I2C_SWITCH
)
main_switch
.
bus
=
I2CBUSNR
main_switch
.
bus
=
I2CBUSNR
ret_ack
=
main_switch
.
write_bytes
(
0x20
,
0x20
)
#select LED
ret_ack
=
main_switch
.
write_bytes
(
0x20
,
0x20
)
#select LED
if
ret_ack
<
1
:
if
ret_ack
<
1
:
print
(
"
Main I2C switch not found
"
)
print
(
"
Main I2C switch not found
"
)
else
:
else
:
front
=
I2C
(
0x41
)
front
=
I2C
(
LED_DRIVER
)
front
.
bus
=
I2CBUSNR
front
.
bus
=
I2CBUSNR
ret_ack
=
front
.
write_bytes
(
0x03
,
0
)
ret_ack
=
front
.
write_bytes
(
0x03
,
0
)
if
ret_ack
<
1
:
if
ret_ack
<
1
:
print
(
"
Front LED driver not found
"
)
print
(
"
Front LED driver not found
"
)
else
:
else
:
front
.
write_bytes
(
0x01
,
value
)
front
.
write_bytes
(
0x01
,
collor
)
sleep
(
0.5
)
sleep
(
0.5
)
for
cnt
in
range
(
6
):
for
cnt
in
range
(
6
):
front
.
write_bytes
(
0x01
,
(
1
<<
cnt
%
3
)
^
0xff
)
front
.
write_bytes
(
0x01
,
(
1
<<
cnt
%
3
)
^
0xff
)
...
@@ -61,14 +54,14 @@ def front_led(value=0xFF):
...
@@ -61,14 +54,14 @@ def front_led(value=0xFF):
def
read_pol
(
node_nr
,
i2c_addr
):
def
read_pol
(
node_nr
,
i2c_addr
):
if
node_nr
>=
0
:
if
node_nr
>=
0
:
main_switch
=
I2C
(
0x71
)
main_switch
=
I2C
(
MAIN_I2C_SWITCH
)
main_switch
.
bus
=
I2CBUSNR
main_switch
.
bus
=
I2CBUSNR
ret_ack
=
main_switch
.
write_bytes
(
0x0
,
0x01
<<
node_nr
)
#select Node
ret_ack
=
main_switch
.
write_bytes
(
0x0
,
0x01
<<
node_nr
)
#select Node
if
ret_ack
<
1
:
if
ret_ack
<
1
:
print
(
"
Main I2C switch not found
"
)
print
(
"
Main I2C switch not found
"
)
return
False
return
False
else
:
else
:
node_switch
=
I2C
(
0x72
)
node_switch
=
I2C
(
NODE_I2C_SWITCH
)
node_switch
.
bus
=
I2CBUSNR
node_switch
.
bus
=
I2CBUSNR
ret_ack
=
node_switch
.
write_bytes
(
0x0
,
0x20
)
#select DDR4
ret_ack
=
node_switch
.
write_bytes
(
0x0
,
0x20
)
#select DDR4
if
ret_ack
<
1
:
if
ret_ack
<
1
:
...
@@ -76,7 +69,7 @@ def read_pol(node_nr, i2c_addr):
...
@@ -76,7 +69,7 @@ def read_pol(node_nr, i2c_addr):
return
False
return
False
else
:
else
:
print
(
"
Central POL
"
)
print
(
"
Central POL
"
)
main_switch
=
I2C
(
0x71
)
main_switch
=
I2C
(
MAIN_I2C_SWITCH
)
main_switch
.
bus
=
I2CBUSNR
main_switch
.
bus
=
I2CBUSNR
ret_ack
=
main_switch
.
write_bytes
(
0x0
,
0x10
)
#select Pol
ret_ack
=
main_switch
.
write_bytes
(
0x0
,
0x10
)
#select Pol
if
ret_ack
<
1
:
if
ret_ack
<
1
:
...
@@ -114,13 +107,13 @@ def read_pol(node_nr, i2c_addr):
...
@@ -114,13 +107,13 @@ def read_pol(node_nr, i2c_addr):
return
True
return
True
def
read_ddr
(
node_nr
=
0
,
module
=
0
):
def
read_ddr
(
node_nr
=
0
,
module
=
0
):
main_switch
=
I2C
(
0x71
)
main_switch
=
I2C
(
MAIN_I2C_SWITCH
)
main_switch
.
bus
=
I2CBUSNR
main_switch
.
bus
=
I2CBUSNR
ret_ack
=
main_switch
.
write_bytes
(
0x0
,
0x01
<<
node_nr
)
#select Node
ret_ack
=
main_switch
.
write_bytes
(
0x0
,
0x01
<<
node_nr
)
#select Node
if
ret_ack
<
1
:
if
ret_ack
<
1
:
print
(
"
Main I2C switch not found
"
)
print
(
"
Main I2C switch not found
"
)
else
:
else
:
node_switch
=
I2C
(
0x72
)
node_switch
=
I2C
(
NODE_I2C_SWITCH
)
node_switch
.
bus
=
I2CBUSNR
node_switch
.
bus
=
I2CBUSNR
ret_ack
=
node_switch
.
write_bytes
(
0x0
,
0x10
)
#select DDR4
ret_ack
=
node_switch
.
write_bytes
(
0x0
,
0x10
)
#select DDR4
if
ret_ack
<
1
:
if
ret_ack
<
1
:
...
@@ -143,13 +136,13 @@ def read_ddr(node_nr = 0, module=0):
...
@@ -143,13 +136,13 @@ def read_ddr(node_nr = 0, module=0):
print
(
stri
)
print
(
stri
)
def
read_qsfp
(
node_nr
=
0
,
module
=
0
):
def
read_qsfp
(
node_nr
=
0
,
module
=
0
):
main_switch
=
I2C
(
0x71
)
main_switch
=
I2C
(
MAIN_I2C_SWITCH
)
main_switch
.
bus
=
I2CBUSNR
main_switch
.
bus
=
I2CBUSNR
ret_ack
=
main_switch
.
write_bytes
(
0x00
,
0x01
<<
node_nr
)
#select Node
ret_ack
=
main_switch
.
write_bytes
(
0x00
,
0x01
<<
node_nr
)
#select Node
if
ret_ack
<
1
:
if
ret_ack
<
1
:
print
(
"
Main I2C switch not found
"
)
print
(
"
Main I2C switch not found
"
)
else
:
else
:
node_switch
=
I2C
(
0x72
)
node_switch
=
I2C
(
NODE_I2C_SWITCH
)
node_switch
.
bus
=
I2CBUSNR
node_switch
.
bus
=
I2CBUSNR
ret_ack
=
node_switch
.
write_bytes
(
0x0
,
QSFP_PORT
[
module
])
#select QSFP cage 1
ret_ack
=
node_switch
.
write_bytes
(
0x0
,
QSFP_PORT
[
module
])
#select QSFP cage 1
if
ret_ack
<
1
:
if
ret_ack
<
1
:
...
@@ -175,16 +168,16 @@ def read_qsfp(node_nr = 0, module=0):
...
@@ -175,16 +168,16 @@ def read_qsfp(node_nr = 0, module=0):
stri
=
"
Voltage QSFP in slot {0} node {1} is {2:3.2f} V
"
.
format
(
module
,
node_nr
,
Power_in_mod
)
stri
=
"
Voltage QSFP in slot {0} node {1} is {2:3.2f} V
"
.
format
(
module
,
node_nr
,
Power_in_mod
)
print
(
stri
)
print
(
stri
)
if
0
:
if
1
:
rw_eeprom
(
0xCD
)
rw_eeprom
(
0xCD
)
front_led
()
front_led
(
LED_COLORS
[
"
green
"
]
)
for
node_cnt
in
range
(
4
):
for
node_cnt
in
range
(
4
):
for
module_cnt
in
range
(
2
):
for
module_cnt
in
range
(
2
):
read_ddr
(
node_nr
=
node_cnt
,
module
=
module_cnt
)
read_ddr
(
node_nr
=
node_cnt
,
module
=
module_cnt
)
for
node_cnt
in
range
(
4
):
for
node_cnt
in
range
(
4
):
for
qsfp_cnt
in
range
(
6
):
for
qsfp_cnt
in
range
(
6
):
read_qsfp
(
node_nr
=
node_cnt
,
module
=
qsfp_cnt
)
read_qsfp
(
node_nr
=
node_cnt
,
module
=
qsfp_cnt
)
else
:
#
else:
for
node_cnt
in
range
(
4
):
for
node_cnt
in
range
(
4
):
read_pol
(
node_cnt
,
LOC_POWER_CORE
)
read_pol
(
node_cnt
,
LOC_POWER_CORE
)
read_pol
(
-
1
,
0x01
)
read_pol
(
-
1
,
0x01
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment