feat(script : nicsensor.sh)Update to version 1.2 Standard

1.更新debug模式下的detect方案为用户自定义
This commit is contained in:
leimingsheng 2024-12-02 18:50:27 +08:00
parent a3b2c16198
commit fcaa50bd0b
2 changed files with 28 additions and 36 deletions

@ -1,9 +1,10 @@
# Script Version 1.2 # Script Version 1.2 20241102
Release Note: Release Note:
1.[新增功能]支持写入板卡FRU 1.[新增功能]支持写入板卡FRU
2.[新增功能]添加适配服务器 donghu yichun 2.[新增功能]添加适配服务器 donghu yichun qiandaohu
3.[功能优化]修复一些交互类bug,增强脚本健壮性 3.[功能优化]修复一些交互类bug,增强脚本健壮性
4.[功能优化]更便捷的支持脚本传感器名称本地化 4.[功能优化]更便捷的支持脚本传感器名称本地化
5.[功能优化]debug模式下执行i2c detect时可自定义执行detect内容
# Script Version 1.1 20240912 # Script Version 1.1 20240912
Release Note: Release Note:

@ -1,10 +1,10 @@
#!/bin/sh #!/bin/sh
# --------------------------------------------------------- # ---------------------------------------------------------
# Project Feature Varible (按照项目需要修改) # Project Feature Varible (Change as need)
# --------------------------------------------------------- # ---------------------------------------------------------
# ADC128 分压系数 (Ravel) # ADC128 Division factor
votage_division_factor_0="1" votage_division_factor_0="1"
votage_division_factor_1="1" votage_division_factor_1="1"
votage_division_factor_2="1" votage_division_factor_2="1"
@ -14,7 +14,7 @@ votage_division_factor_5="0.6"
votage_division_factor_6="0.2326" votage_division_factor_6="0.2326"
votage_division_factor_7="1" votage_division_factor_7="1"
# ADC128 channel名称定制(可更换为对应的 电压/电流/温度 的名称) # ADC128 channel name
ADC128_Channel0_name="Channel 0" ADC128_Channel0_name="Channel 0"
ADC128_Channel1_name="Channel 1" ADC128_Channel1_name="Channel 1"
ADC128_Channel2_name="Channel 2" ADC128_Channel2_name="Channel 2"
@ -24,53 +24,39 @@ ADC128_Channel5_name="Channel 5"
ADC128_Channel6_name="Channel 6" ADC128_Channel6_name="Channel 6"
ADC128_Channel7_name="Channel 7" ADC128_Channel7_name="Channel 7"
# INA3221 分流电阻, 单位(毫欧姆)(Ravel) # INA3221 shunt resistor(unit: mohm)
shunt_resistor_0="2" shunt_resistor_0="2"
shunt_resistor_1="2" shunt_resistor_1="2"
shunt_resistor_2="5" shunt_resistor_2="5"
# INA3221 channel名称定制(可更换为对应的 电压/电流/温度 的名称) # INA3221 channel name
INA3221_Channel0_name="Channel 0" INA3221_Channel0_name="Channel 0"
INA3221_Channel1_name="Channel 1" INA3221_Channel1_name="Channel 1"
INA3221_Channel2_name="Channel 2" INA3221_Channel2_name="Channel 2"
# EMC1413 channel名称定制(可更换为对应的 电压/电流/温度 的名称) # EMC1413 channel name
EMC1413_Channel0_name="Channel 0" EMC1413_Channel0_name="Channel 0"
EMC1413_Channel1_name="Channel 1" EMC1413_Channel1_name="Channel 1"
EMC1413_Channel2_name="Channel 2" EMC1413_Channel2_name="Channel 2"
# fru 烧录的起始地址 # fru basic offset
fru_offset="0x00 0x00" fru_offset="0x00 0x00"
# 应用的服务器产品,根据服务器产品手动修改这个变量 # Which server will use this script
# 当前适配的服务器产品 5280m7 5468m7 donghu yichun qiandaohu # Please set to :5280m7 5468m7 donghu yichun qiandaohu
server_type="5280m7" server_type="5280m7"
# --------------------------------------------------------- # ---------------------------------------------------------
# Common Varible (请勿随意修改) # Common Varible (Don't Change)
# --------------------------------------------------------- # ---------------------------------------------------------
# Input Param # Input Param
# Introduction of pcie_slot
# 1.脚本即将访问的网卡位于服务器上的PCIe插槽位置
pcie_slot=$1 pcie_slot=$1
# Introduction of sensor_type
# 1.脚本即将读取和处理的传感器名称
sensor_type=$2 sensor_type=$2
# Introduction of chip_slave # Introduction of chip_slave
# 1.chip i2c slave address(7bit) # 1.chip i2c slave address(7bit)
chip_slave=$3 chip_slave=$3
# Introduction of option_data
# 1.在FRU的处理过程中,使用option_data来区分是读操作还是写操作,将值设置为
# "read"或者"write"
# 2.在chip的处理过程中,使用option_data来代表一条完整的i2c命令,这条命令会
# 被发到chip上,一个例子:"i2ctransfer -y 12 w2@0x10 0x90 0x00 r9"
option_data=$4 option_data=$4
# Introduction of option_data2
# 1.仅用于fru write操作代表即将写入的fru文件名
option_data2=$5 option_data2=$5
# CHIP REGISTER # CHIP REGISTER
@ -103,19 +89,17 @@ REG_ina3221_bus2="0x04"
REG_ina3221_bus3="0x06" REG_ina3221_bus3="0x06"
# --------------------------------------------------------- # ---------------------------------------------------------
# Global Varible (请勿随意修改) # Global Varible (Don't Change)
# --------------------------------------------------------- # ---------------------------------------------------------
# DEBUG MODE=0 : Disable debug mode # DEBUG MODE=0 : Disable debug mode
# =1 : Enable debug mode # =1 : Enable debug mode
# 启用debug模式后需要手动配置 i2c_bus
DEBUG_MODE=0 DEBUG_MODE=0
# 选通网卡I2C通路的关键变量
i2c_bus=12 i2c_bus=12
pca9641_slave=0x41 pca9641_slave=0x41
pca9548_channel=0x04 pca9548_channel=0x04
pca9548_slave=0x72 pca9548_slave=0x72
# 硬件上是否有PCA9641?
is_have_pca9641=1 is_have_pca9641=1
log="/tmp/nicsensor_debug.log" log="/tmp/nicsensor_debug.log"
@ -133,7 +117,7 @@ ina3221_ch2_volt="0"
ina3221_ch0_current="0" ina3221_ch0_current="0"
ina3221_ch1_current="0" ina3221_ch1_current="0"
ina3221_ch2_current="0" ina3221_ch2_current="0"
SCRIPT_VERSION="1.2 InTest Rev8" SCRIPT_VERSION="1.2 Standard"
fru_file_name=$option_data2 fru_file_name=$option_data2
fru_write_size=0 fru_write_size=0
@ -176,14 +160,14 @@ print_fru_command_format(){
} }
# 格式化输出信息 # 格式化输出信息
# @Param1 信息等级 [Info/Warning/Error] # @Param1 信息等级 [Info Warning Error]
# @Param2 信息内容 # @Param2 信息内容
format_print(){ format_print(){
echo ">>> [$1] $2" echo ">>> [$1] $2"
} }
# 格式化输出信息到日志文件 # 格式化输出信息到日志文件
# @Param1 信息等级 [Info/Warning/Error] # @Param1 信息等级 [Info Warning Error]
# @Param2 信息内容 # @Param2 信息内容
format_log_print(){ format_log_print(){
echo "[$1] $2" >> $log echo "[$1] $2" >> $log
@ -369,7 +353,6 @@ set_configuration_qiandaohu(){
} }
# 根据输入信息调整选通芯片的配置(PCA9641 PCA9548) # 根据输入信息调整选通芯片的配置(PCA9641 PCA9548)
# 20240912 - 更新脚本:支持通过服务器型号进行配置
set_configuration(){ set_configuration(){
format_log_print $INFO "Server Type : $server_type" format_log_print $INFO "Server Type : $server_type"
@ -1035,14 +1018,22 @@ detect_on_qiandaohu(){
do_i2c_detect 6 0x71 0x08 3 11 do_i2c_detect 6 0x71 0x08 3 11
} }
debug_user_defined_detect(){
format_print $INFO "Detect by user-defined"
# default execute
format_print $INFO "Default detect on the current i2c"
i2cdetect -y $i2c_bus
}
# 搜索服务器所有PCIE插槽的I2C设备信息,仅支持特定Riser卡上的设备 # 搜索服务器所有PCIE插槽的I2C设备信息,仅支持特定Riser卡上的设备
# 一些服务器上由于riser卡不同可能导致对应关系不同 # 一些服务器上由于riser卡不同可能导致对应关系不同
start_detect_device(){ start_detect_device(){
# debug mode下进行detect操作仅对当前链路进行detect # debug mode下进行detect操作仅对当前链路进行detect
if [ $DEBUG_MODE -ne 0 ];then if [ $DEBUG_MODE -ne 0 ];then
format_print $INFO "In debug mode now, only detect i2c_bus$i2c_bus:" format_print $INFO "In debug mode now"
i2cdetect -y $i2c_bus debug_user_defined_detect
exit 0 exit 0
fi fi