v2x/gnss-init/usb-hub-reset: extracted the usb hub reset part from v2x

The v2x firmware load script contained also the usb hub reset which
affects the GNSS modem. This means that the GNSS modem worked only
when the v2x recipe was enabled. But without firmware the v2x-service
fails at start-up which affects all other images except vcu.

Therefore the usb-hub reset part was extracted from the v2x firmware
load script so that we decouple those two functions. ZF/OM need a
failing v2x service when no firmware is loaded, thus the v2x service
was moved back to the vcu image (see meta-netmodule-om).

The systemd services v2x and gnss-init depend now on usb-hub-reset
whereas gnss-init additionally depends on v2x (if available).

BugzID: 72787

Signed-off-by: Marc Mattmueller <marc.mattmueller@netmodule.com>
This commit is contained in:
Marc Mattmueller 2021-05-19 10:52:07 +02:00
parent 3c25250176
commit dbdef42445
7 changed files with 136 additions and 12 deletions

View File

@ -46,6 +46,7 @@ MACHINE_FEATURES += " \
wwan \ wwan \
bluetooth \ bluetooth \
neo-m8l \ neo-m8l \
usb-hub-reset \
v2x \ v2x \
imx-boot \ imx-boot \
" "

View File

@ -0,0 +1,86 @@
#!/bin/sh
# ************************************************************
# USB Hub Reset Script
# -----------------------
#
# The USB hub in the HW23 connects the GNSS modem, the v2x-
# module, the user interface and the user module.
#
# During the configuration/start-up the v2x module and the
# GNSS modem are interfering. Thus a sequentialized startup
# is needed.
# This service just powers the USB hub and is the first
# service needed if GNSS or in case of HW23 v2x shall work.
# ************************************************************
SCRIPT_NAME=$(basename "${0}")
SCRIPT_DIR=$(dirname "${0}")
SCRIPT_PATH=$(realpath "${SCRIPT_DIR}")
MYDIR=$(pwd)
HUB_RST=/sys/class/leds/hub_rst/brightness
ON_VALUE=0
OFF_VALUE=255
export HUB_RST_STATE="off"
#**********************************************************************************************
# local helper functions
#**********************************************************************************************
function printUsage()
{
echo -e "\\nUsage: ${SCRIPT_NAME} [OPTIONS] HUB_STATE\\n\\n"
echo -e " HUB_STATE The reqeusted state of the ubs hub:"
echo -e " * on = switch hub ON"
echo -e " * off = switch hub OFF (default)"
echo -e " OPTIONS:"
echo -e " -h|--help Show this help"
echo -e ""
}
#**********************************************************************************************
# main
#**********************************************************************************************
O=$(getopt -o h --long help -- "$@") || exit 1
if [ $? != 0 ]; then
echo "ERROR: Could not parse command line options"
exit 1
fi
eval set -- "$O"
while true; do
case "${1}" in
-h|--help)
printUsage
exit 0
;;
--)
export HUB_RST_STATE="${2}"
shift 2
break
;;
*)
printUsage; exit 0 ;;
esac
done
if [ ! -f $HUB_RST ]; then
echo "ERROR: USB hub reset lines not available"
return 1
fi
HUB_RST_VALUE=$OFF_VALUE
[[ "${HUB_RST_STATE}" != "off" ]] && HUB_RST_VALUE=$ON_VALUE || true
echo $HUB_RST_VALUE > $HUB_RST
if [[ "$?" != "0" ]]; then
echo "ERROR: Could not set usb hub to ${HUB_RST_STATE}"
exit 1
fi
exit 0

View File

@ -0,0 +1,17 @@
[Unit]
Description=USB Hub Reset Service
Before=gpsd.service
[Service]
Type=oneshot
ExecStartPre=/usr/bin/usb-hub-reset on
ExecStart=/usr/bin/echo releasing usb hub from reset
ExecStop=/usr/bin/echo set usb hub into reset state
ExecStopPost=/bin/bin/usb-hub-reset off
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
RequiredBy=multi-user.target

View File

@ -0,0 +1,29 @@
DESCRIPTION = "USB-Hub Reset on HW23"
HOMEPAGE = "www.netmodule.com"
LICENSE = "MIT"
SECTION = "bsp"
RDEPENDS_${PN} = "usbutils coreutils"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
inherit systemd
SRC_URI = " \
file://usb-hub-reset.service \
file://usb-hub-reset\
"
S = "${WORKDIR}"
SYSTEMD_SERVICE_${PN} = " \
usb-hub-reset.service \
"
FILES_${PN} = "${systemd_unitdir}/system ${bindir}"
do_install() {
install -d ${D}${systemd_unitdir}/system
install -m 644 ${WORKDIR}/usb-hub-reset.service ${D}${systemd_unitdir}/system/
install -d ${D}${bindir}
install -m 744 ${WORKDIR}/usb-hub-reset ${D}${bindir}
}

View File

@ -1,21 +1,12 @@
#!/bin/sh #!/bin/sh
HUB_RST=/sys/class/leds/hub_rst/brightness
V2X_RST=/sys/class/leds/v2x_rst/brightness V2X_RST=/sys/class/leds/v2x_rst/brightness
if [ ! -f $HUB_RST ]; then
echo Reset lines not available
return 1
fi
echo 0 > $HUB_RST
echo 0 > $V2X_RST echo 0 > $V2X_RST
timeout 30 bash -c -- 'while true; do lsusb | grep "0483:df11"; if [ $? == 0 ]; then break; fi; done' timeout 30 bash -c -- 'while true; do lsusb | grep "0483:df11"; if [ $? == 0 ]; then break; fi; done'
if [ $? == 124 ]; then if [ $? == 124 ]; then
echo "v2x module is not available on usb bus" echo "v2x module is not available on usb bus"
exit 0 exit 1
fi fi
output=$(dfu-util -d 0483:df11 -s 0x10000000 -D /lib/firmware/v2x/SECTON.packed_bin.rom 2>&1) output=$(dfu-util -d 0483:df11 -s 0x10000000 -D /lib/firmware/v2x/SECTON.packed_bin.rom 2>&1)

View File

@ -1,6 +1,6 @@
[Unit] [Unit]
Description=V2X Firmware loader Description=V2X Firmware loader
Before=gpsd.service After=usb-hub-reset.service
[Service] [Service]
Type=oneshot Type=oneshot

View File

@ -1,6 +1,6 @@
[Unit] [Unit]
Description=GNSS init service Description=GNSS init service
After=v2x-ieee802.11p.service After=usb-hub-reset v2x-ieee802.11p.service
[Service] [Service]
Type=oneshot Type=oneshot