Notes9led管理,进入ME刷bios,树莓派

Posted 码农编程录

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Notes9led管理,进入ME刷bios,树莓派相关的知识,希望对你有一定的参考价值。


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] <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 文件

. /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
			

以上是关于Notes9led管理,进入ME刷bios,树莓派的主要内容,如果未能解决你的问题,请参考以下文章

树莓派4B刷入OpenHarmony 3.0,目前可显示与触控

树莓派Linux启动过程简介

如何让树莓派默认启动进入图形界面

如何让树莓派默认启动进入图形界面

树莓派正式使用树莓派前的一些配置工作

树莓派刷机