【Note7】

【Note7】_第1张图片
ps -ef | grep memtester | grep -v grep | cut -c 9-16 | xargs kill -9,ipmitool二进制文件在os执行默认走/dev/ipmi0(要指定-H,bmc有lan进程通信再到ipmi-host),在bmc执行走dbus ipmi-host通信
【Note7】_第2张图片
安路.aje在线,.bit离线,lattice .vme在线,.jed离线。
【Note7】_第3张图片

在这里插入图片描述
【Note7】_第4张图片
【Note7】_第5张图片
【Note7】_第6张图片
【Note7】_第7张图片
【Note7】_第8张图片
在这里插入图片描述
在这里插入图片描述

【Note7】_第9张图片
【Note7】_第10张图片
【Note7】_第11张图片
将硬件时钟设置为系统时间

VOUT1_NODE=“/sys/bus/i2c/drivers/xdpe12284/29-0040/hwmon/hwmon*/in2_input”
VOUT1_NODE=/sys/bus/i2c/devices/43-0040/hwmon/hwmon*/in2_input
3条回复

两种放头都不行,*当成字符串

此消息已撤回

find时候必须在29-0040后面加上/

【Note7】_第12张图片

在这里插入图片描述

#!/bin/bash
#
# Copyright 2022-present Huaqin. All Rights Reserved.
#
# This program file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program in a file named COPYING; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301 USA
#
#shellcheck disable=SC1091

. /usr/local/bin/openbmc-utils.sh

PSU1_PMBUS_DIR=$(i2c_device_sysfs_abspath 40-0058)
PSU2_PMBUS_DIR=$(i2c_device_sysfs_abspath 41-0058)
INA_U36_DIR=$(i2c_device_sysfs_abspath 25-0040)
INA_U34_DIR=$(i2c_device_sysfs_abspath 26-0040)
INA_U82_DIR=$(i2c_device_sysfs_abspath 27-0040)
XDPE132G=$(i2c_device_sysfs_abspath 29-0040)

program=$(basename "$0")
usage() {
    echo "Usage:"
    echo "  $program "
    echo
    echo "Device:"
    echo "  sysin : total system input power "
    echo "  sysout : total system output power "
    echo "  switch : switching chip power "
    echo
    echo "Examples:"
    echo "  $program sysin "
    echo "  $program sysout "
    echo "  $program switch "
    echo
    exit 1
}

system_in_power() {
    sysin_power_1=0
    sysin_power_2=0
    prsnt=$(get_psu_present 1)
    power_sta=$(get_psu_power_sta 1)
    if [ "$prsnt" -eq 0 ] && [ "$power_sta" -eq 0 ];then
        sysin_power_1=$(head -n 1 "$PSU1_PMBUS_DIR/power1_input")
    fi
    prsnt=$(get_psu_present 2)
    power_sta=$(get_psu_power_sta 2)
    if [ "$prsnt" -eq 0 ] && [ "$power_sta" -eq 0 ];then
        sysin_power_2=$(head -n 1 "$PSU2_PMBUS_DIR/power1_input")
    fi
    echo $((("$sysin_power_1"+"$sysin_power_2")/1000000))"W"
}

system_out_power() {
    sysout_power_1=0
    sysout_power_2=0
    prsnt=$(get_psu_present 1)
    power_sta=$(get_psu_power_sta 1)
    if [ "$prsnt" -eq 0 ] && [ "$power_sta" -eq 0 ];then
        sysout_power_1=$(head -n 1 "$PSU1_PMBUS_DIR/power2_input")
    fi
    prsnt=$(get_psu_present 2)
    power_sta=$(get_psu_power_sta 2)
    if [ "$prsnt" -eq 0 ] && [ "$power_sta" -eq 0 ];then
        sysout_power_2=$(head -n 1 "$PSU2_PMBUS_DIR/power2_input")
    fi
    echo $((("$sysout_power_1"+"$sysout_power_2")/1000000))"W"
}

switch_power() {
    xdpe_pout1=0
    xdpe_pout2=0
    xdpe_pout1_path=$(find "$XDPE132G/" -name "power2_input")
    xdpe_pout2_path=$(find "$XDPE132G/" -name "power3_input")
    xdpe_pout1=$(head "$xdpe_pout1_path" -n 1)
    xdpe_pout2=$(head "$xdpe_pout2_path" -n 1)
    xdpe_pout=$(("$xdpe_pout1"+"$xdpe_pout2"))

    ina_u34_2_vol=0
    ina_u34_2_cur=0
    ina_u34_2_vol_path=$(find "$INA_U34_DIR/" -name "in2_input")
    ina_u34_2_cur_path=$(find "$INA_U34_DIR/" -name "curr2_input")
    ina_u34_2_vol=$(head "$ina_u34_2_vol_path" -n 1)
    ina_u34_2_cur=$(head "$ina_u34_2_cur_path" -n 1)
    ina_u34_2_pout=$(("$ina_u34_2_vol"*"$ina_u34_2_cur"))

    ina_u82_1_vol=0
    ina_u82_1_cur=0
    ina_u82_1_vol_path=$(find "$INA_U82_DIR/" -name "in1_input")
    ina_u82_1_cur_path=$(find "$INA_U82_DIR/" -name "curr1_input")
    ina_u82_1_vol=$(head "$ina_u82_1_vol_path" -n 1)
    ina_u82_1_cur=$(head "$ina_u82_1_cur_path" -n 1)
    ina_u82_1_pout=$(("$ina_u82_1_vol"*"$ina_u82_1_cur"))

    ina_u36_2_vol=0
    ina_u36_2_cur=0
    ina_u36_2_vol_path=$(find "$INA_U36_DIR/" -name "in2_input")
    ina_u36_2_cur_path=$(find "$INA_U36_DIR/" -name "curr2_input")
    ina_u36_2_vol=$(head "$ina_u36_2_vol_path" -n 1)
    ina_u36_2_cur=$(head "$ina_u36_2_cur_path" -n 1)
    ina_u36_2_pout=$(("$ina_u36_2_vol"*"$ina_u36_2_cur"))

    ina_u36_3_vol=0
    ina_u36_3_cur=0
    ina_u36_3_vol_path=$(find "$INA_U36_DIR/" -name "in3_input")
    ina_u36_3_cur_path=$(find "$INA_U36_DIR/" -name "curr3_input")
    ina_u36_3_vol=$(head "$ina_u36_3_vol_path" -n 1)
    ina_u36_3_cur=$(head "$ina_u36_3_cur_path" -n 1)
    ina_u36_3_pout=$(("$ina_u36_3_vol"*"$ina_u36_3_cur"))

    echo $((("$xdpe_pout"+"$ina_u34_2_pout"+"$ina_u82_1_pout"+"$ina_u36_2_pout"+"$ina_u36_3_pout")/1000000))"W"
}

check_parameter()
{
    if [ "$#" -ne 1 ];then
        usage
    fi
    dev="$1"
    if [ "$dev" != "sysin" ] && [ "$dev" != "sysout" ] && [ "$dev" != "switch" ];then
        usage
    fi
}

do_action()
{
    if [ "$dev" == "sysin" ];then
        system_in_power
    fi

    if [ "$dev" == "sysout" ];then
        system_out_power
    fi

    if [ "$dev" == "switch" ];then
        switch_power
    fi
}

check_parameter "$@"

do_action

=函数不会覆盖,={}会覆盖

#!/bin/bash

EXP_COUNT=10000

LOG_PATH=/var/log/script/upgrade_bios
LOG_NAME="upgrade_bios.log"

COUNT=0

ping_action() {
    ping=$(ping -c 4 240.1.1.2 | grep -i "ttl=64" | wc -l)
    if [ $ping -ne 4 ]; then
        echo "Ping Test Fail" 2>&1 | tee -a $LOG_PATH/$LOG_NAME
    else
        echo "Ping ok" 2>&1 | tee -a $LOG_PATH/$LOG_NAME
    fi
}

