From fcaa50bd0b6a117ba4fe4515bfa300e720fc99cd Mon Sep 17 00:00:00 2001 From: leimingsheng Date: Mon, 2 Dec 2024 18:50:27 +0800 Subject: [PATCH] =?UTF-8?q?feat(script=20:=20nicsensor.sh)Update=20to=20ve?= =?UTF-8?q?rsion=201.2=20Standard=201.=E6=9B=B4=E6=96=B0debug=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E4=B8=8B=E7=9A=84detect=E6=96=B9=E6=A1=88=E4=B8=BA?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=87=AA=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 02.nicsensor/change_list.txt | 5 +-- 02.nicsensor/nicsensor.sh | 59 +++++++++++++++--------------------- 2 files changed, 28 insertions(+), 36 deletions(-) diff --git a/02.nicsensor/change_list.txt b/02.nicsensor/change_list.txt index 89bbfe1..2fde5fd 100644 --- a/02.nicsensor/change_list.txt +++ b/02.nicsensor/change_list.txt @@ -1,9 +1,10 @@ -# Script Version 1.2 +# Script Version 1.2 20241102 Release Note: 1.[新增功能]支持写入板卡FRU - 2.[新增功能]添加适配服务器 donghu yichun + 2.[新增功能]添加适配服务器 donghu yichun qiandaohu 3.[功能优化]修复一些交互类bug,增强脚本健壮性 4.[功能优化]更便捷的支持脚本传感器名称本地化 + 5.[功能优化]debug模式下执行i2c detect时可自定义执行detect内容 # Script Version 1.1 20240912 Release Note: diff --git a/02.nicsensor/nicsensor.sh b/02.nicsensor/nicsensor.sh index 7f21929..12b40cb 100644 --- a/02.nicsensor/nicsensor.sh +++ b/02.nicsensor/nicsensor.sh @@ -1,10 +1,10 @@ #!/bin/sh # --------------------------------------------------------- -# Project Feature Varible (按照项目需要修改) +# Project Feature Varible (Change as need) # --------------------------------------------------------- -# ADC128 分压系数 (Ravel) +# ADC128 Division factor votage_division_factor_0="1" votage_division_factor_1="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_7="1" -# ADC128 channel名称定制(可更换为对应的 电压/电流/温度 的名称) +# ADC128 channel name ADC128_Channel0_name="Channel 0" ADC128_Channel1_name="Channel 1" ADC128_Channel2_name="Channel 2" @@ -24,53 +24,39 @@ ADC128_Channel5_name="Channel 5" ADC128_Channel6_name="Channel 6" ADC128_Channel7_name="Channel 7" -# INA3221 分流电阻, 单位(毫欧姆)(Ravel) +# INA3221 shunt resistor(unit: mohm) shunt_resistor_0="2" shunt_resistor_1="2" shunt_resistor_2="5" -# INA3221 channel名称定制(可更换为对应的 电压/电流/温度 的名称) +# INA3221 channel name INA3221_Channel0_name="Channel 0" INA3221_Channel1_name="Channel 1" INA3221_Channel2_name="Channel 2" -# EMC1413 channel名称定制(可更换为对应的 电压/电流/温度 的名称) +# EMC1413 channel name EMC1413_Channel0_name="Channel 0" EMC1413_Channel1_name="Channel 1" EMC1413_Channel2_name="Channel 2" -# fru 烧录的起始地址 +# fru basic offset fru_offset="0x00 0x00" -# 应用的服务器产品,根据服务器产品手动修改这个变量 -# 当前适配的服务器产品 5280m7 5468m7 donghu yichun qiandaohu +# Which server will use this script +# Please set to :5280m7 5468m7 donghu yichun qiandaohu server_type="5280m7" # --------------------------------------------------------- -# Common Varible (请勿随意修改) +# Common Varible (Don't Change) # --------------------------------------------------------- # Input Param -# Introduction of pcie_slot -# 1.脚本即将访问的网卡位于服务器上的PCIe插槽位置 pcie_slot=$1 - -# Introduction of sensor_type -# 1.脚本即将读取和处理的传感器名称 sensor_type=$2 # Introduction of chip_slave # 1.chip i2c slave address(7bit) 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 - -# Introduction of option_data2 -# 1.仅用于fru write操作,代表即将写入的fru文件名 option_data2=$5 # CHIP REGISTER @@ -103,19 +89,17 @@ REG_ina3221_bus2="0x04" REG_ina3221_bus3="0x06" # --------------------------------------------------------- -# Global Varible (请勿随意修改) +# Global Varible (Don't Change) # --------------------------------------------------------- # DEBUG MODE=0 : Disable debug mode # =1 : Enable debug mode -# 启用debug模式后需要手动配置 i2c_bus DEBUG_MODE=0 -# 选通网卡I2C通路的关键变量 + i2c_bus=12 pca9641_slave=0x41 pca9548_channel=0x04 pca9548_slave=0x72 -# 硬件上是否有PCA9641? is_have_pca9641=1 log="/tmp/nicsensor_debug.log" @@ -133,7 +117,7 @@ ina3221_ch2_volt="0" ina3221_ch0_current="0" ina3221_ch1_current="0" ina3221_ch2_current="0" -SCRIPT_VERSION="1.2 InTest Rev8" +SCRIPT_VERSION="1.2 Standard" fru_file_name=$option_data2 fru_write_size=0 @@ -176,14 +160,14 @@ print_fru_command_format(){ } # 格式化输出信息 -# @Param1 信息等级 [Info/Warning/Error] +# @Param1 信息等级 [Info Warning Error] # @Param2 信息内容 format_print(){ echo ">>> [$1] $2" } # 格式化输出信息到日志文件 -# @Param1 信息等级 [Info/Warning/Error] +# @Param1 信息等级 [Info Warning Error] # @Param2 信息内容 format_log_print(){ echo "[$1] $2" >> $log @@ -369,7 +353,6 @@ set_configuration_qiandaohu(){ } # 根据输入信息调整选通芯片的配置(PCA9641 PCA9548) -# 20240912 - 更新脚本:支持通过服务器型号进行配置 set_configuration(){ format_log_print $INFO "Server Type : $server_type" @@ -1035,14 +1018,22 @@ detect_on_qiandaohu(){ 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卡上的设备 # 一些服务器上由于riser卡不同可能导致对应关系不同 start_detect_device(){ # debug mode下进行detect操作仅对当前链路进行detect if [ $DEBUG_MODE -ne 0 ];then - format_print $INFO "In debug mode now, only detect i2c_bus$i2c_bus:" - i2cdetect -y $i2c_bus + format_print $INFO "In debug mode now" + debug_user_defined_detect exit 0 fi