feat(script : nicsensor.sh)update to version 1.3Intest Rev2
1.fix function spell error 2.remove some comments
This commit is contained in:
parent
b4169ce1f5
commit
0c56a7d01d
@ -117,7 +117,7 @@ ina3221_ch2_volt="0"
|
||||
ina3221_ch0_current="0"
|
||||
ina3221_ch1_current="0"
|
||||
ina3221_ch2_current="0"
|
||||
SCRIPT_VERSION="1.3 Intest Rev1"
|
||||
SCRIPT_VERSION="1.3 Intest Rev2"
|
||||
|
||||
fru_file_name=$option_data2
|
||||
fru_write_size=0
|
||||
@ -161,21 +161,21 @@ print_fru_command_format(){
|
||||
echo "Command Format : ./nicsensor.sh [slot] fru [slave] write [fru_file]"
|
||||
}
|
||||
|
||||
# 格式化输出信息
|
||||
# @Param1 信息等级 [Info Warning Error]
|
||||
# @Param2 信息内容
|
||||
# print format message to console
|
||||
# @Param1 message level [Info Warning Error]
|
||||
# @Param2 message content
|
||||
format_print(){
|
||||
echo ">>> [$1] $2"
|
||||
}
|
||||
|
||||
# 格式化输出信息到日志文件
|
||||
# @Param1 信息等级 [Info Warning Error]
|
||||
# @Param2 信息内容
|
||||
# print format message to log file
|
||||
# @Param1 message level [Info Warning Error]
|
||||
# @Param2 message content
|
||||
format_log_print(){
|
||||
echo "[$1] $2" >> $log
|
||||
}
|
||||
|
||||
# 切换一次9548的channel并进行一次标准的i2cdetect
|
||||
# switch pca9548 channels then do i2cdetect one times
|
||||
# @Param1 i2c bus number
|
||||
# @Param2 pca9548 slave address
|
||||
# @Param3 pca9548 channel hex value
|
||||
@ -187,17 +187,15 @@ do_i2c_detect(){
|
||||
i2cdetect -y $1
|
||||
}
|
||||
|
||||
# 自查一些脚本中的属性配置
|
||||
# script self test
|
||||
conf_pre_check(){
|
||||
|
||||
# 校验debug mode的值
|
||||
# check DEBUG_MODE value
|
||||
if [ $DEBUG_MODE -ne 0 && $DEBUG_MODE -ne 1 ];then
|
||||
format_print $ERROR "Invalid conf value, DEBUG_MODE: $DEBUG_MODE"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# 根据5280m7 pcie slot 和 i2c 对对应关系调整变量
|
||||
set_configuration_5280m7(){
|
||||
|
||||
# set pca9641 address && I2C BUS
|
||||
@ -243,7 +241,6 @@ set_configuration_5280m7(){
|
||||
fi
|
||||
}
|
||||
|
||||
# 根据5468m7 pcie slot 和 i2c 对对应关系调整变量
|
||||
set_configuration_5468m7(){
|
||||
|
||||
is_have_pca9641=1
|
||||
@ -285,7 +282,6 @@ set_configuration_5468m7(){
|
||||
fi
|
||||
}
|
||||
|
||||
# 根据donghu pcie slot 和 i2c 对对应关系调整变量
|
||||
set_configuration_donghu(){
|
||||
is_have_pca9641=0
|
||||
|
||||
@ -312,7 +308,6 @@ set_configuration_donghu(){
|
||||
|
||||
}
|
||||
|
||||
# 根据yichun pcie slot 和 i2c 对对应关系调整变量
|
||||
set_configuration_yichun(){
|
||||
is_have_pca9641=0
|
||||
pca9548_slave="0x74"
|
||||
@ -330,7 +325,6 @@ set_configuration_yichun(){
|
||||
fi
|
||||
}
|
||||
|
||||
# 根据qiandaohu pcie slot 和 i2c 对对应关系调整变量
|
||||
set_configuration_qiandaohu(){
|
||||
is_have_pca9641=0
|
||||
|
||||
@ -400,13 +394,12 @@ parse_nic_slot(){
|
||||
format_log_print $INFO "Slot Num : $slot_number"
|
||||
}
|
||||
|
||||
# 根据输入信息调整选通芯片的配置(PCA9641 PCA9548)
|
||||
# Base on the server type, set i2c conf
|
||||
set_configuration(){
|
||||
|
||||
format_log_print $INFO "Server Type : $server_type"
|
||||
parse_nic_slot
|
||||
|
||||
# 根据服务器型号执行对应的配置策略
|
||||
case $server_type in
|
||||
"5280m7")
|
||||
# Support PCIe and OCP configuration
|
||||
@ -431,9 +424,8 @@ set_configuration(){
|
||||
esac
|
||||
}
|
||||
|
||||
# 初始化调试日志
|
||||
init_debuglog(){
|
||||
# 只保留一次日志读取记录
|
||||
# only save one running log
|
||||
if [ -e $log ];then
|
||||
rm $log
|
||||
fi
|
||||
@ -448,10 +440,9 @@ init_debuglog(){
|
||||
fi
|
||||
}
|
||||
|
||||
# 记录配置信息日志
|
||||
# Before start test, record configurtion to log
|
||||
prepare_start_info(){
|
||||
|
||||
# 记录单次配置信息到调试日志中去
|
||||
format_log_print $INFO "PCIE slot : $nic_slot"
|
||||
format_log_print $INFO "I2C Bus: $i2c_bus"
|
||||
if [ $is_have_pca9641 -eq 1];then
|
||||
@ -466,8 +457,7 @@ prepare_start_info(){
|
||||
echo $res_info >> $log
|
||||
}
|
||||
|
||||
# 获取PCA9641的控制权
|
||||
get_pca9641_controll(){
|
||||
get_pca9641_control(){
|
||||
|
||||
# Request 9641 lock
|
||||
res_lock=`i2ctransfer -y $i2c_bus w2@$pca9641_slave $REG_pca9641_controll 0x81 r1`
|
||||
@ -487,7 +477,6 @@ get_pca9641_controll(){
|
||||
fi
|
||||
}
|
||||
|
||||
# 选通PCA9548的channel
|
||||
switch_pca9548_channel(){
|
||||
|
||||
# set 9548 channel
|
||||
@ -503,16 +492,16 @@ switch_pca9548_channel(){
|
||||
# ---------------------------------------------------------
|
||||
# Chip EMC1413
|
||||
# ---------------------------------------------------------
|
||||
# 处理EMC1413读到的数据并输出结果
|
||||
# @Param1 emc1413读取数据高位
|
||||
# @Param2 emc1413读取数据低位
|
||||
# @Param3 channel号/定制化名称
|
||||
# process sensor data then print to console
|
||||
# @Param1 emc1413 data high 8bit
|
||||
# @Param2 emc1413 data low 8bit
|
||||
# @Param3 customization channel name
|
||||
convert_emc1413_data(){
|
||||
# 将读取到的两位数据去掉 0x 前缀
|
||||
# remove data prefix '0x'
|
||||
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
||||
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
||||
|
||||
# 由于 bc 计算器只能识别大写的 十六进制数据,将小写的十六进制数据全部转化为大写的数据
|
||||
# bc calculator recognized upper case only, change data to upper case
|
||||
upper_hex_value1=$(echo "$hex_value1" | awk '{
|
||||
for(i=1; i<=length($0); i++){
|
||||
if(tolower(substr($0,i,1)) ~ /^[a-f]$/)
|
||||
@ -532,21 +521,21 @@ convert_emc1413_data(){
|
||||
print ""
|
||||
}')
|
||||
|
||||
# 转化为10进制数据
|
||||
# change data from hex to dec
|
||||
dec_value1=$(echo "ibase=16; $upper_hex_value1" | bc)
|
||||
dec_value2=$(echo "ibase=16; $upper_hex_value2" | bc)
|
||||
|
||||
# 计算温度值
|
||||
# calculate tempreture
|
||||
temp=$(echo "scale=4; $dec_value1 + ($dec_value2 / 32 * 0.125 )" | bc)
|
||||
|
||||
# 格式化输出数据
|
||||
# print result to consol
|
||||
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芯片每个通道的数据,随后调用数据处理函数进行数据解析并输出
|
||||
# Get the sensor data, then parse raw data
|
||||
read_emc1413_channel_value(){
|
||||
|
||||
format_log_print $INFO "Start EMC1413 channel data ..."
|
||||
@ -558,7 +547,7 @@ read_emc1413_channel_value(){
|
||||
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 数据记录到调试日志中
|
||||
# record i2c raw data to log
|
||||
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"
|
||||
@ -571,7 +560,6 @@ read_emc1413_channel_value(){
|
||||
|
||||
}
|
||||
|
||||
# EMC1413处理逻辑
|
||||
process_emc1413(){
|
||||
# emc1413 no need to init
|
||||
|
||||
@ -582,7 +570,7 @@ process_emc1413(){
|
||||
# ---------------------------------------------------------
|
||||
# Chip ADC128
|
||||
# ---------------------------------------------------------
|
||||
# 进行ADC128芯片的初始化
|
||||
# adc128 chip init if need
|
||||
check_adc128_init(){
|
||||
# Get Reg 0x00 status
|
||||
res_adc128_status=`i2cget -y $i2c_bus $chip_slave $REG_adc128_config`
|
||||
@ -600,18 +588,18 @@ check_adc128_init(){
|
||||
fi
|
||||
}
|
||||
|
||||
# 处理ADC128读到的数据并输出结果
|
||||
# @Param 1 ADC128读取数据高位
|
||||
# @Param 2 ADC128读取数据低位
|
||||
# @Param 3 channel号/定制化名称
|
||||
# @Param 4 分压系数
|
||||
# process sensor data then print to console
|
||||
# @Param 1 adc128 data high 8bit
|
||||
# @Param 2 adc128 data low 8bit
|
||||
# @Param 3 customization channel name
|
||||
# @Param 4 division factor
|
||||
convert_adc128_data(){
|
||||
# 将读取到的两位数据拼接起来
|
||||
# remove data prefix '0x'
|
||||
hex_value1=$(echo "$1" | awk '{sub(/^0x/,""); print}')
|
||||
hex_value2=$(echo "$2" | awk '{sub(/^0x/,""); print}')
|
||||
merge_value="${hex_value1}${hex_value2}"
|
||||
|
||||
# 由于 bc 计算器只能识别大写的 十六进制数据,这里将小写的十六进制数据全部转化为大写的数据
|
||||
# bc calculator recognized upper case only, change data to upper case
|
||||
upper_hex_value=$(echo "$merge_value" | awk '{
|
||||
for(i=1; i<=length($0); i++){
|
||||
if(tolower(substr($0,i,1)) ~ /^[a-f]$/)
|
||||
@ -622,7 +610,7 @@ convert_adc128_data(){
|
||||
print ""
|
||||
}')
|
||||
|
||||
# 利用bc计算器进行运算,并将返回值格式化后输出
|
||||
# calculate dec value then print it to console
|
||||
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 }')
|
||||
@ -630,7 +618,7 @@ convert_adc128_data(){
|
||||
echo "$3 : $format_volt v, hex value: $upper_hex_value"
|
||||
}
|
||||
|
||||
# 读取ADC128芯片每个通道的数据,随后调用数据处理函数进行数据解析并输出
|
||||
# Get the sensor data, then parse raw data
|
||||
read_adc128_channel_value(){
|
||||
format_log_print $INFO "Start Read ADC128 channel data ..."
|
||||
|
||||
@ -643,7 +631,7 @@ read_adc128_channel_value(){
|
||||
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 数据记录到调试日志中
|
||||
# record i2c raw data to log
|
||||
format_log_print $INFO "channel0 : $res_ch0"
|
||||
format_log_print $INFO "channel1 : $res_ch1"
|
||||
format_log_print $INFO "channel2 : $res_ch2"
|
||||
@ -665,7 +653,6 @@ read_adc128_channel_value(){
|
||||
convert_adc128_data $res_ch7 $ADC128_Channel7_name $votage_division_factor_7
|
||||
}
|
||||
|
||||
# ADC128处理逻辑
|
||||
process_adc128(){
|
||||
# check if chip adc128 need init
|
||||
check_adc128_init
|
||||
@ -677,21 +664,21 @@ process_adc128(){
|
||||
# ---------------------------------------------------------
|
||||
# Chip INA3221
|
||||
# ---------------------------------------------------------
|
||||
# 处理INA3221读到的电流数据并输出结果
|
||||
# @Param1 ina3221读取数据高位
|
||||
# @Param2 ina3221读取数据低位
|
||||
# @Param3 channel号
|
||||
# @Param4 0代表数据是shunt volt
|
||||
# 1代表数据是bus volt
|
||||
# @Param5 分流电阻 (仅在 Param4 是 shunt volt时有用)
|
||||
# @Param6 定制化名称
|
||||
# process sensor data then print to console
|
||||
# @Param1 ina3221 data high 8bit
|
||||
# @Param2 ina3221 data high 8bit
|
||||
# @Param3 channel number
|
||||
# @Param4 mode select 0 - shunt volt
|
||||
# 1 - bus volt
|
||||
# @Param5 shunt resistor(only used in mode shunt volt)
|
||||
# @Param6 customization channel name
|
||||
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 计算器只能识别大写的 十六进制数据,这里将小写的十六进制数据全部转化为大写的数据
|
||||
# bc calculator recognized upper case only, change data to upper case
|
||||
upper_hex_value=$(echo "$merge_value" | awk '{
|
||||
for(i=1; i<=length($0); i++){
|
||||
if(tolower(substr($0,i,1)) ~ /^[a-f]$/)
|
||||
@ -702,23 +689,12 @@ convert_ina3221_data(){
|
||||
print ""
|
||||
}')
|
||||
|
||||
# 将16进制数据转化为10进制
|
||||
# change data from hex to dec
|
||||
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 "$6 : $format_volt V, hex value: $upper_hex_value"
|
||||
|
||||
if [ $3 -eq 0 ];then
|
||||
@ -730,11 +706,9 @@ convert_ina3221_data(){
|
||||
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 }')
|
||||
|
||||
@ -749,12 +723,11 @@ convert_ina3221_data(){
|
||||
fi
|
||||
|
||||
elif [ $4 -eq $INA3221_POWER ];then
|
||||
# 计算每个通道上的功耗,并算总和
|
||||
# calculate power
|
||||
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 }')
|
||||
@ -768,7 +741,7 @@ convert_ina3221_data(){
|
||||
fi
|
||||
}
|
||||
|
||||
# 读取INA3221芯片每个通道的数据,随后调用数据处理函数进行数据解析并输出
|
||||
# Get the sensor data, then parse raw data
|
||||
read_ina3221_channel_value(){
|
||||
format_log_print $INFO "Start Read INA3221 channel data ..."
|
||||
|
||||
@ -779,8 +752,7 @@ read_ina3221_channel_value(){
|
||||
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 数据记录到调试日志中
|
||||
# record i2c raw data to log
|
||||
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"
|
||||
@ -804,7 +776,6 @@ read_ina3221_channel_value(){
|
||||
convert_ina3221_data 0 0 0 $INA3221_POWER
|
||||
}
|
||||
|
||||
# INA3221处理逻辑
|
||||
process_ina3221(){
|
||||
|
||||
# ina3221 no need to init first
|
||||
@ -816,7 +787,7 @@ process_ina3221(){
|
||||
# ---------------------------------------------------------
|
||||
# CHIP
|
||||
# ---------------------------------------------------------
|
||||
# 透传i2c命令到设备上
|
||||
# do a customization command
|
||||
write_read_chip(){
|
||||
|
||||
# Modify i2c cmd which write to cpld if need
|
||||
@ -827,22 +798,20 @@ write_read_chip(){
|
||||
format_print $INFO ">>> The Result : $res_wr"
|
||||
}
|
||||
|
||||
# chip处理逻辑
|
||||
process_chip(){
|
||||
|
||||
# cpld no need to init first
|
||||
|
||||
# write and read cpld
|
||||
write_read_chip
|
||||
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# FRU
|
||||
# ---------------------------------------------------------
|
||||
# 将传入的fru文件解析为可被i2cransfer直接写入的数据
|
||||
# parse fru file to hex string which can be used in i2ctransfer
|
||||
parse_fru_write_data(){
|
||||
# 判断fru文件是否存在于当前目录
|
||||
|
||||
if [ -e $fru_file_name ];then
|
||||
format_log_print $INFO "Fru file exist!"
|
||||
else
|
||||
@ -852,12 +821,12 @@ parse_fru_write_data(){
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 计算需要写入的fru文件大小
|
||||
# calculate fru size
|
||||
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
|
||||
# get fru raw data
|
||||
fru_raw_data=`hexdump -C $fru_file_name | awk '{
|
||||
for(i=2;i<18;i++){
|
||||
print $i
|
||||
@ -865,7 +834,7 @@ parse_fru_write_data(){
|
||||
}'`
|
||||
format_log_print $INFO "Fru Raw Data: $fru_raw_data"
|
||||
|
||||
# 将raw data解析为可被 i2ctransfer 写入的数据
|
||||
# parse data to hex string
|
||||
fru_write_data=`echo $fru_raw_data | awk -v size=$fru_write_size '{
|
||||
for(i=1;i<=size;i++){
|
||||
printf "0x%s ",$i
|
||||
@ -877,7 +846,7 @@ read_fru(){
|
||||
|
||||
res_fru=`i2ctransfer -y $i2c_bus w2@$chip_slave $fru_offset r256`
|
||||
|
||||
# 将FRU数据按照每行16个字符输出
|
||||
# print fru data every 16 bytes per row
|
||||
echo "The Fru Data :"
|
||||
echo "$res_fru" | \
|
||||
awk '{
|
||||
@ -907,18 +876,17 @@ read_fru(){
|
||||
|
||||
}
|
||||
|
||||
# todo 未测试功能
|
||||
# !!! untest function !!!s
|
||||
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"
|
||||
|
||||
}
|
||||
|
||||
# fru 处理逻辑
|
||||
process_fru(){
|
||||
# fru no need to init first
|
||||
|
||||
@ -926,7 +894,7 @@ process_fru(){
|
||||
if [ "$option_data" == "write" ];then
|
||||
write_fru
|
||||
else
|
||||
# 默认为读取操作
|
||||
# default action is read
|
||||
read_fru
|
||||
fi
|
||||
}
|
||||
@ -934,24 +902,20 @@ process_fru(){
|
||||
# END of CHIP Function
|
||||
# ---------------------------------------------------------
|
||||
|
||||
# 读取sensor流程的起点
|
||||
start_get_sensor(){
|
||||
|
||||
# 首先选通 PCA9641 和 PCA9548,构建I2C通路
|
||||
# 如果使用了debug模式,那么将不执行选通9641和9548的操作
|
||||
# switch pca9641 and pca9548
|
||||
# if enable debug mode, will not do this action.
|
||||
if [ $DEBUG_MODE -eq 0 ];then
|
||||
# set global varible by server type
|
||||
set_configuration
|
||||
|
||||
# 记录开始执行脚本前的I2C配置信息
|
||||
prepare_start_info
|
||||
|
||||
# 从9641获取I2C控制权
|
||||
# if we have 9641 on i2c, then do it
|
||||
if [ $is_have_pca9641 -eq 1 ];then
|
||||
get_pca9641_controll
|
||||
get_pca9641_control
|
||||
fi
|
||||
|
||||
# 选择9548 channel
|
||||
switch_pca9548_channel
|
||||
fi
|
||||
|
||||
@ -979,12 +943,10 @@ start_get_sensor(){
|
||||
esac
|
||||
}
|
||||
|
||||
# 在 5280m7 上扫描每个pcie slot下的I2C设备
|
||||
detect_on_5280m7(){
|
||||
# 从9641获取I2C控制权
|
||||
i2c_bus=12
|
||||
pca9641_slave="0x41"
|
||||
get_pca9641_controll
|
||||
get_pca9641_control
|
||||
|
||||
do_i2c_detect 12 0x72 0x02 1 0
|
||||
do_i2c_detect 12 0x72 0x04 2 1
|
||||
@ -992,19 +954,17 @@ detect_on_5280m7(){
|
||||
|
||||
i2c_bus=13
|
||||
pca9641_slave="0x42"
|
||||
get_pca9641_controll
|
||||
get_pca9641_control
|
||||
|
||||
do_i2c_detect 13 0x72 0x02 1 3
|
||||
do_i2c_detect 13 0x72 0x04 2 4
|
||||
do_i2c_detect 13 0x72 0x08 3 5
|
||||
}
|
||||
|
||||
# 在 5468m7 上扫描每个pcie slot下的I2C设备
|
||||
detect_on_5468m7(){
|
||||
# 从9641获取I2C控制权
|
||||
i2c_bus=13
|
||||
pca9641_slave="0x31"
|
||||
get_pca9641_controll
|
||||
get_pca9641_control
|
||||
|
||||
do_i2c_detect 13 0x70 0x01 0 0
|
||||
do_i2c_detect 13 0x70 0x02 1 1
|
||||
@ -1014,7 +974,7 @@ detect_on_5468m7(){
|
||||
|
||||
i2c_bus=14
|
||||
pca9641_slave="0x42"
|
||||
get_pca9641_controll
|
||||
get_pca9641_control
|
||||
|
||||
do_i2c_detect 14 0x71 0x01 0 5
|
||||
do_i2c_detect 14 0x71 0x02 1 6
|
||||
@ -1024,7 +984,6 @@ detect_on_5468m7(){
|
||||
do_i2c_detect 14 0x71 0x20 5 10
|
||||
}
|
||||
|
||||
# 在 donghu 上扫描每个pcie slot下的I2C设备
|
||||
detect_on_donghu(){
|
||||
i2c_bus=3
|
||||
do_i2c_detect 3 0x70 0x80 7 0
|
||||
@ -1037,7 +996,6 @@ detect_on_donghu(){
|
||||
do_i2c_detect 3 0x70 0x01 0 7
|
||||
}
|
||||
|
||||
# 在 yichun 上扫描每个pcie slot下的I2C设备
|
||||
detect_on_yichun(){
|
||||
i2c_bus=12
|
||||
do_i2c_detect 12 0x74 0x02 2 0
|
||||
@ -1049,7 +1007,6 @@ detect_on_yichun(){
|
||||
do_i2c_detect 14 0x74 0x02 2 2
|
||||
}
|
||||
|
||||
# 在 qiandaohu 上扫描每个pcie slot下的I2C设备
|
||||
detect_on_qiandaohu(){
|
||||
i2c_bus=3
|
||||
do_i2c_detect 3 0x70 0x08 3 0
|
||||
@ -1076,11 +1033,9 @@ debug_user_defined_detect(){
|
||||
i2cdetect -y $i2c_bus
|
||||
}
|
||||
|
||||
# 搜索服务器所有PCIE插槽的I2C设备信息,仅支持特定Riser卡上的设备
|
||||
# 一些服务器上由于riser卡不同可能导致对应关系不同
|
||||
start_detect_device(){
|
||||
|
||||
# debug mode下进行detect操作仅对当前链路进行detect
|
||||
# In debug mode, do customization detect action
|
||||
if [ $DEBUG_MODE -ne 0 ];then
|
||||
format_print $INFO "In debug mode now"
|
||||
debug_user_defined_detect
|
||||
@ -1114,10 +1069,9 @@ start_detect_device(){
|
||||
# Start Execute Script
|
||||
# ---------------------------------------------------------
|
||||
|
||||
# 配置校验
|
||||
conf_pre_check
|
||||
|
||||
# 参数合法校验
|
||||
# is param legel?
|
||||
if [ "$sensor_type" == "chip" ];then
|
||||
if [ $# -le 3 ];then
|
||||
format_print $ERROR "Command Format illegal"
|
||||
@ -1131,22 +1085,20 @@ if [ "$1" == "detect" ];then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 在正式执行脚本之前初始化调试日志
|
||||
init_debuglog
|
||||
|
||||
# 如果是fru write操作, 需要对即将写入的bin文件进行数据预处理
|
||||
# if the action is fru write, need pre-process fru data
|
||||
if [ "$sensor_type" == "fru" ];then
|
||||
if [ "$option_data" == "write" ];then
|
||||
format_log_print $INFO "Opreation FRU Write"
|
||||
|
||||
# 在fru write操作下要求必须有 option_data2, 做参数检查
|
||||
# is option_data(fru file name) valid?
|
||||
if [ "$option_data2" == "" ];then
|
||||
format_print $ERROR "Please provide fru file name"
|
||||
print_fru_command_format
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 解析fru bin文件
|
||||
parse_fru_write_data
|
||||
fi
|
||||
fi
|
||||
|
||||
Loading…
Reference in New Issue
Block a user