1.led management
1.openbmc-hollywood/common/recipes-utils/openbmc-utils/files/i2c-utils.sh.
SYSFS_I2C_ROOT="/sys/bus/i2c" SYSFS_I2C_DEVICES="${SYSFS_I2C_ROOT}/devices" SYSFS_I2C_DRIVERS="${SYSFS_I2C_ROOT}/drivers" # # Return the given i2c device's absolute sysfs path. # $1 - i2c device in <bus>-00<add> format (for example 0-0050). # i2c_device_sysfs_abspath() { echo "${SYSFS_I2C_DEVICES}/${1}" } # # instantiate an i2c device. # $1 - parent bus number # $2 - device address # $3 - device name/type # i2c_device_add() { bus=$"$1" addr="$2" device="$3" echo "$device" "$addr" > "${SYSFS_I2C_DEVICES}/i2c-${bus}/new_device" } # # delete an i2c device. # $1 - parent bus number # $2 - device address # i2c_device_delete() { bus=$"$1" addr="$2" echo "$addr" > "${SYSFS_I2C_DEVICES}/i2c-${bus}/delete_device" }
2.openbmc-hollywood/meta-huaqin/meta-hollywood/recipes-utils/openbmc-utils/files/setup_i2c.sh.
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin . /usr/local/bin/openbmc-utils.sh #register cmm cpld at first since query psu/lc/fcb status will relay on it # Bus8 # CH2 i2c_device_add 82 0x0d cmmcpld # Bus0 LC1 # 0-0077 # CH0 i2c_device_add 16 0x0d lccpld ret=$(is_lc_ok 1) if [ $ret -eq 0 ];then # CH1 i2c_device_add 17 0x50 24c64 #LC1 EEPROM # CH2 i2c_device_add 18 0x50 24c64 #LC1 COME EEPROM fi # CH3 i2c_device_add 19 0x0d fpgacpld #LC1 FPGA # Bus1 LC2 # 1-0077 # CH0 i2c_device_add 24 0x0d lccpld ret=$(is_lc_ok 2)
3.openbmc-hollywood/common/recipes-kernel/i2c-dev-sysfs-mod/files/i2c_dev_sysfs.h.
typedef struct i2c_dev_attr_st_ { const char *ida_name; const char *ida_help; i2c_dev_attr_show_fn ida_show; i2c_dev_attr_store_fn ida_store; int ida_reg; int ida_bit_offset; int ida_n_bits; unsigned int enable_log_on_write:1; } i2c_dev_attr_st;
4.openbmc-hollywood/meta-huaqin/meta-hollywood/recipes-kernel/cpld-mod/files/cmmcpld.c.
{ "psu1_ac_ok", "0:not ok, 1:ok\n" "PSU1 ac status", I2C_DEV_ATTR_SHOW_DEFAULT, //readable NULL, //Unwritable 0x09, 0, 1, },
5.openbmc-hollywood/meta-huaqin/meta-hollywood/recipes-utils/openbmc-utils/files/board-utils.sh.
###LineCard related get_lc_num() { #echo lc max number echo 8 } get_lc_present() { #$1 is LC index,start from 1 #echo 1 for present, echo 0 for absent path=${CMMCPLD_SYSFS_DIR}/lc$1_present if [ -f ${path} ];then value=$(cat ${path} | sed -n '1p') if [ $value == "0x0" ];then echo "1" else echo "0" fi else echo "0" fi }
1.openbmc-hua/meta-hua/meta-hollywood/recipes-kernel/cpld-mod/files/syscpld.c.
static const i2c_dev_attr_st syscpld_attr_table[] = { { "psu_led_color", "0x0: green\n" "0x1: yellow\n" "0x2: alternate", //Echo 0x0 > psu_ Led_ Color file, equivalent to i2cset I2C_DEV_ATTR_SHOW_DEFAULT, // readable I2C_DEV_ATTR_STORE_DEFAULT, // Writable 0x40, 4, 2, // The fourth byte below begins with two digits }, //One byte = 0x(8421)(8421).
1.1 i2cset
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin usage() { program=$(basename "$0") echo "Usage:" echo " $program [PWR|FAN|SYS|ALM|STA] <green|yellow> <on|off|1hzblink|4hzblink>" echo "" echo "Examples:" echo " $program PWR green on" } case $1 in "PWR") if [ $2 = "green" ]; then if [ $3 = "on" ]; then i2cset -f -y 0 0x0d 0x40 0x40 elif [ $3 = "off" ]; then i2cset -f -y 0 0x0d 0x40 0x41 elif [ $3 = "1hzblink" ]; then i2cset -f -y 0 0x0d 0x40 0x42 elif [ $3 = "4hzblink" ]; then i2cset -f -y 0 0x0d 0x40 0x46 fi elif [ $2 = "yellow" ]; then if [ $3 = "on" ]; then i2cset -f -y 0 0x0d 0x40 0x50 elif [ $3 = "off" ]; then i2cset -f -y 0 0x0d 0x40 0x51 elif [ $3 = "1hzblink" ]; then i2cset -f -y 0 0x0d 0x40 0x52 elif [ $3 = "4hzblink" ]; then i2cset -f -y 0 0x0d 0x40 0x56 fi fi ;; "FAN") if [ $2 = "green" ]; then if [ $3 = "on" ]; then i2cset -f -y 0 0x0d 0x43 0x40 elif [ $3 = "off" ]; then i2cset -f -y 0 0x0d 0x43 0x41 elif [ $3 = "1hzblink" ]; then i2cset -f -y 0 0x0d 0x43 0x42 elif [ $3 = "4hzblink" ]; then i2cset -f -y 0 0x0d 0x43 0x46 fi elif [ $2 = "yellow" ]; then if [ $3 = "on" ]; then i2cset -f -y 0 0x0d 0x43 0x50 elif [ $3 = "off" ]; then i2cset -f -y 0 0x0d 0x43 0x51 elif [ $3 = "1hzblink" ]; then i2cset -f -y 0 0x0d 0x43 0x52 elif [ $3 = "4hzblink" ]; then i2cset -f -y 0 0x0d 0x43 0x56 fi fi ;; "SYS") if [ $2 = "green" ]; then if [ $3 = "on" ]; then i2cset -f -y 0 0x0d 0x41 0x40 elif [ $3 = "off" ]; then i2cset -f -y 0 0x0d 0x41 0x41 elif [ $3 = "1hzblink" ]; then i2cset -f -y 0 0x0d 0x41 0x42 elif [ $3 = "4hzblink" ]; then i2cset -f -y 0 0x0d 0x41 0x46 fi elif [ $2 = "yellow" ]; then if [ $3 = "on" ]; then i2cset -f -y 0 0x0d 0x41 0x50 elif [ $3 = "off" ]; then i2cset -f -y 0 0x0d 0x41 0x51 elif [ $3 = "1hzblink" ]; then i2cset -f -y 0 0x0d 0x41 0x52 elif [ $3 = "4hzblink" ]; then i2cset -f -y 0 0x0d 0x41 0x56 fi fi ;; "ALM") if [ $2 = "green" ]; then if [ $3 = "on" ]; then i2cset -f -y 0 0x0d 0x42 0x40 elif [ $3 = "off" ]; then i2cset -f -y 0 0x0d 0x42 0x41 elif [ $3 = "1hzblink" ]; then i2cset -f -y 0 0x0d 0x42 0x42 elif [ $3 = "4hzblink" ]; then i2cset -f -y 0 0x0d 0x42 0x46 fi elif [ $2 = "yellow" ]; then if [ $3 = "on" ]; then i2cset -f -y 0 0x0d 0x42 0x50 elif [ $3 = "off" ]; then i2cset -f -y 0 0x0d 0x42 0x51 elif [ $3 = "1hzblink" ]; then i2cset -f -y 0 0x0d 0x42 0x52 elif [ $3 = "4hzblink" ]; then i2cset -f -y 0 0x0d 0x42 0x56 fi fi ;; "STA") if [ $2 = "green" ]; then if [ $3 = "on" ]; then i2cset -f -y 0 0x0d 0x44 0x40 elif [ $3 = "off" ]; then i2cset -f -y 0 0x0d 0x44 0x41 elif [ $3 = "1hzblink" ]; then i2cset -f -y 0 0x0d 0x44 0x42 elif [ $3 = "4hzblink" ]; then i2cset -f -y 0 0x0d 0x44 0x46 fi elif [ $2 = "yellow" ]; then if [ $3 = "on" ]; then i2cset -f -y 0 0x0d 0x44 0x50 elif [ $3 = "off" ]; then i2cset -f -y 0 0x0d 0x44 0x51 elif [ $3 = "1hzblink" ]; then i2cset -f -y 0 0x0d 0x44 0x52 elif [ $3 = "4hzblink" ]; then i2cset -f -y 0 0x0d 0x44 0x56 fi fi ;; *) usage exit 1 ;; esac
1.2 Files
. /usr/local/bin/openbmc-utils.sh PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin # SYSCPLD_SYSFS_DIR="/sys/bus/i2c/devices/0-000d" psu_led_status="${SYSCPLD_SYSFS_DIR}/psu_led_status" psu_led_frequency="${SYSCPLD_SYSFS_DIR}/psu_led_frequency" psu_led_color="${SYSCPLD_SYSFS_DIR}/psu_led_color" psu_led_ctrl="${SYSCPLD_SYSFS_DIR}/psu_led_ctrl" fan_led_status="${SYSCPLD_SYSFS_DIR}/fan_led_status" fan_led_frequency="${SYSCPLD_SYSFS_DIR}/fan_led_frequency" fan_led_color="${SYSCPLD_SYSFS_DIR}/fan_led_color" fan_led_ctrl="${SYSCPLD_SYSFS_DIR}/fan_led_ctrl" sys_led_status="${SYSCPLD_SYSFS_DIR}/sys_led_status" sys_led_frequency="${SYSCPLD_SYSFS_DIR}/sys_led_frequency" sys_led_color="${SYSCPLD_SYSFS_DIR}/sys_led_color" sys_led_ctrl="${SYSCPLD_SYSFS_DIR}/sys_led_ctrl" bmc_hb_led_status="${SYSCPLD_SYSFS_DIR}/bmc_hb_led_status" bmc_hb_led_frequency="${SYSCPLD_SYSFS_DIR}/bmc_hb_led_frequency" bmc_hb_led_color="${SYSCPLD_SYSFS_DIR}/bmc_hb_led_color" bmc_hb_led_ctrl="${SYSCPLD_SYSFS_DIR}/bmc_hb_led_ctrl" alr_led_status="${SYSCPLD_SYSFS_DIR}/alr_led_status" alr_led_frequency="${SYSCPLD_SYSFS_DIR}/alr_led_frequency" alr_led_color="${SYSCPLD_SYSFS_DIR}/alr_led_color" alr_led_ctrl="${SYSCPLD_SYSFS_DIR}/alr_led_ctrl" usage() { program=$(basename "$0") echo "Usage:" echo " $program -t [psu/fan/sys/bmc/alr] -s [on/off/blink] -c [green/yellow/alter] -f [1/4]" echo "" echo "Examples:" echo " $program -t psu -s on -c green -f 4" } check_parameter() { if [ $# -ne 8 ];then usage exit 1 fi } check_parameter $@ case $2 in "psu") if [ $4 = "on" ]; then if [ $6 = "green" ]; then if [ $8 = "1" ]; then echo 0x1 > $psu_led_ctrl echo 0x0 > $psu_led_status echo 0x0 > $psu_led_frequency echo 0x0 > $psu_led_color elif [ $8 = "4" ]; then echo 0x1 > $psu_led_ctrl echo 0x0 > $psu_led_status echo 0x1 > $psu_led_frequency echo 0x0 > $psu_led_color fi fi if [ $6 = "yellow" ]; then if [ $8 = "1" ]; then echo 0x1 > $psu_led_ctrl echo 0x0 > $psu_led_status echo 0x0 > $psu_led_frequency echo 0x1 > $psu_led_color elif [ $8 = "4" ]; then echo 0x1 > $psu_led_ctrl echo 0x0 > $psu_led_status echo 0x1 > $psu_led_frequency echo 0x1 > $psu_led_color fi fi if [ $6 = "alter" ]; then if [ $8 = "1" ]; then echo 0x1 > $psu_led_ctrl echo 0x2 > $psu_led_status echo 0x0 > $psu_led_frequency echo 0x2 > $psu_led_color elif [ $8 = "4" ]; then echo 0x1 > $psu_led_ctrl echo 0x2 > $psu_led_status echo 0x1 > $psu_led_frequency echo 0x2 > $psu_led_color fi fi fi if [ $4 = "off" ]; then echo 0x01 > $psu_led_status fi if [ $4 = "blink" ]; then if [ $6 = "green" ]; then if [ $8 = "1" ]; then echo 0x1 > $psu_led_ctrl echo 0x2 > $psu_led_status echo 0x0 > $psu_led_frequency echo 0x0 > $psu_led_color elif [ $8 = "4" ]; then echo 0x1 > $psu_led_ctrl echo 0x2 > $psu_led_status echo 0x1 > $psu_led_frequency echo 0x0 > $psu_led_color fi fi if [ $6 = "yellow" ]; then if [ $8 = "1" ]; then echo 0x1 > $psu_led_ctrl echo 0x2 > $psu_led_status echo 0x0 > $psu_led_frequency echo 0x1 > $psu_led_color elif [ $8 = "4" ]; then echo 0x1 > $psu_led_ctrl echo 0x2 > $psu_led_status echo 0x1 > $psu_led_frequency echo 0x1 > $psu_led_color fi fi if [ $6 = "alter" ]; then if [ $8 = "1" ]; then echo 0x1 > $psu_led_ctrl echo 0x2 > $psu_led_status echo 0x0 > $psu_led_frequency echo 0x2 > $psu_led_color elif [ $8 = "4" ]; then echo 0x1 > $psu_led_ctrl echo 0x2 > $psu_led_status echo 0x1 > $psu_led_frequency echo 0x2 > $psu_led_color fi fi fi ;; #111111111111111111111111111111111111111111111111111111111111111111 "fan") if [ $4 = "on" ]; then if [ $6 = "green" ]; then if [ $8 = "1" ]; then echo 0x1 > $fan_led_ctrl echo 0x0 > $fan_led_status echo 0x0 > $fan_led_frequency echo 0x0 > $fan_led_color elif [ $8 = "4" ]; then echo 0x1 > $fan_led_ctrl echo 0x0 > $fan_led_status echo 0x1 > $fan_led_frequency echo 0x0 > $fan_led_color fi fi if [ $6 = "yellow" ]; then if [ $8 = "1" ]; then echo 0x1 > $fan_led_ctrl echo 0x0 > $fan_led_status echo 0x0 > $fan_led_frequency echo 0x1 > $fan_led_color elif [ $8 = "4" ]; then echo 0x1 > $fan_led_ctrl echo 0x0 > $fan_led_status echo 0x1 > $fan_led_frequency echo 0x1 > $fan_led_color fi fi if [ $6 = "alter" ]; then if [ $8 = "1" ]; then echo 0x1 > $fan_led_ctrl echo 0x2 > $fan_led_status echo 0x0 > $fan_led_frequency echo 0x2 > $fan_led_color elif [ $8 = "4" ]; then echo 0x1 > $fan_led_ctrl echo 0x2 > $fan_led_status echo 0x1 > $fan_led_frequency echo 0x2 > $fan_led_color fi fi fi if [ $4 = "off" ]; then echo 0x0 > $fan_led_status fi if [ $4 = "blink" ]; then if [ $6 = "green" ]; then if [ $8 = "1" ]; then echo 0x1 > $fan_led_ctrl echo 0x2 > $fan_led_status echo 0x0 > $fan_led_frequency echo 0x0 > $fan_led_color elif [ $8 = "4" ]; then echo 0x1 > $fan_led_ctrl echo 0x2 > $fan_led_status echo 0x1 > $fan_led_frequency echo 0x0 > $fan_led_color fi fi if [ $6 = "yellow" ]; then if [ $8 = "1" ]; then echo 0x1 > $fan_led_ctrl echo 0x2 > $fan_led_status echo 0x0 > $fan_led_frequency echo 0x1 > $fan_led_color elif [ $8 = "4" ]; then echo 0x1 > $fan_led_ctrl echo 0x2 > $fan_led_status echo 0x1 > $fan_led_frequency echo 0x1 > $fan_led_color fi fi if [ $6 = "alter" ]; then if [ $8 = "1" ]; then echo 0x1 > $fan_led_ctrl echo 0x2 > $fan_led_status echo 0x0 > $fan_led_frequency echo 0x2 > $fan_led_color elif [ $8 = "4" ]; then echo 0x1 > $fan_led_ctrl echo 0x2 > $fan_led_status echo 0x1 > $fan_led_frequency echo 0x2 > $fan_led_color fi fi fi ;; #111111111111111111111111111111111111111111111111111111111111111111 "sys") if [ $4 = "on" ]; then if [ $6 = "green" ]; then if [ $8 = "1" ]; then echo 0x1 > $sys_led_ctrl echo 0x0 > $sys_led_status echo 0x0 > $sys_led_frequency echo 0x0 > $sys_led_color elif [ $8 = "4" ]; then echo 0x1 > $sys_led_ctrl echo 0x0 > $sys_led_status echo 0x1 > $sys_led_frequency echo 0x0 > $sys_led_color fi fi if [ $6 = "yellow" ]; then if [ $8 = "1" ]; then echo 0x1 > $sys_led_ctrl echo 0x0 > $sys_led_status echo 0x0 > $sys_led_frequency echo 0x1 > $sys_led_color elif [ $8 = "4" ]; then echo 0x1 > $sys_led_ctrl echo 0x0 > $sys_led_status echo 0x1 > $sys_led_frequency echo 0x1 > $sys_led_color fi fi if [ $6 = "alter" ]; then if [ $8 = "1" ]; then echo 0x1 > $sys_led_ctrl echo 0x2 > $sys_led_status echo 0x0 > $sys_led_frequency echo 0x2 > $sys_led_color elif [ $8 = "4" ]; then echo 0x1 > $sys_led_ctrl echo 0x2 > $sys_led_status echo 0x1 > $sys_led_frequency echo 0x2 > $sys_led_color fi fi fi if [ $4 = "off" ]; then echo 0x01 > $sys_led_status fi if [ $4 = "blink" ]; then if [ $6 = "green" ]; then if [ $8 = "1" ]; then echo 0x1 > $sys_led_ctrl echo 0x2 > $sys_led_status echo 0x0 > $sys_led_frequency echo 0x0 > $sys_led_color elif [ $8 = "4" ]; then echo 0x1 > $sys_led_ctrl echo 0x2 > $sys_led_status echo 0x1 > $sys_led_frequency echo 0x0 > $sys_led_color fi fi if [ $6 = "yellow" ]; then if [ $8 = "1" ]; then echo 0x1 > $sys_led_ctrl echo 0x2 > $sys_led_status echo 0x0 > $sys_led_frequency echo 0x1 > $sys_led_color elif [ $8 = "4" ]; then echo 0x1 > $sys_led_ctrl echo 0x2 > $sys_led_status echo 0x1 > $sys_led_frequency echo 0x1 > $sys_led_color fi fi if [ $6 = "alter" ]; then if [ $8 = "1" ]; then echo 0x1 > $sys_led_ctrl echo 0x2 > $sys_led_status echo 0x0 > $sys_led_frequency echo 0x2 > $sys_led_color elif [ $8 = "4" ]; then echo 0x1 > $sys_led_ctrl echo 0x2 > $sys_led_status echo 0x1 > $sys_led_frequency echo 0x2 > $sys_led_color fi fi fi ;; #111111111111111111111111111111111111111111111111111111111111111111 "bmc") if [ $4 = "on" ]; then if [ $6 = "green" ]; then if [ $8 = "1" ]; then echo 0x1 > $bmc_hb_led_ctrl echo 0x0 > $bmc_hb_led_status echo 0x0 > $bmc_hb_led_frequency echo 0x0 > $bmc_hb_led_color elif [ $8 = "4" ]; then echo 0x1 > $bmc_hb_led_ctrl echo 0x0 > $bmc_hb_led_status echo 0x1 > $bmc_hb_led_frequency echo 0x0 > $bmc_hb_led_color fi fi if [ $6 = "yellow" ]; then if [ $8 = "1" ]; then echo 0x1 > $bmc_hb_led_ctrl echo 0x0 > $bmc_hb_led_status echo 0x0 > $bmc_hb_led_frequency echo 0x1 > $bmc_hb_led_color elif [ $8 = "4" ]; then echo 0x1 > $bmc_hb_led_ctrl echo 0x0 > $bmc_hb_led_status echo 0x1 > $bmc_hb_led_frequency echo 0x1 > $bmc_hb_led_color fi fi if [ $6 = "alter" ]; then if [ $8 = "1" ]; then echo 0x1 > $psu_led_ctrl echo 0x2 > $psu_led_status echo 0x0 > $psu_led_frequency echo 0x2 > $psu_led_color elif [ $8 = "4" ]; then echo 0x1 > $bmc_hb_led_ctrl echo 0x2 > $bmc_hb_led_status echo 0x1 > $bmc_hb_led_frequency echo 0x2 > $bmc_hb_led_color fi fi fi if [ $4 = "off" ]; then echo 0x01 > $bmc_hb_led_status fi if [ $4 = "blink" ]; then if [ $6 = "green" ]; then if [ $8 = "1" ]; then echo 0x1 > $bmc_hb_led_ctrl echo 0x2 > $bmc_hb_led_status echo 0x0 > $bmc_hb_led_frequency echo 0x0 > $bmc_hb_led_color elif [ $8 = "4" ]; then echo 0x1 > $bmc_hb_led_ctrl echo 0x2 > $bmc_hb_led_status echo 0x1 > $bmc_hb_led_frequency echo 0x0 > $bmc_hb_led_color fi fi if [ $6 = "yellow" ]; then if [ $8 = "1" ]; then echo 0x1 > $bmc_hb_led_ctrl echo 0x2 > $bmc_hb_led_status echo 0x0 > $bmc_hb_led_frequency echo 0x1 > $bmc_hb_led_color elif [ $8 = "4" ]; then echo 0x1 > $bmc_hb_led_ctrl echo 0x2 > $bmc_hb_led_status echo 0x1 > $bmc_hb_led_frequency echo 0x1 > $bmc_hb_led_color fi fi if [ $6 = "alter" ]; then if [ $8 = "1" ]; then echo 0x1 > $bmc_hb_led_ctrl echo 0x2 > $bmc_hb_led_status echo 0x0 > $bmc_hb_led_frequency echo 0x2 > $bmc_hb_led_color elif [ $8 = "4" ]; then echo 0x1 > $bmc_hb_led_ctrl echo 0x2 > $bmc_hb_led_status echo 0x1 > $bmc_hb_led_frequency echo 0x2 > $bmc_hb_led_color fi fi fi ;; #111111111111111111111111111111111111111111111111111111111111111111 "alr") if [ $4 = "on" ]; then if [ $6 = "green" ]; then if [ $8 = "1" ]; then echo 0x1 > $alr_led_ctrl echo 0x0 > $alr_led_status echo 0x0 > $alr_led_frequency echo 0x0 > $alr_led_color elif [ $8 = "4" ]; then echo 0x1 > $alr_led_ctrl echo 0x0 > $alr_led_status echo 0x1 > $alr_led_frequency echo 0x0 > $alr_led_color fi fi if [ $6 = "yellow" ]; then if [ $8 = "1" ]; then echo 0x1 > $alr_led_ctrl echo 0x0 > $alr_led_status echo 0x0 > $alr_led_frequency echo 0x1 > $alr_led_color elif [ $8 = "4" ]; then echo 0x1 > $alr_led_ctrl echo 0x0 > $alr_led_status echo 0x1 > $alr_led_frequency echo 0x1 > $alr_led_color fi fi if [ $6 = "alter" ]; then if [ $8 = "1" ]; then echo 0x1 > $alr_led_ctrl echo 0x2 > $alr_led_status echo 0x0 > $alr_led_frequency echo 0x2 > $alr_led_color elif [ $8 = "4" ]; then echo 0x1 > $alr_led_ctrl echo 0x2 > $alr_led_status echo 0x1 > $alr_led_frequency echo 0x2 > $alr_led_color fi fi fi if [ $4 = "off" ]; then echo 0x01 > $alr_led_status fi if [ $4 = "blink" ]; then if [ $6 = "green" ]; then if [ $8 = "1" ]; then echo 0x1 > $alr_led_ctrl echo 0x2 > $alr_led_status echo 0x0 > $alr_led_frequency echo 0x0 > $alr_led_color elif [ $8 = "4" ]; then echo 0x1 > $alr_led_ctrl echo 0x2 > $alr_led_status echo 0x1 > $alr_led_frequency echo 0x0 > $alr_led_color fi fi if [ $6 = "yellow" ]; then if [ $8 = "1" ]; then echo 0x1 > $alr_led_ctrl echo 0x2 > $alr_led_status echo 0x0 > $alr_led_frequency echo 0x1 > $alr_led_color elif [ $8 = "4" ]; then echo 0x1 > $alr_led_ctrl echo 0x2 > $alr_led_status echo 0x1 > $alr_led_frequency echo 0x1 > $alr_led_color fi fi if [ $6 = "alter" ]; then if [ $8 = "1" ]; then echo 0x1 > $alr_led_ctrl echo 0x2 > $alr_led_status echo 0x0 > $alr_led_frequency echo 0x2 > $alr_led_color elif [ $8 = "4" ]; then echo 0x1 > $alr_led_ctrl echo 0x2 > $alr_led_status echo 0x1 > $alr_led_frequency echo 0x2 > $alr_led_color fi fi fi ;; *) usage exit 1 ;; esac
1.3 set_sled.sh
/meta-kestrel/recipes-utils/openbmc-utils/files/set_sled.sh
#!/bin/bash . /usr/local/bin/openbmc-utils.sh usage() { program=$(basename "$0") echo "Usage:" echo " $program -t [psu/fan/sys/bmc/alr] -s [on/off/blink] -c [green/yellow/alter] -f [1/4]" echo "" echo "Examples:" echo " $program -t psu -s on -c green -f 1" exit 1 } check_parameter() { remainder=$[$1%2] #Here $1 Here's it check_parameter $# Incoming $# if [ $1 -lt 4 -o $1 -gt 8 ] ;then usage fi if [ $remainder -ne 0 ] ;then usage fi } check_parameter $# #Here $# Is set_ Sled. Number of parameters passed in by SH while [ $# -ne 0 ] do case $1 in "-t") shift if [ $1 == "psu" -o $1 == "fan" -o $1 == "sys" -o $1 == "bmc" -o $1 == "alr" ];then type=$1; else usage fi ;; "-s") shift if [ $1 = "on" ]; then status="0x0" elif [ $1 = "off" ]; then status="0x1" elif [ $1 = "blink" ]; then status="0x2" else usage fi ;; "-c") shift if [ $1 = "green" ]; then color="0x0" elif [ $1 = "yellow" ]; then color="0x1" elif [ $1 = "alter" ]; then color="0x2" else usage fi ;; "-f") shift if [ $1 = "1" ]; then frequency="0x0" elif [ $1 = "4" ]; then frequency="0x1" else usage fi ;; *) usage ;; esac shift done if [ $type ]; then echo 0x1 > "${SYSCPLD_SYSFS_DIR}/${type}_led_ctrl" else usage fi if [ $status ];then echo $status > "${SYSCPLD_SYSFS_DIR}/${type}_led_status" fi if [ $color ];then echo $color > "${SYSCPLD_SYSFS_DIR}/${type}_led_color" fi if [ $frequency ];then echo $frequency > "${SYSCPLD_SYSFS_DIR}/${type}_led_frequency" fi echo "set ${type} led ok."
2. Enter ME brush bios
The essence of BIOS is a program. Hosting in CMOS Memory (Duplicate Rewritable), but a special refresh tool from the BIOS manufacturer must be used. The process of refreshing BIOS is to overwrite old BIOS files with new versions of BIOS files with special refresh software, so that the related accessories can get a software upgrade to support updates, more protocols, provide better hardware performance, or eliminate inherent bugs in the hardware.
# BMC_BIOS_change.py # $interface = "1.0" import time import sys import os import SecureCRT def boot_os(): crt.Screen.WaitForString("localhost login:") crt.Screen.Send("admin" +chr(13)) time.sleep (1) crt.Screen.WaitForString("Password: ") crt.Screen.Send("admin" +chr(13)) time.sleep (1) crt.Screen.WaitForString("admin@localhost:~$") crt.Screen.Send("sudo su" +chr(13)) time.sleep (1) crt.Screen.WaitForString("root@localhost:/home/admin# ") crt.Screen.Send("dmidecode -t 0" +chr(13)) time.sleep (1) def Checkinfo1(): crt.Screen.WaitForString("root@localhost:/home/admin#",1) crt.Screen.Send("lspci |grep -i eth" +chr(13)) time.sleep (1) crt.Screen.WaitForString("root@localhost:/home/admin#",1) crt.Screen.Send("lspci |grep -i 07:00.0" +chr(13)) time.sleep (2) crt.Screen.WaitForString("root@localhost:/home/admin#") crt.Screen.Send("lsblk |grep -i sda" +chr(13)) time.sleep (2) #############switch to BMC lower############### crt.Screen.WaitForString("root@localhost:/home/admin#") crt.Screen.Send("\025"+"\022"+"\024"+"1 \r") crt.Screen.SendSpecial("VT_KEYPAD_ENTER") time.sleep (5) # crt.Screen.WaitForString("bmc-oob. login:") # crt.Screen.Send("root" +chr(13)) # crt.Screen.WaitForString("Password:") # crt.Screen.Send("0penBmc" +chr(13)) crt.Screen.WaitForString("root@bmc-oob:~#") crt.Screen.Send("boot_info.sh all" +chr(13)) time.sleep (2) crt.Screen.Send("boot_info.sh reset bios master" +chr(13)) crt.Screen.WaitForString("root@bmc-oob:~#") time.sleep (90) #############switch to Sonic lower############### crt.Screen.WaitForString("root@bmc-oob:~#") crt.Screen.Send("\025"+"\022"+"\024"+"0 \r") crt.Screen.SendSpecial("VT_KEYPAD_ENTER") time.sleep (1) def Checkinfo2(): crt.Screen.WaitForString("root@localhost:/home/admin#",1) crt.Screen.Send("lspci |grep -i eth" +chr(13)) time.sleep (1) crt.Screen.WaitForString("root@localhost:/home/admin#",1) crt.Screen.Send("lspci |grep -i 07:00.0" +chr(13)) time.sleep (2) crt.Screen.WaitForString("root@localhost:/home/admin#") crt.Screen.Send("lsblk |grep -i sda" +chr(13)) time.sleep (2) #############switch to BMC lower############### crt.Screen.WaitForString("root@localhost:/home/admin#") crt.Screen.Send("\025"+"\022"+"\024"+"1 \r") crt.Screen.SendSpecial("VT_KEYPAD_ENTER") time.sleep (1) # crt.Screen.WaitForString("bmc-oob. login:") # crt.Screen.Send("root" +chr(13)) # crt.Screen.WaitForString("Password:") # crt.Screen.Send("0penBmc" +chr(13)) crt.Screen.WaitForString("root@bmc-oob:~#") crt.Screen.Send("boot_info.sh all" +chr(13)) time.sleep (2) crt.Screen.Send("boot_info.sh reset bios slave" +chr(13)) crt.Screen.WaitForString("root@bmc-oob:~#") time.sleep (90) #############switch to Sonic lower############### crt.Screen.WaitForString("root@bmc-oob:~#") crt.Screen.Send("\025"+"\022"+"\024"+"0 \r") crt.Screen.SendSpecial("VT_KEYPAD_ENTER") time.sleep (1) def Checkinfo3(): crt.Screen.WaitForString("root@localhost:/home/admin#",1) crt.Screen.Send("lspci |grep -i eth" +chr(13)) time.sleep (1) crt.Screen.WaitForString("root@localhost:/home/admin#",1) crt.Screen.Send("lspci |grep -i 07:00.0" +chr(13)) time.sleep (2) crt.Screen.WaitForString("root@localhost:/home/admin#") crt.Screen.Send("lsblk |grep -i sda" +chr(13)) time.sleep (2) #############switch to BMC lower############### crt.Screen.WaitForString("root@localhost:/home/admin#") crt.Screen.Send("\025"+"\022"+"\024"+"1 \r") crt.Screen.SendSpecial("VT_KEYPAD_ENTER") time.sleep (1) crt.Screen.WaitForString("bmc-oob. login:") crt.Screen.Send("root" +chr(13)) crt.Screen.WaitForString("Password:") crt.Screen.Send("0penBmc" +chr(13)) crt.Screen.WaitForString("root@bmc-oob:~#") crt.Screen.Send("/var/log/./util.sh" +chr(13)) time.sleep (2) def Main(): crt.Screen.Synchronous = True for i in range (0,200): boot_os() time.sleep (2) Checkinfo1() boot_os() Checkinfo2() Checkinfo3() time.sleep (2) Main()
# util.sh #!/bin/sh i=1 while(( $i<=3 )) do ipmitool -b 1 -t 0x2c raw 0x2e 0xdf 0x57 0x01 0x00 0x01 #Enter ME Recovery Mode ret=$(/usr/bin/ipmitool -b 1 -t 0x2c raw 6 1 | awk -F " " '{print $15}') #Query ME status if [ "$ret" = "00" ]; then logger -p user.info "Enter ME recovery mode successfully" spi_util.sh write BIOS1 image break fi if [ "$ret" != "00" ]; then logger -p user.info "Three times to enter ME recovery mode failed" continue fi done i=1 while(( $i<=3 )) do ipmitool -b 1 -t 0x2c raw 6 2 #Exit ME ret=$(/usr/bin/ipmitool -b 1 -t 0x2c raw 6 1 | awk -F " " '{print $15}') #Query ME status if [ "$ret" != "00" ]; then logger -p user.info "Exit ME recovery mode successfully" break fi if [ "$ret" = "00" ]; then logger -p user.info "Three times to exit ME recovery mode failed" continue fi done exit
3. Raspberry pie
3.1 System Installation: netstat-antp, arp-a
1. Insert the memory card into the reader and then into the usb interface of the computer to format the u-disk into FAT32 format. If right-click formatting does not have FAT32, use the formatting FAT32 tool: http://www.ridgecrop.demon.co.uk/guiformat.exe . Raspberry pie system website: https://www.raspberrypi.org/downloads/raspbian/ . After downloading the system (1.9G), use the Write Disk tool ( https://www.balena.io/etcher/ Or Win32 diskimager) Write the system to the u disk, do not format other disks after writing.
2. Raspberry dispatch plugs in a memory card, connects to the Internet or connects to WiFi (wifi, eth0 information is empty because there is no connection cable, wlan0 shows intranet ip) to view the network with ifconfig. service ssh start starts ssh service, raspberry dispatch default username pi, password raspberry, sudo netstat-antp can see that there are currently 22 ports that ssh port is being listened on, then turn off the monitor.
3. Create a new ssh connection with putty/xshell/securecrt on your computer, pi@Raspberry pie intranet ip, you can log in to Raspberry pie. If you forget the raspberry intranet ip, enter arp-a in cmd under win to view all IP and mac correspondences under the local area network.
4. The raspberry pie network cable and the machine network cable to be accessed are plugged into the same small switch and connected to the machine through the raspberry pie serial port. This computer can connect the raspberry pie to the machine through picocom-b 115200/dev/ttyUSB0. If you don't have raspberry pie, this computer plugs in the serial line of the machine (one end of the USB port, one end of the network port) and sees the COM number in the Device Manager. After you download and install the driver, this computer connects as follows.
5. Open the raspberry dispatch graphical interface as follows.
vnc viewer needs to be installed on the win side.
6. Click on the node red that comes with the raspberry to start.
The raspberry pie is a complete personal computer. It consumes a lot of power (compared to a single-chip machine without soc). It has to be weak and functional in the Internet of Things. Therefore, the raspberry pie is in an embarrassing position in the Internet of Things. It can only be used for teaching or for a system to try on the raspberry pie first.
Raspberry Pie 4 performs better and has usb3.0-port and Gigabit network cards for NAS, but NAS does not require this high performance for LAN. Buy a router and consume much less power than Raspberry Pie.
3.2 Fancy Lighting LED: node red control
Below is 3.3v. This is the row on the raspberry pie. The resistance is the empty row you bought.
1. Drag in one gpio and two injects to the left below. Select numbers 1 and 0 in inject.
Select the GPIO04-7 pin from the following gpio. Click the Deployment button on the right.
2. Set the flicker effect as follows, and 0 this inject should also be set as follows.
3. As follows, the small lamp is turned on and off through the http interface.
Assign a value of 0 if the action below is on.
Turn on the on to off and the light goes out as follows.