do_action() {
    while [ $COUNT -le $EXP_COUNT ]; do
        echo "---------------------------Test Loop $COUNT--------------------------" 2>&1 | tee -a $LOG_PATH/$LOG_NAME

        cur_bios_version=$(show_version bios)
        echo "current bios version:$cur_bios_version ; image version:6132_793_BIOS_ID0.01.02.bin"  2>&1 | tee -a $LOG_PATH/$LOG_NAME
        config_me on
        sleep 3
        ipmitool  -b 3 -t 0x2c raw 0x2e 0xe7 0x57 0x01 0x0 0x1  # unlock
        sleep 3
        upgrade_bios -o write -s master  -f /var/log/6132_793_BIOS_ID0.01.02.bin
        sleep 3
        ipmitool  -b 3 -t 0x2c raw 0x2e 0xe7 0x57 0x01 0x0 0x0  # lock
        sleep 7
        config_me off

        ping_action

        if [ -f /var/log/bios_version ];then
            rm /var/log/bios_version
        fi

        i2cset -f -y 0 0x0d 0x91 0x4 # off
        sleep 10
        i2cset -f -y 0 0x0d 0x91 0x2 # on


        sleep 100
        count=0
        while true; do
            b=$(i2cget -f -y 0 0x0d 0x85)
            if [ $((($b >> 5) & 0x1)) == 1 ]; then
                sleep 100
                cur_bios_version=$(show_version bios)
                echo "power ok version change to $cur_bios_version"  2>&1 | tee -a $LOG_PATH/$LOG_NAME
                ping_action
                break
            fi
            sleep 20
            ((count++))
            if [ $count == 10 ]; then
                echo "power ok time out"  2>&1 | tee -a $LOG_PATH/$LOG_NAME
                break
            fi
        done
        COUNT+=1

        echo "---------------------------Test Loop $COUNT--------------------------" 2>&1 | tee -a $LOG_PATH/$LOG_NAME

        cur_bios_version=$(show_version bios)
        echo "current bios version:$cur_bios_version ; image version:6132_793_BIOS_ID0.02.00.bin"  2>&1 | tee -a $LOG_PATH/$LOG_NAME
        config_me on
        sleep 3
        ipmitool  -b 3 -t 0x2c raw 0x2e 0xe7 0x57 0x01 0x0 0x1  # unlock
        sleep 3
        upgrade_bios -o write -s master  -f /var/log/6132_793_BIOS_ID0.02.00.bin
        sleep 3
        ipmitool  -b 3 -t 0x2c raw 0x2e 0xe7 0x57 0x01 0x0 0x0  # lock
        sleep 7
        config_me off

        ping_action

        if [ -f /var/log/bios_version ];then
            rm /var/log/bios_version
        fi

        i2cset -f -y 0 0x0d 0x91 0x4 # off
        sleep 10
        i2cset -f -y 0 0x0d 0x91 0x2 # on

        sleep 100
        count=0
        while true; do
            b=$(i2cget -f -y 0 0x0d 0x85)
            if [ $((($b >> 5) & 0x1)) == 1 ]; then
                sleep 100
                cur_bios_version=$(show_version bios)
                echo "power ok version change to $cur_bios_version"  2>&1 | tee -a $LOG_PATH/$LOG_NAME
                ping_action
                break
            fi
            sleep 20
            ((count++))
            if [ $count == 10 ]; then
                echo "power ok time out"  2>&1 | tee -a $LOG_PATH/$LOG_NAME
                break
            fi
        done
        COUNT+=1
    done

}

if [ -f $LOG_PATH/$LOG_NAME ]; then
    rm $LOG_PATH/$LOG_NAME
else
    touch $LOG_PATH/$LOG_NAME
fi

do_action

cpu reset重新加载sonic系统,上下电会加载bios

sed -i ‘’ ( ( l i n e − 1 ) ) ′ d ′ " ((line-1))'d' " ((line1))d"SERVICE_FILE"

SERVICE_FILE=/lib/systemd/system/mTerm_server.service
BAUDRATE_FILE=/var/log/baudrate
DEFALUT_BAUDRATE=9600

if [ -f "$BAUDRATE_FILE" ] ; then
    val=$(head -n 1 < "$BAUDRATE_FILE" 2> /dev/null)
    line=$(cat $SERVICE_FILE | grep -wn "\[Service\]" | awk -F: '{print $1}')
    sed -i ''$line',+2d' "$SERVICE_FILE"
    new_str="ExecStart=/usr/local/bin/mTerm_server obmc-hq "$TTY" "$val""
    echo "[Service]" >> "$SERVICE_FILE"
    echo "$new_str" >> "$SERVICE_FILE"
    systemctl daemon-reload 2> /dev/null
    systemctl restart mTerm_server.service 2> /dev/null
fi

wc -l *

#!/bin/bash
#
# Copyright 2019-present Huaqin. All Rights Reserved.
#
# This program file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program in a file named COPYING; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301 USA
#
#shellcheck disable=SC1091
. /usr/local/bin/openbmc-utils.sh

BLACKBOX_ADDRESS=0xdc
BLACKBOX_PAGE_ADDRESS=0xdb
OUTPUTFILE=/var/log/dump_acbel_psu_blackbox.txt

program=$(basename "$0")
usage() {
    echo "Usage:"
    echo "  $program -i "
    echo
    echo "PSU index:"
    echo "  1-4"
    echo
    echo "Examples:"
    echo "  $program -i 4"
    exit 1
}

decompose_iic_addr()
{
    bus=$(echo "$1" | awk -F "-" '{print $1}')
    str=$(echo "$1" | awk -F "-" '{print $2}')
    address=${str/00/0x}
}

check_parameter()
{
    if [ "$#" -ne 2 ];then
        usage
    fi
    device="$2"
    if [ "$device" != "1" ] && [ "$device" != "2" ] && [ "$device" != "3" ] && [ "$device" != "4" ];then
        usage
    fi
}

linear11_convert()
{
    mantissa=$(((((($1 & 0x7ff)) << 5)) >> 5))
    if [ $((($1 >> 15) & 0x1)) == 1 ] ; then
        exponent=$(((($1 & 0x7FFF)) >> 11))
        exponent=$(($exponent ^ 0xf))
        exponent=$((~$exponent))
    else
        exponent=$(($1>> 11))
    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
}

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
}

