Compare commits
30 Commits
nicsensor-
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
250637a96c | ||
|
|
9b5d4a77d9 | ||
|
|
023aa38673 | ||
|
|
da64a8296a | ||
|
|
455b1509e5 | ||
|
|
daa30910c5 | ||
|
|
78a17a2843 | ||
| 8ec46fc9eb | |||
|
|
75658f06e8 | ||
|
|
3ca7de0ecf | ||
|
|
6458d5daa4 | ||
|
|
ef2c4495b0 | ||
| 27a77f05bd | |||
|
|
5510b0d96e | ||
|
|
5ad98b9226 | ||
|
|
7e3a6a1c38 | ||
|
|
43c1c4b210 | ||
|
|
0c56a7d01d | ||
|
|
b4169ce1f5 | ||
|
|
fcaa50bd0b | ||
| a3b2c16198 | |||
| 9eb8564b6c | |||
| 87e0d2b00a | |||
| 89aae7feb0 | |||
|
|
c58f8fc96f | ||
|
|
fba2e6f2f5 | ||
|
|
6c98851598 | ||
|
|
0836f65cc5 | ||
|
|
1470a86c3d | ||
|
|
034c3d7164 |
@ -1,9 +1,15 @@
|
||||
# Script Version 1.2
|
||||
# Script Version 1.3 20241229
|
||||
Release Note
|
||||
1.[新增功能]支持5280m7的OCP卡的使用
|
||||
2.[新增功能]支持传感器tmp468和tmp112
|
||||
|
||||
# Script Version 1.2 20241102
|
||||
Release Note:
|
||||
1.[新增功能]支持写入板卡FRU
|
||||
2.[新增功能]添加适配服务器 donghu yichun
|
||||
2.[新增功能]添加适配服务器 donghu yichun qiandaohu
|
||||
3.[功能优化]修复一些交互类bug,增强脚本健壮性
|
||||
4.[功能优化]更便捷的支持脚本传感器名称本地化
|
||||
5.[功能优化]debug模式下执行i2c detect时可自定义执行detect内容
|
||||
|
||||
# Script Version 1.1 20240912
|
||||
Release Note:
|
||||
|
||||
10
02.nicsensor/code_structure.txt
Normal file
10
02.nicsensor/code_structure.txt
Normal file
@ -0,0 +1,10 @@
|
||||
On Version V1.2
|
||||
start_get_sensor //启动读取Sensor的流程
|
||||
|--->set_configuration
|
||||
| |--->set_configuration_5280m7/5468m7/donghu/yichun //根据服务器类型设置具体I2C相关参数
|
||||
|--->get_pca9641_controll //如果服务器上有PCA9641,选通它
|
||||
|--->switch_pca9548_channel //切换9548/9546到对应的槽位上
|
||||
|--->process_sensor
|
||||
|--->sensor_init //传感器可能需要初始化
|
||||
|--->read_sensor_value //读取传感器的数值
|
||||
|--->convert_sensor_value //处理传感器的读值并做可视化处理
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,120 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
log="/tmp/nicsensor_debug.log"
|
||||
|
||||
INFO="Info"
|
||||
WARNING="Warning"
|
||||
ERROR="Error"
|
||||
|
||||
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_Channel0_name="Channel 0"
|
||||
ADC128_Channel1_name="Channel 1"
|
||||
ADC128_Channel2_name="Channel 2"
|
||||
ADC128_Channel3_name="Channel 3"
|
||||
ADC128_Channel4_name="Channel 4"
|
||||
ADC128_Channel5_name="Channel 5"
|
||||
ADC128_Channel6_name="Channel 6"
|
||||
ADC128_Channel7_name="Channel 7"
|
||||
|
||||
REG_adc128_config="0x00"
|
||||
REG_adc128_advance="0x0b"
|
||||
REG_adc128_status="0x0c"
|
||||
REG_adc128_ch0="0x20"
|
||||
REG_adc128_ch1="0x21"
|
||||
REG_adc128_ch2="0x22"
|
||||
REG_adc128_ch3="0x23"
|
||||
REG_adc128_ch4="0x24"
|
||||
REG_adc128_ch5="0x25"
|
||||
REG_adc128_ch6="0x26"
|
||||
REG_adc128_ch7="0x27"
|
||||
|
||||
# 进行ADC128芯片的初始化
|
||||
check_adc128_init(){
|
||||
# Get Reg 0x00 status
|
||||
res_adc128_status=`i2cget -y $i2c_bus $chip_slave $REG_adc128_config`
|
||||
format_log_print $INFO "REG adc128 STATUS : $res_adc128_status"
|
||||
|
||||
# if stauts is not 0x01 (Start Monitor) ,then do init
|
||||
if [ "$res_adc128_status" != "0x01" ];then
|
||||
format_log_print $INFO "Start Init ADC128 Chip"
|
||||
# Init ADC128 work as mode 1 (0x02)
|
||||
res_adc128_advance=`i2ctransfer -y $i2c_bus w2@$chip_slave $REG_adc128_advance 0x02`
|
||||
# Set ADC128 on start (0x01)
|
||||
res_adc128_setstart=`i2ctransfer -y $i2c_bus w2@$chip_slave $REG_adc128_config 0x01 r1`
|
||||
|
||||
format_log_print $INFO "After Set status, the REG 0x00 value is $res_adc128_setstart"
|
||||
fi
|
||||
}
|
||||
|
||||
# 处理ADC128读到的数据并输出结果
|
||||
# @Param 1 ADC128读取数据高位
|
||||
# @Param 2 ADC128读取数据低位
|
||||
# @Param 3 channel号/定制化名称
|
||||
# @Param 4 分压系数
|
||||
convert_adc128_data(){
|
||||
# 将读取到的两位数据拼接起来
|
||||
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
||||
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
||||
merge_value="${hex_value1}${hex_value2}"
|
||||
|
||||
# 由于 bc 计算器只能识别大写的 十六进制数据,这里将小写的十六进制数据全部转化为大写的数据
|
||||
upper_hex_value=$(echo "$merge_value" | awk '{
|
||||
for(i=1; i<=length($0); i++){
|
||||
if(tolower(substr($0,i,1)) ~ /^[a-f]$/)
|
||||
printf toupper(substr($0,i,1));
|
||||
else
|
||||
printf substr($0,i,1);
|
||||
}
|
||||
print ""
|
||||
}')
|
||||
|
||||
# 利用bc计算器进行运算,并将返回值格式化后输出
|
||||
dec_val=$(echo "ibase=16; $upper_hex_value" | bc)
|
||||
volt=$(echo "scale=4; $dec_val / 16 / 4096 * 2.65 / $4" | bc)
|
||||
format_volt=$(echo "$volt" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
|
||||
|
||||
echo "$3 : $format_volt v, hex value: $upper_hex_value"
|
||||
}
|
||||
|
||||
# 读取ADC128芯片每个通道的数据,随后调用数据处理函数进行数据解析并输出
|
||||
read_adc128_channel_value(){
|
||||
format_log_print $INFO "Start Read ADC128 channel data ..."
|
||||
|
||||
res_ch0=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_adc128_ch0 r2`
|
||||
res_ch1=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_adc128_ch1 r2`
|
||||
res_ch2=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_adc128_ch2 r2`
|
||||
res_ch3=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_adc128_ch3 r2`
|
||||
res_ch4=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_adc128_ch4 r2`
|
||||
res_ch5=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_adc128_ch5 r2`
|
||||
res_ch6=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_adc128_ch6 r2`
|
||||
res_ch7=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_adc128_ch7 r2`
|
||||
|
||||
# 将 I2C 读取的 raw 数据记录到调试日志中
|
||||
format_log_print $INFO "channel0 : $res_ch0"
|
||||
format_log_print $INFO "channel1 : $res_ch1"
|
||||
format_log_print $INFO "channel2 : $res_ch2"
|
||||
format_log_print $INFO "channel3 : $res_ch3"
|
||||
format_log_print $INFO "channel4 : $res_ch4"
|
||||
format_log_print $INFO "channel5 : $res_ch5"
|
||||
format_log_print $INFO "channel6 : $res_ch6"
|
||||
format_log_print $INFO "channel7 : $res_ch7"
|
||||
|
||||
# start parse raw data
|
||||
echo ">>> The ADC128 value is :"
|
||||
convert_adc128_data $res_ch0 $ADC128_Channel0_name $votage_division_factor_0
|
||||
convert_adc128_data $res_ch1 $ADC128_Channel1_name $votage_division_factor_1
|
||||
convert_adc128_data $res_ch2 $ADC128_Channel2_name $votage_division_factor_2
|
||||
convert_adc128_data $res_ch3 $ADC128_Channel3_name $votage_division_factor_3
|
||||
convert_adc128_data $res_ch4 $ADC128_Channel4_name $votage_division_factor_4
|
||||
convert_adc128_data $res_ch5 $ADC128_Channel5_name $votage_division_factor_5
|
||||
convert_adc128_data $res_ch6 $ADC128_Channel6_name $votage_division_factor_6
|
||||
convert_adc128_data $res_ch7 $ADC128_Channel7_name $votage_division_factor_7
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
log="/tmp/nicsensor_debug.log"
|
||||
|
||||
INFO="Info"
|
||||
WARNING="Warning"
|
||||
ERROR="Error"
|
||||
|
||||
# 临时支持CHIP读取寄存器
|
||||
write_read_chip(){
|
||||
|
||||
# Modify i2c cmd which write to cpld if need
|
||||
cmd_wr=$option_data
|
||||
res_wr=`$cmd_wr`
|
||||
|
||||
format_print $INFO ">>> Chip Command: $cmd_wr"
|
||||
format_print $INFO ">>> The Result : $res_wr"
|
||||
}
|
||||
@ -1,183 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
log="/tmp/nicsensor_debug.log"
|
||||
|
||||
INFO="Info"
|
||||
WARNING="Warning"
|
||||
ERROR="Error"
|
||||
|
||||
# 在 5280m7 上扫描每个pcie slot下的I2C设备
|
||||
# 详细对应关系参阅 readme.txt 第二节
|
||||
detect_on_5280m7(){
|
||||
# 从9641获取I2C控制权
|
||||
i2c_bus=12
|
||||
pca9641_slave="0x41"
|
||||
get_pca9641_controll
|
||||
|
||||
format_print $INFO "PCIe slot 0 : bus12 9548channel 1"
|
||||
i2ctransfer -y $i2c_bus w1@0x72 0x02
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
format_print $INFO "PCIe slot 1 : bus12 9548channel 2"
|
||||
i2ctransfer -y $i2c_bus w1@0x72 0x04
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
format_print $INFO "PCIe slot 2 : bus12 9548channel 3"
|
||||
i2ctransfer -y $i2c_bus w1@0x72 0x08
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
i2c_bus=13
|
||||
pca9641_slave="0x42"
|
||||
get_pca9641_controll
|
||||
|
||||
format_print $INFO "PCIe slot 3 : bus13 9548channel 1"
|
||||
i2ctransfer -y $i2c_bus w1@0x72 0x02
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
format_print $INFO "PCIe slot 4 : bus13 9548channel 2"
|
||||
i2ctransfer -y $i2c_bus w1@0x72 0x04
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
format_print $INFO "PCIe slot 5 : bus13 9548channel 3"
|
||||
i2ctransfer -y $i2c_bus w1@0x72 0x08
|
||||
i2cdetect -y $i2c_bus
|
||||
}
|
||||
|
||||
# 在 5468m7 上扫描每个pcie slot下的I2C设备
|
||||
# 详细对应关系参阅 readme.txt 第二节
|
||||
detect_on_5468m7(){
|
||||
# 从9641获取I2C控制权
|
||||
i2c_bus=13
|
||||
pca9641_slave="0x31"
|
||||
get_pca9641_controll
|
||||
|
||||
format_print $INFO "PCIe slot 0 : bus13 9548channel 0"
|
||||
i2ctransfer -y $i2c_bus w1@0x70 0x01
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
format_print $INFO "PCIe slot 1 : bus13 9548channel 1"
|
||||
i2ctransfer -y $i2c_bus w1@0x70 0x02
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
format_print $INFO "PCIe slot 2 : bus13 9548channel 2"
|
||||
i2ctransfer -y $i2c_bus w1@0x70 0x04
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
format_print $INFO "PCIe slot 3 : bus13 9548channel 3"
|
||||
i2ctransfer -y $i2c_bus w1@0x70 0x08
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
format_print $INFO "PCIe slot 4 : bus13 9548channel 4"
|
||||
i2ctransfer -y $i2c_bus w1@0x70 0x10
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
i2c_bus=14
|
||||
pca9641_slave="0x42"
|
||||
get_pca9641_controll
|
||||
|
||||
format_print $INFO "PCIe slot 5 : bus14 9548channel 0"
|
||||
i2ctransfer -y $i2c_bus w1@0x71 0x01
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
format_print $INFO "PCIe slot 6 : bus14 9548channel 1"
|
||||
i2ctransfer -y $i2c_bus w1@0x71 0x02
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
format_print $INFO "PCIe slot 7 : bus14 9548channel 2"
|
||||
i2ctransfer -y $i2c_bus w1@0x71 0x04
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
format_print $INFO "PCIe slot 8 : bus14 9548channel 3"
|
||||
i2ctransfer -y $i2c_bus w1@0x71 0x08
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
format_print $INFO "PCIe slot 9 : bus14 9548channel 4"
|
||||
i2ctransfer -y $i2c_bus w1@0x71 0x10
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
format_print $INFO "PCIe slot 10 : bus14 9548channel 5"
|
||||
i2ctransfer -y $i2c_bus w1@0x71 0x20
|
||||
i2cdetect -y $i2c_bus
|
||||
}
|
||||
|
||||
# 在 donghu 上扫描每个pcie slot下的I2C设备
|
||||
detect_on_donghu(){
|
||||
|
||||
i2c_bus=3
|
||||
|
||||
format_print $INFO "PCIe slot 0 : bus3 9548channel 7"
|
||||
i2ctransfer -y $i2c_bus w1@0x70 0x80
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
format_print $INFO "PCIe slot 1 : bus3 9548channel 6"
|
||||
i2ctransfer -y $i2c_bus w1@0x70 0x40
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
format_print $INFO "PCIe slot 2 : bus3 9548channel 5"
|
||||
i2ctransfer -y $i2c_bus w1@0x70 0x20
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
format_print $INFO "PCIe slot 3 : bus3 9548channel 4"
|
||||
i2ctransfer -y $i2c_bus w1@0x70 0x10
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
format_print $INFO "PCIe slot 4 : bus3 9548channel 3"
|
||||
i2ctransfer -y $i2c_bus w1@0x70 0x08
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
format_print $INFO "PCIe slot 5 : bus3 9548channel 2"
|
||||
i2ctransfer -y $i2c_bus w1@0x70 0x04
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
format_print $INFO "PCIe slot 6 : bus3 9548channel 1"
|
||||
i2ctransfer -y $i2c_bus w1@0x70 0x02
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
format_print $INFO "PCIe slot 7 : bus3 9548channel 0"
|
||||
i2ctransfer -y $i2c_bus w1@0x70 0x01
|
||||
i2cdetect -y $i2c_bus
|
||||
}
|
||||
|
||||
# 在 yichun 上扫描每个pcie slot下的I2C设备
|
||||
detect_on_yichun(){
|
||||
i2c_bus=12
|
||||
format_print $INFO "PCIe slot 0 : bus12 9546channel 2"
|
||||
i2ctransfer -y $i2c_bus w1@0x74 0x02
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
i2c_bus=13
|
||||
format_print $INFO "PCIe slot 1 : bus13 9546channel 2"
|
||||
i2ctransfer -y $i2c_bus w1@0x74 0x02
|
||||
i2cdetect -y $i2c_bus
|
||||
|
||||
i2c_bus=14
|
||||
format_print $INFO "PCIe slot 2 : bus14 9546channel 2"
|
||||
i2ctransfer -y $i2c_bus w1@0x74 0x02
|
||||
i2cdetect -y $i2c_bus
|
||||
}
|
||||
|
||||
# 搜索服务器所有PCIE插槽的I2C设备信息,当前仅支持特定Riser卡上的设备
|
||||
# change list : 20240912-支持服务器器型号5280m7,5468m7
|
||||
start_detect_device(){
|
||||
|
||||
# debug mode下进行detect操作仅对当前链路进行detect
|
||||
if [ $DEBUG_MODE -ne 0 ];then
|
||||
format_print $INFO "In debug mode now, only detect i2c_bus$i2c_bus:"
|
||||
i2cdetect -y $i2c_bus
|
||||
exit 0
|
||||
fi
|
||||
|
||||
format_print $INFO "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
|
||||
elif [ $server_type == "yichun" ];then
|
||||
detect_on_yichun
|
||||
else
|
||||
format_print $ERROR "Unsupport Server Type !!!"
|
||||
fi
|
||||
}
|
||||
@ -1,86 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
log="/tmp/nicsensor_debug.log"
|
||||
|
||||
INFO="Info"
|
||||
WARNING="Warning"
|
||||
ERROR="Error"
|
||||
|
||||
EMC1413_Channel0_name="Channel 0"
|
||||
EMC1413_Channel1_name="Channel 1"
|
||||
EMC1413_Channel2_name="Channel 2"
|
||||
|
||||
REG_emc1413_TD1_H="0x00"
|
||||
REG_emc1413_TD1_L="0x29"
|
||||
REG_emc1413_TD2_H="0x01"
|
||||
REG_emc1413_TD2_L="0x10"
|
||||
REG_emc1413_TD3_H="0x23"
|
||||
REG_emc1413_TD3_L="0x24"
|
||||
|
||||
# 处理EMC1413读到的数据并输出结果
|
||||
# @Param1 emc1413读取数据高位
|
||||
# @Param2 emc1413读取数据低位
|
||||
# @Param3 channel号/定制化名称
|
||||
convert_emc1413_data(){
|
||||
# 将读取到的两位数据去掉 0x 前缀
|
||||
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
||||
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
||||
|
||||
# 由于 bc 计算器只能识别大写的 十六进制数据,将小写的十六进制数据全部转化为大写的数据
|
||||
upper_hex_value1=$(echo "$hex_value1" | awk '{
|
||||
for(i=1; i<=length($0); i++){
|
||||
if(tolower(substr($0,i,1)) ~ /^[a-f]$/)
|
||||
printf toupper(substr($0,i,1));
|
||||
else
|
||||
printf substr($0,i,1);
|
||||
}
|
||||
print ""
|
||||
}')
|
||||
upper_hex_value2=$(echo "$hex_value2" | awk '{
|
||||
for(i=1; i<=length($0); i++){
|
||||
if(tolower(substr($0,i,1)) ~ /^[a-f]$/)
|
||||
printf toupper(substr($0,i,1));
|
||||
else
|
||||
printf substr($0,i,1);
|
||||
}
|
||||
print ""
|
||||
}')
|
||||
|
||||
# 转化为10进制数据
|
||||
dec_value1=$(echo "ibase=16; $upper_hex_value1" | bc)
|
||||
dec_value2=$(echo "ibase=16; $upper_hex_value2" | bc)
|
||||
|
||||
# 计算温度值
|
||||
temp=$(echo "scale=4; $dec_value1 + ($dec_value2 / 32 * 0.125 )" | bc)
|
||||
|
||||
# 格式化输出数据
|
||||
format_temp=$(echo "$temp" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
|
||||
|
||||
echo "$3 : $format_temp C, hex value : $hex_value1 $hex_value2"
|
||||
|
||||
}
|
||||
|
||||
# 读取EMC1413芯片每个通道的数据,随后调用数据处理函数进行数据解析并输出
|
||||
read_emc1413_channel_value(){
|
||||
|
||||
format_log_print $INFO "Start EMC1413 channel data ..."
|
||||
|
||||
res_td1_h=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_emc1413_TD1_H r1`
|
||||
res_td1_l=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_emc1413_TD1_L r1`
|
||||
res_td2_h=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_emc1413_TD2_H r1`
|
||||
res_td2_l=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_emc1413_TD2_L r1`
|
||||
res_td3_h=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_emc1413_TD3_H r1`
|
||||
res_td3_l=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_emc1413_TD3_L r1`
|
||||
|
||||
# 将 I2C 读取的 raw 数据记录到调试日志中
|
||||
format_log_print $INFO "channel 1 : $res_td1_h $res_td1_l"
|
||||
format_log_print $INFO "channel 2 : $res_td2_h $res_td2_l"
|
||||
format_log_print $INFO "channel 3 : $res_td3_h $res_td3_l"
|
||||
|
||||
# start parse raw data
|
||||
echo ">>> The emc1413 value is:"
|
||||
convert_emc1413_data $res_td1_h $res_td1_l $EMC1413_Channel0_name
|
||||
convert_emc1413_data $res_td2_h $res_td2_l $EMC1413_Channel1_name
|
||||
convert_emc1413_data $res_td3_h $res_td3_l $EMC1413_Channel2_name
|
||||
|
||||
}
|
||||
@ -1,92 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
log="/tmp/nicsensor_debug.log"
|
||||
|
||||
INFO="Info"
|
||||
WARNING="Warning"
|
||||
ERROR="Error"
|
||||
|
||||
# fru 烧录的起始地址
|
||||
fru_offset="0x00 0x00"
|
||||
|
||||
fru_write_size=0
|
||||
fru_write_data=""
|
||||
|
||||
# 将传入的fru文件解析为可被i2cransfer直接写入的数据
|
||||
parse_fru_write_data(){
|
||||
# 判断fru文件是否存在于当前目录
|
||||
if [ -e $fru_file_name ];then
|
||||
format_log_print $INFO "Fru file exist!"
|
||||
else
|
||||
format_log_print $ERROR "Fru file not exist!"
|
||||
format_print $WARNING "Fru file not exist in current directory!"
|
||||
format_print $ERROR "Operation Failed!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 计算需要写入的fru文件大小
|
||||
fru_write_size=`ls -lht | grep $fru_file_name | awk '{print $5}'`
|
||||
format_print $INFO "Fru File [$fru_file_name] size = $fru_write_size Bytes"
|
||||
format_log_print $INFO "Fru File [$fru_file_name] size = $fru_write_size Bytes"
|
||||
|
||||
# 获取fru文件的 raw data
|
||||
fru_raw_data=`hexdump -C $fru_file_name | awk '{
|
||||
for(i=2;i<18;i++){
|
||||
print $i
|
||||
}
|
||||
}'`
|
||||
format_log_print $INFO "Fru Raw Data: $fru_raw_data"
|
||||
|
||||
# 将raw data解析为可被 i2ctransfer 写入的数据
|
||||
fru_write_data=`echo $fru_raw_data | awk -v size=$fru_write_size '{
|
||||
for(i=1;i<=size;i++){
|
||||
printf "0x%s ",$i
|
||||
}
|
||||
}'`
|
||||
}
|
||||
|
||||
# 支持FRU读取
|
||||
read_fru(){
|
||||
|
||||
res_fru=`i2ctransfer -y $i2c_bus w2@$chip_slave $fru_offset r256`
|
||||
|
||||
# 将FRU数据按照每行16个字符输出
|
||||
echo "The Fru Data :"
|
||||
echo "$res_fru" | \
|
||||
awk '{
|
||||
line="";
|
||||
count=0;
|
||||
|
||||
for(i=1; i<=NF; i++){
|
||||
hex=substr($i, 3);
|
||||
|
||||
if(line != ""){
|
||||
line = line " ";
|
||||
}
|
||||
line = line hex;
|
||||
|
||||
count++;
|
||||
if (count == 16){
|
||||
print line;
|
||||
line = "";
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(line != ""){
|
||||
print line;
|
||||
}
|
||||
}'
|
||||
|
||||
}
|
||||
|
||||
# 20240926 支持写板卡FRU
|
||||
write_fru(){
|
||||
|
||||
i2c_write_byte=$(($fru_write_size+2))
|
||||
# 组装command并发送
|
||||
write_command="i2ctransfer -y $i2c_bus w$i2c_write_byte@$chip_slave $fru_offset $fru_write_data"
|
||||
write_res=`$write_command`
|
||||
format_log_print $INFO "Exec Command: $write_command"
|
||||
|
||||
}
|
||||
@ -1,155 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
log="/tmp/nicsensor_debug.log"
|
||||
|
||||
INFO="Info"
|
||||
WARNING="Warning"
|
||||
ERROR="Error"
|
||||
|
||||
shunt_resistor_0="2"
|
||||
shunt_resistor_1="2"
|
||||
shunt_resistor_2="5"
|
||||
|
||||
REG_ina3221_ch1="0x01"
|
||||
REG_ina3221_ch2="0x03"
|
||||
REG_ina3221_ch3="0x05"
|
||||
REG_ina3221_bus1="0x02"
|
||||
REG_ina3221_bus2="0x04"
|
||||
REG_ina3221_bus3="0x06"
|
||||
|
||||
INA3221_SHUNT_VOLT=0
|
||||
INA3221_BUS_VOLT=1
|
||||
INA3221_POWER=2
|
||||
|
||||
ina3221_ch0_volt="0"
|
||||
ina3221_ch1_volt="0"
|
||||
ina3221_ch2_volt="0"
|
||||
ina3221_ch0_current="0"
|
||||
ina3221_ch1_current="0"
|
||||
ina3221_ch2_current="0"
|
||||
|
||||
# 处理INA3221读到的电流数据并输出结果
|
||||
# @Param1 ina3221读取数据高位
|
||||
# @Param2 ina3221读取数据低位
|
||||
# @Param3 channel号
|
||||
# @Param4 0代表数据是shunt volt
|
||||
# 1代表数据是bus volt
|
||||
# @Param5 分流电阻 (仅在 Param4 是 shunt volt时有用)
|
||||
convert_ina3221_data(){
|
||||
# 将读取到的两位数据拼接起来
|
||||
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
||||
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
||||
merge_value="${hex_value1}${hex_value2}"
|
||||
|
||||
# 由于 bc 计算器只能识别大写的 十六进制数据,这里将小写的十六进制数据全部转化为大写的数据
|
||||
upper_hex_value=$(echo "$merge_value" | awk '{
|
||||
for(i=1; i<=length($0); i++){
|
||||
if(tolower(substr($0,i,1)) ~ /^[a-f]$/)
|
||||
printf toupper(substr($0,i,1));
|
||||
else
|
||||
printf substr($0,i,1);
|
||||
}
|
||||
print ""
|
||||
}')
|
||||
|
||||
# 将16进制数据转化为10进制
|
||||
dec_val=$(echo "ibase=16; $upper_hex_value" | bc)
|
||||
|
||||
# todo 检查这个数据的最高位是否为1
|
||||
# max_unsigned_32bit_half=$(echo "scale=0; 2^31 / 2" | bc)
|
||||
# if [ $(echo "$dec_val >= $max_unsigned_32bit_half" | bc) -eq 1 ];then
|
||||
# echo ""
|
||||
# else
|
||||
# echo ""
|
||||
# fi
|
||||
if [ $4 -eq $INA3221_BUS_VOLT ];then
|
||||
# 计算每个通道上的电压
|
||||
volt=$(echo "scale=4; $dec_val / 8 * 40 / 10000 * 2" | bc)
|
||||
|
||||
# 格式化输出数据
|
||||
format_volt=$(echo "$volt" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
|
||||
|
||||
echo "channel $3 : $format_volt V, hex value: $upper_hex_value"
|
||||
|
||||
if [ $3 -eq 0 ];then
|
||||
ina3221_ch0_volt=$format_volt
|
||||
elif [ $3 -eq 1 ];then
|
||||
ina3221_ch1_volt=$format_volt
|
||||
else
|
||||
ina3221_ch2_volt=$format_volt
|
||||
fi
|
||||
|
||||
elif [ $4 -eq $INA3221_SHUNT_VOLT ];then
|
||||
# 计算每个分流电阻上的电压,同时计算出电流
|
||||
current_mv=$(echo "scale=4; $dec_val / 8 * 40 / 1000" | bc)
|
||||
current=$(echo "scale=4; $current_mv / $5" | bc)
|
||||
|
||||
# 格式化输出数据
|
||||
format_current=$(echo "$current" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
|
||||
format_current_mv=$(echo "$current_mv" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
|
||||
|
||||
echo "channel $3 : $format_current A, shunt volt: $format_current_mv mV, shunt resistor: $5 mOhm, hex value: $upper_hex_value"
|
||||
|
||||
if [ $3 -eq 0 ];then
|
||||
ina3221_ch0_current=$format_current
|
||||
elif [ $3 -eq 1 ];then
|
||||
ina3221_ch1_current=$format_current
|
||||
else
|
||||
ina3221_ch2_current=$format_current
|
||||
fi
|
||||
|
||||
elif [ $4 -eq $INA3221_POWER ];then
|
||||
# 计算每个通道上的功耗,并算总和
|
||||
power_ch0=$(echo "scale=4; $ina3221_ch0_volt * $ina3221_ch0_current" | bc)
|
||||
power_ch1=$(echo "scale=4; $ina3221_ch1_volt * $ina3221_ch1_current" | bc)
|
||||
power_ch2=$(echo "scale=4; $ina3221_ch2_volt * $ina3221_ch2_current" | bc)
|
||||
|
||||
# 格式化输出数据
|
||||
format_power_ch0=$(echo "$power_ch0" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
|
||||
format_power_ch1=$(echo "$power_ch1" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
|
||||
format_power_ch2=$(echo "$power_ch2" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
|
||||
|
||||
total_power=$(echo "scale=4; $power_ch0 + $power_ch1 + $power_ch2" | bc)
|
||||
|
||||
echo "channel 0 : $format_power_ch0 W"
|
||||
echo "channel 1 : $format_power_ch1 W"
|
||||
echo "channel 2 : $format_power_ch2 W"
|
||||
echo "total power: $total_power W"
|
||||
fi
|
||||
}
|
||||
|
||||
# 读取INA3221芯片每个通道的数据,随后调用数据处理函数进行数据解析并输出
|
||||
read_ina3221_channel_value(){
|
||||
format_log_print $INFO "Start Read INA3221 channel data ..."
|
||||
|
||||
res_ch0=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_ina3221_ch1 r2`
|
||||
res_ch1=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_ina3221_ch2 r2`
|
||||
res_ch2=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_ina3221_ch3 r2`
|
||||
res_bus0=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_ina3221_bus1 r2`
|
||||
res_bus1=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_ina3221_bus2 r2`
|
||||
res_bus2=`i2ctransfer -y $i2c_bus w1@$chip_slave $REG_ina3221_bus3 r2`
|
||||
|
||||
|
||||
# 将 I2C 读取的 raw 数据记录到调试日志中
|
||||
format_log_print $INFO "channel 0 shunt volt: $res_ch0"
|
||||
format_log_print $INFO "channel 1 shunt volt: $res_ch1"
|
||||
format_log_print $INFO "channel 2 shunt volt: $res_ch2"
|
||||
|
||||
format_log_print $INFO "Channel 0 bus volt : $res_bus0"
|
||||
format_log_print $INFO "Channel 1 bus volt : $res_bus1"
|
||||
format_log_print $INFO "Channel 2 bus volt : $res_bus2"
|
||||
|
||||
# start parse raw data
|
||||
echo ">>> The INA3221 shunt value is :"
|
||||
convert_ina3221_data $res_ch0 0 $INA3221_SHUNT_VOLT $shunt_resistor_0
|
||||
convert_ina3221_data $res_ch1 1 $INA3221_SHUNT_VOLT $shunt_resistor_1
|
||||
convert_ina3221_data $res_ch2 2 $INA3221_SHUNT_VOLT $shunt_resistor_2
|
||||
|
||||
echo ">>> The INA3221 bus value is :"
|
||||
convert_ina3221_data $res_bus0 0 $INA3221_BUS_VOLT
|
||||
convert_ina3221_data $res_bus1 1 $INA3221_BUS_VOLT
|
||||
convert_ina3221_data $res_bus2 2 $INA3221_BUS_VOLT
|
||||
|
||||
echo ">>> The INA3221 bus power is :"
|
||||
convert_ina3221_data 0 0 0 $INA3221_POWER
|
||||
}
|
||||
4
02.nicsensor/readme.md
Normal file
4
02.nicsensor/readme.md
Normal file
@ -0,0 +1,4 @@
|
||||
# 文件更新
|
||||
|
||||
当前不在继续维护
|
||||
继续更新详见 [nicsensor](http://121.36.59.21:3000/Marcin/nicsensor)
|
||||
@ -1,138 +0,0 @@
|
||||
### 重要说明 : 脚本仅用于M7服务器,带有i2c standard tool工具的BMC使用
|
||||
### 仅限用于实验室调试使用
|
||||
|
||||
### 大纲
|
||||
一、脚本使用方法
|
||||
1.1 修改项目专属配置(必做)
|
||||
1.2 增加脚本可执行权限
|
||||
1.3 脚本命令格式
|
||||
1.4 特殊命令
|
||||
1.4.1 Detect命令
|
||||
1.4.2 fru命令
|
||||
1.4.3 读取芯片寄存器
|
||||
1.5 debug模式
|
||||
二、服务器PCIE槽位和PCA9548的channel关系
|
||||
三、M7 sysadmin用户 SSH打开方法
|
||||
四、常见问题
|
||||
|
||||
### 正文
|
||||
|
||||
一、脚本使用方法 Version1.2
|
||||
|
||||
1.1、修改项目专属配置
|
||||
针对不同项目,请先修改脚本中的部分变量(ADC128电压传感器的分压系数,INA3221的分流精密电阻阻值)
|
||||
针对不同服务器产品,请对应修改server_type变量, 当前支持设置的服务器型号:
|
||||
5280m7
|
||||
5468m7
|
||||
donghu
|
||||
|
||||
1.2、增加脚本可执行权限
|
||||
|
||||
在脚本目录下执行命令: chmod +x ./nicsensor.sh
|
||||
|
||||
1.3、脚本命令格式
|
||||
|
||||
./nicsensor.sh <pcie_slot> <chip_type> <chip_slave>
|
||||
|
||||
参数说明:
|
||||
pcie_slot : 网卡所在的PCIE槽位, 填数字0,1,2,3,4,5
|
||||
chip_type : 传感器芯片的类型, emc1413,adc128,ina3221
|
||||
chip_slave: 传感器芯片的I2C地址(7bit)
|
||||
|
||||
举例说明:读取PCIE 1 上网卡的adc128芯片, 芯片slave地址为0x1f
|
||||
./nicsensor.sh 1 adc128 0x1f
|
||||
|
||||
1.4、特殊命令
|
||||
|
||||
1.4.1 Detect命令
|
||||
|
||||
扫描服务器的PCIE slot 0 - 5上所有的I2C设备
|
||||
|
||||
命令: ./nicsensor.sh detect
|
||||
|
||||
1.4.2 fru命令
|
||||
|
||||
命令: ./nicsensor.sh <pcie_slot> fru <chip_slave> read
|
||||
举例说明:读取Ravel板卡的EEPROM中的FRU(0x57)
|
||||
- ./nicsensor.sh 5 fru 0x57 read
|
||||
|
||||
1.4.3 读取芯片寄存器
|
||||
|
||||
命令: ./nicsensor.sh <pcie_slot> chip <chip_slave> <i2c_cmd>
|
||||
举例说明: 读取cpld的寄存器 0x00 ,读2个byte
|
||||
- ./nicsensor.sh 5 chip 0x10 "i2ctransfer -y 13 w1@0x10 0x00 r2"
|
||||
|
||||
1.5、DEBUG模式
|
||||
|
||||
可通过配置脚本中的 DEBUG_MODE 变量(In Srcipt Line:112)来使用debug模式,在debug模式下,不会执行选通
|
||||
9641,9548的操作,仅执行读取传感器的操作,因此启用debug模式后需要手动配置的变量有:
|
||||
i2c_bus
|
||||
|
||||
|
||||
二、服务器PCIE槽位和PCA9548的channel关系
|
||||
|
||||
5280M7的PCIE槽位和PCA9548/9546没有确定的对应关系,取决于使用的riser卡.根据一般情况选择的Riser卡, 对应
|
||||
情况如下:
|
||||
|
||||
PCIE 0 = i2c bus 12 , 9548channel1(0x02)
|
||||
PCIE 1 = i2c bus 12 , 9548channel2(0x04)
|
||||
PCIE 2 = i2c bus 12 , 9548channel3(0x08)
|
||||
PCIE 3 = i2c bus 13 , 9548channel1(0x02)
|
||||
PCIE 4 = i2c bus 13 , 9548channel2(0x04)
|
||||
PCIE 5 = i2c bus 13 , 9548channel3(0x08)
|
||||
|
||||
5468M7的PCIE槽位和PCA9548/9546的对应关系:
|
||||
|
||||
PCIE 0 = i2c bus 13 , 9548channel0(0x01)
|
||||
PCIE 1 = i2c bus 13 , 9548channel1(0x02)
|
||||
PCIE 2 = i2c bus 13 , 9548channel2(0x04)
|
||||
PCIE 3 = i2c bus 13 , 9548channel3(0x08)
|
||||
PCIE 4 = i2c bus 13 , 9548channel4(0x10)
|
||||
PCIE 5 = i2c bus 14 , 9548channel0(0x01)
|
||||
PCIE 6 = i2c bus 14 , 9548channel1(0x02)
|
||||
PCIE 7 = i2c bus 14 , 9548channel2(0x04)
|
||||
PCIE 8 = i2c bus 14 , 9548channel3(0x08)
|
||||
PCIE 9 = i2c bus 14 , 9548channel4(0x10)
|
||||
PCIE 10 = i2c bus 14 , 9548channel5(0x20)
|
||||
|
||||
针对不同服务器产品,请对应修改server_type变量,当前支持的服务器类型:
|
||||
5280m7
|
||||
5468m7
|
||||
|
||||
三、M7 sysadmin用户 SSH打开方法
|
||||
|
||||
5280M7服务器默认不开启SSH, 且串口通常有较多干扰打印, 因此推荐使用SSH来执行脚本, 刷新BMC镜像后需要重新配置
|
||||
|
||||
1、打开M7 BMC的串口, 可通过串口线或者IPMI SOL带外登入
|
||||
|
||||
使用IPMI SOL的前提环境: 可与BMC网络连接, 且电脑上有ipmitool工具
|
||||
SOL登陆方法:
|
||||
(1) 将SOL串口源切换到BMC:
|
||||
ipmitool -I lanplus -H <bmcip> -U admin -P admin raw 0x3c 0x2c 0x02 0x01
|
||||
(2) 打开SOL:
|
||||
ipmitool -I lanplus -H <bmcip> -U admin -P admin sol activate
|
||||
备注: <bmcip> 为目标BMC的ip地址, 请自行更改为对应的ip地址
|
||||
|
||||
2、登录进入bmc的linux系统
|
||||
|
||||
bmc linux系统的默认用户名/密码 : sysadmin/superuser
|
||||
|
||||
3、在BMC的linux系统下执行命令
|
||||
|
||||
(1) cp /etc/defconfig/ssh_server_config_with_sysadmin /etc/ssh/sshd_config
|
||||
|
||||
(2) /etc/init.d/ssh restart
|
||||
|
||||
执行完毕后,就可以使用ssh登录BMC了
|
||||
|
||||
四、常见问题
|
||||
|
||||
1、脚本执行时出现大量的 Error
|
||||
|
||||
由于M7服务器的I2C设计有PCA9641作为I2C仲裁器, 脚本执行过程中可能会被9641强行断开I2C连接, 造成大量的
|
||||
脚本Error, 这种情况在实际运行中是不可避免的, 直接重新执行脚本即可
|
||||
|
||||
2、不建议使用该脚本进行压力测试
|
||||
|
||||
由于BMC shell的版本非常原始, 没有集成高级的命令行工具, 因此处理数值时采用了复杂的脚本逻辑进行执行, 处
|
||||
理效率较低。另外由于9641芯片的存在, 不能保证压力测试的正常执行。
|
||||
9
05.auto_work/obsidian_pull.bat
Normal file
9
05.auto_work/obsidian_pull.bat
Normal file
@ -0,0 +1,9 @@
|
||||
@echo off
|
||||
::配置Obsidian workspace地址
|
||||
set obsidian_path="D:\Files\3.SelfLerning\Marcin's_Repo"
|
||||
::切换目录到 Obsidian workspace下
|
||||
D:
|
||||
cd %obsidian_path%
|
||||
|
||||
::先拉取远端更新
|
||||
git pull
|
||||
20
05.auto_work/obsidian_push.bat
Normal file
20
05.auto_work/obsidian_push.bat
Normal file
@ -0,0 +1,20 @@
|
||||
@echo off
|
||||
::配置Obsidian workspace地址
|
||||
set obsidian_path="D:\Files\3.SelfLerning\Marcin's_Repo"
|
||||
::切换目录到 Obsidian workspace下
|
||||
D:
|
||||
cd %obsidian_path%
|
||||
|
||||
::判断是否有更新并将更新同步到远端仓库
|
||||
for /f "delims=" %%a in ('git status --porcelain') do (
|
||||
set HAS_CHANGES=1
|
||||
goto end_loop
|
||||
)
|
||||
:end_loop
|
||||
if defined HAS_CHANGES (
|
||||
git add -A
|
||||
git commit -m "Daily Sync from workbook"
|
||||
git push origin main
|
||||
) else (
|
||||
echo Git has no changes.
|
||||
)
|
||||
38
07.bmc_tool_script/Linux_CollectOnekeylog.sh
Normal file
38
07.bmc_tool_script/Linux_CollectOnekeylog.sh
Normal file
@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
BMC_IP=$1
|
||||
BMC_USER=$2
|
||||
BMC_PW=$3
|
||||
BMC_INFO="${BMC_USER}:${BMC_PW}"
|
||||
|
||||
if [ $# -lt 3 ];then
|
||||
echo "Script Usage:"
|
||||
echo " ./Outband_Collect_OneKeyLog.sh <BMC_IP> <BMC_USERNAME> <BMC_PASSWORD>"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Get BoardSN
|
||||
BoardSN=`ipmitool -H ${BMC_IP} -I lanplus -U ${BMC_USER} -P ${BMC_PW} fru print | grep "Board Serial" | awk '{print $4}'`
|
||||
|
||||
if [ "${BoardSN}" = "" ];then
|
||||
echo "Error: Can't Get BoardSN, please check network connection or user&password !"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
time=`date "+%Y-%m-%dT%H:%M:%S"`
|
||||
LOG_FILENAME="Product_${BoardSN}_${time}.tar.gz"
|
||||
|
||||
# Post message to BMC to collect all log
|
||||
echo -e "\n Step 1. Post Collect all log to BMC"
|
||||
curl -k -u $BMC_INFO -X POST -H "Content-Length: 0" https://${BMC_IP}/redfish/v1/Managers/1/LogServices/Actions/public/CollectAllLog
|
||||
|
||||
# Wait 60 seconds to Complete
|
||||
echo -e "\n Waiting 150 seconds for collect all log ..."
|
||||
sleep 150
|
||||
|
||||
# Download Onekeylog
|
||||
echo -e "\n Step 2. Download Onekeylog"
|
||||
curl -k -u $BMC_INFO -X POST -H "Content-Length: 0" https://${BMC_IP}/redfish/v1/Managers/1/LogServices/Actions/public/DownloadAllLog --output $LOG_FILENAME
|
||||
|
||||
# Complete
|
||||
echo -e "\n Complete Download Onekeylog"
|
||||
86
07.bmc_tool_script/Windows_CollectOnekeylog.bat
Normal file
86
07.bmc_tool_script/Windows_CollectOnekeylog.bat
Normal file
@ -0,0 +1,86 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
:: Param Check
|
||||
if "%1"=="" goto :USAGE
|
||||
if "%2"=="" goto :USAGE
|
||||
if "%3"=="" goto :USAGE
|
||||
|
||||
:: ==== Script will start here
|
||||
::echo Command Infomation
|
||||
::echo BMC_IP: %1
|
||||
::echo USER: %2
|
||||
::echo PASSWORD: %3
|
||||
|
||||
set "BMC_IP=%1"
|
||||
set "USER=%2"
|
||||
set "PASSWORD=%3"
|
||||
|
||||
set "BMC_INFO=%USER%:%PASSWORD%"
|
||||
set "redfish_fru_result=%CD%\fru_info.json"
|
||||
|
||||
:: Step0. Get BMC SN
|
||||
echo __________
|
||||
echo Opertion 1 : Check Network Connection with BMC...
|
||||
curl -k -u %BMC_INFO% -X GET "https://%BMC_IP%/redfish/v1/Systems/1/public/FRU" > %redfish_fru_result%
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo Connect to BMC Failed
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
for /f "delims=" %%a in ('
|
||||
powershell -command "$json = Get-Content -Path '%redfish_fru_result%' -Raw | ConvertFrom-Json; $json.'board'.'Board Serial'"
|
||||
') do set "value=%%a"
|
||||
set "BoardSN=%value%"
|
||||
|
||||
:: Setp1. Get local time stamp
|
||||
set "dt=%DATE% %TIME%"
|
||||
for /f "tokens=2 delims==" %%a in ('wmic OS get LocalDateTime /value') do set "dt=%%a"
|
||||
set "year=%dt:~0,4%"
|
||||
set "month=%dt:~4,2%"
|
||||
set "day=%dt:~6,2%"
|
||||
set "hour=%dt:~8,2%"
|
||||
set "minute=%dt:~10,2%"
|
||||
set "second=%dt:~12,2%"
|
||||
|
||||
set "timestamp=%year%%month%%day%T%hour%%minute%%second%"
|
||||
::echo TimeStamp: %timestamp%
|
||||
set "LogFile=%CD%\Product_%BoardSN%_%timestamp%.tar.gz"
|
||||
|
||||
:: Step2. Post Collect Onekeylog Request to BMC by redfish
|
||||
echo __________
|
||||
echo Opertion 2 : Post Request to BMC...
|
||||
curl -k -u %BMC_INFO% -X POST -H "Content-Length: 0" "https://%BMC_IP%/redfish/v1/Managers/1/LogServices/Actions/public/CollectAllLog"
|
||||
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo Post Request Error
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:: Step3. Wait 150s to Complete Collect
|
||||
echo __________
|
||||
echo Opertion 3 : Wait 150s for bmc to collect onekeylog...
|
||||
timeout /t 150 /nobreak
|
||||
|
||||
:: Step4. Download Onekeylog
|
||||
echo __________
|
||||
echo Opertion 4 : Download onekeylog now ...
|
||||
curl -k -u %BMC_INFO% -X POST -H "Content-Length: 0" "https://%BMC_IP%/redfish/v1/Managers/1/LogServices/Actions/public/DownloadAllLog" --output %LogFile%
|
||||
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo Download Onekeylog Error
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:: === Complete
|
||||
echo __________
|
||||
echo Opertion 5 : Success Download Onekeylog
|
||||
echo Onekeylog Path: %LogFile%
|
||||
goto :END
|
||||
|
||||
:USAGE
|
||||
echo Invalid command format
|
||||
echo Script Format : CollectOnekeylog.bat [bmc ip] [username] [password]
|
||||
|
||||
:END
|
||||
endlocal
|
||||
5
07.bmc_tool_script/manual_crashdump.sh
Normal file
5
07.bmc_tool_script/manual_crashdump.sh
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
pid=`ps aux | grep Crashdump | awk 'NR==1{print $2}'`
|
||||
kill $pid
|
||||
Crashdump --dump-now
|
||||
114
07.bmc_tool_script/read_adc_reg.sh
Normal file
114
07.bmc_tool_script/read_adc_reg.sh
Normal file
@ -0,0 +1,114 @@
|
||||
#!/bin/sh
|
||||
|
||||
# ADC Base Address 0x1e6e 9000
|
||||
# Channel0 & Channel 1 0x10
|
||||
# Channel2 & Channel 3 0x14
|
||||
# Channel4 & Channel 5 0x18
|
||||
# Channel6 & Channel 7 0x1c
|
||||
# Channel8 & Channel 9 0x20
|
||||
# Channel10 & Channel 11 0x24
|
||||
# Channel12 & Channel 13 0x28
|
||||
# Channel14 & Channel 15 0x2c
|
||||
|
||||
# volt = ((data+1.0) /1024) *1.8; //ADC calculation formular
|
||||
# volt *= resist; /* based on the hardware resistance added*/
|
||||
|
||||
|
||||
Board_Desc="Common_Board"
|
||||
Low_Position=0
|
||||
High_Position=1
|
||||
# ---------------------------------------------------------------
|
||||
# Resist List
|
||||
# ---------------------------------------------------------------
|
||||
Channel00_resist=1
|
||||
Channel01_resist=1
|
||||
Channel02_resist=1
|
||||
Channel03_resist=1
|
||||
Channel04_resist=1
|
||||
Channel05_resist=1
|
||||
Channel06_resist=1
|
||||
Channel07_resist=1
|
||||
Channel08_resist=1
|
||||
Channel09_resist=1
|
||||
Channel10_resist=1
|
||||
Channel11_resist=1
|
||||
Channel12_resist=1
|
||||
Channel13_resist=1
|
||||
Channel14_resist=1
|
||||
Channel15_resist=1
|
||||
|
||||
# ---------------------------------------------------------------
|
||||
# Channel Name
|
||||
# ---------------------------------------------------------------
|
||||
Channel00_name="Channel00_Volt"
|
||||
Channel01_name="Channel01_Volt"
|
||||
Channel02_name="Channel02_Volt"
|
||||
Channel03_name="Channel03_Volt"
|
||||
Channel04_name="Channel04_Volt"
|
||||
Channel05_name="Channel05_Volt"
|
||||
Channel06_name="Channel06_Volt"
|
||||
Channel07_name="Channel07_Volt"
|
||||
Channel08_name="Channel08_Volt"
|
||||
Channel09_name="Channel09_Volt"
|
||||
Channel10_name="Channel10_Volt"
|
||||
Channel11_name="Channel11_Volt"
|
||||
Channel12_name="Channel12_Volt"
|
||||
Channel13_name="Channel13_Volt"
|
||||
Channel14_name="Channel14_Volt"
|
||||
Channel15_name="Channel15_Volt"
|
||||
|
||||
# ---------------------------------------------------------------
|
||||
# Function Define
|
||||
# ---------------------------------------------------------------
|
||||
# @Param1 ChannelNumber
|
||||
# @Param2 ChannelRegOffset
|
||||
# @Param3 Pos Flag
|
||||
# @Param4 ChannelName
|
||||
# @Param5 ChannelResist
|
||||
read_channel_and_convert(){
|
||||
RegAddr=0x1e6e90$2
|
||||
# echo "RegAddr=${RegAddr}"
|
||||
|
||||
res=`devmem ${RegAddr} 32`
|
||||
# echo $res
|
||||
if [ $3 = $Low_Position ];then
|
||||
ex=$(echo ${res} | cut -c 8)
|
||||
h=$(echo ${res} | cut -c 9)
|
||||
l=$(echo ${res} | cut -c 10)
|
||||
hex_raw=${ex}${h}${l}
|
||||
else
|
||||
ex=$(echo ${res} | cut -c 4)
|
||||
h=$(echo ${res} | cut -c 5)
|
||||
l=$(echo ${res} | cut -c 6)
|
||||
hex_raw=${ex}${h}${l}
|
||||
fi
|
||||
|
||||
# Convert hex raw data to sensor value
|
||||
dec_raw=$(echo "ibase=16; ${hex_raw}" | bc)
|
||||
volt=$(echo "scale=4; ((${dec_raw} + 1.0) / 1024) * 1.8 * ${5} " | bc)
|
||||
format_volt=$(echo "$volt" | awk '{ if ($0 ~ /^\./) print "0" $0; else print $0 }')
|
||||
|
||||
# Output result
|
||||
echo "Channel$1 | $4 : ${format_volt}V"
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------
|
||||
# Main
|
||||
# ---------------------------------------------------------------
|
||||
echo "Board Name : ${Board_Desc}"
|
||||
read_channel_and_convert "00" "10" ${Low_Position} "${Channel00_name}" "${Channel00_resist}"
|
||||
read_channel_and_convert "01" "10" ${High_Position} "${Channel01_name}" "${Channel01_resist}"
|
||||
read_channel_and_convert "02" "14" ${Low_Position} "${Channel02_name}" "${Channel02_resist}"
|
||||
read_channel_and_convert "03" "14" ${High_Position} "${Channel03_name}" "${Channel03_resist}"
|
||||
read_channel_and_convert "04" "18" ${Low_Position} "${Channel04_name}" "${Channel04_resist}"
|
||||
read_channel_and_convert "05" "18" ${High_Position} "${Channel05_name}" "${Channel05_resist}"
|
||||
read_channel_and_convert "06" "1c" ${Low_Position} "${Channel06_name}" "${Channel06_resist}"
|
||||
read_channel_and_convert "07" "1c" ${High_Position} "${Channel07_name}" "${Channel07_resist}"
|
||||
read_channel_and_convert "08" "20" ${Low_Position} "${Channel08_name}" "${Channel08_resist}"
|
||||
read_channel_and_convert "09" "20" ${High_Position} "${Channel09_name}" "${Channel09_resist}"
|
||||
read_channel_and_convert "10" "24" ${Low_Position} "${Channel10_name}" "${Channel10_resist}"
|
||||
read_channel_and_convert "11" "24" ${High_Position} "${Channel11_name}" "${Channel11_resist}"
|
||||
read_channel_and_convert "12" "28" ${Low_Position} "${Channel12_name}" "${Channel12_resist}"
|
||||
read_channel_and_convert "13" "28" ${High_Position} "${Channel13_name}" "${Channel13_resist}"
|
||||
read_channel_and_convert "14" "2c" ${Low_Position} "${Channel14_name}" "${Channel14_resist}"
|
||||
read_channel_and_convert "15" "2c" ${High_Position} "${Channel15_name}" "${Channel15_resist}"
|
||||
@ -17,3 +17,9 @@
|
||||
|
||||
### 脚本模板
|
||||
- 简单的循环模板 :[template_loop.sh](./03.template/template_loop.sh)
|
||||
|
||||
### BMC工具脚本
|
||||
- Linux系统下一键收集日志 :[Linux_CollectOnekeylog.sh](./07.bmc_tool_script/Linux_CollectOnekeylog.sh)
|
||||
- Windows系统下一键收集日志 :[Windows_CollectOnekeylog.bat](./07.bmc_tool_script/Windows_CollectOnekeylog.bat)
|
||||
- BMC下快速读取ADC寄存器的数值 :[read_adc_reg.sh](./07.bmc_tool_script/read_adc_reg.sh)
|
||||
- BMC下手动触发Crashdump : [manul_crashdump.sh](./07.bmc_tool_script/manual_crashdump.sh)
|
||||
Loading…
Reference in New Issue
Block a user