# nicsensor工具使用说明 > 本说明仅针对 nicsensorv1.x系列脚本 > 1.x系列工具本体: [nicsensor.sh](./nicsensor.sh) ## 快速使用 工具Usage :`./nicsensor.sh help` 工具版本查询 :`./nicsensor.sh version` 读取传感器:`./nicsensor.sh pcie0 ina3221 0x42` (读取PCIE_0 上网卡的 INA3221 传感器,slave地址0x42) ## 目录 - [nicsensor工具使用说明](#nicsensor工具使用说明) - [目录](#目录) - [1.简介](#1_简介) - [2.使用方法](#2_使用方法) - [2.1 传感器读取](#2_1_传感器读取) - [2.2 FRU读写](#2_2_fru读写) - [2.3 命令透传](#2_3_命令透传) - [2.4 服务器网卡通道I2C信息扫描](#2_4_服务器网卡通道I2C信息扫描) - [2.5 调试模式](#2_5_调试模式) - [2.6 扩展功能](#2_6_扩展功能) - [2.7 参数配置](#2_7_参数配置) - [2.8 PMBUS功能测试](#2_8_pmbus功能) - [2.9 压力测试stress](#2_9_压力测试stress) - [3.常见问题](#3_常见问题) - [3.1 ADC128传感器读值为0](#3_1_adc128传感器读值为0) - [3.2 脚本执行时出现大批量语法错误](#3_2_脚本执行时出现大批量语法错误) - [3.3 传感器读值不正确](#3_3_传感器读值不正确) - [4.附属工具](#4_附属工具) - [4.1 FruParse](#4_1_fruparse) - [4.2 nicsensor\_s(已停用)](#4_2_nicsensor_s) - [5.关于nicsensor\_v2](#5_关于nicsensor_v2) - [6.附录](#6_附录) - [6.1 Project变量说明](#6_1_project变量说明) ## 1_简介 nicsensor工具是在带有i2ctool工具(i2ctransfer、i2cdetect)的BMC下用于测试网卡I2C功能的工具。 **当前支持的功能有:** - 读取网卡上的I2C传感器 - 读取并修改网卡上的FRU - 透传I2C命令到网卡的芯片上 - 遍历服务器上的PCIE插槽的I2C信息 - 部分服务器类型支持读取OCP卡 - 支持记录单次运行日志 - 支持测试PMBUS功能**(new)** - 支持进行压力测试**(new)** **当前支持测试的传感器类型** - adc128 - ina3221 - ina226**(new)** - emc1413 - tmp468 - tmp112 - lm95241**(new)** ## 2_使用方法 > [!warning] > 在使用时针对网卡的硬件特性需要定制化修改脚本的 `Project Varible` ,变量的对应关系及说明见[Project变量说明](#6_1_project变量说明) ### 2_1_传感器读取 **命令格式** ``` shell ./nicsensor.sh ``` **参数说明** | Properties | type | 说明 | | -------------- | ------- | ------------------------------------------------------------ | | `pcie slot` | string | 网卡位于的PCIE SLOT槽位,需要指定pcie/ocp, 不指定时默认为pcie类型 | | `sensor type` | string | 传感器类型 | | `sensor slave` | hex num | 传感器的slave地址(7 bit) | **命令示例** ``` shell # 读取pcie2槽位上的adc128的信息, adc128芯片的地址为0x1f(7bit) ./nicsensor.sh pcie2 adc128 0x1f # 读取pcie3槽位上的ina3221的信息, ina3221芯片的地址为0x40(7bit) ./nicsensor.sh 3 ina3221 0x40 # 读取ocp0槽位上的tmp112的信息, tmp112芯片的地址为0x48(7bit) ./nicsensor.sh ocp0 tmp112 0x48 ``` ### 2_2_FRU读写 > [!warning] > 在写入网卡FRU操作时,受限于服务器PCA9641的影响,**建议**将服务器关机后执行 **命令格式** ``` shell # 读取FRU ./nicsensor.sh fru # 写入FRU ./nicsensor.sh fru write ``` **参数说明** | Properties | type | 说明 | | -------------- | ------- | ------------------------------------------------------------ | | `pcie slot` | string | 网卡位于的PCIE SLOT槽位,需要指定pcie/ocp, 不指定时默认为pcie类型 | | `eeprom slave` | hex num | FRU所在的eeprom芯片的slave地址(7 bit) | | `filename` | string | 仅在写入FRU时提供, 要写入的FRU bin文件路径 | **命令示例** ``` shell # 读取pcie2槽位上的fru信息, eeprom的芯片地址为0x50(7bit) ./nicsensor.sh pcie2 fru 0x50 # 写入pcie2槽位上网卡的fru ./nicsensor.sh pcie2 fru 0x50 write fru.bin ``` ### 2_3_命令透传 提供对芯片直接执行i2c命令的能力,通常用于访问网卡核心芯片如FPGA,Nic Controller等。 **命令格式** ``` shell ./nicsensor.sh chip ``` **参数说明** | Properties | type | 说明 | | ------------ | ------- | ------------------------------------------------------------ | | `pcie slot` | string | 网卡位于的PCIE SLOT槽位,需要指定pcie/ocp, 不指定时默认为pcie类型 | | `chip slave` | hex num | 芯片的slave地址(7 bit) | | `command` | string | 要透传执行的I2C命令 | **命令示例** ``` shell # 对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" ``` ### 2_4_服务器网卡通道I2C信息扫描 **命令格式** ``` shell ./nicsensor.sh detect ``` **参数说明** - `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 ``` **命令示例** ``` 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 pmbus ``` **参数说明** - `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 stress