do_action()
{
    value=$(i2ctransfer -f -y $bus w1@$address $BLACKBOX_ADDRESS r52)
    present_psu_on_time_l=${value:7:2}
    present_psu_on_time_m=${value:12:2}
    present_psu_on_time_h=${value:17:2}
    present_psu_on_time="0x""$present_psu_on_time_h""$present_psu_on_time_m""$present_psu_on_time_l"
    present_psu_on_time=$(printf %d "$present_psu_on_time")
    echo "Present total PSU ON time:                      $present_psu_on_time min" >> $OUTPUTFILE

    present_num_ac_cycles_l=${value:22:2}
    present_num_ac_cycles_h=${value:27:2}
    present_num_ac_cycles="0x""$present_num_ac_cycles_h""$present_num_ac_cycles_l"
    present_num_ac_cycles=$(printf %d "$present_num_ac_cycles")
    echo "Present number of AC power cycles:              $present_num_ac_cycles" >> $OUTPUTFILE

    present_num_pson_cycles_l=${value:32:2}
    present_num_pson_cycles_h=${value:37:2}
    present_num_pson_cycles="0x""$present_num_pson_cycles_h""$present_num_pson_cycles_l"
    present_num_pson_cycles=$(printf %d "$present_num_pson_cycles")
    echo "Present number of PSON power cycles:            $present_num_pson_cycles" >> $OUTPUTFILE

    power_on_time_l=${value:42:2}
    power_on_time_m=${value:47:2}
    power_on_time_h=${value:52:2}
    power_on_time="0x""$power_on_time_h""$power_on_time_m""$power_on_time_l"
    power_on_time=$(printf %d "$power_on_time")
    echo "Power supply total power on time:               $power_on_time" >> $OUTPUTFILE

    clock_data_l=${value:57:2}
    clock_data_m1=${value:62:2}
    clock_data_m2=${value:67:2}
    clock_data_h=${value:72:2}
    clock_data="0x""$clock_data_h""$clock_data_m2""$clock_data_m1""$clock_data_l"
    clock_data=$(printf %d "$clock_data")
    echo "Real Time Clock Data from System:               $clock_data" >> $OUTPUTFILE

    num_ac_cycles_l=${value:77:2}
    num_ac_cycles_h=${value:82:2}
    num_ac_cycles="0x""$num_ac_cycles_h""$num_ac_cycles_l"
    num_ac_cycles=$(printf %d "$num_ac_cycles")
    echo "Number of AC power cycles:                      $num_ac_cycles" >> $OUTPUTFILE

    num_pson_cycles_l=${value:87:2}
    num_pson_cycles_h=${value:92:2}
    num_pson_cycles="0x""$num_pson_cycles_h""$num_pson_cycles_l"
    num_pson_cycles=$(printf %d "$num_pson_cycles")
    echo "Number of PSON power cycles:                    $num_pson_cycles" >> $OUTPUTFILE

    status_word_l=${value:97:2}
    status_word_h=${value:102:2}
    status_word="0x""$status_word_h""$status_word_l"
    if [ $((($status_word >> 1) & 0x1)) == 1 ] ; then
        echo "STATUS_WORD: CML:                           A communications, memory or logic fault has occurred         Refer to STATUS_CML"  >> $OUTPUTFILE
    elif [ $((($status_word >> 2) & 0x1)) == 1 ] ; then
        echo "STATUS_WORD: TEMPERATURE:                   A temperature fault or warning has occurred                  Refer to STATUS_TEMPER ATURE" >> $OUTPUTFILE
    elif [ $((($status_word >> 3) & 0x1)) == 1 ] ; then
        echo "STATUS_WORD: VIN_UV_FAULT:                  An input under voltage fault has occurred                    Refer to STATUS_INPUT" >> $OUTPUTFILE
    elif [ $((($status_word >> 4) & 0x1)) == 1 ] ; then
        echo "STATUS_WORD: IOUT_OC_FAULT:                 An output over current fault has occurred                    Refer to STATUS_IOUT" >> $OUTPUTFILE
    elif [ $((($status_word >> 5) & 0x1)) == 1 ] ; then
        echo "STATUS_WORD: VOUT_OV_FAULT:                 An output overvoltage fault has occurred                     Refer to STATUS_VOUT" >> $OUTPUTFILE
    elif [ $((($status_word >> 6) & 0x1)) == 1 ] ; then
        echo "STATUS_WORD: OFF:                           This bit is asserted if the unit is not providing power to the output  " >> $OUTPUTFILE
    elif [ $((($status_word >> 10) & 0x1)) == 1 ] ; then
        echo "STATUS_WORD: FANS:                          A fan or airflow fault or warning has occurred               Refer to STATUS_FANS" >> $OUTPUTFILE
    elif [ $((($status_word >> 11) & 0x1)) == 1 ] ; then
        echo "STATUS_WORD: POWER_GOOD:                    The POWER_GOOD signal, if present, is negated                Reflects real time state of PSU" >> $OUTPUTFILE
    elif [ $((($status_word >> 13) & 0x1)) == 1 ] ; then
        echo "STATUS_WORD: INPUT:                         An input voltage, input current, or input power fault or warning has occurred   Refer to STATUS_INPUT" >> $OUTPUTFILE
    elif [ $((($status_word >> 14) & 0x1)) == 1 ] ; then
        echo "STATUS_WORD: IOUT/POUT:                     An output current or output power fault or warning has occurred                 Refer to STATUS_IOUT"  >> $OUTPUTFILE
    elif [ $((($status_word >> 15) & 0x1)) == 1 ] ; then
        echo "STATUS_WORD: VOUT:                          An output voltage fault or warning has occurred              Refer to STATUS_VOUT"  >> $OUTPUTFILE
    fi

    status_vout_l=${value:107:2}
    status_vout="0x""$status_vout_l"
    if [ $((($status_vout >> 4) & 0x1)) == 1 ] ; then
        echo "STATUS_VOUT: VOUT_UV_FAULT:                 Output Under voltage Fault       STATUS bit Auto Recovery: No       PSU state when bit is asserted('1'): OFF"  >> $OUTPUTFILE
    elif [ $((($status_vout >> 7) & 0x1)) == 1 ] ; then
        echo "STATUS_VOUT: VOUT_OV_FAULT:                 Output Overvoltage Fault         STATUS bit Auto Recovery: No       PSU state when bit is asserted('1'): OFF"  >> $OUTPUTFILE
    fi

    status_iout_l=${value:112:2}
    status_iout="0x""$status_iout_l"
    if [ $(($status_iout & 0x1)) == 1 ] ; then
        echo "STATUS_IOUT: POUT_OP_WARNING:               Predictive failure               STATUS bit Auto Recovery: Yes      PSU state when bit is asserted('1'): ON" >> $OUTPUTFILE
    elif [ $((($status_iout >> 1) & 0x1)) == 1 ] ; then
        echo "STATUS_IOUT: POUT_OP_FAULT:                 Failure                          STATUS bit Auto Recovery: No       PSU state when bit is asserted('1'): OFF" >> $OUTPUTFILE
    elif [ $((($status_iout >> 5) & 0x1)) == 1 ] ; then
        echo "STATUS_IOUT: IOUT_OC_WARNING:               Predictive failure               STATUS bit Auto Recovery: Yes      PSU state when bit is asserted('1'): ON" >> $OUTPUTFILE
    elif [ $((($status_iout >> 7) & 0x1)) == 1 ] ; then
        echo "STATUS_IOUT: IOUT_OC_FAULT :                Failure                          STATUS bit Auto Recovery: No       PSU state when bit is asserted('1'): OFF">> $OUTPUTFILE
    fi

    status_input_l=${value:117:2}
    status_input="0x""$status_input_l"
    if [ $(($status_input & 0x1)) == 1 ] ; then
        echo "STATUS_INPUT: PIN_OP_WARNING:              Predictive failure                STATUS bit Auto Recovery: No       PSU state when bit is asserted('1'): ON" >> $OUTPUTFILE
    elif [ $((($status_input >> 1) & 0x1)) == 1 ] ; then
        echo "STATUS_INPUT: IIN_OC_WARNING:              Predictive failure                STATUS bit Auto Recovery: No       PSU state when bit is asserted('1'): ON" >> $OUTPUTFILE
    elif [ $((($status_input >> 2) & 0x1)) == 1 ] ; then
        echo "STATUS_INPUT: IIN_OC_FAULT:                Input Overcurrent Fault           STATUS bit Auto Recovery: No       PSU state when bit is asserted('1'): OFF" >> $OUTPUTFILE
    elif [ $((($status_input >> 3) & 0x1)) == 1 ] ; then
        echo "STATUS_INPUT: Unit Off for Low Input Voltage :                               Either the input voltage has never exceeded the input turn-on threshold or if the unit did start,\
        the input voltage decreased below the turn-off threshold            STATUS bit Auto Recovery: Yes                     PSU state when bit is asserted('1'): OFF" >> $OUTPUTFILE
    elif [ $((($status_input >> 4) & 0x1)) == 1 ] ; then
        echo "STATUS_INPUT: VIN_UV_FAULT:                Input Under voltage Fault         STATUS bit Auto Recovery: Yes      PSU state when bit is asserted('1'): OFF" >> $OUTPUTFILE
    elif [ $((($status_input >> 5) & 0x1)) == 1 ] ; then
        echo "STATUS_INPUT: VIN_UV_WARNING:              Predictive failure                STATUS bit Auto Recovery: Yes      PSU state when bit is asserted('1'): ON" >> $OUTPUTFILE
    elif [ $((($status_input >> 7) & 0x1)) == 1 ] ; then
        echo "STATUS_INPUT: VIN_OV_FAULT:                Input Overvoltage Fault           STATUS bit Auto Recovery: Yes      PSU state when bit is asserted('1'): OFF" >> $OUTPUTFILE
    fi

    status_temp_l=${value:122:2}
    status_temp="0x""$status_temp_l"
    if [ $((($status_temp >> 6) & 0x1)) == 1 ] ; then
        echo "STATUS_TEMPERATURE: OT_WARNING:            Over Temperature Warning          STATUS bit Auto Recovery: Yes      PSU state when bit is asserted('1'): ON" >> $OUTPUTFILE
    elif [ $((($status_temp >> 7) & 0x1)) == 1 ] ; then
        echo "STATUS_TEMPERATURE: OT_FAULT:              Over Temperature Fault            STATUS bit Auto Recovery: Yes      PSU state when bit is asserted('1'): OFF" >> $OUTPUTFILE
    fi

    status_cml_l=${value:127:2}
    status_cml="0x""$status_cml_l"
    if [ $((($status_cml >> 5) & 0x1)) == 1 ] ; then
        echo "STATUS_CML: Packet Error Check Failed:     Packet Error Check Failed                STATUS bit Auto Recovery: No    PSU state when bit is asserted('1'): ON" >> $OUTPUTFILE
    elif [ $((($status_cml >> 6) & 0x1)) == 1 ] ; then
        echo "STATUS_CML: Invalid/Unsupported Data:      Invalid Or Unsupported Data Received     STATUS bit Auto Recovery: No    PSU state when bit is asserted('1'): ON" >> $OUTPUTFILE
    elif [ $((($status_cml >> 7) & 0x1)) == 1 ] ; then
        echo "STATUS_CML: Invalid/Unsupported Command:   Invalid Or Unsupported Command Received  STATUS bit Auto Recovery: No    PSU state when bit is asserted('1'): ON" >> $OUTPUTFILE
    fi

    status_fan_1_2_l=${value:132:2}
    status_fan_1_2="0x""$status_fan_1_2_l"
    if [ $((($status_fan_1_2 >> 3) & 0x1)) == 1 ] ; then
        echo "STATUS_FAN_1_2: Fan 1 Speed Overridden :   Fan 1 overridden occurred                STATUS bit Auto Recovery: Yes" >> $OUTPUTFILE
    elif [ $((($status_fan_1_2 >> 5) & 0x1)) == 1 ] ; then
        echo "STATUS_FAN_1_2: Fan 1 Warning :            Fan 1 warning occurred                   STATUS bit Auto Recovery: Yes" >> $OUTPUTFILE
    elif [ $((($status_fan_1_2 >> 7) & 0x1)) == 1 ] ; then
        echo "STATUS_FAN_1_2: Fan 1 Fault :              Fan 1 fault occurred                     STATUS bit Auto Recovery: Yes" >> $OUTPUTFILE
    fi

    read_vin_l=${value:137:2}
    read_vin_h=${value:142:2}
    read_vin="0x""$read_vin_h""$read_vin_l"
    read_vin=$(linear11_convert $read_vin)
    read_vin=$(awk 'BEGIN{printf "%.2f\n",'$read_vin'/1000}')
    echo "READ_VIN:                                       $read_vin V" >> $OUTPUTFILE

    read_iin_l=${value:147:2}
    read_iin_h=${value:152:2}
    read_iin="0x""$read_iin_h""$read_iin_l"
    read_iin=$(linear11_convert $read_iin)
    read_iin=$(awk 'BEGIN{printf "%.2f\n",'$read_iin'/1000}')
    echo "READ_IIN:                                       $read_iin A" >> $OUTPUTFILE

    read_vout_l=${value:157:2}
    read_vout_h=${value:162:2}
    read_vout="0x""$read_vout_h""$read_vout_l"
    mode_vout=$(i2cget -f -y $bus $address 0x20)
    read_vout=$(linear16_convert $read_vout $mode_vout)
    read_vout=$(awk 'BEGIN{printf "%.2f\n",'$read_vout'/1000}')
    echo "READ_VOUT:                                      $read_vout V" >> $OUTPUTFILE

    read_iout_l=${value:167:2}
    read_iout_h=${value:172:2}
    read_iout="0x""$read_iout_h""$read_iout_l"
    read_iout=$(linear11_convert $read_iout)
    read_iout=$(awk 'BEGIN{printf "%.2f\n",'$read_iout'/1000}')
    echo "READ_IOUT:                                      $read_iout A" >> $OUTPUTFILE

    read_temp_1_l=${value:177:2}
    read_temp_1_h=${value:182:2}
    read_temp_1="0x""$read_temp_1_h""$read_temp_1_l"
    read_temp_1=$(linear11_convert $read_temp_1)
    read_temp_1=$(awk 'BEGIN{printf "%.2f\n",'$read_temp_1'/1000}')
    echo "READ_TEMPERATURE_1 (Ambient):                   $read_temp_1 C" >> $OUTPUTFILE

    read_temp_2_l=${value:187:2}
    read_temp_2_h=${value:192:2}
    read_temp_2="0x""$read_temp_2_h""$read_temp_2_l"
    read_temp_2=$(linear11_convert $read_temp_2)
    read_temp_2=$(awk 'BEGIN{printf "%.2f\n",'$read_temp_2'/1000}')
    echo "READ_TEMPERATURE_2 (Hot Spot):                  $read_temp_2 C" >> $OUTPUTFILE

    read_temp_3_l=${value:197:2}
    read_temp_3_h=${value:202:2}
    read_temp_3="0x""$read_temp_3_h""$read_temp_3_l"
    read_temp_3=$(linear11_convert $read_temp_3)
    read_temp_3=$(awk 'BEGIN{printf "%.2f\n",'$read_temp_3'/1000}')
    echo "READ_TEMPERATURE_3 (Primary):                   $read_temp_3 C" >> $OUTPUTFILE

    read_fan_speed_1_l=${value:207:2}
    read_fan_speed_1_h=${value:212:2}
    read_fan_speed_1="0x""$read_fan_speed_1_h""$read_fan_speed_1_l"
    read_fan_speed_1=$(linear11_convert $read_fan_speed_1)
    read_fan_speed_1=$(awk 'BEGIN{printf "%.2f\n",'$read_fan_speed_1'/1000}')
    echo "READ_FAN_SPEED_1:                               $read_fan_speed_1 RPM" >> $OUTPUTFILE

    read_pout_l=${value:217:2}
    read_pout_h=${value:222:2}
    read_pout="0x""$read_pout_h""$read_pout_l"
    read_pout=$(linear11_convert $read_pout)
    read_pout=$(awk 'BEGIN{printf "%.2f\n",'$read_pout'/1000}')
    echo "READ_POUT:                                      $read_pout W" >> $OUTPUTFILE

    read_pin_l=${value:227:2}
    read_pin_h=${value:232:2}
    read_pin="0x""$read_pin_h""$read_pin_l"
    read_pin=$(linear11_convert $read_pin)
    read_pin=$(awk 'BEGIN{printf "%.2f\n",'$read_pin'/1000}')
    echo "READ_PIN:                                       $read_pin W" >> $OUTPUTFILE

    ac_shutdown=${value:237:2}
    ac_shutdown="0x""$ac_shutdown"
    ac_shutdown_l=$(($ac_shutdown & 0xf))
    ac_shutdown_l=$(printf %d "$ac_shutdown_l")
    echo "AC shutdown due to under voltage on input:      $ac_shutdown_l" >> $OUTPUTFILE
    thermal_shutdown_h=$((($ac_shutdown >> 4) & 0xf))
    thermal_shutdown_h=$(printf %d "$thermal_shutdown_h")
    echo "Thermal shutdown:                               $thermal_shutdown_h" >> $OUTPUTFILE

    output_shutdown=${value:242:2}
    output_shutdown="0x""$output_shutdown"
    output_shutdown_l=$(($output_shutdown & 0xf))
    output_shutdown_l=$(printf %d "$output_shutdown_l")
    echo "Over current or over power shutdown on output:  $output_shutdown_l" >> $OUTPUTFILE
    general_shutdown_h=$((($output_shutdown >> 4) & 0xf))
    general_shutdown_h=$(printf %d "$general_shutdown_h")
    echo "General failure shutdown:                       $general_shutdown_h" >> $OUTPUTFILE

    fan_fail_shutdown=${value:247:2}
    fan_fail_shutdown="0x""$fan_fail_shutdown"
    fan_fail_shutdown_l=$(($fan_fail_shutdown & 0xf))
    fan_fail_shutdown_l=$(printf %d "$fan_fail_shutdown_l")
    echo "Fan failure shutdown:                           $fan_fail_shutdown_l" >> $OUTPUTFILE
    voltage_shutdown_h=$((($fan_fail_shutdown >> 4) & 0xf))
    voltage_shutdown_h=$(printf %d "$voltage_shutdown_h")
    echo "Shutdown due to over voltage on output:         $voltage_shutdown_h" >> $OUTPUTFILE

    voltage_warning_no_shutdown=${value:252:2}
    voltage_warning_no_shutdown="0x""$voltage_warning_no_shutdown"
    voltage_warning_no_shutdown_l=$(($voltage_warning_no_shutdown & 0xf))
    voltage_warning_no_shutdown_l=$(printf %d "$voltage_warning_no_shutdown_l")
    echo "Input voltage warning; no shutdown:             $voltage_warning_no_shutdown_l" >> $OUTPUTFILE
    thermal_warning_no_shutdown_h=$((($voltage_warning_no_shutdown >> 4) & 0xf))
    thermal_warning_no_shutdown_h=$(printf %d "$thermal_warning_no_shutdown_h")
    echo "Thermal warning; no shutdown:                   $thermal_warning_no_shutdown_h" >> $OUTPUTFILE

    current_power_warning_no_shutdown=${value:257:2}
    current_power_warning_no_shutdown="0x""$current_power_warning_no_shutdown"
    current_power_warning_no_shutdown_l=$(($current_power_warning_no_shutdown & 0xf))
    current_power_warning_no_shutdown_l=$(printf %d "$current_power_warning_no_shutdown_l")
    echo "Output current power warning; no shutdown:      $current_power_warning_no_shutdown_l" >> $OUTPUTFILE
    fan_slow_warning_no_shutdown_h=$((($current_power_warning_no_shutdown >> 4) & 0xf))
    fan_slow_warning_no_shutdown_h=$(printf %d "$fan_slow_warning_no_shutdown_h")
    echo "Fan slow warning; no shutdown:                  $fan_slow_warning_no_shutdown_h" >> $OUTPUTFILE
}

