Skip to content

Instantly share code, notes, and snippets.

@garygan89
Created August 11, 2020 21:56
Show Gist options
  • Select an option

  • Save garygan89/d80a5c99081db6b1adbf04285046555f to your computer and use it in GitHub Desktop.

Select an option

Save garygan89/d80a5c99081db6b1adbf04285046555f to your computer and use it in GitHub Desktop.
Hardware test on Solidrun Hummingboard Pulse.
#!/bin/bash
# Hardware test on Solidrun Hummingboard Pulse.
#usage: hwtest [log]
# --------------------------------------------------------------------------------
black=$(tput setaf 0); red=$(tput setaf 1); green=$(tput setaf 2); yellow=$(tput setaf 3);
blue=$(tput setaf 4); magenta=$(tput setaf 5); cyan=$(tput setaf 6); white=$(tput setaf 7);
on_red=$(tput setab 1); on_green=$(tput setab 2); on_yellow=$(tput setab 3); on_blue=$(tput setab 4);
on_magenta=$(tput setab 5); on_cyan=$(tput setab 6); on_white=$(tput setab 7); bold=$(tput bold);
dim=$(tput dim); underline=$(tput smul); reset_underline=$(tput rmul); standout=$(tput smso);
reset_standout=$(tput rmso); normal=$(tput sgr0); alert=${white}${on_red}; title=${standout};
baihuangse=${white}${on_yellow}; bailanse=${white}${on_blue}; bailvse=${white}${on_green};
baiqingse=${white}${on_cyan}; baihongse=${white}${on_red}; baizise=${white}${on_magenta}; jiacu=${normal}${bold}
heibaise=${black}${on_white}; shanshuo=$(tput blink); wuguangbiao=$(tput civis); guangbiao=$(tput cnorm)
CW="${bold}${baihongse} ERROR ${jiacu}";ZY="${baihongse}${bold} ATTENTION ${jiacu}";JG="${baihongse}${bold} WARNING ${jiacu}"
SEP="==============================================="
SEP2="-----------------------------------------------"
# --------------------------------------------------------------------------------
if [ ! -z $1 ]; then # redirect all output to logfile if log arg is specified
logfile=srhbpulse-hwtest-$(hostname)-$(date "+%Y%m%d_%H%M").log
echo "Writing stdout to ${bold}$logfile${normal}"
exec >> $logfile # redirect all output to logfile
fi
function timestamp() {
DATE=`date "+%Y%m%d_%H%M"`
}
function _checkhdmi() {
echo $SEP
echo "Checking HDMI..."
echo $SEP
echo "${bold}CMD = dmesg | grep -E 'hdmi|HDMI'${normal}"
dmesg | grep --color=auto -E 'hdmi|HDMI'
# echo "CMD = dmesg | grep HDMI"
# echo "$(dmesg | grep HDMI)"
echo "Launching weston desktop compositor"
echo $SEP
}
function _checkusb() {
echo $SEP
echo "Checking USB..."
echo $SEP
echo "${bold}Listing USB${normal}"
lsusb
echo $SEP2
echo "${bold}Listing USB tree${normal}"
echo "${bold}12M = USB1"
echo "480M = USB2"
echo "5000M = USB3.0 / USB3.1 gen 1"
echo "10000M = USB3.1 gen ${normal}"
lsusb -t
echo $SEP2
echo "${bold}Listing USB details${normal}"
usb-devices
echo $SEP
}
function _checknetwork() {
echo $SEP
echo "${bold}Checking network interface...${normal}"
echo "${bold}Listing all network interface...${normal}"
ip a
echo "${bold}Listing interface with IP...${normal}"
ip -o addr | awk '{split($4, a, "/"); print $2" : "a[1]}'
echo "Ping 8.8.8.8"
ping -c 4 8.8.8.8 ; pingresult=$?
if [ $pingresult == 0 ]; then
echo "Result: ${green}Passed${normal}"
else
echo "Result: ${red}Failed${normal}"
fi
# check dns resolve
echo "Ping google.com"
ping -c 4 google.com ; pingresult=$?
if [ $pingresult == 0 ]; then
echo "Result: ${green}Passed${normal}"
else
echo "Result: ${red}Failed${normal}"
fi
echo $SEP
}
function _launchweston() {
echo $SEP
echo "Checking Weston desktop compositor..."
# Stop X xerver
sudo service gdm stop; sudo pkill -9 Xorg
# Environment and directory setup
unset DISPLAY
mkdir /tmp/xdg
chmod 700 /tmp/xdg
# Choose a valid tty
export WESTON_TTY=1
# Launch Weston
# need to use fbdev-backend, otherwise following will have seg fault
# sudo XDG_RUNTIME_DIR=/tmp/xdg weston --tty="$WESTON_TTY" --idle-time=0 &
# Optional: WAYLAND_DEBUG=server
# Optional: use --use-egldevice to disable gbm swapchains and use EGLStreams at weston output
sudo XDG_RUNTIME_DIR=/tmp/xdg weston --tty="$WESTON_TTY" --idle-time=0 --backend=fbdev-backend.so &
# run sample code
sudo XDG_RUNTIME_DIR=/tmp/xdg weston-terminal
# should show spinning triangle
sudo XDG_RUNTIME_DIR=/tmp/xdg weston-simple-egl
# should show a white clover
sudo XDG_RUNTIME_DIR=/tmp/xdg weston-flower
echo $SEP
}
# -------------------
_checkhdmi
_checkusb
_checknetwork
_launchweston # show desktop GUI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment