Browse Source

ODU: add new odu-gpiotool script

The odu-gpiotool is a small script created by roh to selectively reset
individual peripherals of the system by the administrator. It originates
from ticket https://projects.sysmocom.de/ortelius/issues/655
neels/inmarsat
Harald Welte 7 years ago
parent
commit
121196bbd4
  1. 113
      recipes-bsp/sob-odu/files/odu-gpiotool
  2. 4
      recipes-bsp/sob-odu/usb2514_1.bb

113
recipes-bsp/sob-odu/files/odu-gpiotool

@ -0,0 +1,113 @@
#!/bin/sh
USB2514=/usr/bin/usb2514
GPIODIR=/sys/devices/platform/sob-odu.0
DEBUG=0
DRYRUN=0
test -x ${USB2514}
if [ $? -ne 0 ];
then
echo "ERROR - ${USB2514} does not exist or is not exeutable"
echo
fi
if [ $DRYRUN -ne 0 ] || [ $DEBUG -ne 0 ]; then
echo "DEBUG=$DEBUG\nDRYRUN=$DRYRUN\n"
fi;
### helper
echodeb() {
if [ $DEBUG -ne 0 ]; then
echo "DEBUG - $*"
fi;
}
gpioecho() {
echodeb "echo ${1} > ${2}"
if [ $DRYRUN -eq 0 ]; then
echo ${1} > ${2}
fi;
}
# $1 gpio $2 direction
init_pin() {
echodeb init_pin $1 $2
gpioecho ${1} "${GPIODIR}/export"
gpioecho ${2} "${GPIODIR}/gpio$_{1}/direction"
}
# $1 gpio $2 value
set_pin() {
echodeb set_pin $1 $2
gpioecho ${2} "${GPIODIR}/gpio_${1}/value"
}
# $1 pin $2 tempvalue $3 endvalue
toggle_pin() {
set_pin ${1} ${2}
sleep 1
set_pin ${1} ${3}
}
###
reset_modem1() {
toggle_pin mdm1_rst 1 0
}
reset_modem2() {
toggle_pin mdm2_rst 1 0
}
reset_gnss() {
toggle_pin gnss_rst 1 0
}
reset_adsb() {
toggle_pin adsb_rst 1 0
}
reset_ais() {
toggle_pin ais_off 1 0
}
reset_usb() {
# usb2514 now has internal code to assert/de-assert !hub_reset
${USB2514} 1
}
reset_all() {
reset_modem1
reset_modem2
reset_gnss
reset_adsb
reset_ais
reset_usb
}
print_help() {
echo $0 v0.2
echo
echo "help - this text"
echo "reset [device] - reset all/one device(s)"
echo
}
case "$1" in
start)
;;
reset)
if [ -n "$2" ]; then
reset_${2}
else
reset_all
fi
;;
restart)
${0} reset
;;
*)
print_help
;;
esac

4
recipes-bsp/sob-odu/usb2514_1.bb

@ -4,10 +4,11 @@ LICENSE = "GPLv2+"
LIC_FILES_CHKSUM = "file://${WORKDIR}/usb2514.c;beginline=1;endline=18;md5=3b8421a1c05d21add65cc20fccfa29cd"
DEPENDS += "lmsensors-apps"
PR = "r2"
PR = "r3"
SRC_URI = "file://usb2514.c \
file://gpio_usb2514 \
file://odu-gpiotool \
file://i2c-dev.h \
file://usb2514.service \
"
@ -23,6 +24,7 @@ do_install() {
install -d ${D}${bindir}/
install -m 0755 ${WORKDIR}/usb2514 ${D}${bindir}/
install -m 0755 ${WORKDIR}/gpio_usb2514 ${D}${bindir}/
install -m 0755 ${WORKDIR}/odu-gpiotool ${D}${bindir}/
install -d ${D}${systemd_unitdir}/system/multi-user.target.wants/
install -m 0644 /${WORKDIR}/usb2514.service ${D}${systemd_unitdir}/system/
ln -sf ../usb2514.service ${D}${systemd_unitdir}/system/multi-user.target.wants/

Loading…
Cancel
Save