do_action_all()
{
    prn_sta=$(get_psu_present "$device")
    if [ "$prn_sta" -eq 0 ];then
        echo "psu$device absent , please dump present psu"
        exit 1
    fi

    full_addr=${PSU_PMBUS_SLAVE_ADDR_ARRAY[$device-1]}
    decompose_iic_addr "${full_addr}"

    echo "MFR_BLACKBOX_PAGE =                             0x00 " >> $OUTPUTFILE
    i2cset -f -y $bus $address $BLACKBOX_PAGE_ADDRESS 0x00
    do_action

    echo " " >> $OUTPUTFILE
    echo "MFR_BLACKBOX_PAGE =                             0x01 " >> $OUTPUTFILE
    i2cset -f -y $bus $address $BLACKBOX_PAGE_ADDRESS 0x01
    do_action

    echo " " >> $OUTPUTFILE
    echo "MFR_BLACKBOX_PAGE =                             0x02 " >> $OUTPUTFILE
    i2cset -f -y $bus $address $BLACKBOX_PAGE_ADDRESS 0x02
    do_action

    echo " " >> $OUTPUTFILE
    echo "MFR_BLACKBOX_PAGE =                             0x03 " >> $OUTPUTFILE
    i2cset -f -y $bus $address $BLACKBOX_PAGE_ADDRESS 0x03
    do_action

    echo " " >> $OUTPUTFILE
    echo "MFR_BLACKBOX_PAGE =                             0x04 " >> $OUTPUTFILE
    i2cset -f -y $bus $address $BLACKBOX_PAGE_ADDRESS 0x04
    do_action

    echo "dump psu$psu_num blackbox data to $OUTPUTFILE ok."
}

check_parameter "$@"
do_action_all

在这里插入图片描述
【Note7】_第13张图片
bmc芯片运存2G,主flash 64M 分出4M用作/mnt/data,备flash 64M,emmc 8G

【Note7】_第14张图片

