【Notes9】led管理,进入ME刷bios,树莓派

【Notes9】led管理,进入ME刷bios,树莓派,第1张

【Notes9】led管理,进入ME刷bios,树莓派

文章目录
  • 1.led管理
    • 1.1 i2cset
    • 1.2 文件
    • 1.3 set_sled.sh
  • 2.进入ME刷bios
  • 3.树莓派
    • 3.1 系统安装:netstat -antp,arp -a
    • 3.2 花式点亮LED:node red控制


1.led管理

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]  "
    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 文件
. /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]     #这里 $1 就是下面check_parameter $# 传入的 $#
       
    if [ $1 -lt 4 -o  $1 -gt 8  ] ;then
        usage
    fi

    if [ $remainder -ne 0 ] ;then   
        usage
    fi
}

check_parameter $#  #这里 $# 是set_sled.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.进入ME刷bios

BIOS的实质是一个程序,驻留在CMOS存储器(重复可擦写),但必须用BIOS厂商出品的专门刷新工具。刷写BIOS的过程就是用新版本的BIOS文件通过专门的刷新软件覆盖旧版本的BIOS文件,从而让相关配件获得一种软升级让你的配件支持更新,更多的协议,提供更好的硬件性能或消除硬件固有的Bug等。

# 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)
#############切换到BMC下###############
	crt.Screen.WaitForString("root@localhost:/home/admin#")
	crt.Screen.Send("25"+"22"+"24"+"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)
#############切换到Sonic下###############
	crt.Screen.WaitForString("root@bmc-oob:~#")
	crt.Screen.Send("25"+"22"+"24"+"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)
#############切换到BMC下###############
	crt.Screen.WaitForString("root@localhost:/home/admin#")
	crt.Screen.Send("25"+"22"+"24"+"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)
#############切换到Sonic下###############
	crt.Screen.WaitForString("root@bmc-oob:~#")
	crt.Screen.Send("25"+"22"+"24"+"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)
#############切换到BMC下###############
	crt.Screen.WaitForString("root@localhost:/home/admin#")
	crt.Screen.Send("25"+"22"+"24"+"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  #进入ME恢复模式

	ret=$(/usr/bin/ipmitool -b 1 -t 0x2c raw 6 1 | awk -F " " '{print }') #查询ME状态

	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 #退出ME
	 
	ret=$(/usr/bin/ipmitool -b 1 -t 0x2c raw 6 1 | awk -F " " '{print }') #查询ME状态

	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.树莓派 3.1 系统安装:netstat -antp,arp -a

1.内存卡插入读卡器再插入电脑的usb接口,将u盘格式化为FAT32格式。如果右击格式化没有FAT32,用格式化fat32工具:http://www.ridgecrop.demon.co.uk/guiformat.exe。树莓派系统官网:https://www.raspberrypi.org/downloads/raspbian/。下载完系统(1.9G),用写盘工具(https://www.balena.io/etcher/或win32diskimager)将系统写入u盘,写完后不要格式化其他盘。

2.树莓派插上内存卡,接上网线或连上wifi(连wifi,eth0信息为空,因为没有连接网线,wlan0显示内网ip)用ifconfig查看网络。service ssh start开启ssh服务,树莓派默认用户名pi,密码raspberry,sudo netstat -antp可查看到当前有22端口即ssh端口被监听,这时可关闭显示器。

3.用自己电脑上的putty/xshell/securecrt新建一个ssh连接,pi@树莓派内网ip,可登录树莓派。如果忘了树莓派内网ip,可用win下cmd中输入arp -a查看局域网下所有ip和mac对应。

4.树莓派网线和要访问的机器网线插在同一个小型交换机上并且树莓派的串口连接机器,本电脑就可以连接树莓派再通过picocom -b 115200 /dev/ttyUSB0连接到机器。如果没有树莓派,本电脑插上机器的串口线(一端USB口,一端网口)后在设备管理器里看到COM号右击添加驱动,下载并安装驱动后,本电脑通过如下连接。

5.如下打开树莓派自带的图像化界面。



win端需安装vnc viewer。

6.如下点击树莓派自带的node red启动。


树莓派是一个完整的个人电脑,树莓派功耗非常大(相比于没有soc的单片机),物联网中要性能弱并能实现功能就行,所以树莓派处于物联网处于尴尬地位,只用于教学或做一个系统先在树莓派上试试。

树莓派4性能更强并有了usb3.0口和千兆网卡,用来做NAS,但做局域网中NAS不需要这么高性能,买个路由器就行且功耗比树莓派低的多。

3.2 花式点亮LED:node red控制

如下3.3v这个是树莓派上的排座,连电阻的是自己买的空排座。


1.如下左边拖进一个gpio和两个inject。inject中选择数字1和0。

如下gpio中选择GPIO04-7管脚。点击右边部署按钮。

2.如下设置闪烁效果,0这个inject也要如下设置。

3.如下通过http接口实现小灯的亮灭。

如下action为on的话赋值为0。

如下点亮小灯,将on改为off,灯熄灭。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/zaji/5693762.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存