Note2MPS/PXE/ADS/INA电流电压,i2c设备在位和读,samba/nfs,ntp/log/me/树莓派,pip/office,vr,i2ctool,大数据,pam
Posted 码农编程录
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Note2MPS/PXE/ADS/INA电流电压,i2c设备在位和读,samba/nfs,ntp/log/me/树莓派,pip/office,vr,i2ctool,大数据,pam相关的知识,希望对你有一定的参考价值。
文章目录
- 1.读MPS5023芯片:0x03ff即将前6位屏蔽
- 2.读PXE1410CDM电压和电流:一个数&0x7ff,将这个数前5位全变为0,其余位不变
- 3.读ADS7830的8个channel电压: 无电流,max,min
- 4.读INA220电压和电流:Read_INA220_Voltage_Current.sh
- 5.check.sh:运行在BMC下用于检查i2c设备,自动打印检查结果,须在脚本后添加检查次数,否则一直循环。./check.sh num
- 6.check.py:运行在OS下用于检查DDR SFP CPLD设备,自动打印检查结果,需在脚本后指定DDR的bus,python check.py bus
- 7.check_port_tx_rx_setup.sh:取出第8位和第16位
- 8.pcie_check.py:检查PCIE信息,dec2hex,uuid
- 9.Samba服务器:利用文件传输协议:ftp,http,SMB(Samba)
- 10.NFS服务器:linux和linux之间,也可共享给win客户端
- 11./etc/ntp.conf:restrict (什么可访问我并可修改我的时间)10.75.92.0 mask 255.255.255.0 nomodify(nomodify不能修改我,只能访问同步走)
- 12.导出log:filenum=$(ls -l | wc -l) ,ls -tr | head -1
- 13.ME:bios是一段程序包含me文件,bios存在cpu的主备flash中,cpu上电后me通过spi通路一直往bios里写东西,bmc要升级bios时必须把me停了且把spi通路切到bmc端
- 14.树莓派:是完整个人电脑,功耗非常大(相比于没有soc的单片机),物联网中要性能弱,树莓派只用于教学,树莓派4性能更强并有了usb3.0口和千兆网卡,用来做NAS,但做局域网中NAS不需要这么高性能,路由器就行且功耗比树莓派低的多
- 15.pip/ffmpeg/office:su直接切换root,需输入root密码。sudo su/-i:当前用户暂时申请root权限,需输入当前用户密码
- 16.远程升级PXE和XDPE的FW:Use SMBus protocol to update VR controller fimware
- 17.i2ctransfer写数据到switch的eeprom:dd
- 18.i2c-tools使用:b(bus)d(device)f(offset)
- 19.大数据:DFS即分布式文件系统也是文件系统(使用这文件系统的用户,不用关心文件是如何分布的),像windows右击磁盘属性,可看到是NTFS文件系统格式
- 20.pam:linux下可扩展的鉴权模块,应用程序调用相应的/etc/pam.d/下配置文件进而调用本地的认证模块(模块放置在/lib/security下,以加载动态库的形式)。su命令系统会提示你输入root用户的密码,这就是su命令通过调用PAM模块实现的
1.读MPS5023芯片:0x03ff即将前6位屏蔽
# Read_FPGA_Power.sh
#!/bin/bash
stop_ipmistack()
cnt=0
while true
do
/etc/init.d/ipmistack stop >/dev/null 2>&1
s1=$(ps aux)
s2="/usr/local/bin/IPMIMain"
result=$(echo $s1 | grep "$s2")
if [[ "$result" == "" ]]
then
break
fi
if [ $cnt -eq 5 ]
then
echo "Unable to stop ipmistack !"
exit 1
fi
cnt=$(($cnt+1))
sleep 10
done
delete()
cnt=0
while true
do
echo 0x73 > /sys/bus/i2c/devices/i2c-7/delete_device #将bus7上0x73这设备删除
if [ $? = 0 ]
then
break
fi
if [ $cnt -eq 5 ]
then
echo "Unable to delete device !"
exit 1
fi
cnt=$(($cnt+1))
done
access()
cnt=0
while true
do
i2c-test -b 7 -s 0x73 -w -d 0x08 >/dev/null 2>&1
if [ $? = 0 ]
then
break
fi
if [ $cnt -eq 5 ]
then
echo $cnt
echo "Unable to access 9545 !"
exit 1
fi
cnt=$(($cnt+1))
echo $cnt
done
OpenChannel()
cnt=0
while true
do
i2c-test -b 7 -s 0x71 -w -d 0x80 >/dev/null 2>&1 #0x80打开channel8
if [ $? = 0 ]
then
break
fi
if [ $cnt -eq 5 ]
then
echo "Unable to access 9548 channel8 !"
exit 1
fi
cnt=$(($cnt+1))
done
read_voltage()
cnt=0
while true
do
val_v=$(i2c-test -b 7 -s 0x40 -m 1 -rc 2 -d 0x8b)
if [ $? = 0 ]
then
hexval_v_h=$val_v:14:2
hexval_v_l=$val_v:17:2
hexval_v=$hexval_v_l$hexval_v_h
#echo $hexval_v #0183
dec_v=$((0x$hexval_v & 0x3ff)) #&:有0为0,3ff:10个1, hex->dec
#echo $dec_v #388
dec_v_wv=$((dec_v*3125)) #31.25mV/LSB
dec_v_v=$((dec_v_wv/100000))
#echo $dec_v_v #12
break
fi
if [ $cnt -eq 5 ]
then
echo "Unable to read voltage !"
exit 1
fi
cnt=$(($cnt+1))
done
read_power()
cnt=0
while true
do
val_a=$(i2c-test -b 7 -s 0x40 -m 1 -rc 2 -d 0x8c) #电流
if [ $? = 0 ]
then
hexval_a_h=$val_a:14:2
hexval_a_l=$val_a:17:2
hexval_a=$hexval_a_l$hexval_a_h
#echo $hexval_a #0054
dec_a=$((0x$hexval_a & 0x3ff))
dec_a_wa=$((dec_a*6250))
dec_a_a=$((dec_a_wa/100000))
#echo $dec_a_a
power=$(($dec_v_v * $dec_a_a))
echo "FPGA Power : "$power"W"
break
fi
if [ $cnt -eq 5 ]
then
echo "Unable to read electricity !"
exit 1
fi
cnt=$(($cnt+1))
done
start_ipmistack()
cnt=0
while true
do
/etc/init.d/ipmistack start >/dev/null 2>&1
s1=$(ps aux)
s2="/usr/local/bin/IPMIMain"
result=$(echo $s1 | grep "$s2")
if [[ "$result" != "" ]]
then
break
fi
if [ $cnt -eq 5 ]
then
echo "Unable to start ipmistack !"
exit 1
fi
cnt=$(($cnt+1))
sleep 10
done
start_ipmistack
stop_ipmistack
delete
access
OpenChannel
read_voltage
read_power
start_ipmistack
2.读PXE1410CDM电压和电流:一个数&0x7ff,将这个数前5位全变为0,其余位不变
ipmitool raw 0x3a 0x10 <bus id> <slave addr> <Read count> <Data to write>
(00:第一个状态码不显示)
status , log_psu1 = run_command("sudo bash -c 'a=$(ipmitool raw 0x3a 0x10 14 0xb0 2 0x88) ; b=$a:1:2 ; c=$a:4:5 ; d=$c$b ; \\
f=`../utility/diag-tools/pmbus_tool/line11 0x$d` ; echo $f'") # psu1 输入电压
status , log_psu2 = run_command("sudo bash -c 'a=$(ipmitool raw 0x3a 0x10 15 0xb0 2 0x88) ; b=$a:1:2 ; c=$a:4:5 ; d=$c$b ; \\
f=`../utility/diag-tools/pmbus_tool/line11 0x$d` ; echo $f'") # psu2 输入电压
status , log_psu11 = run_command("sudo bash -c 'a=$(ipmitool raw 0x3a 0x10 14 0xb0 2 0x8b) ; b=$a:1:2 ; c=$a:4:5 ; d=$c$b ; \\
f=`../utility/diag-tools/pmbus_tool/line16 0x$d` ; echo $f'") # psu1 输出电压
status , log_psu22 = run_command("sudo bash -c 'a=$(ipmitool raw 0x3a 0x10 15 0xb0 2 0x8b) ; b=$a:1:2 ; c=$a:4:5 ; d=$c$b ; \\
f=`../utility/diag-tools/pmbus_tool/line16 0x$d` ; echo $f'") # psu2 输出电压
输入电压(mv):
root@gnr5713bb:/var/log/abak# i2cget -f -y 15 0x60 0x88 w
0xe9b6
root@gnr5713bb:/var/log/abak# i2cget -f -y 15 0x61 0x88 w
0xe9b5
root@gnr5713bb:/var/log/abak# i2cget -f -y 15 0x62 0x88 w
0xe9b6
root@gnr5713bb:/var/log/abak# ./line11_arm 0xe9b6
54750
输出电压(mv):
root@gnr5713bb:/var/log/abak# i2cget -f -y 15 0x60 0x8b w
0xc2ad
root@gnr5713bb:/var/log/abak# i2cget -f -y 15 0x61 0x8b w
0xc395
root@gnr5713bb:/var/log/abak# i2cget -f -y 15 0x62 0x8b w
0xc0f8
VOUT_MODE:
root@gnr5713bb:/var/log/abak# i2cget -f -y 15 0x60 0x20
0x14
root@gnr5713bb:/var/log/abak# i2cget -f -y 15 0x61 0x20
0x14
root@gnr5713bb:/var/log/abak# i2cget -f -y 15 0x62 0x20
0x14
root@gnr5713bb:/var/log/abak# ./line16_arm 0xc2ad 0x14
12167
root@gnr5713bb:/var/log/abak# ./line16_arm 0xc395 0x14
12223
root@gnr5713bb:/var/log/abak# ./line16_arm 0xc0f8 0x14
12060
2.1 1ine11
如下计算机以补码形式存放负数,0010+1=0011(十进制3)。
438乘2的-3次方 = 54.8(V)。
2.2 1ine16:一种方法
如下十六进制HEX c2ad ,49837乘2的-12次方 = 12.1(A)(不用0x20寄存器,0x14取反加1就是-12)。
2.3 1ine16:另一种方法
如下是0x20读出来是0x17的电源芯片:
如下取反加1后,十进制和十六进制都为9。
如下是c语言的线性转换,0x0184十六进制printf输出为十进制388。
//current.c arm编译器arm-linux-gcc (不是x86的gcc)编译成current(电流)可执行文件, linear11
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char ** argv)
short exponent;
int mantissa;
int val_x;
mantissa = ((signed short)((strtoul(argv[1],0,0) & 0x7ff) << 5)) >> 5;
// printf("%x\\n",mantissa);
exponent = ((signed short)strtoul(argv[1],0,0))>>11;
// printf("%d\\n",exponent);
val_x = mantissa * 1000L;
if (exponent >= 0)
val_x <<= exponent;
else
val_x >>= -exponent;
printf("%d\\n",val_x);
return 0;
// linear16
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char ** argv)
short exponent;
int mantissa;
int val_x;
mantissa = (signed short)strtoul(argv[1],0,0);
exponent = ((signed short)(0x17 << 11)) >> 11 ;
val_x = mantissa * 1000L;
if (exponent >= 0)
val_x <<= exponent;
else
val_x >>= -exponent;
printf("%d\\n",val_x);
return 0;
linear16_convert()
mantissa=$(printf %d "$1") # 有符号,也需像上面一样判断
if [ $((($2 >> 4) & 0x1)) == 1 ] ; then
exponent=$(((((($2 << 11)) >> 11)) & 0xf))
exponent=$(($exponent ^ 0xf))
exponent=$((~$exponent))
else
exponent=$(printf %d "$2")
fi
val_x=$((mantissa * 1000))
if [ $exponent -ge 0 ]; then
val_x=$(($val_x<<$exponent))
else
val_x=$(($val_x>>$((-$exponent))))
fi
echo $val_x
i2ctransfer -f -y $bus w1@$address $BLACKBOX_ADDRESS r51 # 读出的第一个byte是字节数即0x33即51字节
# Read_PXE1410CDM_0X62_Voltage_Current.sh
#!/bin/bash
write_ch0()
cnt=0
while true
do
i2c-test -b 7 -s 0x60 -w -d 0x0 0x00 >/dev/null 2>&1
if [ $? = 0 ]
then
break
fi
if [ $cnt -eq 5 ]
then
echo "Unable to write PXE CH0!"
exit 1
fi
cnt=$(($cnt+1))
done
read_ch0_voltage()
cnt=0
while true
do
val_v_0=$(i2c-test -b 7 -s 0x60 -m 1 -rc 2 -d 0x8b)
if [ $? = 0 ]
then
hex_v_h_0=$val_v_0:14:2
hex_v_l_0=$val_v_0:17:2
hex_v_0=$hex_v_l_0$hex_v_h_0
dec_v_0=$((0x$hex_v_0 & 0xff))
#echo $dec_v_0
dec_v_0=$(((500 + (dec_v_0 - 1) * 10)/2))
echo "PXE_0x60_0_P0V9_VCCH Voltage : "$dec_v_0"mV"
break
fi
if [ $cnt -eq 5 ]
then
echo "Unable to read ch0 voltage !"
exit 1
fi
cnt=$(($cnt+1))
done
read_ch0_current()
cnt=0
while true
do
val_a_0=$(i2c-test -b 7 -s 0x60 -m 1 -rc 2 -d 0x8c)
if [ $? = 0 ]
then
hex_a_h_0=$val_a_0:14:2
hex_a_l_0=$val_a_0:17:2
hex_a_0=$hex_a_l_0$hex_a_h_0
dec_a_0=$(./current 0x$hex_a_0)
echo "PXE_0x60_0 Current : "$dec_a_0"mA"
break
fi
if [ $cnt -eq 5 ]
then
echo "Unable to read ch0 current !"
exit 1
以上是关于Note2MPS/PXE/ADS/INA电流电压,i2c设备在位和读,samba/nfs,ntp/log/me/树莓派,pip/office,vr,i2ctool,大数据,pam的主要内容,如果未能解决你的问题,请参考以下文章