umount_dev() {
pids=$(fuser -m P A R T 2 M O U N T P O I N T ) n u m s = PART2_MOUNT_POINT) nums= PART2MOUNTPOINT)nums=(echo KaTeX parse error: Double superscript at position 17: …ids | awk -F ' '̲ '{print NF}') …nums;i++));
do
pid=$(echo $pids | awk -F ’ ’ ‘{print ′ ' i’}')
kill -9 “$pid”
done
umount $PART2 || (echo “umount $PART2 fail !” && exit 1)
}

root@bmc-oob:~# fuser -m /var/volatile/log/
4671
root@bmc-oob:~# umount /dev/mmcblk0p2
umount: /var/volatile/log: target is busy.
root@bmc-oob:~# umount -lf /dev/mmcblk0p2
root@bmc-oob:~# umount /dev/mmcblk0p2
umount: /dev/mmcblk0p2: not mounted
在这里插入图片描述
【Note7】_第15张图片
【Note7】_第16张图片
在这里插入图片描述
root@bmc-oob:~# mount /dev/mmcblk0p1 /var/log/
root@bmc-oob:~# blkid /dev/mmcblk0 |grep ext4
root@bmc-oob:~# blkid /dev/mmcblk0p1
/dev/mmcblk0p1: UUID=“c41280ba-4eb5-442d-987b-44781f31ce1b” TYPE=“ext4” PARTUUID=“5e09c2ea-01”
在这里插入图片描述
【Note7】_第17张图片

mount_partition() {
    info=$(blkid "$1" |grep ext4 )
    if [ ! "$info" ]; then
        echo "Format $1 partition ......"
        logger -t "mount_data1.sh" "Format $1 partition ......"
        mkfs.ext4 "$1"
        echo " Done"
        echo "Mouting $1 partition ......"
        if [ ! -d "$2" ]; then
            mkdir -p "$2"
        fi
        mount "$1" "$2"
        echo " Done"
    else
        echo "Mouting $1 partition ......"
        if [ ! -d "$2" ]; then
            mkdir -p "$2"
        fi
        #e2fsck -a $DEV
        fsck.ext4 -a "$1"
        mount "$1" "$2"
        echo " Done"
    fi
}

    DEV="/dev/mmcblk0"
    MOUNT_POINT="/var/log"
    info=`blkid $DEV`
    if [ ! "$info" ]; then
        echo "Format EMMC disk ......"
        logger "Format EMMC disk ......"
        mkfs.ext4 $DEV
        echo " Done"
        echo "Mouting EMMC ......"
        if [ ! -d "$MOUNT_POINT" ]; then
            mkdir $MOUNT_POINT
        fi
        mount $DEV $MOUNT_POINT
        echo " Done"
    else
        echo "Mouting EMMC ......"
        if [ ! -d "$MOUNT_POINT" ]; then
            mkdir $MOUNT_POINT
        fi
        #e2fsck -a $DEV
        fsck.ext4 -a $DEV
        mount $DEV $MOUNT_POINT
        echo " Done"
    fi
    echo "$DEV mounted successfully, device usage:"
    df -h "$DEV"
    exit 0

【Note7】_第18张图片
【Note7】_第19张图片
PART1=“/dev/mmcblk0p1”
PART2=“/dev/mmcblk0p2”
PART1_MOUNT_POINT=“/overlay/”
PART2_MOUNT_POINT=“/var/volatile/log/”
DEV=“/dev/mmcblk0”
【Note7】_第20张图片
MOUNT_TIMEOUT=60
if timeout --help 2>&1 | grep "Usage:.*[-t " > /dev/null 2>&1; then
timeout -t “ M O U N T T I M E O U T " " MOUNT_TIMEOUT" " MOUNTTIMEOUT""MOUNT_SCRIPT” “ P A R T 1 " " PART1" " PART1""MOUNT_OVERLAY”
timeout -t “ M O U N T T I M E O U T " " MOUNT_TIMEOUT" " MOUNTTIMEOUT""MOUNT_SCRIPT” “ P A R T 2 " " PART2" " PART2""MOUNT_POINT”
else
timeout “ M O U N T T I M E O U T " " MOUNT_TIMEOUT" " MOUNTTIMEOUT""MOUNT_SCRIPT” “ P A R T 1 " " PART1" " PART1""MOUNT_OVERLAY”
timeout “ M O U N T T I M E O U T " " MOUNT_TIMEOUT" " MOUNTTIMEOUT""MOUNT_SCRIPT” “ P A R T 2 " " PART2" " PART2""MOUNT_POINT”
fi

在这里插入图片描述
root@bmc-oob:~# mkdir p1
root@bmc-oob:~# mkdir p2
root@bmc-oob:~# mount /dev/mmcblk0p
mmcblk0p1 mmcblk0p2
root@bmc-oob:~# mount /dev/mmcblk0p1 p1
mount: /home/root/p1: wrong fs type, bad option, bad superblock on /dev/mmcblk0p1, missing codepage or helper program, or other error.
root@bmc-oob:~# mount /dev/mmcblk0p2 p2
[ 314.129091] EXT4-fs (mmcblk0p2): recovery complete
[ 314.135456] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)

在这里插入图片描述
在这里插入图片描述
【Note7】_第21张图片
第一个问题umount可以,但是mkfs格式化不了
【Note7】_第22张图片
【Note7】_第23张图片
如上操作主登不进,拔掉flash,如下操作后插上flash,主能登进
在这里插入图片描述
【Note7】_第24张图片
在这里插入图片描述
在这里插入图片描述
【Note7】_第25张图片
【Note7】_第26张图片
【Note7】_第27张图片
【Note7】_第28张图片
scp -r [email protected]:/home_a/yutao/alibmc/build/tmp/work/obmc_hq-fb-linux-gnueabi/obmc-hq-image/1.0-r0/rootfs/lib/modules/4.1.51/extra/psu_driver.ko ~/

value = psu_reg_read(dev, attr); value十进制
def d():
fru = {}
fru[“d”] = {“a”:“c”}
return fru

def Main():
# crt.Screen.Synchronous = True
# for i in range (0,2):
# Checkinfo1()
fru = {}
fru[“Name”] = “psu_name”
fru[“a”] = {“d”:{“a”:“c”}}
print(fru)
Main()
【Note7】_第29张图片
【Note7】_第30张图片

from hal.hal_sensor import *
sensor=HalSensor()
from hal.hal_dcdc import *
a=HalDcdc(sensor)

【Note7】_第31张图片
【Note7】_第32张图片
-m 1 只匹配一次,匹配到就终止匹配(根据自己需求调整)

在这里插入图片描述

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * net_brcm.c - The i2c driver for net_brcm
 *
 * Copyright 2020-present Huaqin. All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */

#include 
#include 
#include 
#include 
#include 
#include 

#define BUILD_U64(_high, _low) (((u_int64_t)(_high) << 32) | (_low))

#define NET_NCSI_MSG_LEN                    4
#define NET_OPCODE                          11
#define NET_DST_BLOCK                       8
#define NET_ACC_TYPE                        28
#define NET_DLEN                            4
#define NET_MISC                            0
#define NET_BRCM_BASE                       0x0201d000
#define NET_BRCM_OFFSET                     0x800
#define NET_BRCM_I2C_SLAVE_IOCTL            0x703
#define CMIC_COMMON_POOL_SCHAN_CH9_CTRL     0x03210900
#define CMIC_COMMON_POOL_SCHAN_CH9_MESSAGE  0x0321090c
#define CMIC_COMMON_START_COMMOND           0x00000001

struct net_brcm_data {
	struct i2c_client *client;
	struct mutex update_lock; /* mutex protect updates */
};

static void net_brcm_i2c_write(const struct i2c_client *client, u_int32_t msb,
		u_int32_t lsb, u_int32_t len)
{
	u_int32_t index = 0;
	u_int32_t bit_shift = 0;
	u_int64_t tmp_val = 0;
	char send_buf[NET_NCSI_MSG_LEN * 2];

	tmp_val = BUILD_U64(msb, lsb);

	for (index = 0; index < len; index++) {
		bit_shift = (len - 1 - index) * 8;
		send_buf[index] = (tmp_val &
				(((u_int64_t)0xff) << bit_shift)) >> bit_shift;
	}

	/* Unfortunately, must skip error checking since final byte will NACK */
	i2c_master_send(client, send_buf, len);
}

