update ( script : nicsensor.sh) update to version 1.1
This commit is contained in:
parent
2e8af56674
commit
9c62eeb8b6
9
02.nicsensor/change_list.txt
Normal file
9
02.nicsensor/change_list.txt
Normal file
@ -0,0 +1,9 @@
|
||||
# Script Version 1.1 20240912
|
||||
Release Note:
|
||||
1.添加根据服务器类型适配 pcie slot 和 i2c对应关系的接口。当前可应用的服务器, 5280M7,5468M7.
|
||||
2.添加debug模式, 当启用debug模式时, 不会执行选通9641和9548的操作,仅执行读取传感器的操作
|
||||
3.考虑到读取寄存器时可能也会操作fpga芯片, 为防止混淆, 修改命令cpld, 名称更改为 chip
|
||||
|
||||
# Script Version 1.0 20240614
|
||||
Release Mote:
|
||||
1.发布初版
|
||||
@ -1,10 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
# script Version 1.0 20240614
|
||||
# script Version 1.1 20240912
|
||||
# 支持测试的传感器芯片 emc1413 ina3221 adc128
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Project Feature Varible (按照项目需要修改)
|
||||
# Project Feature Varible (按照项目需要修改)
|
||||
# ---------------------------------------------------------
|
||||
|
||||
# ADC128 分压系数 (Ravel)
|
||||
@ -17,7 +17,7 @@ votage_division_factor_5="0.6"
|
||||
votage_division_factor_6="0.2326"
|
||||
votage_division_factor_7="1"
|
||||
|
||||
# INA3221 分流电阻, 单位(毫欧姆)(Ravel)
|
||||
# INA3221 分流电阻, 单位(毫欧姆)(Ravel)
|
||||
shunt_resistor_0="2"
|
||||
shunt_resistor_1="2"
|
||||
shunt_resistor_2="5"
|
||||
@ -25,6 +25,10 @@ shunt_resistor_2="5"
|
||||
# fru 烧录的起始地址
|
||||
fru_offset="0x00 0x00"
|
||||
|
||||
# 应用的服务器产品,根据服务器产品手动修改这个变量
|
||||
# 当前适配的服务器产品 5280m7 5468m7
|
||||
server_type="5468m7"
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Common Varible (请勿随意修改)
|
||||
# ---------------------------------------------------------
|
||||
@ -34,10 +38,10 @@ sensor_type=$2
|
||||
chip_slave=$3
|
||||
|
||||
# Introduction of option_data
|
||||
# 1.在FRU的处理过程中,使用option_data来区分是读操作还是写操作,将值设置为
|
||||
# 1.在FRU的处理过程中,使用option_data来区分是读操作还是写操作,将值设置为
|
||||
# "read"或者"write"
|
||||
# 2.在CPLD的处理过程中,使用option_data来代表一条完整的i2c命令,这条命令会
|
||||
# 被发到CPLD上,一个例子:"i2ctransfer -y 12 w2@0x10 0x90 0x00 r9"
|
||||
# 2.在chip的处理过程中,使用option_data来代表一条完整的i2c命令,这条命令会
|
||||
# 被发到chip上,一个例子:"i2ctransfer -y 12 w2@0x10 0x90 0x00 r9"
|
||||
option_data=$4
|
||||
|
||||
# CHIP REGISTER
|
||||
@ -73,6 +77,9 @@ REG_ina3221_bus3="0x06"
|
||||
# Global Varible (请勿随意修改)
|
||||
# ---------------------------------------------------------
|
||||
|
||||
# DEBUG MODE=0 : Disable debug mode
|
||||
# DEBUG MODE=1 : Enable debug mode
|
||||
DEBUG_MODE=0
|
||||
# 选通网卡I2C通路的关键变量
|
||||
pca9641_slave=0x41
|
||||
i2c_bus=12
|
||||
@ -91,7 +98,7 @@ ina3221_ch2_volt="0"
|
||||
ina3221_ch0_current="0"
|
||||
ina3221_ch1_current="0"
|
||||
ina3221_ch2_current="0"
|
||||
|
||||
SCRIPT_VRESION="1.1"
|
||||
# ---------------------------------------------------------
|
||||
# Script Function Defination
|
||||
# ---------------------------------------------------------
|
||||
@ -101,17 +108,22 @@ print_usage(){
|
||||
echo ""
|
||||
echo "================>>> nicsensor script usage <<<================="
|
||||
echo " format : ./nicsensor.sh [slot] [sensor tpye] [slave]"
|
||||
echo " slot : 0 1 2 3 4 5"
|
||||
echo " slot : 0 1 2 3 4 5 ..."
|
||||
echo " sensor type : emc1413, adc128, ina3221"
|
||||
echo " slave : chip slave address , please provide 7 bit address"
|
||||
echo " E.G. : ./nicsensor.sh 0 adc128 0x1f"
|
||||
echo ""
|
||||
echo " If want to read/write chip register, use the below format"
|
||||
echo " ./nicsensor.sh [slot] chip [slave] [i2c_command]"
|
||||
echo " i2c_command : such as [i2ctransfer -y 13 w1@0x10 0x00 r2]"
|
||||
echo ""
|
||||
echo " If want to use debug mode, please modify the DEBUG_MODE to 1"
|
||||
echo " now status : [Line 82] debug mode = $DEBUG_MODE"
|
||||
echo ""
|
||||
}
|
||||
|
||||
# 根据输入信息调整选通芯片的配置(PCA9641 PCA9548)
|
||||
# 配置信息的具体方案根据5280M7 riser映射表来配置
|
||||
set_configuration(){
|
||||
|
||||
# 根据5280m7 pcie slot 和 i2c 对对应关系调整变量
|
||||
set_configuration_5280m7(){
|
||||
# set pca9641 address && I2C BUS
|
||||
if [ $pcie_slot -le 2 ];then
|
||||
pca9641_slave="0x41"
|
||||
@ -135,7 +147,62 @@ set_configuration(){
|
||||
elif [ $pcie_slot -eq 5 ];then
|
||||
pca9548_channel="0x08"
|
||||
fi
|
||||
}
|
||||
|
||||
# 根据5468m7 pcie slot 和 i2c 对对应关系调整变量
|
||||
set_configuration_5468m7(){
|
||||
# set pca9641 address && I2C BUS
|
||||
if [ $pcie_slot -le 4 ];then
|
||||
pca9641_slave="0x31"
|
||||
pca9548_slave="0x70"
|
||||
i2c_bus=13
|
||||
else
|
||||
pca9641_slave="0x42"
|
||||
pca9548_slave="0x71"
|
||||
i2c_bus=14
|
||||
fi
|
||||
|
||||
# set pca9548 switch channel
|
||||
if [ $pcie_slot -eq 0 ];then
|
||||
pca9548_channel="0x01"
|
||||
elif [ $pcie_slot -eq 1 ];then
|
||||
pca9548_channel="0x02"
|
||||
elif [ $pcie_slot -eq 2 ];then
|
||||
pca9548_channel="0x04"
|
||||
elif [ $pcie_slot -eq 3 ];then
|
||||
pca9548_channel="0x08"
|
||||
elif [ $pcie_slot -eq 4 ];then
|
||||
pca9548_channel="0x10"
|
||||
elif [ $pcie_slot -eq 5 ];then
|
||||
pca9548_channel="0x01"
|
||||
elif [ $pcie_slot -eq 6 ];then
|
||||
pca9548_channel="0x02"
|
||||
elif [ $pcie_slot -eq 7 ];then
|
||||
pca9548_channel="0x04"
|
||||
elif [ $pcie_slot -eq 8 ];then
|
||||
pca9548_channel="0x08"
|
||||
elif [ $pcie_slot -eq 9 ];then
|
||||
pca9548_channel="0x10"
|
||||
elif [ $pcie_slot -eq 10 ];then
|
||||
pca9548_channel="0x20"
|
||||
fi
|
||||
}
|
||||
|
||||
# 根据输入信息调整选通芯片的配置(PCA9641 PCA9548)
|
||||
# 20240912 - 更新脚本:支持通过服务器型号进行配置
|
||||
set_configuration(){
|
||||
|
||||
echo "Server Type : $server_type" >> $log
|
||||
|
||||
# 根据服务器型号执行对应的配置策略
|
||||
if [ $server_type == "5280m7" ];then
|
||||
set_configuration_5280m7
|
||||
elif [ $server_type == "5468m7" ];then
|
||||
set_configuration_5468m7
|
||||
else
|
||||
echo " Unsupport Server Type !!! - $server_type"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# 初始化调试日志
|
||||
@ -148,6 +215,7 @@ prepare_start_info(){
|
||||
# print time header
|
||||
res_date=`date`
|
||||
echo "=========================== $res_date" >> $log
|
||||
echo "Script Version : $SCRIPT_VERSION"
|
||||
|
||||
# 记录单次配置信息到调试日志中去
|
||||
echo "PCIE slot : $pcie_slot" >> $log
|
||||
@ -476,26 +544,26 @@ process_ina3221(){
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# CPLD
|
||||
# CHIP
|
||||
# ---------------------------------------------------------
|
||||
# 临时支持CPLD读取
|
||||
write_read_cpld(){
|
||||
# 临时支持CHIP读取寄存器
|
||||
write_read_chip(){
|
||||
|
||||
# Modify i2c cmd which write to cpld if need
|
||||
cmd_wr=$option_data
|
||||
res_wr=`$cmd_wr`
|
||||
|
||||
echo ">>> CPLD Command: $cmd_wr"
|
||||
echo ">>> Chip Command: $cmd_wr"
|
||||
echo ">>> The Result : $res_wr"
|
||||
}
|
||||
|
||||
# cpld处理逻辑
|
||||
process_cpld(){
|
||||
process_chip(){
|
||||
|
||||
# cpld no need to init first
|
||||
|
||||
# write and read cpld
|
||||
write_read_cpld
|
||||
write_read_chip
|
||||
|
||||
}
|
||||
|
||||
@ -569,6 +637,13 @@ process_fru(){
|
||||
|
||||
# 读取sensor流程的起点
|
||||
start_get_sensor(){
|
||||
|
||||
# 首先选通 PCA9641 和 PCA9548,构建I2C通路
|
||||
# 如果使用了debug模式,那么将不执行选通9641和9548的操作
|
||||
if [ $DEBUG_MODE -eq 0 ];then
|
||||
# set global varible by server type
|
||||
set_configuration
|
||||
|
||||
# print start info in log
|
||||
prepare_start_info
|
||||
|
||||
@ -577,6 +652,7 @@ start_get_sensor(){
|
||||
|
||||
# 选择9548 channel
|
||||
switch_pca9548_channel
|
||||
fi
|
||||
|
||||
# get sensor detail value
|
||||
if [ "$sensor_type" == "emc1413" ];then
|
||||
@ -585,15 +661,19 @@ start_get_sensor(){
|
||||
process_adc128
|
||||
elif [ "$sensor_type" == "ina3221" ];then
|
||||
process_ina3221
|
||||
elif [ "$sensor_type" == "cpld" ];then
|
||||
process_cpld
|
||||
elif [ "$sensor_type" == "chip" ];then
|
||||
process_chip
|
||||
elif [ "$sensor_type" == "fru" ];then
|
||||
process_fru
|
||||
else
|
||||
echo "Error Sensor Type !!!"
|
||||
print_usage
|
||||
fi
|
||||
}
|
||||
|
||||
# 搜索服务器所有PCIE插槽的I2C设备信息,当前仅支持特定Riser卡上的设备
|
||||
start_detect_device(){
|
||||
# 在 5280m7 上扫描每个pcie slot下的I2C设备
|
||||
# 详细对应关系参阅 readme.txt 第二节
|
||||
detect_on_5280m7(){
|
||||
# 从9641获取I2C控制权
|
||||
i2c_bus=12
|
||||
pca9641_slave="0x41"
|
||||
@ -628,6 +708,82 @@ start_detect_device(){
|
||||
i2cdetect -y $i2c_bus
|
||||
}
|
||||
|
||||
# 在 5468m7 上扫描每个pcie slot下的I2C设备
|
||||
# 详细对应关系参阅 readme.txt 第二节
|
||||
detect_on_5468m7(){
|
||||
# 从9641获取I2C控制权
|
||||
i2c_bus=13
|
||||
pca9641_slave="0x31"
|
||||
get_pca9641_controll
|
||||
|
||||
echo ">>> PCIe slot 0 : bus13 9548channel 0"
|
||||
i2ctransfer -y $i2c_bus w1@0x70 0x01
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
echo ">>> PCIe slot 1 : bus13 9548channel 1"
|
||||
i2ctransfer -y $i2c_bus w1@0x70 0x02
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
echo ">>> PCIe slot 2 : bus13 9548channel 2"
|
||||
i2ctransfer -y $i2c_bus w1@0x70 0x04
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
echo ">>> PCIe slot 3 : bus13 9548channel 3"
|
||||
i2ctransfer -y $i2c_bus w1@0x70 0x08
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
echo ">>> PCIe slot 4 : bus13 9548channel 4"
|
||||
i2ctransfer -y $i2c_bus w1@0x70 0x10
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
i2c_bus=14
|
||||
pca9641_slave="0x42"
|
||||
get_pca9641_controll
|
||||
|
||||
echo ">>> PCIe slot 5 : bus14 9548channel 0"
|
||||
i2ctransfer -y $i2c_bus w1@0x71 0x01
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
echo ">>> PCIe slot 6 : bus14 9548channel 1"
|
||||
i2ctransfer -y $i2c_bus w1@0x71 0x02
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
echo ">>> PCIe slot 7 : bus14 9548channel 2"
|
||||
i2ctransfer -y $i2c_bus w1@0x71 0x04
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
echo ">>> PCIe slot 8 : bus14 9548channel 3"
|
||||
i2ctransfer -y $i2c_bus w1@0x71 0x08
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
echo ">>> PCIe slot 9 : bus14 9548channel 4"
|
||||
i2ctransfer -y $i2c_bus w1@0x71 0x10
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
echo ">>> PCIe slot 10 : bus14 9548channel 5"
|
||||
i2ctransfer -y $i2c_bus w1@0x71 0x20
|
||||
i2cdetect -y $i2c_bus
|
||||
}
|
||||
|
||||
# 搜索服务器所有PCIE插槽的I2C设备信息,当前仅支持特定Riser卡上的设备
|
||||
# change list : 20240912-支持服务器器型号5280m7,5468m7
|
||||
start_detect_device(){
|
||||
|
||||
# debug mode下不支持进行detect操作
|
||||
if [ $DEBUG_MODE -ne 0 ];then
|
||||
echo "Can't do this action in debug mode"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ $server_type == "5280m7" ];then
|
||||
detect_on_5280m7
|
||||
elif [ $server_type == "5468m7" ];then
|
||||
detect_on_5468m7
|
||||
else
|
||||
echo "Unsupport Server Type !!!"
|
||||
fi
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Start Execute Script
|
||||
# ---------------------------------------------------------
|
||||
@ -640,6 +796,5 @@ fi
|
||||
if [ $# -le 2 ];then
|
||||
print_usage
|
||||
else
|
||||
set_configuration
|
||||
start_get_sensor
|
||||
fi
|
||||
|
||||
@ -1,19 +1,21 @@
|
||||
### 重要说明 :脚本仅用于M7服务器,带有i2c standard tool工具的BMC使用
|
||||
### 重要说明 : 脚本仅用于M7服务器,带有i2c standard tool工具的BMC使用
|
||||
### 仅限用于实验室调试使用
|
||||
|
||||
一、脚本使用方法 V1.0
|
||||
一、脚本使用方法 V1.1
|
||||
|
||||
1、针对不同项目,请先修改脚本中的部分变量(ADC128电压传感器的分压系数,INA3221的分流精密电阻阻值)
|
||||
1、针对不同项目,请先修改脚本中的部分变量(ADC128电压传感器的分压系数,INA3221的分流精密电阻阻值)
|
||||
针对不同服务器产品,请对应修改server_type变量
|
||||
|
||||
2、为脚本增加可执行权限 chmod +x ./nicsensor.sh
|
||||
|
||||
3、脚本命令格式 ./nicsensor.sh <pcie_slot> <chip_type> <chip_slave>
|
||||
|
||||
参数说明:
|
||||
pcie_slot : 网卡所在的PCIE槽位,填数字0,1,2,3,4,5
|
||||
chip_type : 传感器芯片的类型,emc1413,adc128,ina3221
|
||||
chip_slave: 传感器芯片的I2C地址(7bit)
|
||||
pcie_slot : 网卡所在的PCIE槽位, 填数字0,1,2,3,4,5
|
||||
chip_type : 传感器芯片的类型, emc1413,adc128,ina3221
|
||||
chip_slave: 传感器芯片的I2C地址(7bit)
|
||||
|
||||
举例说明:读取PCIE 1 上网卡的adc128芯片, 芯片slave地址为0x1f
|
||||
举例说明:读取PCIE 1 上网卡的adc128芯片, 芯片slave地址为0x1f
|
||||
./nicsensor.sh 1 adc128 0x1f
|
||||
|
||||
4、特殊命令
|
||||
@ -28,17 +30,23 @@
|
||||
举例说明:读取Ravel板卡的EEPROM中的FRU(0x57)
|
||||
- ./nicsensor.sh 5 fru 0x57 read
|
||||
|
||||
4.3 读取CPLD寄存器
|
||||
4.3 读取芯片寄存器
|
||||
|
||||
命令: ./nicsensor.sh <pcie_slot> cpld <chip_slave> <i2c_cmd>
|
||||
命令: ./nicsensor.sh <pcie_slot> chip <chip_slave> <i2c_cmd>
|
||||
举例说明:读取cpld的寄存器 0x00 ,读2个byte
|
||||
- ./nicsensor.sh 5 cpld 0x10 "i2ctransfer -y 13 w1@0x10 0x00 r2"
|
||||
- ./nicsensor.sh 5 chip 0x10 "i2ctransfer -y 13 w1@0x10 0x00 r2"
|
||||
|
||||
5、DEBUG模式
|
||||
|
||||
可通过配置脚本中的 DEBUG_MODE 变量来使用debug模式,在debug模式下,不会执行选通9641,9548的操作,
|
||||
仅执行读取传感器的操作,因此需要手动配置的变量有:
|
||||
i2c_bus
|
||||
|
||||
|
||||
二、5280M7 PCIE槽位和PCA9548的channel关系
|
||||
二、服务器 PCIE槽位和PCA9548的channel关系
|
||||
|
||||
5280M7的PCIE槽位和PCA9548/9546没有确定的对应关系,取决于使用的riser卡。根据一般情况选择的Riser卡,对应
|
||||
情况如下:
|
||||
5280M7的PCIE槽位和PCA9548/9546没有确定的对应关系,取决于使用的riser卡.根据一般情况选择的Riser卡, 对应
|
||||
情况如下:
|
||||
|
||||
PCIE 0 = i2c bus 12 , 9548channel1(0x02)
|
||||
PCIE 1 = i2c bus 12 , 9548channel2(0x04)
|
||||
@ -47,25 +55,41 @@
|
||||
PCIE 4 = i2c bus 13 , 9548channel2(0x04)
|
||||
PCIE 5 = i2c bus 13 , 9548channel3(0x08)
|
||||
|
||||
可以根据实际情况选择性的修改脚本中的 start_detect_device 和 set_configuration 两个函数
|
||||
5468M7的PCIE槽位和PCA9548/9546的对应关系:
|
||||
|
||||
PCIE 0 = i2c bus 13 , 9548channel0(0x01)
|
||||
PCIE 1 = i2c bus 13 , 9548channel1(0x02)
|
||||
PCIE 2 = i2c bus 13 , 9548channel2(0x04)
|
||||
PCIE 3 = i2c bus 13 , 9548channel3(0x08)
|
||||
PCIE 4 = i2c bus 13 , 9548channel4(0x10)
|
||||
PCIE 5 = i2c bus 14 , 9548channel0(0x01)
|
||||
PCIE 6 = i2c bus 14 , 9548channel1(0x02)
|
||||
PCIE 7 = i2c bus 14 , 9548channel2(0x04)
|
||||
PCIE 8 = i2c bus 14 , 9548channel3(0x08)
|
||||
PCIE 9 = i2c bus 14 , 9548channel4(0x10)
|
||||
PCIE 10 = i2c bus 14 , 9548channel5(0x20)
|
||||
|
||||
针对不同服务器产品,请对应修改server_type变量,当前支持的服务器类型:
|
||||
5280m7
|
||||
5468m7
|
||||
|
||||
三、M7 sysadmin用户 SSH打开方法
|
||||
|
||||
5280M7服务器默认不开启SSH,且串口通常有较多干扰打印,因此推荐使用SSH来执行脚本,刷新BMC镜像后需要重新配置
|
||||
5280M7服务器默认不开启SSH, 且串口通常有较多干扰打印, 因此推荐使用SSH来执行脚本, 刷新BMC镜像后需要重新配置
|
||||
|
||||
1、打开M7 BMC的串口,可通过串口线或者IPMI SOL带外登入
|
||||
1、打开M7 BMC的串口, 可通过串口线或者IPMI SOL带外登入
|
||||
|
||||
使用IPMI SOL的前提环境:可与BMC网络连接,且电脑上有ipmitool工具
|
||||
SOL登陆方法:
|
||||
1)将SOL串口源切换到BMC:
|
||||
使用IPMI SOL的前提环境: 可与BMC网络连接, 且电脑上有ipmitool工具
|
||||
SOL登陆方法:
|
||||
1)将SOL串口源切换到BMC:
|
||||
ipmitool -I lanplus -H <bmcip> -U admin -P admin raw 0x3c 0x2c 0x02 0x01
|
||||
2)打开SOL:
|
||||
2)打开SOL:
|
||||
ipmitool -I lanplus -H <bmcip> -U admin -P admin sol activate
|
||||
备注:<bmcip> 为目标BMC的ip地址,请自行更改为对应的ip地址
|
||||
备注: <bmcip> 为目标BMC的ip地址, 请自行更改为对应的ip地址
|
||||
|
||||
2、登录进入bmc的linux系统
|
||||
|
||||
bmc linux系统的默认用户名/密码 :sysadmin/superuser
|
||||
bmc linux系统的默认用户名/密码 : sysadmin/superuser
|
||||
|
||||
3、在BMC的linux系统下执行命令
|
||||
|
||||
@ -79,10 +103,10 @@
|
||||
|
||||
1、脚本执行时出现大量的 Error
|
||||
|
||||
由于M7服务器的I2C设计有PCA9641作为I2C仲裁器,脚本执行过程中可能会被9641强行断开I2C连接,造成大量的
|
||||
脚本Error,这种时候重新执行脚本即可
|
||||
由于M7服务器的I2C设计有PCA9641作为I2C仲裁器, 脚本执行过程中可能会被9641强行断开I2C连接, 造成大量的
|
||||
脚本Error, 这种时候重新执行脚本即可
|
||||
|
||||
2、不建议使用该脚本进行压力测试
|
||||
|
||||
由于BMC shell的版本非常原始,没有集成高级的命令行工具,因此处理数值时采用了复杂的脚本逻辑进行执行,处
|
||||
理效率较低。另外由于9641芯片的存在,不能保证压力测试的正常执行。
|
||||
由于BMC shell的版本非常原始, 没有集成高级的命令行工具, 因此处理数值时采用了复杂的脚本逻辑进行执行, 处
|
||||
理效率较低。另外由于9641芯片的存在, 不能保证压力测试的正常执行。
|
||||
|
||||
Loading…
Reference in New Issue
Block a user