diff --git a/conf/machine/imx8-nmhw23.conf b/conf/machine/imx8-nmhw23.conf index f351c3a..473aac5 100644 --- a/conf/machine/imx8-nmhw23.conf +++ b/conf/machine/imx8-nmhw23.conf @@ -46,6 +46,7 @@ MACHINE_FEATURES += " \ wwan \ bluetooth \ neo-m8l \ + usb-hub-reset \ v2x \ imx-boot \ " diff --git a/recipes-bsp/usb-hub-reset/files/usb-hub-reset b/recipes-bsp/usb-hub-reset/files/usb-hub-reset new file mode 100644 index 0000000..a0e52e7 --- /dev/null +++ b/recipes-bsp/usb-hub-reset/files/usb-hub-reset @@ -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 diff --git a/recipes-bsp/usb-hub-reset/files/usb-hub-reset.service b/recipes-bsp/usb-hub-reset/files/usb-hub-reset.service new file mode 100644 index 0000000..2643d91 --- /dev/null +++ b/recipes-bsp/usb-hub-reset/files/usb-hub-reset.service @@ -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 diff --git a/recipes-bsp/usb-hub-reset/usb-hub-reset.bb b/recipes-bsp/usb-hub-reset/usb-hub-reset.bb new file mode 100644 index 0000000..3852f10 --- /dev/null +++ b/recipes-bsp/usb-hub-reset/usb-hub-reset.bb @@ -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} +} diff --git a/recipes-bsp/v2x-ieee802.11p/files/v2x-fw-load b/recipes-bsp/v2x-ieee802.11p/files/v2x-fw-load index ac96eae..bc11dc6 100644 --- a/recipes-bsp/v2x-ieee802.11p/files/v2x-fw-load +++ b/recipes-bsp/v2x-ieee802.11p/files/v2x-fw-load @@ -1,21 +1,12 @@ #!/bin/sh -HUB_RST=/sys/class/leds/hub_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 timeout 30 bash -c -- 'while true; do lsusb | grep "0483:df11"; if [ $? == 0 ]; then break; fi; done' if [ $? == 124 ]; then echo "v2x module is not available on usb bus" - exit 0 + exit 1 fi output=$(dfu-util -d 0483:df11 -s 0x10000000 -D /lib/firmware/v2x/SECTON.packed_bin.rom 2>&1) diff --git a/recipes-bsp/v2x-ieee802.11p/files/v2x-ieee802.11p.service b/recipes-bsp/v2x-ieee802.11p/files/v2x-ieee802.11p.service index 9317112..a0b7e1c 100644 --- a/recipes-bsp/v2x-ieee802.11p/files/v2x-ieee802.11p.service +++ b/recipes-bsp/v2x-ieee802.11p/files/v2x-ieee802.11p.service @@ -1,6 +1,6 @@ [Unit] Description=V2X Firmware loader -Before=gpsd.service +After=usb-hub-reset.service [Service] Type=oneshot diff --git a/recipes-connectivity/gnss-init/files/gnss-init.service b/recipes-connectivity/gnss-init/files/gnss-init.service index 30fd75e..1cd286f 100644 --- a/recipes-connectivity/gnss-init/files/gnss-init.service +++ b/recipes-connectivity/gnss-init/files/gnss-init.service @@ -1,6 +1,6 @@ [Unit] Description=GNSS init service -After=v2x-ieee802.11p.service +After=usb-hub-reset v2x-ieee802.11p.service [Service] Type=oneshot