static int net_brcm_i2c_read(struct net_brcm_data *data,
		unsigned int reg, unsigned int *value)
{
	struct i2c_client *client = data->client;
	char read_buf[NET_NCSI_MSG_LEN];
	u_int32_t index = 0;
	u_int32_t bit_shift = 0;

	mutex_lock(&data->update_lock);

	net_brcm_i2c_write(client, CMIC_COMMON_POOL_SCHAN_CH9_MESSAGE,
			((NET_OPCODE << 26) | (NET_DST_BLOCK << 19) |
			 (NET_ACC_TYPE << 14) | (NET_DLEN << 8) | NET_MISC),
			NET_NCSI_MSG_LEN * 2);

	net_brcm_i2c_write(client, CMIC_COMMON_POOL_SCHAN_CH9_CTRL + 0x10,
			reg,
			NET_NCSI_MSG_LEN * 2);

	net_brcm_i2c_write(client, CMIC_COMMON_POOL_SCHAN_CH9_CTRL,
			CMIC_COMMON_START_COMMOND,
			NET_NCSI_MSG_LEN * 2);

	net_brcm_i2c_write(client, 0,
			CMIC_COMMON_POOL_SCHAN_CH9_CTRL + 0x10,
			NET_NCSI_MSG_LEN);

	if (i2c_master_recv(client, read_buf, NET_NCSI_MSG_LEN)
			!= NET_NCSI_MSG_LEN) {
		goto err_exit;
	}

	mutex_unlock(&data->update_lock);

	*value = 0;
	for (index = 0; index < NET_NCSI_MSG_LEN; index++) {
		// Convert read buffer to 32-bits value
		bit_shift = (NET_NCSI_MSG_LEN - 1 - index) * 8;
		*value |= (read_buf[index] << bit_shift);
	}

	return 0;

err_exit:
	mutex_unlock(&data->update_lock);
	return -1;
}

/* sysfs callback function */
static ssize_t net_brcm_temp_show(struct device *dev,
		struct device_attribute *dev_attr, char *buf)
{
	struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr);
	struct net_brcm_data *data = dev_get_drvdata(dev);
	u_int32_t value = -1;

	int file_index = attr->index;
	int reg = NET_BRCM_BASE + file_index * NET_BRCM_OFFSET;

	if (net_brcm_i2c_read(data, reg, &value))
		goto err_exit;

	/*
	 * return the temperature
	 * Temp = -0.23734 * value + 356.07
	 */
	return sprintf(buf, "%d\n", -237 * value + 356070);

err_exit:
	return -1;
}

static SENSOR_DEVICE_ATTR(temp1_input, 0444, net_brcm_temp_show, NULL, 1);
static SENSOR_DEVICE_ATTR(temp2_input, 0444, net_brcm_temp_show, NULL, 2);
static SENSOR_DEVICE_ATTR(temp3_input, 0444, net_brcm_temp_show, NULL, 3);
static SENSOR_DEVICE_ATTR(temp4_input, 0444, net_brcm_temp_show, NULL, 4);
static SENSOR_DEVICE_ATTR(temp5_input, 0444, net_brcm_temp_show, NULL, 5);
static SENSOR_DEVICE_ATTR(temp6_input, 0444, net_brcm_temp_show, NULL, 6);
static SENSOR_DEVICE_ATTR(temp7_input, 0444, net_brcm_temp_show, NULL, 7);
static SENSOR_DEVICE_ATTR(temp8_input, 0444, net_brcm_temp_show, NULL, 8);
static SENSOR_DEVICE_ATTR(temp9_input, 0444, net_brcm_temp_show, NULL, 9);
static SENSOR_DEVICE_ATTR(temp10_input, 0444, net_brcm_temp_show, NULL, 10);
static SENSOR_DEVICE_ATTR(temp11_input, 0444, net_brcm_temp_show, NULL, 11);
static SENSOR_DEVICE_ATTR(temp12_input, 0444, net_brcm_temp_show, NULL, 12);
static SENSOR_DEVICE_ATTR(temp13_input, 0444, net_brcm_temp_show, NULL, 13);
static SENSOR_DEVICE_ATTR(temp14_input, 0444, net_brcm_temp_show, NULL, 14);
static SENSOR_DEVICE_ATTR(temp15_input, 0444, net_brcm_temp_show, NULL, 15);
//static SENSOR_DEVICE_ATTR(temp16_input, 0444, net_brcm_temp_show, NULL, 16);

static struct attribute *net_brcm_attrs[] = {
	&sensor_dev_attr_temp1_input.dev_attr.attr,
	&sensor_dev_attr_temp2_input.dev_attr.attr,
	&sensor_dev_attr_temp3_input.dev_attr.attr,
	&sensor_dev_attr_temp4_input.dev_attr.attr,
	&sensor_dev_attr_temp5_input.dev_attr.attr,
	&sensor_dev_attr_temp6_input.dev_attr.attr,
	&sensor_dev_attr_temp7_input.dev_attr.attr,
	&sensor_dev_attr_temp8_input.dev_attr.attr,
	&sensor_dev_attr_temp9_input.dev_attr.attr,
	&sensor_dev_attr_temp10_input.dev_attr.attr,
	&sensor_dev_attr_temp11_input.dev_attr.attr,
	&sensor_dev_attr_temp12_input.dev_attr.attr,
	&sensor_dev_attr_temp13_input.dev_attr.attr,
	&sensor_dev_attr_temp14_input.dev_attr.attr,
	&sensor_dev_attr_temp15_input.dev_attr.attr,
//	&sensor_dev_attr_temp16_input.dev_attr.attr,
	NULL,
};
ATTRIBUTE_GROUPS(net_brcm);

static int net_brcm_probe(struct i2c_client *client,
		const struct i2c_device_id *id)
{
	struct net_brcm_data *data;
	struct device *dev = &client->dev;
	struct device *hwmon_dev;

	data = devm_kzalloc(dev, sizeof(struct net_brcm_data), GFP_KERNEL);
	if (!data)
		return -ENOMEM;

	if (!i2c_verify_client(dev))
		return -1;

	data->client = client;
	mutex_init(&data->update_lock);

	hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
			data, net_brcm_groups);
	return PTR_ERR_OR_ZERO(hwmon_dev);
}

/* net_brcm id */
static const struct i2c_device_id net_brcm_id[] = {
	{"net_brcm", 0},
	{ },
};
MODULE_DEVICE_TABLE(i2c, net_brcm_id);

static struct i2c_driver net_brcm_driver = {
	.driver = {
		.name = "net_brcm",
	},
	.probe = net_brcm_probe,
	.id_table = net_brcm_id,
};

module_i2c_driver(net_brcm_driver);

MODULE_AUTHOR("[email protected]");
MODULE_DESCRIPTION("NET_BRCM Driver");
MODULE_LICENSE("GPL");

在这里插入图片描述
【Note7】_第33张图片
bitbake obmc-hq-image -c clean
smlink,i2c,peci cpu和bmc
bmc dts 5个串口/dev/ttyS*
【Note7】_第34张图片
【Note7】_第35张图片
【Note7】_第36张图片
在这里插入图片描述
root@bmc:/tmp# scp -P 60051 -r [email protected]:/tmp/flash-obmc-hq .
在连一个ssh,杀掉client
【Note7】_第37张图片
【Note7】_第38张图片
#include

int main(int argc, char **argv) {
char *stty, *dev;
dev = argv[1];
stty = argv[2];
printf(“%s\n%s\n”,dev,stty);
}
【Note7】_第39张图片
【Note7】_第40张图片
【Note7】_第41张图片
【Note7】_第42张图片
git stash drop stash@{0}
git stash save保存的是改动,新增不保存
在这里插入图片描述
【Note7】_第43张图片
在这里插入图片描述
【Note7】_第44张图片
【Note7】_第45张图片
【Note7】_第46张图片

VOUT1_NODE=“/sys/bus/i2c/drivers/xdpe12284/29-0040/hwmon/hwmon*/in2_input”

VOUT1_NODE=/sys/bus/i2c/devices/43-0040/hwmon/hwmon*/in2_input
43-0040软连接,find找不到

两种放头都不行,*当成字符串

find时候必须在29-0040后面加上/

【Note7】_第47张图片
在这里插入图片描述
【Note7】_第48张图片
在这里插入图片描述
在这里插入图片描述
【Note7】_第49张图片
【Note7】_第50张图片
【Note7】_第51张图片
在这里插入图片描述
在这里插入图片描述
将硬件时钟设置为系统时间

【Note7】_第52张图片

【Note7】_第53张图片

#!/bin/bash
#
# Copyright 2022-present Huaqin. All Rights Reserved.
#
# This program file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program in a file named COPYING; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301 USA
#
#shellcheck disable=SC1091

. /usr/local/bin/openbmc-utils.sh

PSU1_PMBUS_DIR=$(i2c_device_sysfs_abspath 40-0058)
PSU2_PMBUS_DIR=$(i2c_device_sysfs_abspath 41-0058)
INA_U36_DIR=$(i2c_device_sysfs_abspath 25-0040)
INA_U34_DIR=$(i2c_device_sysfs_abspath 26-0040)
INA_U82_DIR=$(i2c_device_sysfs_abspath 27-0040)
XDPE132G=$(i2c_device_sysfs_abspath 29-0040)

program=$(basename "$0")
usage() {
    echo "Usage:"
    echo "  $program "
    echo
    echo "Device:"
    echo "  sysin : total system input power "
    echo "  sysout : total system output power "
    echo "  switch : switching chip power "
    echo
    echo "Examples:"
    echo "  $program sysin "
    echo "  $program sysout "
    echo "  $program switch "
    echo
    exit 1
}

