Commit 98e1e4d9 authored by Benoit Rat's avatar Benoit Rat

scripts: Add simple scripts to make the use of the starting kit easier

parent 814cc3f4
#!/bin/bash
###########################################
#
# Ease the way to load and list WR kernel modules.
#
# Copyright (c) 2012, Benoit RAT
# Authors: Benoit RAT <benoit(AT)sevensols.com.
# Licence: GPL v2 or later.
# Website: http://www.sevensols.com
#
###########################################
## Array of kernel modules
modArray[0]="rawrabbit"
modArray[1]="spec"
modArray[2]="wr_nic"
modArray[3]="spec-wr-nic"
modArray[4]="spec-fine-delay"
modArray[5]="fmc-write-eeprom"
modArray[6]="fmc-trivial"
modArray[7]="fmc"
help ()
{
cat << EOF
Usage: $(basename $0) <Options>
Options:
-l|--list) list modules
-r|--remove) remove modules
EOF
exit 0
}
list()
{
lspci | grep CERN
for mod in "${modArray[@]}"; do
lsmod | grep ${mod}
done
}
remove()
{
for mod in "${modArray[@]}"; do
lsmod | grep ${mod} &> /dev/null
if [ "x$?" = "x0" ]; then
echo "Removing ${mod}"
sudo rmmod ${mod}
fi
done
}
while [ $# -gt 0 ]; do
# Until you run out of parameters . . .
case "$1" in
-h|--help) help;;
-r|--remove) remove; exit $?;;
-l|--list) list; exit $?;;
*) echo "Unknown arg $1"; help;;
esac
shift # Check next set of parameters.
done
help
#! /bin/bash
# ----------------------------------------------------------------------------
# This program opens uart to connect with spec card.
# Version: 1.0
# Author: Benoit RAT
# Miguel Jimenez Lopez
#
# Note: look at the help() or use --help
# ----------------------------------------------------------------------------
help()
{
cat << EOF
Usage: $(basename $0) <Options> [<#board>]
#board is 1, 2, etc...
Options:
-h|--help) show little help
-p|--physical) Use physical interface (Default)
-v|--virtual) Use virtual UART
-i|--inplace) does not open a new terminal (Only open the first one)
EOF
exit 0
}
while [ $# -gt 0 ]; do
# Until you run out of parameters . . .
case "$1" in
-h|--help) help;;
-p|--physical) phy=1;;
-v|--virtual) vir=1;;
-i|--inplace) inp=1;;
[1-9]) boardnum=$1;;
*) echo "Unknown arg $1"; help;;
esac
shift # Check next set of parameters.
done
## Obtain the terminal to ask
if [ "x$vir" = "x1" ]; then
res="$(lspci | grep CERN | cut -f1 -d: )"
cmd="sudo /WRProject/Repositorios/spec-sw/tools/spec-vuart -b "
else
res="$(ls /dev/ | grep ttyUSB )"
cmd="sudo minicom --baudrate=11520 --device=/dev/"
fi
##Select only one board with board num
if [ -n $boardnum ]; then
res="$(echo "$res" | sed -n ${boardnum}p)"
fi
##For loop
for d in ${res}; do
sudo echo "Try to access $d (pci spec)" ;
if [ "x$inp" = "x1" ]; then
${cmd}${d}
break;
else
sudo xterm -hold -e "${cmd}${d}" &
fi
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment