Compare commits
No commits in common. "master" and "v1.6" have entirely different histories.
@ -1,42 +1,3 @@
|
|||||||
# Script Version 1.11
|
|
||||||
#Release Note
|
|
||||||
1.[新增功能]解耦脚本参数配置功能, 脚本配置全部放到project.config中
|
|
||||||
2.[新增功能]增加对pmbus set命令的支持
|
|
||||||
3.[新增功能]增加setup.sh, 用于一键部署脚本
|
|
||||||
4.[功能优化]代码结构目录重新归档
|
|
||||||
|
|
||||||
# Script Verison 1.10
|
|
||||||
Release Note
|
|
||||||
1.[新增功能]新增适配传感器 ina226, lm95241
|
|
||||||
2.[新增功能]增加stress压测插件, 可支持自定义压测读取功能
|
|
||||||
3.[功能优化]优化help显示功能
|
|
||||||
4.[功能优化]优化脚本交互, 增加安全性检查
|
|
||||||
5.[功能优化]插件脚本加入版本号
|
|
||||||
6.[功能优化]nicsensor配置项全部放置到 /tmp/nicsensor_config 目录下, 便于维护
|
|
||||||
7.[功能优化]version命令移除debug, n_detect的显示,仅显示脚本版本号
|
|
||||||
8.[功能优化]默认i2cbus支持在参数配置功能中通过命令配置, 可用于debug模式默认搜索
|
|
||||||
9.[功能优化]默认fru offset支持在参数配置功能中通过命令配置
|
|
||||||
|
|
||||||
# Script Verison 1.9
|
|
||||||
Release Note
|
|
||||||
1.[新增功能]添加pmbus插件功能, 可支持对VR芯片的pmbus测试
|
|
||||||
2.[功能优化]fru size支持在属性配置功能中通过命令配置大小
|
|
||||||
3.[功能优化]对于 DISABLE_DETECT 的简写由 detect 变更为 n_detect, 便于理解
|
|
||||||
4.[问题修复]修复nicsensor_v2中5280m7平台的detect功能不显示插槽信息的问题
|
|
||||||
|
|
||||||
# Script Version 1.8
|
|
||||||
Release Note
|
|
||||||
1.[新增功能]默认server type调整为auto, 通用服务器可自动检索boardid,确认服务器类型
|
|
||||||
2.[新增功能]新增set get功能, 可使用命令对配置进行修改(详见readme)
|
|
||||||
3.[问题修复]修正无法识别两位数槽位号的问题
|
|
||||||
4.[功能优化]添加脚本 nicsensor_s.sh, 是nicsensor主体功能的简化版,删去了相对次要功能来确保功能快速执行
|
|
||||||
|
|
||||||
# Script Version 1.7 20250610
|
|
||||||
Release Note
|
|
||||||
1.[新增功能]预留扩展函数, 用于自定义选通网卡后的I2C操作
|
|
||||||
2.[功能优化]优化代码结构
|
|
||||||
3.[文档完善]新增脚本扩展方法, 用于指导新增适配服务器
|
|
||||||
|
|
||||||
# Script Version 1.6 20250422
|
# Script Version 1.6 20250422
|
||||||
Release Note
|
Release Note
|
||||||
1.[新增功能]添加配置项 DISABLE_DETECT ,默认在执行时不进行i2cdetect
|
1.[新增功能]添加配置项 DISABLE_DETECT ,默认在执行时不进行i2cdetect
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
On Version V1.x
|
On Version V1.x
|
||||||
PART I. Sensor读取
|
|
||||||
start_get_sensor //启动读取Sensor的流程
|
start_get_sensor //启动读取Sensor的流程
|
||||||
|--->set_configuration
|
|--->set_configuration
|
||||||
| |--->set_configuration_5280m7/5468m7/donghu/yichun //根据服务器类型设置具体I2C相关参数
|
| |--->set_configuration_5280m7/5468m7/donghu/yichun //根据服务器类型设置具体I2C相关参数
|
||||||
@ -8,8 +7,4 @@ On Version V1.x
|
|||||||
|--->process_sensor
|
|--->process_sensor
|
||||||
|--->sensor_init //传感器可能需要初始化
|
|--->sensor_init //传感器可能需要初始化
|
||||||
|--->read_sensor_value //读取传感器的数值
|
|--->read_sensor_value //读取传感器的数值
|
||||||
|--->convert_sensor_value //处理传感器的读值并做可视化处理
|
|--->convert_sensor_value //处理传感器的读值并做可视化处理
|
||||||
|
|
||||||
PART II. Detect操作
|
|
||||||
start_detect_device //启动detect i2c的流程
|
|
||||||
|--->detect_on_5280m7/5468m7/donghu/yichun //根据服务器类型进行对应的detect操作
|
|
||||||
119
docs/扩展脚本说明.md
119
docs/扩展脚本说明.md
@ -1,119 +0,0 @@
|
|||||||
# 如何扩展脚本?
|
|
||||||
|
|
||||||
## 一、前言
|
|
||||||
|
|
||||||
> [!tip]
|
|
||||||
>
|
|
||||||
> 脚本扩展一般涉及到两部分内容的扩充,包含对于支持服务器类型的扩充,或者对支持读取的传感器类型的扩充。
|
|
||||||
|
|
||||||
不论如何修改脚本,请在完成后主要修改后,修改 `SCRIPT_VERSION` 用于和主线脚本进行版本区分。
|
|
||||||
|
|
||||||
例如:
|
|
||||||
|
|
||||||
- `SCRIPT_VERSION="1.6.5 for project"` 代表基于脚本1.6.5版本为某个项目做特殊定制
|
|
||||||
|
|
||||||
## 二、新增支持服务器
|
|
||||||
|
|
||||||
### 修改点1-Support_Server_List
|
|
||||||
|
|
||||||
``````sh
|
|
||||||
# 可以在这里添加对应的服务器型号
|
|
||||||
Support_Server_List="5280m7, 5468m7, 5688m7, donghu, yichun, qiandaohu"
|
|
||||||
``````
|
|
||||||
|
|
||||||
### 修改点2-添加服务器配置入口
|
|
||||||
|
|
||||||
``````sh
|
|
||||||
# 修改函数 set_configuration
|
|
||||||
set_configuration(){
|
|
||||||
# ... 省略部分代码
|
|
||||||
case ${server_type} in
|
|
||||||
"5280m7")
|
|
||||||
set_configuration_5280m7
|
|
||||||
;;
|
|
||||||
# [开始修改]在这里针对要添加的服务器添加如下语句,将 {server_name} 替换为对应的服务器型号
|
|
||||||
# 这里修改的意义在于添加一个设置服务器I2C拓扑的入口,后面会专门编写 set_configuration_{server_name} 函数
|
|
||||||
"{server_name}")
|
|
||||||
set_configuration_{server_name}
|
|
||||||
;;
|
|
||||||
# [结束修改]
|
|
||||||
esac
|
|
||||||
# ... 省略部分代码
|
|
||||||
}
|
|
||||||
``````
|
|
||||||
|
|
||||||
### 修改点3-添加I2C拓扑适配函数
|
|
||||||
|
|
||||||
``````sh
|
|
||||||
# 在脚本中找到函数 set_configuration_5280m7,在这个函数上面新建一个函数,名为
|
|
||||||
set_configuration_{server_name}(){
|
|
||||||
# 可以模仿 5280m7 函数的写法,来编写本函数
|
|
||||||
# 主体编写的内容就是,针对卡的类型和槽位来配置通道上正确的I2C属性
|
|
||||||
# 需要考虑的内容如下:
|
|
||||||
# 1.是否支持OCP网卡
|
|
||||||
# 2.I2C链路上是否存在PCA9641
|
|
||||||
# 3.每个物理slot和I2C Bus的对应关系
|
|
||||||
# 4.每个物理slot和I2C PCA9546/9548 channel的对应关系
|
|
||||||
# 5.PCA9641和PCA9546/9548的slave地址
|
|
||||||
|
|
||||||
# 提供一种模板
|
|
||||||
# 首先判断网卡类型是否为 pcie (ocp形态同理)
|
|
||||||
if [ ${nic_type} = "pcie" ];then
|
|
||||||
# 根据 SLOT number 做针对性配置
|
|
||||||
if [ ${slot_number} -eq 0 ];then
|
|
||||||
i2c_bus=12
|
|
||||||
is_have_pca9641=1
|
|
||||||
pca9641_slave=0x41
|
|
||||||
pca9548_slave=0x70
|
|
||||||
pca9548_channel="0x01"
|
|
||||||
elif [ ${slot_number} -eq 1 ]; then
|
|
||||||
i2c_bus=12
|
|
||||||
is_have_pca9641=1
|
|
||||||
pca9641_slave=0x41
|
|
||||||
pca9548_slave=0x70
|
|
||||||
pca9548_channel="0x02"
|
|
||||||
elif [ ${slot_number} -eq 2 ]; then
|
|
||||||
i2c_bus=12
|
|
||||||
is_have_pca9641=1
|
|
||||||
pca9641_slave=0x41
|
|
||||||
pca9548_slave=0x70
|
|
||||||
pca9548_channel="0x04"
|
|
||||||
else
|
|
||||||
format_print $WARNING "Unspecified card slot!"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
``````
|
|
||||||
|
|
||||||
### 修改点4-添加I2C扫描函数(可选)
|
|
||||||
|
|
||||||
``````sh
|
|
||||||
# 类似 修改点2, 在 start_detect_device 函数中添加入口函数
|
|
||||||
# 形如 detect_on_{server_name}
|
|
||||||
|
|
||||||
# 随后新建一个对应的函数
|
|
||||||
detect_on_{server_name}(){
|
|
||||||
# 首先给定对应 slot 的 i2c bus号码
|
|
||||||
i2c_bus=12
|
|
||||||
|
|
||||||
# 根据链路上是否存在9641来编写,如果没有9641,跳过这里
|
|
||||||
pca9641_slave="0x31"
|
|
||||||
get_pca9641_control
|
|
||||||
|
|
||||||
# 调用 do_i2c_detect 函数,来执行一次9548的通道切换并做一次i2cdetect
|
|
||||||
# 参数表如下 i2cbus 9548_slave 9548_channel(hex) 9548_index slot_number
|
|
||||||
do_i2c_detect $i2c_bus "0x70" "0x01" 0 1
|
|
||||||
do_i2c_detect $i2c_bus "0x70" "0x02" 1 2
|
|
||||||
do_i2c_detect $i2c_bus "0x70" "0x04" 2 3
|
|
||||||
}
|
|
||||||
``````
|
|
||||||
|
|
||||||
### 修改点5-服务器auto选择配置(可选)
|
|
||||||
|
|
||||||
> [!note]
|
|
||||||
>
|
|
||||||
> script v1.8 新增特性:
|
|
||||||
>
|
|
||||||
> - server_type 配置为 auto 后可以自行搜索boardid进行匹配服务器类型(仅限通用服务器)
|
|
||||||
|
|
||||||
可以针对已知的boardid对 `try_get_server_type`函数中做针对性修改。
|
|
||||||
@ -1,195 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# Desc : This script used to find pmbus code and read size
|
|
||||||
# Changelist : 2025-12-25|v0.1 Create this file
|
|
||||||
# 2026-04-17|v1.1 Add PAGE command support
|
|
||||||
|
|
||||||
# How to use this pmbus plugin?
|
|
||||||
# Follow readme.md file to use this plugin or use setup.sh to install this plugin
|
|
||||||
EXTENSION_VERSION="v1.1"
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
# Varible Define
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
operation_type=$1
|
|
||||||
str_cmd=$2
|
|
||||||
hex_cmd=0xff
|
|
||||||
read_size=0
|
|
||||||
|
|
||||||
PMBUS_BYTE=1
|
|
||||||
PMBUS_WORD=2
|
|
||||||
PMBUS_BLOCK=3
|
|
||||||
PMBUS_RAW=4
|
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
# Function Define
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
pmbus_command_help(){
|
|
||||||
echo " Extend Function - PMBUS command test"
|
|
||||||
echo " Version : $EXTENSION_VERSION"
|
|
||||||
echo " 1) Command Format : ./nicsensor.sh [slot] pmbus [slave] [command] <data>"
|
|
||||||
echo " 2) Option Detail"
|
|
||||||
echo " - [slot] : 0 1 2 3 4 5 ..."
|
|
||||||
echo " - [slave] : power manage chip slave address , please provide 7 bit address"
|
|
||||||
echo " - [command] : The pmbus command which will set to the power manage chip"
|
|
||||||
echo " - <data> : The data which will set to the power manage chip, only set operation type is set"
|
|
||||||
echo " 3) E.G. : ./nicsensor.sh pcie1 pmbus 0x60 READ_TEMPERATURE_1"
|
|
||||||
echo " : ./nicsensor.sh pcie1 pmbus 0x60 PAGE 0x00"
|
|
||||||
echo ""
|
|
||||||
echo " *****************Pmbus Support Command List********************"
|
|
||||||
echo " Command Name Code op_type Read Size "
|
|
||||||
echo " PAGE 0x00 set Byte "
|
|
||||||
echo " READ_VIN 0x88 get Word "
|
|
||||||
echo " READ_IIN 0x89 get Word "
|
|
||||||
echo " READ_VOUT 0x8b get Word "
|
|
||||||
echo " READ_IOUT 0x8c get Word "
|
|
||||||
echo " READ_TEMPERATURE_1 0x8d get Word "
|
|
||||||
echo " READ_TEMPERATURE_2 0x8e get Word "
|
|
||||||
echo " READ_TEMPERATURE_3 0x8f get Word "
|
|
||||||
echo " READ_POUT 0x96 get Word "
|
|
||||||
echo " READ_PIN 0x97 get Word "
|
|
||||||
echo " ***************************************************************"
|
|
||||||
echo ""
|
|
||||||
}
|
|
||||||
|
|
||||||
find_pmbus_hex_code(){
|
|
||||||
case ${str_cmd} in
|
|
||||||
"PAGE")
|
|
||||||
hex_cmd=0x00
|
|
||||||
;;
|
|
||||||
"READ_VIN")
|
|
||||||
hex_cmd=0x88
|
|
||||||
;;
|
|
||||||
"READ_IIN")
|
|
||||||
hex_cmd=0x89
|
|
||||||
;;
|
|
||||||
"READ_VOUT")
|
|
||||||
hex_cmd=0x8b
|
|
||||||
;;
|
|
||||||
"READ_IOUT")
|
|
||||||
hex_cmd=0x8c
|
|
||||||
;;
|
|
||||||
"READ_TEMPERATURE_1")
|
|
||||||
hex_cmd=0x8d
|
|
||||||
;;
|
|
||||||
"READ_TEMPERATURE_2")
|
|
||||||
hex_cmd=0x8e
|
|
||||||
;;
|
|
||||||
"READ_TEMPERATURE_3")
|
|
||||||
hex_cmd=0x8f
|
|
||||||
;;
|
|
||||||
"READ_POUT")
|
|
||||||
hex_cmd=0x96
|
|
||||||
;;
|
|
||||||
"READ_PIN")
|
|
||||||
hex_cmd=0x97
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
hex_cmd=0xff
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
echo $hex_cmd
|
|
||||||
}
|
|
||||||
|
|
||||||
find_pmbus_operation_type(){
|
|
||||||
case ${str_cmd} in
|
|
||||||
"PAGE")
|
|
||||||
op_type="set"
|
|
||||||
;;
|
|
||||||
"READ_VIN")
|
|
||||||
op_type="get"
|
|
||||||
;;
|
|
||||||
"READ_IIN")
|
|
||||||
op_type="get"
|
|
||||||
;;
|
|
||||||
"READ_VOUT")
|
|
||||||
op_type="get"
|
|
||||||
;;
|
|
||||||
"READ_IOUT")
|
|
||||||
op_type="get"
|
|
||||||
;;
|
|
||||||
"READ_TEMPERATURE_1")
|
|
||||||
op_type="get"
|
|
||||||
;;
|
|
||||||
"READ_TEMPERATURE_2")
|
|
||||||
op_type="get"
|
|
||||||
;;
|
|
||||||
"READ_TEMPERATURE_3")
|
|
||||||
op_type="get"
|
|
||||||
;;
|
|
||||||
"READ_POUT")
|
|
||||||
op_type="get"
|
|
||||||
;;
|
|
||||||
"READ_PIN")
|
|
||||||
op_type="get"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
op_type=""
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
echo $op_type
|
|
||||||
}
|
|
||||||
|
|
||||||
find_pmbus_read_size(){
|
|
||||||
case ${str_cmd} in
|
|
||||||
"PAGE")
|
|
||||||
read_size=$PMBUS_BYTE
|
|
||||||
;;
|
|
||||||
"READ_VIN")
|
|
||||||
read_size=$PMBUS_WORD
|
|
||||||
;;
|
|
||||||
"READ_IIN")
|
|
||||||
read_size=$PMBUS_WORD
|
|
||||||
;;
|
|
||||||
"READ_VOUT")
|
|
||||||
read_size=$PMBUS_WORD
|
|
||||||
;;
|
|
||||||
"READ_IOUT")
|
|
||||||
read_size=$PMBUS_WORD
|
|
||||||
;;
|
|
||||||
"READ_TEMPERATURE_1")
|
|
||||||
read_size=$PMBUS_WORD
|
|
||||||
;;
|
|
||||||
"READ_TEMPERATURE_2")
|
|
||||||
read_size=$PMBUS_WORD
|
|
||||||
;;
|
|
||||||
"READ_TEMPERATURE_3")
|
|
||||||
read_size=$PMBUS_WORD
|
|
||||||
;;
|
|
||||||
"READ_POUT")
|
|
||||||
read_size=$PMBUS_WORD
|
|
||||||
;;
|
|
||||||
"READ_PIN")
|
|
||||||
read_size=$PMBUS_WORD
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
read_size=0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
echo $read_size
|
|
||||||
}
|
|
||||||
|
|
||||||
main(){
|
|
||||||
|
|
||||||
case ${operation_type} in
|
|
||||||
"code")
|
|
||||||
find_pmbus_hex_code
|
|
||||||
;;
|
|
||||||
"operation")
|
|
||||||
find_pmbus_operation_type
|
|
||||||
;;
|
|
||||||
"size")
|
|
||||||
find_pmbus_read_size
|
|
||||||
;;
|
|
||||||
"help")
|
|
||||||
pmbus_command_help
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Error command type"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
# Start Execute Script(main)
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
main
|
|
||||||
@ -1,209 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# Desc: Stress test script for nicsensor
|
|
||||||
# Detail: This script will stress test the nicsensor by reading the sensor data
|
|
||||||
# and print the result to the console.
|
|
||||||
|
|
||||||
EXTENSION_VERSION="v1.0 Base Dev 1"
|
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
# Varible Define
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
Param1=$1
|
|
||||||
Param2=$2
|
|
||||||
|
|
||||||
CONFIG_DIR="/tmp/nicsensor_config"
|
|
||||||
CONFIG_NICSENSOR="${CONFIG_DIR}/stress_tool"
|
|
||||||
CONFIG_SLOT="${CONFIG_DIR}/stress_slot"
|
|
||||||
CONFIG_SENSOR="${CONFIG_DIR}/stress_sensor"
|
|
||||||
CONFIG_ROUND="${CONFIG_DIR}/stress_round"
|
|
||||||
CONFIG_INTERVAL="${CONFIG_DIR}/stress_interval"
|
|
||||||
CONFIG_SLAVE="${CONFIG_DIR}/stress_slave"
|
|
||||||
|
|
||||||
config_tool=""
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
# Function Define
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
print_usage(){
|
|
||||||
echo " Extend Function - Stress Test"
|
|
||||||
echo " Version: $EXTENSION_VERSION"
|
|
||||||
echo " 1) Description"
|
|
||||||
echo " This plugin will stress test the nicsensor by reading the sensor data"
|
|
||||||
echo " and print the result to the console."
|
|
||||||
echo " 2) Command Format : ./nicsensor.sh [slot] stress [option] [data]"
|
|
||||||
echo " 3) Option Detail"
|
|
||||||
echo " - [slot] : The nicsensor slot number"
|
|
||||||
echo " - [option] : start|show|round|tool|interval|slot|sensor|slave"
|
|
||||||
echo " - [data] : The option data"
|
|
||||||
echo " 4) Example"
|
|
||||||
echo " Case: Test PCIe1 Nic's INA3221, slave=0x42, round=1000, interval=3s"
|
|
||||||
echo " Step 1 : Set the stress test parameter"
|
|
||||||
echo " ./nicsensor.sh pcie1 stress slot pcie1"
|
|
||||||
echo " ./nicsensor.sh pcie1 stress round 1000"
|
|
||||||
echo " ./nicsensor.sh pcie1 stress interval 3"
|
|
||||||
echo " ./nicsensor.sh pcie1 stress sensor ina3221"
|
|
||||||
echo " ./nicsensor.sh pcie1 stress slave 0x42"
|
|
||||||
echo " Step 2 : Check the stress test configuration"
|
|
||||||
echo " ./nicsensor.sh pcie1 stress show"
|
|
||||||
echo " Step 3 : Start the stress test"
|
|
||||||
echo " ./nicsensor.sh pcie1 stress start"
|
|
||||||
}
|
|
||||||
|
|
||||||
set_stress_config(){
|
|
||||||
case ${Param1} in
|
|
||||||
"round")
|
|
||||||
echo "Set the stress test round to ${Param2}"
|
|
||||||
echo ${Param2} > ${CONFIG_ROUND}
|
|
||||||
;;
|
|
||||||
"interval")
|
|
||||||
echo "Set the stress test interval to ${Param2}s"
|
|
||||||
echo ${Param2} > ${CONFIG_INTERVAL}
|
|
||||||
;;
|
|
||||||
"sensor")
|
|
||||||
echo "Set the stress test sensor to ${Param2}"
|
|
||||||
echo ${Param2} > ${CONFIG_SENSOR}
|
|
||||||
;;
|
|
||||||
"slave")
|
|
||||||
echo "Set the stress test slave to ${Param2}"
|
|
||||||
echo ${Param2} > ${CONFIG_SLAVE}
|
|
||||||
;;
|
|
||||||
"slot")
|
|
||||||
echo "Set the stress test slot to ${Param2}"
|
|
||||||
echo ${Param2} > ${CONFIG_SLOT}
|
|
||||||
;;
|
|
||||||
"tool")
|
|
||||||
echo "Set the stress test tool to ${Param2}"
|
|
||||||
echo ${Param2} > ${CONFIG_NICSENSOR}
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Invalid option: ${Param1}"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
get_stress_all_config(){
|
|
||||||
echo "Stress Test Config:"
|
|
||||||
if [ -f ${CONFIG_NICSENSOR} ]; then
|
|
||||||
echo " Tool : $(cat ${CONFIG_NICSENSOR})"
|
|
||||||
else
|
|
||||||
echo " Tool : nicsensor.sh"
|
|
||||||
fi
|
|
||||||
if [ -f ${CONFIG_ROUND} ]; then
|
|
||||||
echo " Round : $(cat ${CONFIG_ROUND})"
|
|
||||||
else
|
|
||||||
echo " Round : Not Set"
|
|
||||||
fi
|
|
||||||
if [ -f ${CONFIG_INTERVAL} ]; then
|
|
||||||
echo " Interval: $(cat ${CONFIG_INTERVAL})s"
|
|
||||||
else
|
|
||||||
echo " Interval: Not Set"
|
|
||||||
fi
|
|
||||||
if [ -f ${CONFIG_SLOT} ]; then
|
|
||||||
echo " Slot : $(cat ${CONFIG_SLOT})"
|
|
||||||
else
|
|
||||||
echo " Slot : Not Set"
|
|
||||||
fi
|
|
||||||
if [ -f ${CONFIG_SENSOR} ]; then
|
|
||||||
echo " Sensor : $(cat ${CONFIG_SENSOR})"
|
|
||||||
else
|
|
||||||
echo " Sensor : Not Set"
|
|
||||||
fi
|
|
||||||
if [ -f ${CONFIG_SLAVE} ]; then
|
|
||||||
echo " Slave : $(cat ${CONFIG_SLAVE})"
|
|
||||||
else
|
|
||||||
echo " Slave : Not Set"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
start_stress_test(){
|
|
||||||
# nicsensor tool check
|
|
||||||
if [ -f ${CONFIG_NICSENSOR} ]; then
|
|
||||||
config_tool=$(cat ${CONFIG_NICSENSOR})
|
|
||||||
else
|
|
||||||
config_tool="/extlog/nicsensor/nicsensor.sh"
|
|
||||||
fi
|
|
||||||
if [ ! -f "${config_tool}" ]; then
|
|
||||||
echo "Error: ${config_tool} tool not found"
|
|
||||||
echo "Info : Please check the nicsensor tool path and name"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# option check
|
|
||||||
if [ ! -f ${CONFIG_ROUND} ]; then
|
|
||||||
echo "Error: Round is not set"
|
|
||||||
echo "Info : Please set the stress test round first, use command: ${config_tool} [slot] stress round [data]"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if [ ! -f ${CONFIG_INTERVAL} ]; then
|
|
||||||
echo "Error: Interval is not set"
|
|
||||||
echo "Info : Please set the stress test interval first, use command: ${config_tool} [slot] stress interval [data]"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if [ ! -f ${CONFIG_SLOT} ]; then
|
|
||||||
echo "Error: Slot is not set"
|
|
||||||
echo "Info : Please set the stress test slot first, use command: ${config_tool} [slot] stress slot [data]"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if [ ! -f ${CONFIG_SENSOR} ]; then
|
|
||||||
echo "Error: Sensor is not set"
|
|
||||||
echo "Info : Please set the stress test sensor first, use command: ${config_tool} [slot] stress sensor [data]"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if [ ! -f ${CONFIG_SLAVE} ]; then
|
|
||||||
echo "Error: Slave is not set"
|
|
||||||
echo "Info : Please set the stress test slave first, use command: ${config_tool} [slot] stress slave [data]"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# start stress test
|
|
||||||
echo "Stress Test Config Info:"
|
|
||||||
config_round=$(cat ${CONFIG_ROUND})
|
|
||||||
config_interval=$(cat ${CONFIG_INTERVAL})
|
|
||||||
config_slot=$(cat ${CONFIG_SLOT})
|
|
||||||
config_sensor=$(cat ${CONFIG_SENSOR})
|
|
||||||
config_slave=$(cat ${CONFIG_SLAVE})
|
|
||||||
echo " Round : ${config_round}"
|
|
||||||
echo " Interval: ${config_interval}s"
|
|
||||||
echo " Slot : ${config_slot}"
|
|
||||||
echo " Sensor : ${config_sensor}"
|
|
||||||
echo " Slave : ${config_slave}"
|
|
||||||
|
|
||||||
run_count=1
|
|
||||||
while [ ${run_count} -le ${config_round} ]; do
|
|
||||||
echo ""
|
|
||||||
timestamp=$(date +"%Y-%m-%dT%H:%M:%S")
|
|
||||||
echo "====== ${timestamp}, Run Count: ${run_count}"
|
|
||||||
exec_cmd="${config_tool} ${config_slot} ${config_sensor} ${config_slave}"
|
|
||||||
${exec_cmd}
|
|
||||||
sleep ${config_interval}
|
|
||||||
run_count=$((run_count+1))
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "==========================================="
|
|
||||||
echo " Stress Test Completed"
|
|
||||||
}
|
|
||||||
|
|
||||||
main(){
|
|
||||||
cmd=${Param1}
|
|
||||||
case ${cmd} in
|
|
||||||
"start")
|
|
||||||
echo "Start the stress test"
|
|
||||||
start_stress_test
|
|
||||||
;;
|
|
||||||
"show")
|
|
||||||
echo "Show the stress test configuration"
|
|
||||||
get_stress_all_config
|
|
||||||
;;
|
|
||||||
"help")
|
|
||||||
print_usage
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Set Stress Config"
|
|
||||||
set_stress_config
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
# Start Execute Script(main)
|
|
||||||
# ---------------------------------------------------------
|
|
||||||
main
|
|
||||||
1745
nicsensor.sh
1745
nicsensor.sh
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
script_version="v2.0"
|
script_version="v2.0"
|
||||||
default_server_type="5688m7"
|
server_type="5688m7"
|
||||||
server_platform="m7"
|
server_platform="m7"
|
||||||
|
|
||||||
slot_name=$1
|
slot_name=$1
|
||||||
@ -11,47 +11,13 @@ param_num=$#
|
|||||||
|
|
||||||
nic_type=""
|
nic_type=""
|
||||||
slot_id=""
|
slot_id=""
|
||||||
server_type=""
|
|
||||||
|
|
||||||
path=`pwd`
|
path=`pwd`
|
||||||
server_script=""
|
server_script="${path}/platform_${server_type}.sh"
|
||||||
sensor_script=""
|
sensor_script="${path}/plugin_${sensor_type}.sh"
|
||||||
i2c_script="${path}/i2c_${server_platform}.sh"
|
i2c_script="${path}/i2c_${server_platform}.sh"
|
||||||
fmt_print="${path}/format_print.sh"
|
fmt_print="${path}/format_print.sh"
|
||||||
|
|
||||||
# According to boardid, parse server_type
|
|
||||||
# Only valid on Gen 7 series
|
|
||||||
try_get_server_type(){
|
|
||||||
if [ -e "/tmp/ns_servertype" ];then
|
|
||||||
server_type=`cat /tmp/ns_servertype`
|
|
||||||
else
|
|
||||||
boardid=`cat /proc/cmdline | awk -F 'boardid=' '{split($2, a," "); print a[1]}'`
|
|
||||||
|
|
||||||
if [ "$boardid" = "" ];then
|
|
||||||
server_type=$default_server_type
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
if [ $boardid -eq 130 ];then
|
|
||||||
server_type="5280m7"
|
|
||||||
elif [ $boardid -eq 150 ];then
|
|
||||||
server_type="5468m7"
|
|
||||||
elif [ $boardid -eq 152 ];then
|
|
||||||
server_type="5688m7"
|
|
||||||
else
|
|
||||||
server_type=$default_server_type
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo $server_type > /tmp/ns_servertype
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
script_info_load(){
|
|
||||||
path=`pwd`
|
|
||||||
server_script="${path}/platform_${server_type}.sh"
|
|
||||||
sensor_script="${path}/plugin_${sensor_type}.sh"
|
|
||||||
}
|
|
||||||
|
|
||||||
print_helper(){
|
print_helper(){
|
||||||
echo "======>>> nicsensor Scirpt Usage <<<======"
|
echo "======>>> nicsensor Scirpt Usage <<<======"
|
||||||
echo "Genenral Usage : ./nicsensor.sh [slot] [sensor] [i2c slave]"
|
echo "Genenral Usage : ./nicsensor.sh [slot] [sensor] [i2c slave]"
|
||||||
@ -86,12 +52,9 @@ conf_pre_check(){
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If action is detect , skip this check
|
if [ ! -e $sensor_script ];then
|
||||||
if [ $param_num -gt 3 ];then
|
$fmt_print "console" "Error" "Sensor Script $sensor_script not exist! Maybe unsupport for now!"
|
||||||
if [ ! -e $sensor_script ];then
|
exit 1
|
||||||
$fmt_print "console" "Error" "Sensor Script $sensor_script not exist! Maybe unsupport for now!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -e $i2c_script ];then
|
if [ ! -e $i2c_script ];then
|
||||||
@ -137,22 +100,15 @@ connect_i2c(){
|
|||||||
start_sensor_reading(){
|
start_sensor_reading(){
|
||||||
$fmt_print "log" "Info" "start sensor reading"
|
$fmt_print "log" "Info" "start sensor reading"
|
||||||
|
|
||||||
$sensor_script "read" "${i2c_bus}" "${chip_slave}" "${server_platform}" "${server_type}"
|
$sensor_script "read" "${i2c_bus}" "${chip_slave}" "${server_platform}"
|
||||||
}
|
|
||||||
|
|
||||||
pre_exec_hook(){
|
|
||||||
# init debug log
|
|
||||||
if [ -e "/tmp/nicsensor_debug.log" ];then
|
|
||||||
rm /tmp/nicsensor_debug.log
|
|
||||||
fi
|
|
||||||
try_get_server_type
|
|
||||||
script_info_load
|
|
||||||
conf_pre_check
|
|
||||||
}
|
}
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
# Start Execute Script
|
# Start Execute Script
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
pre_exec_hook
|
# init debug log
|
||||||
|
if [ -e "/tmp/nicsensor_debug.log" ];then
|
||||||
|
rm /tmp/nicsensor_debug.log
|
||||||
|
fi
|
||||||
|
|
||||||
# check if is detect option
|
# check if is detect option
|
||||||
if [ "$1" = "detect" ];then
|
if [ "$1" = "detect" ];then
|
||||||
@ -160,6 +116,8 @@ if [ "$1" = "detect" ];then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
conf_pre_check
|
||||||
|
|
||||||
parse_slot_name
|
parse_slot_name
|
||||||
|
|
||||||
i2c_bus=`connect_i2c`
|
i2c_bus=`connect_i2c`
|
||||||
@ -4,9 +4,6 @@ action=$1
|
|||||||
nic_type=$2
|
nic_type=$2
|
||||||
slot_id=$3
|
slot_id=$3
|
||||||
|
|
||||||
# Param: i2c_command only valid for function 'send'
|
|
||||||
i2c_command=$4
|
|
||||||
|
|
||||||
path=`pwd`
|
path=`pwd`
|
||||||
i2c_script="${path}/i2c_m7.sh"
|
i2c_script="${path}/i2c_m7.sh"
|
||||||
fmt_print="${path}/format_print.sh"
|
fmt_print="${path}/format_print.sh"
|
||||||
@ -128,9 +125,9 @@ build_i2c_connect(){
|
|||||||
# @Param5 pcie slot number
|
# @Param5 pcie slot number
|
||||||
do_i2c_detect(){
|
do_i2c_detect(){
|
||||||
if [ "${nic_type}" == "ocp" ];then
|
if [ "${nic_type}" == "ocp" ];then
|
||||||
$fmt_print "console" "Info" "OCP slot $5 : bus$1 9548channel$4"
|
$fmt_print "log" "Info" "OCP slot $5 : bus$1 9548channel$4"
|
||||||
else
|
else
|
||||||
$fmt_print "console" "Info" "PCIe slot $5 : bus$1 9548channel$4"
|
$fmt_print "log" "Info" "PCIe slot $5 : bus$1 9548channel$4"
|
||||||
fi
|
fi
|
||||||
i2ctransfer -y $1 w1@$2 $3
|
i2ctransfer -y $1 w1@$2 $3
|
||||||
i2cdetect -y $1
|
i2cdetect -y $1
|
||||||
@ -144,7 +141,6 @@ detect_on_server(){
|
|||||||
do_i2c_detect 3 0x70 0x01 0 0
|
do_i2c_detect 3 0x70 0x01 0 0
|
||||||
do_i2c_detect 3 0x70 0x02 1 1
|
do_i2c_detect 3 0x70 0x02 1 1
|
||||||
do_i2c_detect 3 0x70 0x04 2 2
|
do_i2c_detect 3 0x70 0x04 2 2
|
||||||
i2ctransfer -y 3 w1@0x70 0x00
|
|
||||||
else
|
else
|
||||||
i2c_bus=12
|
i2c_bus=12
|
||||||
pca9641_slave="0x41"
|
pca9641_slave="0x41"
|
||||||
@ -153,7 +149,6 @@ detect_on_server(){
|
|||||||
do_i2c_detect 12 0x72 0x02 1 0
|
do_i2c_detect 12 0x72 0x02 1 0
|
||||||
do_i2c_detect 12 0x72 0x04 2 1
|
do_i2c_detect 12 0x72 0x04 2 1
|
||||||
do_i2c_detect 12 0x72 0x08 3 2
|
do_i2c_detect 12 0x72 0x08 3 2
|
||||||
i2ctransfer -y 12 w1@0x72 0x00
|
|
||||||
|
|
||||||
i2c_bus=13
|
i2c_bus=13
|
||||||
pca9641_slave="0x42"
|
pca9641_slave="0x42"
|
||||||
@ -162,26 +157,9 @@ detect_on_server(){
|
|||||||
do_i2c_detect 13 0x72 0x02 1 3
|
do_i2c_detect 13 0x72 0x02 1 3
|
||||||
do_i2c_detect 13 0x72 0x04 2 4
|
do_i2c_detect 13 0x72 0x04 2 4
|
||||||
do_i2c_detect 13 0x72 0x08 3 5
|
do_i2c_detect 13 0x72 0x08 3 5
|
||||||
i2ctransfer -y 13 w1@0x72 0x00
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
reset_all_pca9548(){
|
|
||||||
$fmt_print "log" "Info" "[platform_5280m7] Bypass reset pca9548"
|
|
||||||
}
|
|
||||||
|
|
||||||
send_i2c_command(){
|
|
||||||
$fmt_print "log" "Info" "[platform_5280m7] Send an i2c command"
|
|
||||||
|
|
||||||
set_i2c_config
|
|
||||||
if [ $is_have_pca9641 -eq 1 ];then
|
|
||||||
get_pca9641_control
|
|
||||||
fi
|
|
||||||
select_pca9548_channel
|
|
||||||
|
|
||||||
$i2c_command
|
|
||||||
}
|
|
||||||
|
|
||||||
# ---------------------------------------------------
|
# ---------------------------------------------------
|
||||||
# Start Execute Script
|
# Start Execute Script
|
||||||
# ---------------------------------------------------
|
# ---------------------------------------------------
|
||||||
@ -192,12 +170,6 @@ case "${action}" in
|
|||||||
"detect")
|
"detect")
|
||||||
detect_on_server
|
detect_on_server
|
||||||
;;
|
;;
|
||||||
"reset")
|
|
||||||
reset_all_pca9548
|
|
||||||
;;
|
|
||||||
"send")
|
|
||||||
send_i2c_command
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
$fmt_print "console" "Error" "[platform_5280m7] Unspecified Operation : $action"
|
$fmt_print "console" "Error" "[platform_5280m7] Unspecified Operation : $action"
|
||||||
exit 1
|
exit 1
|
||||||
@ -4,9 +4,6 @@ action=$1
|
|||||||
nic_type=$2
|
nic_type=$2
|
||||||
slot_id=$3
|
slot_id=$3
|
||||||
|
|
||||||
# Param: i2c_command only valid for function 'send'
|
|
||||||
i2c_command=$4
|
|
||||||
|
|
||||||
path=`pwd`
|
path=`pwd`
|
||||||
i2c_script="${path}/i2c_m7.sh"
|
i2c_script="${path}/i2c_m7.sh"
|
||||||
fmt_print="${path}/format_print.sh"
|
fmt_print="${path}/format_print.sh"
|
||||||
@ -144,33 +141,13 @@ detect_on_server(){
|
|||||||
do_i2c_detect $i2c_bus 0x71 0x02 1 1
|
do_i2c_detect $i2c_bus 0x71 0x02 1 1
|
||||||
do_i2c_detect $i2c_bus 0x71 0x04 2 2
|
do_i2c_detect $i2c_bus 0x71 0x04 2 2
|
||||||
do_i2c_detect $i2c_bus 0x71 0x08 3 3
|
do_i2c_detect $i2c_bus 0x71 0x08 3 3
|
||||||
i2ctransfer -y $i2c_bus w1@0x71 0x00
|
|
||||||
|
|
||||||
do_i2c_detect $i2c_bus 0x72 0x01 0 4
|
do_i2c_detect $i2c_bus 0x72 0x01 0 4
|
||||||
do_i2c_detect $i2c_bus 0x72 0x02 1 5
|
do_i2c_detect $i2c_bus 0x72 0x02 1 5
|
||||||
do_i2c_detect $i2c_bus 0x72 0x04 2 6
|
do_i2c_detect $i2c_bus 0x72 0x04 2 6
|
||||||
do_i2c_detect $i2c_bus 0x72 0x08 3 7
|
do_i2c_detect $i2c_bus 0x72 0x08 3 7
|
||||||
i2ctransfer -y $i2c_bus w1@0x72 0x00
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
reset_all_pca9548(){
|
|
||||||
i2ctransfer -y 12 w1@0x71 0x00
|
|
||||||
i2ctransfer -y 12 w1@0x72 0x00
|
|
||||||
}
|
|
||||||
|
|
||||||
send_i2c_command(){
|
|
||||||
$fmt_print "log" "Info" "[platform_5280m7] Send an i2c command"
|
|
||||||
|
|
||||||
set_i2c_config
|
|
||||||
if [ $is_have_pca9641 -eq 1 ];then
|
|
||||||
get_pca9641_control
|
|
||||||
fi
|
|
||||||
select_pca9548_channel
|
|
||||||
|
|
||||||
$i2c_command
|
|
||||||
}
|
|
||||||
|
|
||||||
# ---------------------------------------------------
|
# ---------------------------------------------------
|
||||||
# Start Execute Script
|
# Start Execute Script
|
||||||
# ---------------------------------------------------
|
# ---------------------------------------------------
|
||||||
@ -181,12 +158,6 @@ case "${action}" in
|
|||||||
"detect")
|
"detect")
|
||||||
detect_on_server
|
detect_on_server
|
||||||
;;
|
;;
|
||||||
"reset")
|
|
||||||
reset_all_pca9548
|
|
||||||
;;
|
|
||||||
"send")
|
|
||||||
send_i2c_command
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
$fmt_print "console" "Error" "[platform_5688m7] Unspecified Operation : $action"
|
$fmt_print "console" "Error" "[platform_5688m7] Unspecified Operation : $action"
|
||||||
exit 1
|
exit 1
|
||||||
@ -24,7 +24,6 @@ mode=$1
|
|||||||
i2c_bus=$2
|
i2c_bus=$2
|
||||||
chip_slave=$3
|
chip_slave=$3
|
||||||
server_platform=$4
|
server_platform=$4
|
||||||
server_type=$5
|
|
||||||
|
|
||||||
# Only for test purpose
|
# Only for test purpose
|
||||||
test_data1=$2
|
test_data1=$2
|
||||||
@ -34,7 +33,6 @@ test_factor=$4
|
|||||||
path=`pwd`
|
path=`pwd`
|
||||||
fmt_print="${path}/format_print.sh"
|
fmt_print="${path}/format_print.sh"
|
||||||
i2c_script="${path}/i2c_${server_platform}.sh"
|
i2c_script="${path}/i2c_${server_platform}.sh"
|
||||||
server_script="${path}/platform_${server_type}.sh"
|
|
||||||
|
|
||||||
REG_adc128_config="0x00"
|
REG_adc128_config="0x00"
|
||||||
REG_adc128_advance="0x0b"
|
REG_adc128_advance="0x0b"
|
||||||
@ -89,10 +87,6 @@ check_adc128_init(){
|
|||||||
# @Param 3 customization channel name
|
# @Param 3 customization channel name
|
||||||
# @Param 4 division factor
|
# @Param 4 division factor
|
||||||
convert_adc128_data(){
|
convert_adc128_data(){
|
||||||
if [ "$3" = "disable" ];then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# remove data prefix '0x'
|
# remove data prefix '0x'
|
||||||
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
||||||
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
||||||
@ -130,9 +124,6 @@ read_adc128_data(){
|
|||||||
res_ch6=`$i2c_script $i2c_bus 1 $chip_slave $REG_adc128_ch6 2`
|
res_ch6=`$i2c_script $i2c_bus 1 $chip_slave $REG_adc128_ch6 2`
|
||||||
res_ch7=`$i2c_script $i2c_bus 1 $chip_slave $REG_adc128_ch7 2`
|
res_ch7=`$i2c_script $i2c_bus 1 $chip_slave $REG_adc128_ch7 2`
|
||||||
|
|
||||||
# After read option , reset pca9548
|
|
||||||
$server_script reset
|
|
||||||
|
|
||||||
# record i2c raw data to log
|
# record i2c raw data to log
|
||||||
$fmt_print "log" "Info" "[plugin_adc128] channel0 : $res_ch0"
|
$fmt_print "log" "Info" "[plugin_adc128] channel0 : $res_ch0"
|
||||||
$fmt_print "log" "Info" "[plugin_adc128] channel1 : $res_ch1"
|
$fmt_print "log" "Info" "[plugin_adc128] channel1 : $res_ch1"
|
||||||
@ -4,7 +4,6 @@ mode=$1
|
|||||||
i2c_bus=$2
|
i2c_bus=$2
|
||||||
chip_slave=$3
|
chip_slave=$3
|
||||||
server_platform=$4
|
server_platform=$4
|
||||||
server_type=$5
|
|
||||||
|
|
||||||
test_data1=$2
|
test_data1=$2
|
||||||
test_data2=$3
|
test_data2=$3
|
||||||
@ -12,7 +11,6 @@ test_data2=$3
|
|||||||
path=`pwd`
|
path=`pwd`
|
||||||
fmt_print="${path}/format_print.sh"
|
fmt_print="${path}/format_print.sh"
|
||||||
i2c_script="${path}/i2c_${server_platform}.sh"
|
i2c_script="${path}/i2c_${server_platform}.sh"
|
||||||
server_script="${path}/platform_${server_type}.sh"
|
|
||||||
|
|
||||||
# EMC1413 channel name
|
# EMC1413 channel name
|
||||||
EMC1413_Channel0_name="Channel0"
|
EMC1413_Channel0_name="Channel0"
|
||||||
@ -46,10 +44,6 @@ print_help(){
|
|||||||
# @Param2 emc1413 data low 8bit
|
# @Param2 emc1413 data low 8bit
|
||||||
# @Param3 customization channel name
|
# @Param3 customization channel name
|
||||||
convert_emc1413_data(){
|
convert_emc1413_data(){
|
||||||
if [ "$3" = "disable" ];then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# remove data prefix '0x'
|
# remove data prefix '0x'
|
||||||
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
||||||
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
||||||
@ -96,9 +90,6 @@ read_emc1413_data(){
|
|||||||
res_td3_h=`$i2c_script $i2c_bus 1 $chip_slave $REG_emc1413_TD3_H 1`
|
res_td3_h=`$i2c_script $i2c_bus 1 $chip_slave $REG_emc1413_TD3_H 1`
|
||||||
res_td3_l=`$i2c_script $i2c_bus 1 $chip_slave $REG_emc1413_TD3_L 1`
|
res_td3_l=`$i2c_script $i2c_bus 1 $chip_slave $REG_emc1413_TD3_L 1`
|
||||||
|
|
||||||
# After read option , reset pca9548
|
|
||||||
$server_script reset
|
|
||||||
|
|
||||||
$fmt_print "log" "Info" "[plugin_emc1413] TD1 : $res_td1_h $res_td1_l"
|
$fmt_print "log" "Info" "[plugin_emc1413] TD1 : $res_td1_h $res_td1_l"
|
||||||
$fmt_print "log" "Info" "[plugin_emc1413] TD2 : $res_td2_h $res_td2_l"
|
$fmt_print "log" "Info" "[plugin_emc1413] TD2 : $res_td2_h $res_td2_l"
|
||||||
$fmt_print "log" "Info" "[plugin_emc1413] TD3 : $res_td3_h $res_td3_l"
|
$fmt_print "log" "Info" "[plugin_emc1413] TD3 : $res_td3_h $res_td3_l"
|
||||||
@ -4,7 +4,6 @@ mode=$1
|
|||||||
i2c_bus=$2
|
i2c_bus=$2
|
||||||
chip_slave=$3
|
chip_slave=$3
|
||||||
server_platform=$4
|
server_platform=$4
|
||||||
server_type=$5
|
|
||||||
|
|
||||||
test_data1=$2
|
test_data1=$2
|
||||||
test_data2=$3
|
test_data2=$3
|
||||||
@ -13,7 +12,6 @@ test_resistor=$4
|
|||||||
path=`pwd`
|
path=`pwd`
|
||||||
fmt_print="${path}/format_print.sh"
|
fmt_print="${path}/format_print.sh"
|
||||||
i2c_script="${path}/i2c_${server_platform}.sh"
|
i2c_script="${path}/i2c_${server_platform}.sh"
|
||||||
server_script="${path}/platform_${server_type}.sh"
|
|
||||||
|
|
||||||
# INA3221 shunt resistor(unit: mohm)
|
# INA3221 shunt resistor(unit: mohm)
|
||||||
shunt_resistor_0="2"
|
shunt_resistor_0="2"
|
||||||
@ -68,10 +66,6 @@ print_help(){
|
|||||||
# @Param6 customization channel name
|
# @Param6 customization channel name
|
||||||
convert_ina3221_data(){
|
convert_ina3221_data(){
|
||||||
|
|
||||||
if [ "$6" = "disable" ];then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
||||||
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
||||||
merge_value="${hex_value1}${hex_value2}"
|
merge_value="${hex_value1}${hex_value2}"
|
||||||
@ -140,15 +134,12 @@ convert_ina3221_data(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
read_ina3221_data(){
|
read_ina3221_data(){
|
||||||
res_ch0=`$i2c_script $i2c_bus 1 $chip_slave $REG_ina3221_ch1 2`
|
res_ch0=`$i2c_script $i2c_bus 1 $chip_slave $REG_ina3221_ch1 r2`
|
||||||
res_ch1=`$i2c_script $i2c_bus 1 $chip_slave $REG_ina3221_ch2 2`
|
res_ch1=`$i2c_script $i2c_bus 1 $chip_slave $REG_ina3221_ch2 r2`
|
||||||
res_ch2=`$i2c_script $i2c_bus 1 $chip_slave $REG_ina3221_ch3 2`
|
res_ch2=`$i2c_script $i2c_bus 1 $chip_slave $REG_ina3221_ch3 r2`
|
||||||
res_bus0=`$i2c_script $i2c_bus 1 $chip_slave $REG_ina3221_bus1 2`
|
res_bus0=`$i2c_script $i2c_bus 1 $chip_slave $REG_ina3221_bus1 r2`
|
||||||
res_bus1=`$i2c_script $i2c_bus 1 $chip_slave $REG_ina3221_bus2 2`
|
res_bus1=`$i2c_script $i2c_bus 1 $chip_slave $REG_ina3221_bus2 r2`
|
||||||
res_bus2=`$i2c_script $i2c_bus 1 $chip_slave $REG_ina3221_bus3 2`
|
res_bus2=`$i2c_script $i2c_bus 1 $chip_slave $REG_ina3221_bus3 r2`
|
||||||
|
|
||||||
# After read option , reset pca9548
|
|
||||||
$server_script reset
|
|
||||||
|
|
||||||
$fmt_print "log" "Info" "[plugin_ina3221] channel 0 shunt volt: $res_ch0"
|
$fmt_print "log" "Info" "[plugin_ina3221] channel 0 shunt volt: $res_ch0"
|
||||||
$fmt_print "log" "Info" "[plugin_ina3221] channel 1 shunt volt: $res_ch1"
|
$fmt_print "log" "Info" "[plugin_ina3221] channel 1 shunt volt: $res_ch1"
|
||||||
@ -4,7 +4,6 @@ mode=$1
|
|||||||
i2c_bus=$2
|
i2c_bus=$2
|
||||||
chip_slave=$3
|
chip_slave=$3
|
||||||
server_platform=$4
|
server_platform=$4
|
||||||
server_type=$5
|
|
||||||
|
|
||||||
test_data1=$2
|
test_data1=$2
|
||||||
test_data2=$3
|
test_data2=$3
|
||||||
@ -12,7 +11,6 @@ test_data2=$3
|
|||||||
path=`pwd`
|
path=`pwd`
|
||||||
fmt_print="${path}/format_print.sh"
|
fmt_print="${path}/format_print.sh"
|
||||||
i2c_script="${path}/i2c_${server_platform}.sh"
|
i2c_script="${path}/i2c_${server_platform}.sh"
|
||||||
server_script="${path}/platform_${server_type}.sh"
|
|
||||||
|
|
||||||
sensor_name="TMP112"
|
sensor_name="TMP112"
|
||||||
|
|
||||||
@ -36,10 +34,6 @@ print_help(){
|
|||||||
# @Param2 tmp112 data low 8bit
|
# @Param2 tmp112 data low 8bit
|
||||||
# @Param3 customization sensor name
|
# @Param3 customization sensor name
|
||||||
convert_tmp112_data(){
|
convert_tmp112_data(){
|
||||||
if [ "$3" = "disable" ];then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
||||||
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
||||||
merge_value="${hex_value1}${hex_value2}"
|
merge_value="${hex_value1}${hex_value2}"
|
||||||
@ -76,10 +70,6 @@ convert_tmp112_data(){
|
|||||||
|
|
||||||
read_tmp112_data(){
|
read_tmp112_data(){
|
||||||
res=`$i2c_script $i2c_bus "1" "$chip_slave" "0x00" "2"`
|
res=`$i2c_script $i2c_bus "1" "$chip_slave" "0x00" "2"`
|
||||||
|
|
||||||
# After read option , reset pca9548
|
|
||||||
$server_script reset
|
|
||||||
|
|
||||||
convert_tmp112_data $res "$sensor_name"
|
convert_tmp112_data $res "$sensor_name"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4,7 +4,6 @@ mode=$1
|
|||||||
i2c_bus=$2
|
i2c_bus=$2
|
||||||
chip_slave=$3
|
chip_slave=$3
|
||||||
server_platform=$4
|
server_platform=$4
|
||||||
server_type=$5
|
|
||||||
|
|
||||||
test_data1=$2
|
test_data1=$2
|
||||||
test_data2=$3
|
test_data2=$3
|
||||||
@ -12,7 +11,6 @@ test_data2=$3
|
|||||||
path=`pwd`
|
path=`pwd`
|
||||||
fmt_print="${path}/format_print.sh"
|
fmt_print="${path}/format_print.sh"
|
||||||
i2c_script="${path}/i2c_${server_platform}.sh"
|
i2c_script="${path}/i2c_${server_platform}.sh"
|
||||||
server_script="${path}/platform_${server_type}.sh"
|
|
||||||
|
|
||||||
REG_tmp468="0x80"
|
REG_tmp468="0x80"
|
||||||
# TMP468 channel name
|
# TMP468 channel name
|
||||||
@ -47,10 +45,6 @@ print_help(){
|
|||||||
# @Param2 tmp468 data high 8bit
|
# @Param2 tmp468 data high 8bit
|
||||||
# @Param3 customization channel name
|
# @Param3 customization channel name
|
||||||
convert_tmp468_data(){
|
convert_tmp468_data(){
|
||||||
if [ "$3" = "disable" ];then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
||||||
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
||||||
merge_value="${hex_value1}${hex_value2}"
|
merge_value="${hex_value1}${hex_value2}"
|
||||||
@ -76,9 +70,6 @@ convert_tmp468_data(){
|
|||||||
read_tmp468_data(){
|
read_tmp468_data(){
|
||||||
res_tmp468=`$i2c_script $i2c_bus 1 $chip_slave $REG_tmp468 18`
|
res_tmp468=`$i2c_script $i2c_bus 1 $chip_slave $REG_tmp468 18`
|
||||||
|
|
||||||
# After read option , reset pca9548
|
|
||||||
$server_script reset
|
|
||||||
|
|
||||||
$fmt_print "log" "Info" "[plugin_tmp468] Read Raw Data : $res_tmp468"
|
$fmt_print "log" "Info" "[plugin_tmp468] Read Raw Data : $res_tmp468"
|
||||||
|
|
||||||
tmp468_res1_h=`echo $res_tmp468 | awk '{print $1}'`
|
tmp468_res1_h=`echo $res_tmp468 | awk '{print $1}'`
|
||||||
@ -1,56 +0,0 @@
|
|||||||
# ADC128 Division factor
|
|
||||||
votage_division_factor_0="1"
|
|
||||||
votage_division_factor_1="1"
|
|
||||||
votage_division_factor_2="1"
|
|
||||||
votage_division_factor_3="0.8"
|
|
||||||
votage_division_factor_4="0.6"
|
|
||||||
votage_division_factor_5="0.6"
|
|
||||||
votage_division_factor_6="0.2326"
|
|
||||||
votage_division_factor_7="1"
|
|
||||||
|
|
||||||
# ADC128 channel name
|
|
||||||
ADC128_Channel0_name="Channel0"
|
|
||||||
ADC128_Channel1_name="Channel1"
|
|
||||||
ADC128_Channel2_name="Channel2"
|
|
||||||
ADC128_Channel3_name="Channel3"
|
|
||||||
ADC128_Channel4_name="Channel4"
|
|
||||||
ADC128_Channel5_name="Channel5"
|
|
||||||
ADC128_Channel6_name="Channel6"
|
|
||||||
ADC128_Channel7_name="Channel7"
|
|
||||||
|
|
||||||
# INA3221 shunt resistor(unit: mohm)
|
|
||||||
shunt_resistor_0="2"
|
|
||||||
shunt_resistor_1="2"
|
|
||||||
shunt_resistor_2="5"
|
|
||||||
|
|
||||||
# INA3221 channel name
|
|
||||||
INA3221_Channel0_name="Channel0"
|
|
||||||
INA3221_Channel1_name="Channel1"
|
|
||||||
INA3221_Channel2_name="Channel2"
|
|
||||||
|
|
||||||
# EMC1413 channel name
|
|
||||||
EMC1413_Channel0_name="Channel0"
|
|
||||||
EMC1413_Channel1_name="Channel1"
|
|
||||||
EMC1413_Channel2_name="Channel2"
|
|
||||||
|
|
||||||
# TMP468 channel name
|
|
||||||
TMP468_Channel0_name="Local"
|
|
||||||
TMP468_Channel1_name="Remote1"
|
|
||||||
TMP468_Channel2_name="Remote2"
|
|
||||||
TMP468_Channel3_name="Remote3"
|
|
||||||
TMP468_Channel4_name="Remote4"
|
|
||||||
TMP468_Channel5_name="Remote5"
|
|
||||||
TMP468_Channel6_name="Remote6"
|
|
||||||
TMP468_Channel7_name="Remote7"
|
|
||||||
TMP468_Channel8_name="Remote8"
|
|
||||||
|
|
||||||
# TMP112 sensor name
|
|
||||||
TMP112_Sensor_name="Temperature"
|
|
||||||
|
|
||||||
# INA226 channel name
|
|
||||||
INA226_Channel0_name="Channel0"
|
|
||||||
|
|
||||||
# LM95241 channel name
|
|
||||||
LM95241_Local_name="Local"
|
|
||||||
LM95241_Remote1_name="Remote1"
|
|
||||||
LM95241_Remote2_name="Remote2"
|
|
||||||
585
readme.md
585
readme.md
@ -1,429 +1,156 @@
|
|||||||
# nicsensor工具使用说明
|
# nicsensor工具使用说明
|
||||||
|
|
||||||
> 本说明仅针对 nicsensorv1.x系列脚本
|
> 本说明仅针对 nicsensorv1.x系列脚本
|
||||||
> 1.x系列工具本体: [nicsensor.sh](./nicsensor.sh)
|
|
||||||
|
## 目录
|
||||||
## 快速使用
|
|
||||||
|
- [nicsensor工具使用说明](#nicsensor工具使用说明)
|
||||||
工具Usage :`./nicsensor.sh help`
|
- [目录](#目录)
|
||||||
|
- [1\_简介](#1_简介)
|
||||||
工具版本查询 :`./nicsensor.sh version`
|
- [2\_使用方法](#2_使用方法)
|
||||||
|
- [2\_1\_传感器读取](#2_1_传感器读取)
|
||||||
读取传感器:`./nicsensor.sh pcie0 ina3221 0x42` (读取PCIE_0 上网卡的 INA3221 传感器,slave地址0x42)
|
- [2\_2\_FRU相关操作](#2_2_fru相关操作)
|
||||||
|
- [2\_3\_命令透传](#2_3_命令透传)
|
||||||
## 目录
|
- [2\_4\_插槽I2C信息遍历](#2_4_插槽i2c信息遍历)
|
||||||
|
- [2\_5\_调试模式使用](#2_5_调试模式使用)
|
||||||
- [nicsensor工具使用说明](#nicsensor工具使用说明)
|
- [3\_常见问题](#3_常见问题)
|
||||||
- [目录](#目录)
|
- [3\_1\_ADC128传感器读值为0](#3_1_adc128传感器读值为0)
|
||||||
- [1.简介](#1_简介)
|
- [3\_2\_脚本执行时出现大批量语法错误](#3_2_脚本执行时出现大批量语法错误)
|
||||||
- [2.使用方法](#2_使用方法)
|
- [4\_附属工具](#4_附属工具)
|
||||||
- [2.1 传感器读取](#2_1_传感器读取)
|
- [4\_1\_FruParse](#4_1_fruparse)
|
||||||
- [2.2 FRU读写](#2_2_fru读写)
|
- [5\_关于nicsensor\_v2](#5_关于nicsensor_v2)
|
||||||
- [2.3 命令透传](#2_3_命令透传)
|
|
||||||
- [2.4 服务器网卡通道I2C信息扫描](#2_4_服务器网卡通道I2C信息扫描)
|
## 1_简介
|
||||||
- [2.5 调试模式](#2_5_调试模式)
|
|
||||||
- [2.6 扩展功能](#2_6_扩展功能)
|
nicsensor工具是在带有i2ctool工具(i2ctransfer、i2cdetect)的BMC下用于测试网卡I2C功能的工具。
|
||||||
- [2.7 参数配置](#2_7_参数配置)
|
|
||||||
- [2.8 PMBUS功能测试](#2_8_pmbus功能)
|
**当前支持的功能有:**
|
||||||
- [2.9 压力测试stress](#2_9_压力测试stress)
|
- 读取网卡上的I2C传感器
|
||||||
- [3.常见问题](#3_常见问题)
|
- 读取并修改网卡上的FRU
|
||||||
- [3.1 ADC128传感器读值为0](#3_1_adc128传感器读值为0)
|
- 透传I2C命令到网卡的芯片上
|
||||||
- [3.2 脚本执行时出现大批量语法错误](#3_2_脚本执行时出现大批量语法错误)
|
- 遍历服务器上的PCIE插槽的I2C信息
|
||||||
- [3.3 传感器读值不正确](#3_3_传感器读值不正确)
|
- 部分服务器类型支持读取OCP卡
|
||||||
- [4.附属工具](#4_附属工具)
|
|
||||||
- [4.1 FruParse](#4_1_fruparse)
|
**当前支持测试的传感器类型**
|
||||||
- [4.2 nicsensor\_s(已停用)](#4_2_nicsensor_s)
|
- adc128
|
||||||
- [5.关于nicsensor\_v2](#5_关于nicsensor_v2)
|
- ina3221
|
||||||
- [6.附录](#6_附录)
|
- emc1413
|
||||||
- [6.1 Project变量说明](#6_1_project变量说明)
|
- tmp468
|
||||||
|
- tmp112
|
||||||
|
|
||||||
|
> [!tip]
|
||||||
## 1_简介
|
> 每次执行脚本都可以在 `/tmp/nicsensor_debug.log` 查询详细的命令执行记录
|
||||||
|
|
||||||
nicsensor工具是在带有i2ctool工具(i2ctransfer、i2cdetect)的BMC下用于测试网卡I2C功能的工具。
|
## 2_使用方法
|
||||||
|
|
||||||
**当前支持的功能有:**
|
> [!warning]
|
||||||
|
> 在使用时针对网卡的硬件特性需要定制化修改脚本的 `Project Varible`
|
||||||
- 读取网卡上的I2C传感器
|
|
||||||
- 读取并修改网卡上的FRU
|
### 2_1_传感器读取
|
||||||
- 透传I2C命令到网卡的芯片上
|
|
||||||
- 遍历服务器上的PCIE插槽的I2C信息
|
**命令格式**
|
||||||
- 部分服务器类型支持读取OCP卡
|
``` shell
|
||||||
- 支持记录单次运行日志
|
./nicsensor.sh <pcie_slot> <sensor_tpye> <sensor_slave>
|
||||||
- 支持测试PMBUS功能**(new)**
|
```
|
||||||
- 支持进行压力测试**(new)**
|
**参数说明**
|
||||||
|
- `pcie slot`:网卡位于的PCIE SLOT槽位,需要指定pcie/ocp, 不指定时默认为pcie类型
|
||||||
**当前支持测试的传感器类型**
|
- `sensor type`:传感器类型
|
||||||
|
- `sensor slave`:传感器的slave地址
|
||||||
- adc128
|
|
||||||
- ina3221
|
**命令示例**
|
||||||
- ina226**(new)**
|
``` shell
|
||||||
- emc1413
|
# 读取pcie2槽位上的adc128的信息, adc128芯片的地址为0x1f(7bit)
|
||||||
- tmp468
|
./nicsensor.sh pcie2 adc128 0x1f
|
||||||
- tmp112
|
```
|
||||||
- lm95241**(new)**
|
|
||||||
|
### 2_2_FRU相关操作
|
||||||
## 2_使用方法
|
|
||||||
|
> [!warning]
|
||||||
> [!warning]
|
> 在写入网卡FRU操作时,受限于服务器PCA9641的影响,需要将服务器关机后执行
|
||||||
> 在使用时针对网卡的硬件特性需要定制化修改脚本的 `Project Varible` ,变量的对应关系及说明见[Project变量说明](#6_1_project变量说明)
|
|
||||||
|
**命令格式**
|
||||||
### 2_1_传感器读取
|
``` shell
|
||||||
|
# 读取FRU
|
||||||
**命令格式**
|
./nicsensor.sh <pcie_slot> fru <eeprom_slave>
|
||||||
|
|
||||||
``` shell
|
# 写入FRU
|
||||||
./nicsensor.sh <pcie_slot> <sensor_tpye> <sensor_slave>
|
./nicsensor.sh <pcie_slot> fru <eeprom_slave> write <filename>
|
||||||
```
|
```
|
||||||
**参数说明**
|
|
||||||
|
**参数说明**
|
||||||
| Properties | type | 说明 |
|
- `pcie slot`:网卡位于的PCIE SLOT槽位,需要指定pcie/ocp, 不指定时默认为pcie类型
|
||||||
| -------------- | ------- | ------------------------------------------------------------ |
|
- `eeprom slave`: FRU所在的eeprom芯片的slave地址
|
||||||
| `pcie slot` | string | 网卡位于的PCIE SLOT槽位,需要指定pcie/ocp, 不指定时默认为pcie类型 |
|
- `filename`: 仅在写入FRU时提供, 要写入的FRU bin文件
|
||||||
| `sensor type` | string | 传感器类型 |
|
|
||||||
| `sensor slave` | hex num | 传感器的slave地址(7 bit) |
|
**命令示例**
|
||||||
|
``` shell
|
||||||
**命令示例**
|
# 读取pcie2槽位上的fru信息, eeprom的芯片地址为0x50(7bit)
|
||||||
``` shell
|
./nicsensor.sh pcie2 fru 0x50
|
||||||
# 读取pcie2槽位上的adc128的信息, adc128芯片的地址为0x1f(7bit)
|
|
||||||
./nicsensor.sh pcie2 adc128 0x1f
|
# 写入pcie2槽位上网卡的fru
|
||||||
# 读取pcie3槽位上的ina3221的信息, ina3221芯片的地址为0x40(7bit)
|
./nicsensor.sh pcie2 fru 0x50 write fru.bin
|
||||||
./nicsensor.sh 3 ina3221 0x40
|
```
|
||||||
# 读取ocp0槽位上的tmp112的信息, tmp112芯片的地址为0x48(7bit)
|
|
||||||
./nicsensor.sh ocp0 tmp112 0x48
|
### 2_3_命令透传
|
||||||
```
|
|
||||||
|
**命令格式**
|
||||||
|
``` shell
|
||||||
|
./nicsensor.sh <pcie_slot> chip <chip slave> <command>
|
||||||
### 2_2_FRU读写
|
```
|
||||||
|
**参数说明**
|
||||||
> [!warning]
|
- `pcie slot`:网卡位于的PCIE SLOT槽位,需要指定pcie/ocp, 不指定时默认为pcie类型
|
||||||
> 在写入网卡FRU操作时,受限于服务器PCA9641的影响,**建议**将服务器关机后执行
|
- `chip slave`: 芯片的slave地址
|
||||||
|
- `command`: 要透传执行的I2C命令
|
||||||
**命令格式**
|
|
||||||
``` shell
|
**命令示例**
|
||||||
# 读取FRU
|
``` shell
|
||||||
./nicsensor.sh <pcie_slot> fru <eeprom_slave>
|
# 对pcie2槽位上的chip透传命令 i2ctransfer -y 12 w2@0x11 0x00 0x00 r2 , 芯片地址为0x11(7bit)
|
||||||
|
./nicsensor.sh pcie2 chip 0x11 "i2ctransfer -y 12 w2@0x11 0x00 0x00 r2"
|
||||||
# 写入FRU
|
```
|
||||||
./nicsensor.sh <pcie_slot> fru <eeprom_slave> write <filename>
|
|
||||||
```
|
### 2_4_插槽I2C信息遍历
|
||||||
|
|
||||||
**参数说明**
|
**命令格式**
|
||||||
|
``` shell
|
||||||
| Properties | type | 说明 |
|
./nicsensor.sh detect <nic_type>
|
||||||
| -------------- | ------- | ------------------------------------------------------------ |
|
```
|
||||||
| `pcie slot` | string | 网卡位于的PCIE SLOT槽位,需要指定pcie/ocp, 不指定时默认为pcie类型 |
|
|
||||||
| `eeprom slave` | hex num | FRU所在的eeprom芯片的slave地址(7 bit) |
|
**参数说明**
|
||||||
| `filename` | string | 仅在写入FRU时提供, 要写入的FRU bin文件路径 |
|
- `nic type`:需要指定pcie/ocp, 不指定时默认为pcie类型
|
||||||
|
|
||||||
**命令示例**
|
**命令示例**
|
||||||
``` shell
|
``` shell
|
||||||
# 读取pcie2槽位上的fru信息, eeprom的芯片地址为0x50(7bit)
|
./nicsensor.sh detect pcie
|
||||||
./nicsensor.sh pcie2 fru 0x50
|
```
|
||||||
|
|
||||||
# 写入pcie2槽位上网卡的fru
|
### 2_5_调试模式使用
|
||||||
./nicsensor.sh pcie2 fru 0x50 write fru.bin
|
|
||||||
```
|
> 关联变量 `DEBUG_MODE`, 启用调试模式时需要将该变量的值配置为1
|
||||||
|
|
||||||
|
如果不需要借助脚本来选通服务器上对应的channel, 仅需要做传感器数值测试, 可以启用调试模式。
|
||||||
|
在调试模式下, 脚本不会执行选通PCA9641以及PCA9546/9548的操作。仅直接测试传感器。因此,需要手动调整两个变量
|
||||||
### 2_3_命令透传
|
- `DEBUG_MODE`
|
||||||
|
- `i2c_bus`
|
||||||
提供对芯片直接执行i2c命令的能力,通常用于访问网卡核心芯片如FPGA,Nic Controller等。
|
|
||||||
|
> 关联变量 `DISABLE_DETECT`, 启用时配置为1, 将不会在切换PCA9641和PCA9548时进行i2cdetect
|
||||||
**命令格式**
|
|
||||||
|
## 3_常见问题
|
||||||
``` shell
|
|
||||||
./nicsensor.sh <pcie_slot> chip <chip slave> <command>
|
### 3_1_ADC128传感器读值为0
|
||||||
```
|
|
||||||
**参数说明**
|
ADC128传感器在使用时需要初始化, 因此第一次读取时传感器可能并未完成初始化, 所以读值为0
|
||||||
|
|
||||||
| Properties | type | 说明 |
|
### 3_2_脚本执行时出现大批量语法错误
|
||||||
| ------------ | ------- | ------------------------------------------------------------ |
|
|
||||||
| `pcie slot` | string | 网卡位于的PCIE SLOT槽位,需要指定pcie/ocp, 不指定时默认为pcie类型 |
|
通常是因为服务器上含有PCA9641切断了BMC的I2C控制权导致,重试即可
|
||||||
| `chip slave` | hex num | 芯片的slave地址(7 bit) |
|
|
||||||
| `command` | string | 要透传执行的I2C命令 |
|
## 4_附属工具
|
||||||
|
|
||||||
**命令示例**
|
### 4_1_FruParse
|
||||||
``` shell
|
提供了一个简单python脚本用于解析FRU的数据, 将nicsensor读取到的FRU数据拷贝到frudata.txt后, 执行
|
||||||
# 对pcie2槽位上的chip透传命令 i2ctransfer -y 12 w2@0x11 0x00 0x00 r2 , 芯片地址为0x11(7bit)
|
`python fru_parse.py`即可将读取到的数据转化为FRU内容
|
||||||
./nicsensor.sh pcie2 chip 0x11 "i2ctransfer -y 12 w2@0x11 0x00 0x00 r2"
|
|
||||||
```
|
## 5_关于nicsensor_v2
|
||||||
|
|
||||||
|
nicsensor_v2将服务器选通channel和读取传感器数值的功能解耦,因此在单独使用某个功能时可以直接找到对应的脚本进行测试。
|
||||||
|
详见[nicsensor_v2](./nicsensor_v2/readme.md)
|
||||||
### 2_4_服务器网卡通道I2C信息扫描
|
|
||||||
|
|
||||||
**命令格式**
|
|
||||||
``` shell
|
|
||||||
./nicsensor.sh detect <nic_type>
|
|
||||||
```
|
|
||||||
|
|
||||||
**参数说明**
|
|
||||||
- `nic type`:需要指定pcie/ocp, 不指定时默认为pcie类型
|
|
||||||
|
|
||||||
**命令示例**
|
|
||||||
``` shell
|
|
||||||
./nicsensor.sh detect pcie
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 2_5_调试模式
|
|
||||||
|
|
||||||
如果不需要借助脚本来选通服务器上对应的channel, 仅需要做传感器数值测试, 可以启用调试模式。
|
|
||||||
在调试模式下, 脚本不会执行选通PCA9641以及PCA9546/9548的操作。仅直接测试传感器。
|
|
||||||
|
|
||||||
**开启调试模式**
|
|
||||||
|
|
||||||
``````sh
|
|
||||||
./nicsensor.sh set debug 1
|
|
||||||
``````
|
|
||||||
|
|
||||||
**关闭调试模式**
|
|
||||||
|
|
||||||
``````sh
|
|
||||||
./nicsensor.sh set debug 0
|
|
||||||
``````
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 2_6_扩展功能
|
|
||||||
|
|
||||||
脚本中预留了函数 `handle_reserve` 用于扩展功能。针对有特殊需求的项目可能会使用。
|
|
||||||
|
|
||||||
在 `handle_reserve` 中可以自定义需要对网卡实现的功能。在调用该函数之前脚本会将 PCA9641及PCA9548选通。扩展功能时无需考虑PCA9641和PCA9548的状态。
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 2_7_参数配置
|
|
||||||
|
|
||||||
可以通过一组名为 `get/set` 的指令对脚本中的如下变量做即时修改而无需修改脚本(下电后恢复默认)。支持修改的变量如下:
|
|
||||||
| Properties | 对应脚本变量 | 说明 |
|
|
||||||
| ------------ | ---------------- | ---------------------------------------- |
|
|
||||||
| `server` | `server_type` | 脚本应用的服务器类型 |
|
|
||||||
| `debug` | `DEBUG_MODE` | 是否启用调试模式 |
|
|
||||||
| `n_detect` | `DISABLE_DETECT` | 是否禁止执行时的i2c detect操作 |
|
|
||||||
| `fru_size` | `fru_size` | 默认fru的读取字节数 |
|
|
||||||
| `fru_offset` | `fru_offset` | 默认fru在eeprom的起始偏移地址 |
|
|
||||||
| `i2cbus` | `i2c_bus` | 默认的i2c bus,通常需要搭配debug一起使用 |
|
|
||||||
|
|
||||||
**命令格式**
|
|
||||||
|
|
||||||
``` shell
|
|
||||||
./nicsensor.sh <get/set> <property> <value>
|
|
||||||
```
|
|
||||||
|
|
||||||
**命令示例**
|
|
||||||
``` shell
|
|
||||||
./nicsensor.sh set server 5280m7
|
|
||||||
|
|
||||||
./nicsneosr.sh get debug
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 2_8_PMBUS功能
|
|
||||||
|
|
||||||
> [!warning]
|
|
||||||
> 支持的脚本版本:v1.9及以上
|
|
||||||
> PMBUS功能属于额外的功能,需要将 [pmbus_cmd_list.sh](./pmbus_cmd_list.sh) 拷贝到和nicsensor脚本相同的目录。
|
|
||||||
> 如果不添加该脚本, 该功能无法正常使用
|
|
||||||
|
|
||||||
**命令格式**
|
|
||||||
``` shell
|
|
||||||
./nicsensor.sh <pcie slot> pmbus <chip slave> <pmbus cmd>
|
|
||||||
```
|
|
||||||
|
|
||||||
**参数说明**
|
|
||||||
- `pcie slot`: 网卡位于的PCIE SLOT槽位,需要指定pcie/ocp, 不指定时默认为pcie类型
|
|
||||||
- `chip slave`: 芯片的slave地址
|
|
||||||
- `pmbus cmd`: 要读取的pmbus命令码, 支持列表请使用命令 `./nicsensor.sh help` 查询
|
|
||||||
|
|
||||||
**命令示例**
|
|
||||||
``` shell
|
|
||||||
./nicsensor.sh pcie1 pmbus 0x60 READ_TEMPERATURE_1
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 2_9_压力测试stress
|
|
||||||
|
|
||||||
> [!Warning]
|
|
||||||
>
|
|
||||||
> 支持的脚本版本:v1.10及以上
|
|
||||||
>
|
|
||||||
> 压力测试属于额外的功能,需要将 [stress_test.sh](./stress_test.sh) 拷贝到和nicsensor脚本相同的目录。
|
|
||||||
>
|
|
||||||
> 如果不添加该脚本,该功能无法正常使用
|
|
||||||
|
|
||||||
**功能介绍**
|
|
||||||
|
|
||||||
一个模块化的压力测试工具,通过配置文件管理测试参数,支持灵活设置测试轮次、间隔、传感器类型等,方便用户进行nicsensor的稳定性测试。
|
|
||||||
|
|
||||||
**命令格式**
|
|
||||||
|
|
||||||
``````sh
|
|
||||||
./nicsensor.sh <pcie slot> stress <option> <option data>
|
|
||||||
``````
|
|
||||||
|
|
||||||
**参数说明**
|
|
||||||
|
|
||||||
| 参数名称 | 数据类型 | 说明 |
|
|
||||||
| ------------- | -------- | ------------------------------------------------------------ |
|
|
||||||
| `pcie slot` | string | nicsensor工具通用格式,在这里无特殊含义 |
|
|
||||||
| `option` | string | 要执行的stress命令类型,有如下取值<br>`start` : 开始执行压力测试,无需option data<br>`show`: 显示压力测试的配置项, 无需option data<br>`round`: 要执行的压力测试圈数<br>`tool`: 要使用的nicsensor脚本,默认为nicsensor.sh<br>`interval`: 每一圈执行的时间间隔,单位为秒(s)<br>`slot`: 目标测试的插槽号<br>`sensor`: 需要测试的传感器类型<br>`slave`: 目标传感器的slave地址 |
|
|
||||||
| `option data` | string | 依据option类型决定是否需要该字段 |
|
|
||||||
|
|
||||||
**命令示例**
|
|
||||||
|
|
||||||
``````sh
|
|
||||||
#场景说明:对pcie1的网卡压测 ina3221(0x42) 100次, 读取间隔2s
|
|
||||||
# step 1 配置测试项
|
|
||||||
./nicsensor.sh pcie1 stress round 100
|
|
||||||
./nicsensor.sh pcie1 stress interval 2
|
|
||||||
./nicsensor.sh pcie1 stress slot pcie1
|
|
||||||
./nicsensor.sh pcie1 stress sensor ina3221
|
|
||||||
./nicsensor.sh pcie1 stress slave 0x42
|
|
||||||
# step 2 查看测试项是否符合预期
|
|
||||||
./nicsensor.sh pcie1 stress show
|
|
||||||
# step 3 开始测试
|
|
||||||
./nicsensor.sh pcie1 stress start
|
|
||||||
``````
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 3_常见问题
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 3_1_ADC128传感器读值为0
|
|
||||||
|
|
||||||
ADC128传感器在使用时需要初始化, 因此第一次读取时传感器可能并未完成初始化, 所以读值为0
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 3_2_脚本执行时出现大批量语法错误
|
|
||||||
|
|
||||||
通常是因为服务器上含有PCA9641切断了BMC的I2C控制权导致, 重试即可
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 3_3_传感器读值不正确
|
|
||||||
|
|
||||||
常见于ina3221传感器读值明显不正确, 因为ina3221的i2c slave地址比较敏感, 容易和pca9641产生冲突, 可首先按照i2c地址冲突的方向去排查问题。
|
|
||||||
|
|
||||||
## 4_附属工具
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 4_1_FruParse
|
|
||||||
|
|
||||||
提供了一个简单python脚本用于解析FRU的数据, 将nicsensor读取到的FRU数据拷贝到frudata.txt后, 执行
|
|
||||||
`python fru_parse.py`即可将读取到的数据转化为FRU内容
|
|
||||||
|
|
||||||
**工具路径**:[fru_parse.py](./tool/fru_parse/fru_parse.py)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 4_2_nicsensor_s
|
|
||||||
|
|
||||||
该工具已于`nicsensor v1.10` 移除
|
|
||||||
|
|
||||||
~~基于脚本版本1.8, 剔除了所有记日志的操作, 用于加速i2c的执行, 确保在9641工作的生命周期内尽快完成i2c任务~~
|
|
||||||
|
|
||||||
~~**工具路径**:[nicsensor_s.sh](./nicsensor_s.sh)~~
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 5_关于nicsensor_v2
|
|
||||||
|
|
||||||
nicsensor_v2将服务器选通channel和读取传感器数值的功能解耦, 因此在单独使用某个功能时可以直接找到对应的脚本进行测试。
|
|
||||||
详见[nicsensor_v2](./nicsensor_v2/readme.md)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 6_附录
|
|
||||||
|
|
||||||
### 6_1_Project变量说明
|
|
||||||
|
|
||||||
> [!important]
|
|
||||||
> 对于所有传感器的`xxx_Channel_name`, 将其配置为`disable`即可跳过对应的channel的数据解析。
|
|
||||||
> 推荐在硬件上空置的Channel将其配置为 `disable`,防止脚本解析数据时出现混淆
|
|
||||||
|
|
||||||
**ADC128**相关
|
|
||||||
|
|
||||||
| 变量 | 定义 |
|
|
||||||
| -------------------------- | ----------------------------------- |
|
|
||||||
| `votage_division_factor_0` | ADC128芯片Channel 0的分压系数 |
|
|
||||||
| `votage_division_factor_1` | ADC128芯片Channel 1的分压系数 |
|
|
||||||
| `votage_division_factor_2` | ADC128芯片Channel 2的分压系数 |
|
|
||||||
| `votage_division_factor_3` | ADC128芯片Channel 3的分压系数 |
|
|
||||||
| `votage_division_factor_4` | ADC128芯片Channel 4的分压系数 |
|
|
||||||
| `votage_division_factor_5` | ADC128芯片Channel 5的分压系数 |
|
|
||||||
| `votage_division_factor_6` | ADC128芯片Channel 6的分压系数 |
|
|
||||||
| `votage_division_factor_7` | ADC128芯片Channel 7的分压系数 |
|
|
||||||
| `ADC128_Channel0_name` | 定制化ADC128芯片Channel 0的电压名称 |
|
|
||||||
| `ADC128_Channel1_name` | 定制化ADC128芯片Channel 1的电压名称 |
|
|
||||||
| `ADC128_Channel2_name` | 定制化ADC128芯片Channel 2的电压名称 |
|
|
||||||
| `ADC128_Channel3_name` | 定制化ADC128芯片Channel 3的电压名称 |
|
|
||||||
| `ADC128_Channel4_name` | 定制化ADC128芯片Channel 4的电压名称 |
|
|
||||||
| `ADC128_Channel5_name` | 定制化ADC128芯片Channel 5的电压名称 |
|
|
||||||
| `ADC128_Channel6_name` | 定制化ADC128芯片Channel 6的电压名称 |
|
|
||||||
| `ADC128_Channel7_name` | 定制化ADC128芯片Channel 7的电压名称 |
|
|
||||||
|
|
||||||
**INA3221**相关
|
|
||||||
|
|
||||||
| 变量 | 定义 |
|
|
||||||
| ----------------------- | ----------------------------------------------------- |
|
|
||||||
| `shunt_resistor_0` | INA3221芯片的Channel 0外接的分流电阻的大小(单位:毫欧) |
|
|
||||||
| `shunt_resistor_1` | INA3221芯片的Channel 1外接的分流电阻的大小(单位:毫欧) |
|
|
||||||
| `shunt_resistor_2` | INA3221芯片的Channel 2外接的分流电阻的大小(单位:毫欧) |
|
|
||||||
| `INA3221_Channel0_name` | 定制化INA3221芯片Channel 0的名称 |
|
|
||||||
| `INA3221_Channel1_name` | 定制化INA3221芯片Channel 1的名称 |
|
|
||||||
| `INA3221_Channel2_name` | 定制化INA3221芯片Channel 2的名称 |
|
|
||||||
|
|
||||||
**EMC1413**相关
|
|
||||||
|
|
||||||
| 变量 | 定义 |
|
|
||||||
| ----------------------- | ------------------------------------ |
|
|
||||||
| `EMC1413_Channel0_name` | 定制化EMC1413芯片Channel 0的温度名称 |
|
|
||||||
| `EMC1413_Channel1_name` | 定制化EMC1413芯片Channel 1的温度名称 |
|
|
||||||
| `EMC1413_Channel2_name` | 定制化EMC1413芯片Channel 2的温度名称 |
|
|
||||||
|
|
||||||
**TMP468**相关
|
|
||||||
|
|
||||||
| 变量 | 定义 |
|
|
||||||
| ---------------------- | ----------------------------------------- |
|
|
||||||
| `TMP468_Channel0_name` | 定制化TMP468芯片Loacl Channel的温度名称 |
|
|
||||||
| `TMP468_Channel1_name` | 定制化TMP468芯片Remote1 Channel的温度名称 |
|
|
||||||
| `TMP468_Channel2_name` | 定制化TMP468芯片Remote2 Channel的温度名称 |
|
|
||||||
| `TMP468_Channel3_name` | 定制化TMP468芯片Remote3 Channel的温度名称 |
|
|
||||||
| `TMP468_Channel4_name` | 定制化TMP468芯片Remote4 Channel的温度名称 |
|
|
||||||
| `TMP468_Channel5_name` | 定制化TMP468芯片Remote5 Channel的温度名称 |
|
|
||||||
| `TMP468_Channel6_name` | 定制化TMP468芯片Remote6 Channel的温度名称 |
|
|
||||||
| `TMP468_Channel7_name` | 定制化TMP468芯片Remote7 Channel的温度名称 |
|
|
||||||
| `TMP468_Channel8_name` | 定制化TMP468芯片Remote8 Channel的温度名称 |
|
|
||||||
|
|
||||||
**TMP112**相关
|
|
||||||
|
|
||||||
| 变量 | 定义 |
|
|
||||||
| -------------------- | ---------------------- |
|
|
||||||
| `TMP112_Sensor_name` | 定制化TMP112对应的名称 |
|
|
||||||
|
|
||||||
**INA226**相关
|
|
||||||
|
|
||||||
| 变量 | 定义 |
|
|
||||||
| ---------------------- | ------------------------------- |
|
|
||||||
| `INA226_Channel0_name` | 定制化INA226芯片Channel 0的名称 |
|
|
||||||
|
|
||||||
**LM95241**相关
|
|
||||||
|
|
||||||
| 变量 | 定义 |
|
|
||||||
| ---------------------- | ------------------------------------------ |
|
|
||||||
| `LM95241_Local_name` | 定制化LM95241芯片Loacl Channel的温度名称 |
|
|
||||||
| `LM95241_Remote1_name` | 定制化LM95241芯片Remote1 Channel的温度名称 |
|
|
||||||
| `LM95241_Remote2_name` | 定制化LM95241芯片Remote2 Channel的温度名称 |
|
|
||||||
|
|
||||||
57
setup.sh
57
setup.sh
@ -1,57 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# Script Description:
|
|
||||||
# This script is used to auto setup the nicsensor tool and its extensions.
|
|
||||||
|
|
||||||
SCRIPT_VERSION="1.0.0"
|
|
||||||
SUPPORT_TOOL_VERSION="1.11"
|
|
||||||
|
|
||||||
# Default values
|
|
||||||
source_extension_dir="./extension"
|
|
||||||
destination_tool_dir="/extlog/nicsensor"
|
|
||||||
destination_extension_dir="/extlog/nicsensor/extension"
|
|
||||||
exec_path="/extlog/nicsensor/nicsensor.sh"
|
|
||||||
|
|
||||||
# PRINT SCRIPT INFO
|
|
||||||
echo "=== Nicsensor Quick Setup Script! ==="
|
|
||||||
echo "Setup Tool Version : $SCRIPT_VERSION"
|
|
||||||
echo "Support nicsensor tool Version : $SUPPORT_TOOL_VERSION"
|
|
||||||
|
|
||||||
# Check if the destination extension directory exists, if not, create it
|
|
||||||
if [ ! -d "$destination_extension_dir" ]; then
|
|
||||||
echo "Step 0 : Create directory $destination_extension_dir"
|
|
||||||
mkdir -p "$destination_extension_dir"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Get script Path
|
|
||||||
script_dir=$(pwd)
|
|
||||||
source_extension_dir="$script_dir/extension"
|
|
||||||
|
|
||||||
# check if the source extension directory exists, if not, exit
|
|
||||||
if [ ! -d "$source_extension_dir" ]; then
|
|
||||||
echo "Error : Source extension directory $source_extension_dir does not exist"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# copy the extension files to the destination directory
|
|
||||||
echo "Step 1 : Copy extension files to $destination_extension_dir"
|
|
||||||
cp -rf "$source_extension_dir"/* "$destination_extension_dir"
|
|
||||||
|
|
||||||
# Add execute permission for extension files
|
|
||||||
echo "Step 2 : Add execute permission for extension files"
|
|
||||||
chmod +x "$destination_extension_dir"/*
|
|
||||||
|
|
||||||
# copy the project config to the destination directory
|
|
||||||
echo "Step 3 : Copy project.config to $destination_tool_dir"
|
|
||||||
cp -f "./project.config" "$destination_tool_dir"
|
|
||||||
|
|
||||||
# copy the exec file to the destination directory
|
|
||||||
echo "Step 4 : Copy nicsensor to $exec_path"
|
|
||||||
cp -f "./nicsensor.sh" "$exec_path"
|
|
||||||
|
|
||||||
# Add execute permission for exec file
|
|
||||||
echo "Step 5 : Add execute permission for nicsensor"
|
|
||||||
chmod +x "$exec_path"
|
|
||||||
|
|
||||||
|
|
||||||
echo "Complete auto setup nicsensor tool and its extensions."
|
|
||||||
@ -1,122 +0,0 @@
|
|||||||
import os
|
|
||||||
import zipfile
|
|
||||||
import sys
|
|
||||||
|
|
||||||
# ===================== 【可配置项】 =====================
|
|
||||||
# 输出目录(可自定义修改,例如 D:/release / /home/user/release)
|
|
||||||
OUTPUT_DIR = ""
|
|
||||||
|
|
||||||
# 最小打包内容
|
|
||||||
MIN_FILES = [
|
|
||||||
"extension",
|
|
||||||
"nicsensor.sh",
|
|
||||||
"project.config",
|
|
||||||
"setup.sh"
|
|
||||||
]
|
|
||||||
|
|
||||||
# 完整工程打包内容(所有文件)
|
|
||||||
FULL_FILES = [
|
|
||||||
"docs",
|
|
||||||
"extension",
|
|
||||||
"tool",
|
|
||||||
"nicsensor.sh",
|
|
||||||
"project.config",
|
|
||||||
"readme.md",
|
|
||||||
"setup.sh"
|
|
||||||
]
|
|
||||||
# ======================================================
|
|
||||||
|
|
||||||
|
|
||||||
def get_project_root():
|
|
||||||
"""
|
|
||||||
自动获取工程根目录(脚本在 tool/auto_package/ 下)
|
|
||||||
"""
|
|
||||||
# 当前脚本目录:tool/auto_package
|
|
||||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
||||||
# 工程根目录 = 往上两级
|
|
||||||
project_root = os.path.abspath(os.path.join(current_dir, "../.."))
|
|
||||||
return project_root
|
|
||||||
|
|
||||||
|
|
||||||
def pack_files(zip_path, file_list, project_root):
|
|
||||||
"""
|
|
||||||
统一打包函数
|
|
||||||
"""
|
|
||||||
os.chdir(project_root) # 切换到工程根目录,保证打包路径正确
|
|
||||||
|
|
||||||
with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as zipf:
|
|
||||||
for item in file_list:
|
|
||||||
if not os.path.exists(item):
|
|
||||||
print(f"⚠️ 跳过不存在:{item}")
|
|
||||||
continue
|
|
||||||
|
|
||||||
# 递归打包文件夹
|
|
||||||
if os.path.isdir(item):
|
|
||||||
for root, dirs, files_in_dir in os.walk(item):
|
|
||||||
for f in files_in_dir:
|
|
||||||
file_path = os.path.join(root, f)
|
|
||||||
arc_path = os.path.relpath(file_path, project_root)
|
|
||||||
zipf.write(file_path, arc_path)
|
|
||||||
print(f" ✔ {arc_path}")
|
|
||||||
else:
|
|
||||||
zipf.write(item, item)
|
|
||||||
print(f" ✔ {item}")
|
|
||||||
|
|
||||||
|
|
||||||
def build_all(version):
|
|
||||||
"""
|
|
||||||
一次性构建 min + full 两个包
|
|
||||||
"""
|
|
||||||
project_root = get_project_root()
|
|
||||||
OUTPUT_DIR = os.path.join(project_root, "Release")
|
|
||||||
output_abs = os.path.abspath(OUTPUT_DIR)
|
|
||||||
|
|
||||||
# 创建输出目录
|
|
||||||
if not os.path.exists(output_abs):
|
|
||||||
os.makedirs(output_abs)
|
|
||||||
|
|
||||||
# 文件名
|
|
||||||
zip_min = os.path.join(output_abs, f"nicsensor-{version}-min.zip")
|
|
||||||
zip_full = os.path.join(output_abs, f"nicsensor-{version}-full.zip")
|
|
||||||
|
|
||||||
print("=" * 60)
|
|
||||||
print(" 开始自动打包")
|
|
||||||
print(f"版本号:{version}")
|
|
||||||
print(f"工程根目录:{project_root}")
|
|
||||||
print(f"输出目录:{output_abs}")
|
|
||||||
print("=" * 60)
|
|
||||||
|
|
||||||
# 打包最小版
|
|
||||||
print("\n📦 开始打包【最小版本】")
|
|
||||||
pack_files(zip_min, MIN_FILES, project_root)
|
|
||||||
|
|
||||||
# 打包完整版
|
|
||||||
print("\n📦 开始打包【完整工程】")
|
|
||||||
pack_files(zip_full, FULL_FILES, project_root)
|
|
||||||
|
|
||||||
print("\n✅ 全部打包完成!")
|
|
||||||
print(f"📍 最小包:{zip_min}")
|
|
||||||
print(f"📍 完整包:{zip_full}")
|
|
||||||
print("=" * 60)
|
|
||||||
|
|
||||||
|
|
||||||
def show_usage():
|
|
||||||
print("=" * 50)
|
|
||||||
print(" Nicsensor 一键打包脚本")
|
|
||||||
print("=" * 50)
|
|
||||||
print("使用方法:")
|
|
||||||
print(" python pack.py 版本号")
|
|
||||||
print()
|
|
||||||
print("示例:")
|
|
||||||
print(" python pack.py v1.0.0")
|
|
||||||
print(" python pack.py 2.5.0")
|
|
||||||
print("=" * 50)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
if len(sys.argv) != 2:
|
|
||||||
show_usage()
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
version = sys.argv[1]
|
|
||||||
build_all(version)
|
|
||||||
@ -1,45 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# 20250627
|
|
||||||
# A tool script to test a value greater or less than threhold
|
|
||||||
|
|
||||||
data=$1
|
|
||||||
direction=$2
|
|
||||||
threhold=$3
|
|
||||||
param_num=$#
|
|
||||||
|
|
||||||
print_usage(){
|
|
||||||
echo " Script Usage"
|
|
||||||
echo " ./check_threhold.sh <value> <direction> <threhold>"
|
|
||||||
echo " @Param direction : greater , >"
|
|
||||||
echo " less , <"
|
|
||||||
echo " equal , ="
|
|
||||||
echo ""
|
|
||||||
echo " E.G. ./check_threhold.sh 500 > 1000"
|
|
||||||
echo " +--> Result : 0"
|
|
||||||
echo ""
|
|
||||||
echo " About Result: 1 means true, 0 means fault"
|
|
||||||
echo ""
|
|
||||||
}
|
|
||||||
|
|
||||||
main(){
|
|
||||||
if [ ${param_num} -ne 3 ];then
|
|
||||||
print_usage
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${direction}" = "great" ] || [ "${direction}" = ">" ];then
|
|
||||||
res= `echo " $data > $threhold" | bc -l`
|
|
||||||
elif [ "${direction}" = "less" ] || [ "${direction}" = "<" ];then
|
|
||||||
res= `echo " $data < $threhold" | bc -l`
|
|
||||||
elif [ "${direction}" = "equal" ] || [ "${direction}" = "=" ];then
|
|
||||||
res= `echo " $data = $threhold" | bc -l`
|
|
||||||
else
|
|
||||||
echo "Invalid direction"
|
|
||||||
print_usage
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo $res
|
|
||||||
}
|
|
||||||
|
|
||||||
main
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
# 测试治具说明
|
|
||||||
|
|
||||||
> [!info]
|
|
||||||
> nicsensor提供了一部分测试治具脚本用于辅助编写测试脚本
|
|
||||||
|
|
||||||
## 阈值校验脚本-check_threhold.sh
|
|
||||||
|
|
||||||
阈值校验脚本提供了判断数值是否大于目标阈值的方法, 可进行整数和小数的比较。使用方法如下:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
# 测试数据大于阈值
|
|
||||||
# 例如测试数据是否大于100,有如下使用方法
|
|
||||||
res=`./check_threhold.sh ${data} > 100`
|
|
||||||
if [ $res -eq 1 ];then
|
|
||||||
echo "data is greater than threholds"
|
|
||||||
else
|
|
||||||
echo "data isn't greater than threholds"
|
|
||||||
fi
|
|
||||||
```
|
|
||||||
Loading…
Reference in New Issue
Block a user