system_in_power() {
    sysin_power_1=0
    sysin_power_2=0
    prsnt=$(get_psu_present 1)
    power_sta=$(get_psu_power_sta 1)
    if [ "$prsnt" -eq 0 ] && [ "$power_sta" -eq 0 ];then
        sysin_power_1=$(head -n 1 "$PSU1_PMBUS_DIR/power1_input")
    fi
    prsnt=$(get_psu_present 2)
    power_sta=$(get_psu_power_sta 2)
    if [ "$prsnt" -eq 0 ] && [ "$power_sta" -eq 0 ];then
        sysin_power_2=$(head -n 1 "$PSU2_PMBUS_DIR/power1_input")
    fi
    echo $((("$sysin_power_1"+"$sysin_power_2")/1000000))"W"
}

system_out_power() {
    sysout_power_1=0
    sysout_power_2=0
    prsnt=$(get_psu_present 1)
    power_sta=$(get_psu_power_sta 1)
    if [ "$prsnt" -eq 0 ] && [ "$power_sta" -eq 0 ];then
        sysout_power_1=$(head -n 1 "$PSU1_PMBUS_DIR/power2_input")
    fi
    prsnt=$(get_psu_present 2)
    power_sta=$(get_psu_power_sta 2)
    if [ "$prsnt" -eq 0 ] && [ "$power_sta" -eq 0 ];then
        sysout_power_2=$(head -n 1 "$PSU2_PMBUS_DIR/power2_input")
    fi
    echo $((("$sysout_power_1"+"$sysout_power_2")/1000000))"W"
}

switch_power() {
    xdpe_pout1=0
    xdpe_pout2=0
    xdpe_pout1_path=$(find "$XDPE132G/" -name "power2_input")
    xdpe_pout2_path=$(find "$XDPE132G/" -name "power3_input")
    xdpe_pout1=$(head "$xdpe_pout1_path" -n 1)
    xdpe_pout2=$(head "$xdpe_pout2_path" -n 1)
    xdpe_pout=$(("$xdpe_pout1"+"$xdpe_pout2"))

    ina_u34_2_vol=0
    ina_u34_2_cur=0
    ina_u34_2_vol_path=$(find "$INA_U34_DIR/" -name "in2_input")
    ina_u34_2_cur_path=$(find "$INA_U34_DIR/" -name "curr2_input")
    ina_u34_2_vol=$(head "$ina_u34_2_vol_path" -n 1)
    ina_u34_2_cur=$(head "$ina_u34_2_cur_path" -n 1)
    ina_u34_2_pout=$(("$ina_u34_2_vol"*"$ina_u34_2_cur"))

    ina_u82_1_vol=0
    ina_u82_1_cur=0
    ina_u82_1_vol_path=$(find "$INA_U82_DIR/" -name "in1_input")
    ina_u82_1_cur_path=$(find "$INA_U82_DIR/" -name "curr1_input")
    ina_u82_1_vol=$(head "$ina_u82_1_vol_path" -n 1)
    ina_u82_1_cur=$(head "$ina_u82_1_cur_path" -n 1)
    ina_u82_1_pout=$(("$ina_u82_1_vol"*"$ina_u82_1_cur"))

    ina_u36_2_vol=0
    ina_u36_2_cur=0
    ina_u36_2_vol_path=$(find "$INA_U36_DIR/" -name "in2_input")
    ina_u36_2_cur_path=$(find "$INA_U36_DIR/" -name "curr2_input")
    ina_u36_2_vol=$(head "$ina_u36_2_vol_path" -n 1)
    ina_u36_2_cur=$(head "$ina_u36_2_cur_path" -n 1)
    ina_u36_2_pout=$(("$ina_u36_2_vol"*"$ina_u36_2_cur"))

    ina_u36_3_vol=0
    ina_u36_3_cur=0
    ina_u36_3_vol_path=$(find "$INA_U36_DIR/" -name "in3_input")
    ina_u36_3_cur_path=$(find "$INA_U36_DIR/" -name "curr3_input")
    ina_u36_3_vol=$(head "$ina_u36_3_vol_path" -n 1)
    ina_u36_3_cur=$(head "$ina_u36_3_cur_path" -n 1)
    ina_u36_3_pout=$(("$ina_u36_3_vol"*"$ina_u36_3_cur"))

    echo $((("$xdpe_pout"+"$ina_u34_2_pout"+"$ina_u82_1_pout"+"$ina_u36_2_pout"+"$ina_u36_3_pout")/1000000))"W"
}

check_parameter()
{
    if [ "$#" -ne 1 ];then
        usage
    fi
    dev="$1"
    if [ "$dev" != "sysin" ] && [ "$dev" != "sysout" ] && [ "$dev" != "switch" ];then
        usage
    fi
}

do_action()
{
    if [ "$dev" == "sysin" ];then
        system_in_power
    fi

    if [ "$dev" == "sysout" ];then
        system_out_power
    fi

    if [ "$dev" == "switch" ];then
        switch_power
    fi
}

check_parameter "$@"

do_action

=函数不会覆盖,={}会覆盖
在这里插入图片描述

#!/bin/bash

EXP_COUNT=10000

LOG_PATH=/var/log/script/upgrade_bios
LOG_NAME="upgrade_bios.log"

COUNT=0

ping_action() {
    ping=$(ping -c 4 240.1.1.2 | grep -i "ttl=64" | wc -l)
    if [ $ping -ne 4 ]; then
        echo "Ping Test Fail" 2>&1 | tee -a $LOG_PATH/$LOG_NAME
    else
        echo "Ping ok" 2>&1 | tee -a $LOG_PATH/$LOG_NAME
    fi
}

do_action() {
    while [ $COUNT -le $EXP_COUNT ]; do
        echo "---------------------------Test Loop $COUNT--------------------------" 2>&1 | tee -a $LOG_PATH/$LOG_NAME

        cur_bios_version=$(show_version bios)
        echo "current bios version:$cur_bios_version ; image version:6132_793_BIOS_ID0.01.02.bin"  2>&1 | tee -a $LOG_PATH/$LOG_NAME
        config_me on
        sleep 3
        ipmitool  -b 3 -t 0x2c raw 0x2e 0xe7 0x57 0x01 0x0 0x1  # unlock
        sleep 3
        upgrade_bios -o write -s master  -f /var/log/6132_793_BIOS_ID0.01.02.bin
        sleep 3
        ipmitool  -b 3 -t 0x2c raw 0x2e 0xe7 0x57 0x01 0x0 0x0  # lock
        sleep 7
        config_me off

        ping_action

        if [ -f /var/log/bios_version ];then
            rm /var/log/bios_version
        fi

        i2cset -f -y 0 0x0d 0x91 0x4 # off
        sleep 10
        i2cset -f -y 0 0x0d 0x91 0x2 # on


        sleep 100
        count=0
        while true; do
            b=$(i2cget -f -y 0 0x0d 0x85)
            if [ $((($b >> 5) & 0x1)) == 1 ]; then
                sleep 100
                cur_bios_version=$(show_version bios)
                echo "power ok version change to $cur_bios_version"  2>&1 | tee -a $LOG_PATH/$LOG_NAME
                ping_action
                break
            fi
            sleep 20
            ((count++))
            if [ $count == 10 ]; then
                echo "power ok time out"  2>&1 | tee -a $LOG_PATH/$LOG_NAME
                break
            fi
        done
        COUNT+=1

        echo "---------------------------Test Loop $COUNT--------------------------" 2>&1 | tee -a $LOG_PATH/$LOG_NAME

        cur_bios_version=$(show_version bios)
        echo "current bios version:$cur_bios_version ; image version:6132_793_BIOS_ID0.02.00.bin"  2>&1 | tee -a $LOG_PATH/$LOG_NAME
        config_me on
        sleep 3
        ipmitool  -b 3 -t 0x2c raw 0x2e 0xe7 0x57 0x01 0x0 0x1  # unlock
        sleep 3
        upgrade_bios -o write -s master  -f /var/log/6132_793_BIOS_ID0.02.00.bin
        sleep 3
        ipmitool  -b 3 -t 0x2c raw 0x2e 0xe7 0x57 0x01 0x0 0x0  # lock
        sleep 7
        config_me off

        ping_action

        if [ -f /var/log/bios_version ];then
            rm /var/log/bios_version
        fi

        i2cset -f -y 0 0x0d 0x91 0x4 # off
        sleep 10
        i2cset -f -y 0 0x0d 0x91 0x2 # on

        sleep 100
        count=0
        while true; do
            b=$(i2cget -f -y 0 0x0d 0x85)
            if [ $((($b >> 5) & 0x1)) == 1 ]; then
                sleep 100
                cur_bios_version=$(show_version bios)
                echo "power ok version change to $cur_bios_version"  2>&1 | tee -a $LOG_PATH/$LOG_NAME
                ping_action
                break
            fi
            sleep 20
            ((count++))
            if [ $count == 10 ]; then
                echo "power ok time out"  2>&1 | tee -a $LOG_PATH/$LOG_NAME
                break
            fi
        done
        COUNT+=1
    done

}

if [ -f $LOG_PATH/$LOG_NAME ]; then
    rm $LOG_PATH/$LOG_NAME
else
    touch $LOG_PATH/$LOG_NAME
fi

do_action

cpu reset重新加载sonic系统,上下电会加载bios

sed -i “s/” T T Y " / " {TTY}"/" TTY"/"{TTY}" “ v a l " / g " " {val}"/g" " val"/g""SERVICE_FILE”

