From 4cde69408d019fb57e8b7bcb2b3c9b15c1338297 Mon Sep 17 00:00:00 2001 From: Missing Date: Fri, 18 Oct 2024 11:31:22 +0800 Subject: [PATCH] feat ( script : nicsensor.sh ) update to version 1.2 Intest Rev1 --- 02.nicsensor/change_list.txt | 5 +- 02.nicsensor/nicsensor.sh | 89 ++++++++++++++++++++++++++++++++++-- 02.nicsensor/readme.txt | 3 +- 3 files changed, 90 insertions(+), 7 deletions(-) diff --git a/02.nicsensor/change_list.txt b/02.nicsensor/change_list.txt index 817bbf5..f4d84aa 100644 --- a/02.nicsensor/change_list.txt +++ b/02.nicsensor/change_list.txt @@ -1,8 +1,9 @@ # Script Version 1.2 Release Note: 1.[新增功能]支持写入板卡FRU - 2.[功能优化]修复一些交互类bug,增强脚本健壮性 - 3.[功能优化]更便捷的支持脚本传感器名称本地化 + 2.[新增功能]添加适配服务器 donghu + 3.[功能优化]修复一些交互类bug,增强脚本健壮性 + 4.[功能优化]更便捷的支持脚本传感器名称本地化 # Script Version 1.1 20240912 Release Note: diff --git a/02.nicsensor/nicsensor.sh b/02.nicsensor/nicsensor.sh index 414cd82..d38d89c 100644 --- a/02.nicsensor/nicsensor.sh +++ b/02.nicsensor/nicsensor.sh @@ -43,7 +43,7 @@ EMC1413_Channel2_name="Channel 2" fru_offset="0x00 0x00" # 应用的服务器产品,根据服务器产品手动修改这个变量 -# 当前适配的服务器产品 5280m7 5468m7 +# 当前适配的服务器产品 5280m7 5468m7 donghu server_type="5280m7" # --------------------------------------------------------- @@ -103,11 +103,14 @@ REG_ina3221_bus3="0x06" # 启用debug模式后需要手动配置 i2c_bus DEBUG_MODE=0 # 选通网卡I2C通路的关键变量 -pca9641_slave=0x41 i2c_bus=12 +pca9641_slave=0x41 pca9548_channel=0x04 pca9548_slave=0x72 +# 硬件上是否有PCA9641? +is_have_pca9641=1 + log="/tmp/nicsensor_debug.log" INA3221_SHUNT_VOLT=0 INA3221_BUS_VOLT=1 @@ -123,7 +126,7 @@ ina3221_ch2_volt="0" ina3221_ch0_current="0" ina3221_ch1_current="0" ina3221_ch2_current="0" -SCRIPT_VRESION="1.2 InTest" +SCRIPT_VRESION="1.2 InTest Rev1" fru_file_name=$option_data2 fru_write_size=0 @@ -187,6 +190,9 @@ conf_pre_check(){ # 根据5280m7 pcie slot 和 i2c 对对应关系调整变量 set_configuration_5280m7(){ + + is_have_pca9641=1 + # set pca9641 address && I2C BUS if [ $pcie_slot -le 2 ];then pca9641_slave="0x41" @@ -214,6 +220,9 @@ set_configuration_5280m7(){ # 根据5468m7 pcie slot 和 i2c 对对应关系调整变量 set_configuration_5468m7(){ + + is_have_pca9641=1 + # set pca9641 address && I2C BUS if [ $pcie_slot -le 4 ];then pca9641_slave="0x31" @@ -251,6 +260,32 @@ set_configuration_5468m7(){ fi } +# 根据donghu pcie slot 和 i2c 对对应关系调整变量 +set_configuration_donghu(){ + is_have_pca9641=0 + + i2c_bus=3 + + # set pca9548 switch channel + if [ $pcie_slot -eq 0 ];then + pca9548_channel="0x80" + elif [ $pcie_slot -eq 1 ];then + pca9548_channel="0x40" + elif [ $pcie_slot -eq 2 ];then + pca9548_channel="0x20" + elif [ $pcie_slot -eq 3 ];then + pca9548_channel="0x10" + elif [ $pcie_slot -eq 4 ];then + pca9548_channel="0x08" + elif [ $pcie_slot -eq 5 ];then + pca9548_channel="0x04" + elif [ $pcie_slot -eq 6 ];then + pca9548_channel="0x02" + elif [ $pcie_slot -eq 7 ];then + pca9548_channel="0x01" + +} + # 根据输入信息调整选通芯片的配置(PCA9641 PCA9548) # 20240912 - 更新脚本:支持通过服务器型号进行配置 set_configuration(){ @@ -262,6 +297,8 @@ set_configuration(){ set_configuration_5280m7 elif [ $server_type == "5468m7" ];then set_configuration_5468m7 + elif [ $server_type == "donghu" ];then + set_configuration_donghu else format_print $ERROR "Error: Unsupport Server Type !!! - $server_type" exit 1 @@ -781,7 +818,9 @@ start_get_sensor(){ prepare_start_info # 从9641获取I2C控制权 - get_pca9641_controll + if [ $is_have_pca9641 -eq 1 ];then + get_pca9641_controll + fi # 选择9548 channel switch_pca9548_channel @@ -898,6 +937,44 @@ detect_on_5468m7(){ i2cdetect -y $i2c_bus } +# 在 donghu 上扫描每个pcie slot下的I2C设备 +detect_on_donghu(){ + + i2c_bus=3 + + echo ">>> PCIe slot 0 : bus3 9548channel 7" + i2ctransfer -y $i2c_bus w1@0x70 0x80 + i2cdetect -y $i2c_bus + + echo ">>> PCIe slot 1 : bus3 9548channel 6" + i2ctransfer -y $i2c_bus w1@0x70 0x40 + i2cdetect -y $i2c_bus + + echo ">>> PCIe slot 2 : bus3 9548channel 5" + i2ctransfer -y $i2c_bus w1@0x70 0x20 + i2cdetect -y $i2c_bus + + echo ">>> PCIe slot 3 : bus3 9548channel 4" + i2ctransfer -y $i2c_bus w1@0x70 0x10 + i2cdetect -y $i2c_bus + + echo ">>> PCIe slot 4 : bus3 9548channel 3" + i2ctransfer -y $i2c_bus w1@0x70 0x08 + i2cdetect -y $i2c_bus + + echo ">>> PCIe slot 5 : bus3 9548channel 2" + i2ctransfer -y $i2c_bus w1@0x70 0x04 + i2cdetect -y $i2c_bus + + echo ">>> PCIe slot 6 : bus3 9548channel 1" + i2ctransfer -y $i2c_bus w1@0x70 0x02 + i2cdetect -y $i2c_bus + + echo ">>> PCIe slot 7 : bus3 9548channel 0" + i2ctransfer -y $i2c_bus w1@0x70 0x01 + i2cdetect -y $i2c_bus +} + # 搜索服务器所有PCIE插槽的I2C设备信息,当前仅支持特定Riser卡上的设备 # change list : 20240912-支持服务器器型号5280m7,5468m7 start_detect_device(){ @@ -909,10 +986,14 @@ start_detect_device(){ exit 0 fi + echo ">>>>>> Detect on server : $server_type" + if [ $server_type == "5280m7" ];then detect_on_5280m7 elif [ $server_type == "5468m7" ];then detect_on_5468m7 + elif [ $server_type == "donghu" ];then + detect_on_donghu else echo "Error: Unsupport Server Type !!!" fi diff --git a/02.nicsensor/readme.txt b/02.nicsensor/readme.txt index ad60749..56b159c 100644 --- a/02.nicsensor/readme.txt +++ b/02.nicsensor/readme.txt @@ -24,6 +24,7 @@ 针对不同服务器产品,请对应修改server_type变量, 当前支持设置的服务器型号: 5280m7 5468m7 + donghu 1.2、增加脚本可执行权限 @@ -63,7 +64,7 @@ 1.5、DEBUG模式 - 可通过配置脚本中的 DEBUG_MODE 变量(In Srcipt Line:84)来使用debug模式,在debug模式下,不会执行选通 + 可通过配置脚本中的 DEBUG_MODE 变量(In Srcipt Line:104)来使用debug模式,在debug模式下,不会执行选通 9641,9548的操作,仅执行读取传感器的操作,因此启用debug模式后需要手动配置的变量有: i2c_bus