feat(develop : nicsensor) update to 1.10 Base Dev 3
1. fix nicsensor语法问题 2. 修复错误输入时的help信息显示问题 3. 更新文档 4. fix setup 语法错误 5. update changelist 6. 修正pmbus set操作在进行i2c读写时的write byte
This commit is contained in:
parent
775fe461b0
commit
14c45a75ff
@ -117,3 +117,64 @@ detect_on_{server_name}(){
|
|||||||
> - server_type 配置为 auto 后可以自行搜索boardid进行匹配服务器类型(仅限通用服务器)
|
> - server_type 配置为 auto 后可以自行搜索boardid进行匹配服务器类型(仅限通用服务器)
|
||||||
|
|
||||||
可以针对已知的boardid对 `try_get_server_type`函数中做针对性修改。
|
可以针对已知的boardid对 `try_get_server_type`函数中做针对性修改。
|
||||||
|
|
||||||
|
## 三、新增支持传感器
|
||||||
|
|
||||||
|
### 修改点1-Support_Sensor_List
|
||||||
|
|
||||||
|
``````shell
|
||||||
|
# 可以在这里添加对应的支持测试的传感器型号
|
||||||
|
Support_Sensor_List="emc1413, adc128, ina3221, ina226, tmp468, tmp112, lm95241"
|
||||||
|
``````
|
||||||
|
|
||||||
|
### 修改点2-添加sensor执行入口
|
||||||
|
|
||||||
|
``````shell
|
||||||
|
# 修改函数 start_get_sensor
|
||||||
|
start_get_sensor(){
|
||||||
|
# ... 省略部分代码
|
||||||
|
|
||||||
|
# get sensor detail value
|
||||||
|
case $sensor_type in
|
||||||
|
"emc1413")
|
||||||
|
process_emc1413
|
||||||
|
;;
|
||||||
|
# ... 省略部分代码
|
||||||
|
# 添加新增的传感器入口, 其中 process_{new_sensor} 函数是后续sensor处理的入口
|
||||||
|
"{new_sensor}")
|
||||||
|
process_{new_sensor}
|
||||||
|
;;
|
||||||
|
"chip")
|
||||||
|
process_chip
|
||||||
|
;;
|
||||||
|
"fru")
|
||||||
|
process_fru
|
||||||
|
;;
|
||||||
|
"pmbus")
|
||||||
|
process_pmbus
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
fmt_print "console" $ERROR "Unsupport Sensor Type !!! - $sensor_type"
|
||||||
|
fmt_print "console" $INFO "Support list: $Support_Sensor_List"
|
||||||
|
print_usage
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
``````
|
||||||
|
|
||||||
|
### 修改点3-添加sensor处理逻辑
|
||||||
|
|
||||||
|
这一部分可以参考其它的sensor处理逻辑进行开发。主要涵盖三部分内容:
|
||||||
|
|
||||||
|
- sensor是否需要初始化?(adc128通常第一次读取时需要初始化)
|
||||||
|
- 使用i2c命令读取sensor的指定寄存器值并记录下来
|
||||||
|
- 编写解析函数,将读到的寄存器值作为参数传递到解析函数,进行可视化展示
|
||||||
|
|
||||||
|
## 四、新增插件
|
||||||
|
|
||||||
|
插件一般情况下需要做preprocess,参考函数`extension_preprocess`,结合这里的功能开发插件即可。
|
||||||
|
|
||||||
|
插件执行分为两种情况:
|
||||||
|
|
||||||
|
- 如果插件需要读取网卡的某些芯片的寄存器值,那么读取过程正常导入到 `start_get_sensor`流程中。
|
||||||
|
- 插件不需要读取网卡I2C,直接在 preprocess 中完成逻辑调用即可。
|
||||||
|
|||||||
20
nicsensor.sh
20
nicsensor.sh
@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
SCRIPT_VERSION="1.10 Base Dev 2"
|
SCRIPT_VERSION="1.10 Base Dev 3"
|
||||||
|
|
||||||
# Load project config file
|
# Load project config file
|
||||||
PROJECT_VARIBLE_CONFIG="/extlog/nicsensor/project.config"
|
PROJECT_VARIBLE_CONFIG="/extlog/nicsensor/project.config"
|
||||||
@ -75,7 +75,7 @@ LM95241_Remote2_name="${LM95241_Remote2_name:-Remote2}"
|
|||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
Support_Sensor_List="emc1413, adc128, ina3221, ina226, tmp468, tmp112, lm95241"
|
Support_Sensor_List="emc1413, adc128, ina3221, ina226, tmp468, tmp112, lm95241"
|
||||||
Support_Server_List="5280m7, 5468m7, 5688m7, donghu, yichun, qiandaohu"
|
Support_Server_List="5280m7, 5468m7, 5688m7, donghu, yichun, qiandaohu"
|
||||||
Support_Property_List="debug|n_detect|server|fru_size|fru_offset|i2cbus"
|
Support_Property_List="debug|n_detect|server|fru_size|fru_offset|i2cbus|fix_temperature"
|
||||||
# Which server will use this script
|
# Which server will use this script
|
||||||
server_type="auto"
|
server_type="auto"
|
||||||
|
|
||||||
@ -159,6 +159,7 @@ ina3221_ch1_current="0"
|
|||||||
ina3221_ch2_current="0"
|
ina3221_ch2_current="0"
|
||||||
fru_file_name=$option_data2
|
fru_file_name=$option_data2
|
||||||
fru_write_size=0
|
fru_write_size=0
|
||||||
|
fix_temperature=0
|
||||||
fru_write_data=""
|
fru_write_data=""
|
||||||
nic_type=""
|
nic_type=""
|
||||||
slot_number=""
|
slot_number=""
|
||||||
@ -402,9 +403,14 @@ get_set_properties(){
|
|||||||
elif [ "$Param2" = "i2cbus" ];then
|
elif [ "$Param2" = "i2cbus" ];then
|
||||||
target_file="${CONFIG_DIR}ns_i2cbus"
|
target_file="${CONFIG_DIR}ns_i2cbus"
|
||||||
default_data=$i2c_bus
|
default_data=$i2c_bus
|
||||||
|
elif [ "$Param2" = "fix_temperature" ];then
|
||||||
|
# Useless property for now
|
||||||
|
target_file="${CONFIG_DIR}ns_fixtemperature"
|
||||||
|
default_data=$fix_temperature
|
||||||
else
|
else
|
||||||
fmt_print "console" $ERROR "Invalid Property : $Param2"
|
fmt_print "console" $ERROR "Invalid Property : $Param2"
|
||||||
fmt_print "console" $INFO "Support Property List : $Support_Property_List"
|
fmt_print "console" $INFO "Support Property List : $Support_Property_List"
|
||||||
|
print_usage 5
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -447,6 +453,10 @@ load_properties_from_cache(){
|
|||||||
if [ -e "${CONFIG_DIR}ns_i2cbus" ];then
|
if [ -e "${CONFIG_DIR}ns_i2cbus" ];then
|
||||||
i2c_bus=`cat ${CONFIG_DIR}ns_i2cbus`
|
i2c_bus=`cat ${CONFIG_DIR}ns_i2cbus`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -e "${CONFIG_DIR}ns_fixtemperature" ];then
|
||||||
|
fix_temperature=`cat ${CONFIG_DIR}ns_fixtemperature`
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# According to boardid, parse server_type
|
# According to boardid, parse server_type
|
||||||
@ -638,6 +648,7 @@ pre_exec_hook(){
|
|||||||
if [ $param_num -le 3 ];then
|
if [ $param_num -le 3 ];then
|
||||||
fmt_print "console" $ERROR "Command Format illegal"
|
fmt_print "console" $ERROR "Command Format illegal"
|
||||||
echo "Command Format : ./nicsensor.sh [slot] chip [slave] [i2c_command]"
|
echo "Command Format : ./nicsensor.sh [slot] chip [slave] [i2c_command]"
|
||||||
|
print_usage 3
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -651,6 +662,7 @@ pre_exec_hook(){
|
|||||||
if [ "$option_data2" = "" ];then
|
if [ "$option_data2" = "" ];then
|
||||||
fmt_print "console" $ERROR "Please provide fru file name"
|
fmt_print "console" $ERROR "Please provide fru file name"
|
||||||
echo "Command Format : ./nicsensor.sh [slot] fru [slave] write [fru_file]"
|
echo "Command Format : ./nicsensor.sh [slot] fru [slave] write [fru_file]"
|
||||||
|
print_usage 4
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -1527,6 +1539,7 @@ transfer_pmbus_command(){
|
|||||||
reset_pca9548 $i2c_bus $pca9548_slave
|
reset_pca9548 $i2c_bus $pca9548_slave
|
||||||
fmt_print "console" $INFO "$option_data ,Command Code:$2, Setting Data:${option_data2}"
|
fmt_print "console" $INFO "$option_data ,Command Code:$2, Setting Data:${option_data2}"
|
||||||
fmt_print "log" $INFO "[PMBUS] Set Command : $exec_cmd"
|
fmt_print "log" $INFO "[PMBUS] Set Command : $exec_cmd"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Do pmbus test if plugin avalible
|
# Do pmbus test if plugin avalible
|
||||||
@ -1597,7 +1610,7 @@ start_get_sensor(){
|
|||||||
*)
|
*)
|
||||||
fmt_print "console" $ERROR "Unsupport Sensor Type !!! - $sensor_type"
|
fmt_print "console" $ERROR "Unsupport Sensor Type !!! - $sensor_type"
|
||||||
fmt_print "console" $INFO "Support list: $Support_Sensor_List"
|
fmt_print "console" $INFO "Support list: $Support_Sensor_List"
|
||||||
print_usage
|
print_usage 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
@ -1772,6 +1785,7 @@ start_detect_device(){
|
|||||||
*)
|
*)
|
||||||
fmt_print "console" $ERROR "Unsupport Server Type - $server_type"
|
fmt_print "console" $ERROR "Unsupport Server Type - $server_type"
|
||||||
fmt_print "console" $INFO "Support list : $Support_Server_List"
|
fmt_print "console" $INFO "Support list : $Support_Server_List"
|
||||||
|
print_usage 2
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|||||||
51
readme.md
51
readme.md
@ -5,6 +5,23 @@
|
|||||||
|
|
||||||
## 快速使用
|
## 快速使用
|
||||||
|
|
||||||
|
### 脚本部署
|
||||||
|
|
||||||
|
> [!Important]
|
||||||
|
>
|
||||||
|
> 1.11 版本的nicsensor支持了 `setup.sh` 脚本。
|
||||||
|
|
||||||
|
操作步骤:
|
||||||
|
|
||||||
|
1. 将整个压缩包nicsensor-{version}.zip在本地解压
|
||||||
|
2. 如果针对板卡硬件参数需要修改,对应修改 `project.config` 文件(无需修改`nicsensor.sh`本体)
|
||||||
|
3. 使用scp命令将代码包传递到服务器BMC上:`scp -r nicsensor/ sysadmin@{bmc ip}:/tmp/`
|
||||||
|
4. ssh登录进入服务器BMC,后执行 `/tmp/nicsensor/setup.sh` 即可完成工具初始化
|
||||||
|
|
||||||
|
完成上述工作后即可正常使用该工具,脚本默认目录:`/extlog/nicsensor/nicsensor.sh`
|
||||||
|
|
||||||
|
### 脚本命令
|
||||||
|
|
||||||
工具Usage :`./nicsensor.sh help`
|
工具Usage :`./nicsensor.sh help`
|
||||||
|
|
||||||
工具版本查询 :`./nicsensor.sh version`
|
工具版本查询 :`./nicsensor.sh version`
|
||||||
@ -22,7 +39,7 @@
|
|||||||
- [2.3 命令透传](#2_3_命令透传)
|
- [2.3 命令透传](#2_3_命令透传)
|
||||||
- [2.4 服务器网卡通道I2C信息扫描](#2_4_服务器网卡通道I2C信息扫描)
|
- [2.4 服务器网卡通道I2C信息扫描](#2_4_服务器网卡通道I2C信息扫描)
|
||||||
- [2.5 调试模式](#2_5_调试模式)
|
- [2.5 调试模式](#2_5_调试模式)
|
||||||
- [2.6 扩展功能](#2_6_扩展功能)
|
- [2.6 扩展功能(已停用)](#2_6_扩展功能)
|
||||||
- [2.7 参数配置](#2_7_参数配置)
|
- [2.7 参数配置](#2_7_参数配置)
|
||||||
- [2.8 PMBUS功能测试](#2_8_pmbus功能)
|
- [2.8 PMBUS功能测试](#2_8_pmbus功能)
|
||||||
- [2.9 压力测试stress](#2_9_压力测试stress)
|
- [2.9 压力测试stress](#2_9_压力测试stress)
|
||||||
@ -30,6 +47,7 @@
|
|||||||
- [3.1 ADC128传感器读值为0](#3_1_adc128传感器读值为0)
|
- [3.1 ADC128传感器读值为0](#3_1_adc128传感器读值为0)
|
||||||
- [3.2 脚本执行时出现大批量语法错误](#3_2_脚本执行时出现大批量语法错误)
|
- [3.2 脚本执行时出现大批量语法错误](#3_2_脚本执行时出现大批量语法错误)
|
||||||
- [3.3 传感器读值不正确](#3_3_传感器读值不正确)
|
- [3.3 传感器读值不正确](#3_3_传感器读值不正确)
|
||||||
|
- [3.4 插件升级](#3_4_插件升级)
|
||||||
- [4.附属工具](#4_附属工具)
|
- [4.附属工具](#4_附属工具)
|
||||||
- [4.1 FruParse](#4_1_fruparse)
|
- [4.1 FruParse](#4_1_fruparse)
|
||||||
- [4.2 nicsensor\_s(已停用)](#4_2_nicsensor_s)
|
- [4.2 nicsensor\_s(已停用)](#4_2_nicsensor_s)
|
||||||
@ -67,7 +85,11 @@ nicsensor工具是在带有i2ctool工具(i2ctransfer、i2cdetect)的BMC下用于
|
|||||||
## 2_使用方法
|
## 2_使用方法
|
||||||
|
|
||||||
> [!warning]
|
> [!warning]
|
||||||
> 在使用时针对网卡的硬件特性需要定制化修改脚本的 `Project Varible` ,变量的对应关系及说明见[Project变量说明](#6_1_project变量说明)
|
> ~~在使用时针对网卡的硬件特性需要定制化修改脚本的 Project Varible~~ ,
|
||||||
|
>
|
||||||
|
> V1.11之后的脚本:修改 project.config即可,无需修改脚本本体
|
||||||
|
>
|
||||||
|
> 变量的对应关系及说明见[Project变量说明](#6_1_project变量说明)
|
||||||
|
|
||||||
### 2_1_传感器读取
|
### 2_1_传感器读取
|
||||||
|
|
||||||
@ -192,11 +214,11 @@ nicsensor工具是在带有i2ctool工具(i2ctransfer、i2cdetect)的BMC下用于
|
|||||||
|
|
||||||
### 2_6_扩展功能
|
### 2_6_扩展功能
|
||||||
|
|
||||||
脚本中预留了函数 `handle_reserve` 用于扩展功能。针对有特殊需求的项目可能会使用。
|
该功能已在v1.11之后脚本舍弃 ,如果需要对脚本进行功能性的自定义修改,参照文档[扩展说明](docs/扩展脚本说明.md)
|
||||||
|
|
||||||
在 `handle_reserve` 中可以自定义需要对网卡实现的功能。在调用该函数之前脚本会将 PCA9641及PCA9548选通。扩展功能时无需考虑PCA9641和PCA9548的状态。
|
|
||||||
|
|
||||||
|
~~脚本中预留了函数 `handle_reserve` 用于扩展功能。针对有特殊需求的项目可能会使用。~~
|
||||||
|
|
||||||
|
~~在 `handle_reserve` 中可以自定义需要对网卡实现的功能。在调用该函数之前脚本会将 PCA9641及PCA9548选通。扩展功能时无需考虑PCA9641和PCA9548的状态。~~
|
||||||
|
|
||||||
### 2_7_参数配置
|
### 2_7_参数配置
|
||||||
|
|
||||||
@ -229,10 +251,13 @@ nicsensor工具是在带有i2ctool工具(i2ctransfer、i2cdetect)的BMC下用于
|
|||||||
|
|
||||||
> [!warning]
|
> [!warning]
|
||||||
> 支持的脚本版本:v1.9及以上
|
> 支持的脚本版本:v1.9及以上
|
||||||
> PMBUS功能属于额外的功能,需要将 [pmbus_cmd_list.sh](./pmbus_cmd_list.sh) 拷贝到和nicsensor脚本相同的目录。
|
> ~~PMBUS功能属于额外的功能,需要将 [pmbus_cmd_list.sh](./pmbus_cmd_list.sh) 拷贝到和nicsensor脚本相同的目录。~~
|
||||||
> 如果不添加该脚本, 该功能无法正常使用
|
> ~~如果不添加该脚本, 该功能无法正常使用~~
|
||||||
|
>
|
||||||
|
> v1.11版本执行setup.sh会自动将`pmbus_cmd_list.sh`拷贝到正确的位置,无需手动拷贝
|
||||||
|
|
||||||
**命令格式**
|
**命令格式**
|
||||||
|
|
||||||
``` shell
|
``` shell
|
||||||
./nicsensor.sh <pcie slot> pmbus <chip slave> <pmbus cmd>
|
./nicsensor.sh <pcie slot> pmbus <chip slave> <pmbus cmd>
|
||||||
```
|
```
|
||||||
@ -255,9 +280,11 @@ nicsensor工具是在带有i2ctool工具(i2ctransfer、i2cdetect)的BMC下用于
|
|||||||
>
|
>
|
||||||
> 支持的脚本版本:v1.10及以上
|
> 支持的脚本版本:v1.10及以上
|
||||||
>
|
>
|
||||||
> 压力测试属于额外的功能,需要将 [stress_test.sh](./stress_test.sh) 拷贝到和nicsensor脚本相同的目录。
|
> ~~压力测试属于额外的功能,需要将 [stress_test.sh](./stress_test.sh) 拷贝到和nicsensor脚本相同的目录。~~
|
||||||
>
|
>
|
||||||
> 如果不添加该脚本,该功能无法正常使用
|
> ~~如果不添加该脚本,该功能无法正常使用~~
|
||||||
|
>
|
||||||
|
> v1.11版本执行setup.sh会自动将`stress_test.sh`拷贝到正确的位置,无需手动拷贝
|
||||||
|
|
||||||
**功能介绍**
|
**功能介绍**
|
||||||
|
|
||||||
@ -295,7 +322,7 @@ nicsensor工具是在带有i2ctool工具(i2ctransfer、i2cdetect)的BMC下用于
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 3_常见问题
|
## 3_常见问题FAQ
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -315,6 +342,10 @@ ADC128传感器在使用时需要初始化, 因此第一次读取时传感器可
|
|||||||
|
|
||||||
常见于ina3221传感器读值明显不正确, 因为ina3221的i2c slave地址比较敏感, 容易和pca9641产生冲突, 可首先按照i2c地址冲突的方向去排查问题。
|
常见于ina3221传感器读值明显不正确, 因为ina3221的i2c slave地址比较敏感, 容易和pca9641产生冲突, 可首先按照i2c地址冲突的方向去排查问题。
|
||||||
|
|
||||||
|
### 3_4_插件升级
|
||||||
|
|
||||||
|
如果插件功能,例如 pmbus , stress 需要更新功能,通常更新对应 nicsensor/extension 目录下的插件本体即可,无需修改nicsensor脚本本体。通过 `nicsensor.sh help ex` 可以查询当前所有插件脚本的版本信息。
|
||||||
|
|
||||||
## 4_附属工具
|
## 4_附属工具
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user