sed -i ‘‘ l i n e ′ i ′ line'i ' lineinew_str’’ “$SERVICE_FILE”

sed -i ‘’ ( ( l i n e − 1 ) ) ′ d ′ " ((line-1))'d' " ((line1))d"SERVICE_FILE"

SERVICE_FILE=/lib/systemd/system/mTerm_server.service
BAUDRATE_FILE=/var/log/baudrate
DEFALUT_BAUDRATE=9600

if [ -f "$BAUDRATE_FILE" ] ; then
    val=$(head -n 1 < "$BAUDRATE_FILE" 2> /dev/null)
    line=$(cat $SERVICE_FILE | grep -wn "\[Service\]" | awk -F: '{print $1}')
    sed -i ''$line',+2d' "$SERVICE_FILE"
    new_str="ExecStart=/usr/local/bin/mTerm_server obmc-hq "$TTY" "$val""
    echo "[Service]" >> "$SERVICE_FILE"
    echo "$new_str" >> "$SERVICE_FILE"
    systemctl daemon-reload 2> /dev/null
    systemctl restart mTerm_server.service 2> /dev/null
fi

wc -l *

systemctl restart restful
getty 2>&1 | grep “BusyBox v1” > /dev/null 2>&1
busybox --list |grep tty

curl -g http://240.1.1.1:8080/api/sensor/info | python -m json.tool

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
【Note7】_第54张图片
在这里插入图片描述
bash -x show_fan
在这里插入图片描述
【Note7】_第55张图片
检测shell 语法1:shellcheck ./
检测Python语法1:python3 -m flake8 ./
检测Python语法2:python3 -m black ./
检测C 语法 :cppcheck 4 -q --enable=all ./
【Note7】_第56张图片
在这里插入图片描述
在这里插入图片描述
/usr/bin/python3 /usr/lib/python3.5/site-packages/fanctrl/fand.pyc
hwclock --systohc

【Note7】_第57张图片
在这里插入图片描述
date -s 2022.05.05-09:47:00
date +“%Y-%m-%d %H:%M.%S”
【Note7】_第58张图片
【Note7】_第59张图片
在这里插入图片描述
【Note7】_第60张图片
【Note7】_第61张图片
【Note7】_第62张图片

# Synchronize NTP time to RTC
write_rtc()
{
    if [ ! -d /etc/cron/crontabs ];then
        mkdir -p /etc/cron/crontabs
    fi
    echo "0 0 * * * hwclock --systohc" >> /etc/cron/crontabs/root
    /usr/sbin/crond -c /etc/cron/crontabs &
}
write_rtc

workspace,patch append , devtool reset, butbake
devtool modify linux-aspeed
在这里插入图片描述
在这里插入图片描述
yutao@obmc-server:~/alibmc/build$ devtool reset linux-aspeed
gpio_set SPI_UPDATE_CTRL 1 连到bmc,0x24写切主备,0x25读来确定bmc还是cpu连到主还是备
【Note7】_第63张图片

# a=2
# a+=1   #拼接
# echo $a
a=2
let a+=1
echo $a
# a=1
# a=$(($a + 1))
# echo $a

在这里插入图片描述
在这里插入图片描述
i2c_device_add 1 0x1010 slave-mqueue
【Note7】_第64张图片
【Note7】_第65张图片

#!/bin/bash
#
#
# This program file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program in a file named COPYING; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301 USA
# shellcheck disable=SC1091
. /usr/local/bin/openbmc-utils.sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin

#PSU
psu_register_status=()          #0:registered 1:un-register
PSUNUM=$(get_psu_num)
#FAN
fan_fru_register_status=()      #0:registered 1:un-register
fan_present_status=()           #0:absent 1:presnet
FANNUM=$(get_fan_num)

BASE_FRU_FILE="/tmp/sys.txt"

psu_initialize()
{
    for((i=0;i<"${PSUNUM}";i++))
    {
        ret=$(is_hwmon_registed "${PSU_PMBUS_SLAVE_ADDR_ARRAY[$i]}" "in1_input")
        if [ "${ret}" -eq 1 ];then
            psu_register_status[i]=1
        else
            psu_register_status[i]=0
        fi
    }
}

fan_fru_initialize()
{
    for((i=0;i<"${FANNUM}";i++))
    {
        ret=$(is_hwmon_registed "${FAN_EEPROM_SLAVE_ADDR_ARRAY[$i]}" "eeprom")
        if [ "${ret}" -eq 1 ];then #文件节点不存在
            fan_fru_register_status[i]=1
        else
            fan_fru_register_status[i]=0
        fi
    }
}

generate_fan_fru_info()
{
    for((i=0;i<"${FANNUM}";i++))
    {
        if [ "${fan_fru_register_status[$i]}" -eq 0 ];then
            "$FRU_CMD" fan$((i + 1)) > /tmp/fan$((i + 1)).txt
            fan_present_status[i]=1
        else
            fan_present_status[i]=0
        fi
    }
}

generate_sys_fru_info()
{
    "$FRU_CMD" base > "$BASE_FRU_FILE"
}

decompose_iic_addr()
{
    #eg: decompose 0-000d to 0 and 0x0d
    #$1 is full addr
    bus=$(echo "${full_addr}" | awk -F "-" '{print $1}')
    str=$(echo "${full_addr}" | awk -F "-" '{print $2}')
    addr=${str/00/0x}
}

do_register()
{
    #$1 is index start from 0
    #$2 is module type eg: PSU FAN
    case ${2} in 
    "PSU")
        logger -t "hotswap"  "Register PSU $(($1 + 1)) driver"
        full_addr=${PSU_PMBUS_SLAVE_ADDR_ARRAY[$1]}
        decompose_iic_addr "${full_addr}"
        i2c_device_add "${bus}" "${addr}" psu_driver
        ;;
    "FAN")
        logger -t "hotswap"  "Register FCB $(($1 + 1)) eeprom"
        full_addr=${FAN_EEPROM_SLAVE_ADDR_ARRAY[$1]}
        decompose_iic_addr "${full_addr}"
        i2c_device_add "${bus}" "${addr}" 24c64
        ;;
    esac
}

psu_status_check()
{
    for((i=0;i<"${PSUNUM}";i++))
    {
        if [ "${psu_register_status[$i]}" -eq 1 ];then
            val=$(is_psu_ok $((i + 1)))
            if [ "${val}" -eq 0 ];then
                do_register "${i}" "PSU"
                psu_register_status[i]=0
            fi
        fi
    }
}

fan_fru_status_check()
{
    for((i=0;i<"${FANNUM}";i++))
    {
        if [ "${fan_fru_register_status[$i]}" -eq 1 ];then
            val=$(get_fan_present $((i + 1)))
            if [ "${val}" -eq 1 ];then
                do_register "${i}" "FAN"
                fan_fru_register_status[i]=0
            fi
        fi
    }
}

update_fan_fru_info()
{
    for((i=0;i<"${FANNUM}";i++))
    {
        if [ "${fan_fru_register_status[$i]}" -eq 0 ];then
            val=$(get_fan_present $((i + 1)))
            if [ "${val}" -ne "${fan_present_status[$i]}" ];then
                if [ "${val}" -eq 0 ];then
                     rm /tmp/fan$((i + 1)).txt
                else
                    "$FRU_CMD" fan$((i + 1)) > /tmp/fan$((i + 1)).txt
                fi
                fan_present_status[i]="$val"
            fi
        fi
    }
}

update_cpu_temp()
{
    sta=$(get_come_power_sta)
    if [ "$sta" = "0" ];then
        str=$(/usr/local/bin/show_temp cpu)
        raw=$(echo "$str" | awk -F ' ' '{printf "%s\n", $4}')
        value=$((raw * 1000))
    else
        value="0"
    fi
    echo $value > "/sys/bus/i2c/devices/0-000d/temp1_input"
}
#####main#####
psu_initialize
fan_fru_initialize # 遍历所有风扇,看驱动节点是否在,更新fan_fru_register_status数组
generate_fan_fru_info # 遍历所有风扇,如果文件节点存在即已经注册过,生成fru,更新fan_present_status数组
generate_sys_fru_info
update_cpu_temp
while true;
do
    psu_status_check
    fan_fru_status_check # 遍历所有风扇,如果没有注册且风扇在位的话,则进行注册,更新fan_fru_register_status=0
    update_fan_fru_info # 遍历所有风扇,如果已经注册且风扇此时在位和上次在位状态不等,则更新fru和fan_present_status
    update_cpu_temp
    sleep 5
done

在这里插入图片描述
【Note7】_第66张图片
【Note7】_第67张图片

在这里插入图片描述
【Note7】_第68张图片
【Note7】_第69张图片
【Note7】_第70张图片
【Note7】_第71张图片
【Note7】_第72张图片

【Note7】_第73张图片
【Note7】_第74张图片
logrotate /etc/logrotate.rsyslog
【Note7】_第75张图片
【Note7】_第76张图片

【Note7】_第77张图片
【Note7】_第78张图片
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
【Note7】_第79张图片

在这里插入图片描述
在这里插入图片描述

你可能感兴趣的:(linux)