diff options
author | John Klug <john.klug@multitech.com> | 2020-11-11 16:17:52 -0600 |
---|---|---|
committer | John Klug <john.klug@multitech.com> | 2020-11-11 16:17:52 -0600 |
commit | 4bb6f26b05450777d14aa96e10783066c2503dc2 (patch) | |
tree | 3ed6c4bb86736d28926fd37a3c2b4eb81de44c82 /recipes-bsp/multitech | |
download | meta-multitech-atmel-4bb6f26b05450777d14aa96e10783066c2503dc2.tar.gz meta-multitech-atmel-4bb6f26b05450777d14aa96e10783066c2503dc2.tar.bz2 meta-multitech-atmel-4bb6f26b05450777d14aa96e10783066c2503dc2.zip |
Diffstat (limited to 'recipes-bsp/multitech')
24 files changed, 1592 insertions, 0 deletions
diff --git a/recipes-bsp/multitech/get-eeprom-device-config/get-eeprom-device-config.sh b/recipes-bsp/multitech/get-eeprom-device-config/get-eeprom-device-config.sh new file mode 100755 index 0000000..ab47d31 --- /dev/null +++ b/recipes-bsp/multitech/get-eeprom-device-config/get-eeprom-device-config.sh @@ -0,0 +1,281 @@ +#!/bin/bash +# Radio ID loop count +TRY_COUNT=30 + +CONFIG_PATH=/var/run/config + +#system capabilities +CAPABILITY_ADC="false" +CAPABILITY_BLUETOOTH="false" +CAPABILITY_DIN="false" +CAPABILITY_DOUT="false" +#CAPABILITY_EXTERNAL_SERIAL_PORT="false" +#CAPABILITY_FLEXIBLE_SERIAL_PORT="false" +CAPABILITY_GPS="false" +CAPABILITY_WIFI="false" +CAPABILITY_CELL="false" +CAPABILITY_LORA="false" +CAPABILITY_GPIO="false" +CAPABILITY_SERIAL="false" +CAPABILITY_RS232="false" +CAPABILITY_RS422="false" +CAPABILITY_RS485="false" +CAPABILITY_NODE_RED="false" +CAPABILITY_LORA_NETWORK_SERVER="false" + + +# accessory cards constans +TEMP_AC_PATH="/var/volatile/tmp" +TEMP_AC_JSON="$TEMP_AC_PATH/ac_data.json" +# Number of accessory card places - size of array +AC_CARD_COUNT=4 + +function usage { + echo 'get-eeprom-device-info [-t TRY_COUNT]' + echo ' Where TRY_COUNT is the number of half' + echo ' second waits for the cellular radio' + echo ' to be ready for identification' + exit 1 +} + +# Reads accessory cards data +# WARNING: Make sure function called after CAPABILITIY_* variables is set with initial values. +ReadAcData() { + # Doing the same as mts-io-sysfs, but with one step, without unnesesary parsing. + MTS_IO_DIR="/sys/devices/platform/mts-io" + AC_PRFIX="ap" + TEMP_AC_FILE_PREFIX="/card" + TEMP_AC_PREFIX="$TEMP_AC_PATH$TEMP_AC_FILE_PREFIX" + # Fill property data for each accessory card + rm -f $TEMP_AC_PREFIX* + for f in `find $MTS_IO_DIR/$AC_PRFIX* -follow -maxdepth 1 -type f -follow -maxdepth 1 -type f 2>/dev/null`; + do + FILENAME=${f##*$MTS_IO_DIR/$AC_PRFIX} + case $FILENAME in + modalias ) + ;; + power ) + ;; + subsystem* ) + ;; + uevent ) + ;; + * ) + AC_NUMBER=$(echo "$FILENAME" | cut -d "/" -f1) + AC_PROP=$(echo "$FILENAME" | cut -d "/" -f2) + # Do camel casing + # Because {sed -r '{s/-([a-z])/\U\1/g;}'} did not work for Not GNU sed 4.0 use awk + tr + # Removing next 2 lines gives about 50% function speed-up + AC_PROP=$( echo $AC_PROP | awk -F"-" '{for(j=1;j<=NF;j++){$j=toupper(substr($j,1,1))substr($j,2)}}1' | sed -r '{s/ //g;}' ) + AC_PROP=`echo ${AC_PROP:0:1} | tr '[A-Z]' '[a-z]'`${AC_PROP:1} + #Output to temp file + AC_FILE="$TEMP_AC_PREFIX$AC_NUMBER" + printf "\"$AC_PROP\" : \"%s\",\n" `cat $f` >> $AC_FILE + ;; + esac + done + # Compose accessory cards data to array + echo "\"accessoryCards\" : [ " > $TEMP_AC_JSON + for ((I=1; I<=$AC_CARD_COUNT; ++I)) ; + do + AC_FILE="$TEMP_AC_PREFIX$I" + if [ -f "$AC_FILE" ];then + sed -i '$s/,$//' $AC_FILE # remove last comma + echo "{" >> $TEMP_AC_JSON + cat $AC_FILE >> $TEMP_AC_JSON + echo "}," >> $TEMP_AC_JSON + + # Map product-id with capabilities. + if $(grep -q '"productId" : "MTAC-MFSER-DTE"' $AC_FILE) || $(grep -q '"productId" : "MTAC-MFSER-DCE"' $AC_FILE); then + CAPABILITY_SERIAL="true" + CAPABILITY_RS232="true" + CAPABILITY_RS422="true" + CAPABILITY_RS485="true" + elif $(grep -q '"productId" : "MTAC-GPIOB"' $AC_FILE) || $(grep -q '"productId" : "MTAC-GPIOI"' $AC_FILE); then + CAPABILITY_GPIO="true" + CAPABILITY_ADC="true" + CAPABILITY_DIN="true" + CAPABILITY_DOUT="true" + elif $(grep -q '"productId" : "MTAC-LORA-.*"' $AC_FILE); then + CAPABILITY_LORA="true" + fi + else + echo "null," >> $TEMP_AC_JSON + fi + done + sed -i '$s/,$//' $TEMP_AC_JSON # remove last comma + echo "]," >> $TEMP_AC_JSON +} + +#check if LORA is present onboard a device. +#Lora capability from an MTAC card is determined by ReadAcData() +isNativeLoraPresent() { + LORA_ID_PREFIX="MTCAP-LORA-" + LORA_ID=$(mts-io-sysfs show lora/product-id 2> /dev/null) + if [[ $LORA_ID == $LORA_ID_PREFIX* ]]; then + return 0 + else + return 1 + fi +} + +TEMP=$(getopt -o t: -n 'get-eeprom-device-info' -- "$@") +eval set -- "$TEMP" +# extract options and their arguments into variables. +while true ; do + case "$1" in + -t) + case "$2" in + "") usage ;; + *) TRY_COUNT=$2 ; shift 2 ;; + esac ;; + --) shift ; break ;; + *) echo "usage" ;; + esac +done + +# Read device information from eeprom device + +mts-id-eeprom --in-file /sys/bus/i2c/devices/i2c-0/0-0056/eeprom > ${CONFIG_PATH}/device_info + +DEVICE_CAPA=${CONFIG_PATH}/device_capa +DEVICE_INFO_JSON=${CONFIG_PATH}/device_info.json + +# Create json data files +echo "{" > $DEVICE_CAPA +echo "{" > ${CONFIG_PATH}/device_info.json + + +# Read each line and parse the device data +while read line +do + +if [[ $line =~ ^vendor-id:\ \"(.*)\" ]]; then + echo ${BASH_REMATCH[1]} > ${CONFIG_PATH}/vendor_id + echo \"vendorId\": \"${BASH_REMATCH[1]}\", >> $DEVICE_INFO_JSON +elif [[ $line =~ ^product-id:\ \"(.*)\" ]]; then + echo ${BASH_REMATCH[1]} > ${CONFIG_PATH}/device_type + echo \"productId\": \"${BASH_REMATCH[1]}\", >> $DEVICE_INFO_JSON +elif [[ $line =~ ^device-id:\ \"(.*)\" ]]; then + echo ${BASH_REMATCH[1]} > ${CONFIG_PATH}/device_id + echo \"deviceId\": \"${BASH_REMATCH[1]}\", >> $DEVICE_INFO_JSON +elif [[ $line =~ ^hw-version:\ \"(.*)\" ]]; then + echo ${BASH_REMATCH[1]} > ${CONFIG_PATH}/hw_version + echo \"hardwareVersion\": \"${BASH_REMATCH[1]}\", >> $DEVICE_INFO_JSON +elif [[ $line =~ ^mac-addr:\ \"(.*)\" ]]; then + echo ${BASH_REMATCH[1]} > ${CONFIG_PATH}/mac_addr + echo \"macAddress\": \"${BASH_REMATCH[1]}\", >> $DEVICE_INFO_JSON +elif [[ $line =~ ^mac-bluetooth:\ \"(.*)\" ]]; then + echo ${BASH_REMATCH[1]} > ${CONFIG_PATH}/mac_bluetooth + echo \"macBluetooth\": \"${BASH_REMATCH[1]}\", >> $DEVICE_INFO_JSON +elif [[ $line =~ ^mac-wifi:\ \"(.*)\" ]]; then + echo ${BASH_REMATCH[1]} > ${CONFIG_PATH}/mac_wifi + echo \"macWifi\": \"${BASH_REMATCH[1]}\", >> $DEVICE_INFO_JSON +elif [[ $line =~ ^uuid:\ \"(.*)\" ]]; then + echo ${BASH_REMATCH[1]} > ${CONFIG_PATH}/uuid + echo \"uuid\": \"${BASH_REMATCH[1]}\", >> $DEVICE_INFO_JSON +elif [[ $line =~ ^imei:\ \"(.*)\" ]]; then + echo ${BASH_REMATCH[1]} > ${CONFIG_PATH}/modem_imei + echo \"imei\": \"${BASH_REMATCH[1]}\", >> $DEVICE_INFO_JSON +elif [[ $line =~ capa-gps:\ (.*) ]]; then + CAPABILITY_GPS=$(echo ${BASH_REMATCH[1]}) +elif [[ $line =~ capa-din:\ (.*) ]]; then + CAPABILITY_DIN=$(echo ${BASH_REMATCH[1]}) +elif [[ $line =~ capa-dout:\ (.*) ]]; then + CAPABILITY_DOUT=$(echo ${BASH_REMATCH[1]}) +elif [[ $line =~ capa-adc:\ (.*) ]]; then + CAPABILITY_ADC=$(echo ${BASH_REMATCH[1]}) +elif [[ $line =~ capa-wifi:\ (.*) ]]; then + CAPABILITY_WIFI=$(echo ${BASH_REMATCH[1]}) +elif [[ $line =~ capa-bluetooth:\ (.*) ]]; then + CAPABILITY_BLUETOOTH=$(echo ${BASH_REMATCH[1]}) +elif [[ $line =~ capa:\ \"(.*)\" ]]; then + echo \"mask\": \"${BASH_REMATCH[1]}\", >> $DEVICE_CAPA +fi + +done <${CONFIG_PATH}/device_info + +HASRADIO=$(cat /sys/devices/platform/mts-io/has-radio) +if ((HASRADIO == 1)) ; then + echo "Finding cellular module..." + for ((i=0; i < TRY_COUNT; i++)) + do + # Check cellular module + echo "Try #"$i + if [[ -L "/dev/modem_at0" && -L "/dev/modem_at1" ]]; then + CAPABILITY_CELL="true" + break + fi + if ((TRY_COUNT > 1)) ; then + sleep 0.5 + fi + done +fi + +if isNativeLoraPresent; then + CAPABILITY_LORA="true" +fi + +# +# Check if NODE-RED and Lora Network Server packages are installed +# +OPKG_FILE=/tmp/opkg_inst.tmp +opkg list-installed > $OPKG_FILE + +cat $OPKG_FILE | grep node-red > /dev/null +[ $? -eq 0 ] && CAPABILITY_NODE_RED="true" + +cat $OPKG_FILE | grep lora-network-server > /dev/null +[ $? -eq 0 ] && CAPABILITY_LORA_NETWORK_SERVER="true" + +rm -f $OPKG_FILE + + +# Read firmware info from /etc/issue +cat /etc/issue | +( +while read line +do + +if [[ $line =~ Version:\ (.*) ]]; then + echo \"firmware\": \"${BASH_REMATCH[1]}\", >> $DEVICE_INFO_JSON +elif [[ $line =~ Date:\ (.*) ]]; then + echo \"firmwareDate\": \"${BASH_REMATCH[1]}\", >> $DEVICE_INFO_JSON +fi + +done +) +# Add accessory cards +echo "Reading accessory cards data" +ReadAcData +echo "Adding accessory cards data" +cat $TEMP_AC_JSON >> $DEVICE_INFO_JSON + +# Complete the json files +echo \"adc\": $CAPABILITY_ADC, >> $DEVICE_CAPA +echo \"bluetooth\": $CAPABILITY_BLUETOOTH, >> $DEVICE_CAPA +echo \"din\": $CAPABILITY_DIN, >> $DEVICE_CAPA +echo \"dout\": $CAPABILITY_DOUT, >> $DEVICE_CAPA +echo \"gps\": $CAPABILITY_GPS, >> $DEVICE_CAPA +echo \"wifi\": $CAPABILITY_WIFI, >> $DEVICE_CAPA +echo \"cell\": $CAPABILITY_CELL, >> $DEVICE_CAPA +echo \"lora\": $CAPABILITY_LORA, >> $DEVICE_CAPA +echo \"gpio\": $CAPABILITY_GPIO, >> $DEVICE_CAPA +echo \"serial\": $CAPABILITY_SERIAL, >> $DEVICE_CAPA +echo \"rs232\": $CAPABILITY_RS232, >> $DEVICE_CAPA +echo \"rs422\": $CAPABILITY_RS422, >> $DEVICE_CAPA +echo \"rs485\": $CAPABILITY_RS485, >> $DEVICE_CAPA +echo \"nodeRed\": $CAPABILITY_NODE_RED, >> $DEVICE_CAPA +echo \"loraNetworkServer\": $CAPABILITY_LORA_NETWORK_SERVER >> $DEVICE_CAPA +echo "}" >> $DEVICE_CAPA +echo \"capabilities\": >> $DEVICE_INFO_JSON +cat $DEVICE_CAPA >> $DEVICE_INFO_JSON +echo "}" >> $DEVICE_INFO_JSON + +# Clean up temp files +rm $DEVICE_CAPA +rm ${CONFIG_PATH}/device_info + +#echo device_info.json ---------- +#cat /var/run/config/device_info.json +#echo --------------------------- diff --git a/recipes-bsp/multitech/get-eeprom-device-config/init b/recipes-bsp/multitech/get-eeprom-device-config/init new file mode 100755 index 0000000..0ba5075 --- /dev/null +++ b/recipes-bsp/multitech/get-eeprom-device-config/init @@ -0,0 +1,50 @@ +#! /bin/bash + +### BEGIN INIT INFO +# Provides: eeprom-config +# Required-Start: mts-io +# Default-Start: 2 3 4 5 +# Default-Stop: +# Short-Description: Create /run/config with eeprom configuration +### END INIT INFO + +GETCONFIG=/sbin/get-eeprom-device-config +JASONFILE=/run/config/device_info.json + +case "$1" in + start) + if ! [[ -f /run/config/device_info.json ]] ; then + [[ -d /run/config ]] || mkdir -m 755 -p /run/config + if [[ -x ${GETCONFIG} ]] ; then + ${GETCONFIG} -t1 # Radio might not be found yet. + fi + fi + ;; + stop) + ;; + force-reload) + rm -rf /run/config/* + ${GETCONFIG} + ;; + restart) + ${GETCONFIG} + ;; + reload) + ${GETCONFIG} + ;; + status) + if [[ -f ${JASONFILE} ]] ; then + echo EEPROM Config is populated + exit 0 + else + echo EEPROM Config is not populated + exit 3 + fi + ;; + *) + echo "Usage: ntpd { start | stop | status | restart | reload | force-reload }" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/recipes-bsp/multitech/get-eeprom-device-config_1.2.1.bb b/recipes-bsp/multitech/get-eeprom-device-config_1.2.1.bb new file mode 100644 index 0000000..c2330c3 --- /dev/null +++ b/recipes-bsp/multitech/get-eeprom-device-config_1.2.1.bb @@ -0,0 +1,32 @@ +# Script to copy the EEPROM to /run/config and +# init script to populate /run/config +inherit update-rc.d +PR = "r1" +DESCRIPTION = "EEPROM copyting tool" +HOMEPAGE = "http://www.multitech.net/" +SECTION = "console/utils" +PRIORITY = "optional" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.GPLv2;md5=751419260aa954499f7abaabaa882bbe" +RDEPENDS_${PN} =+ "bash" + +SRCREV = "${PV}" + +SRC_URI = "file://${PN}.sh \ + file://init" + +PARALLEL_MAKE = "" + + +fakeroot do_install_append() { + # install MTCAP mts-io init script + install -d 0755 ${D}${base_sbindir} + install -d 0755 ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/${PN}.sh ${D}${base_sbindir}/${PN} + install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/eeprom-config +} + + +INITSCRIPT_NAME = "eeprom-config" +# Must start after MTS-IO to read the accessory cards. +INITSCRIPT_PARAMS = "start 40 S ." diff --git a/recipes-bsp/multitech/mt-dt-overlay_1.0.0.bb b/recipes-bsp/multitech/mt-dt-overlay_1.0.0.bb new file mode 100644 index 0000000..2714705 --- /dev/null +++ b/recipes-bsp/multitech/mt-dt-overlay_1.0.0.bb @@ -0,0 +1,53 @@ +DESCRIPTION = "Compile MT board device tree overlays" +LICENSE = "(GPLv2+)" +LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f" +PACKAGE_ARCH = "${MACHINE_ARCH}" + +# By using an overlay, we should be able to support multiple pinouts +# using the same image. The overlays go into /lib/dtoverlays. +# There names are: [hw-version]-driver.dtbo +# e.g. /lib/dtoverlays/MTRV1-0.0-pps.dtbo +# The idea is that mts-io will search for the overlays, and install the +# appropriate device tree overlay for the current hw-version. + +dt_dir = "/lib/dtoverlays" + +PR = "r1" + +SRC_URI = "git://git.multitech.net/mt-dt-overlay.git;protocol=git" + +SRCREV = "${PV}" + +DEPENDS = "virtual/kernel u-boot-mkimage-native" + +S = "${WORKDIR}/git" + +do_compile[depends] += "virtual/kernel:do_deploy virtual/kernel:do_shared_workdir" +do_compile[nostamp] = "1" + +do_compile () { + echo MACHINE is ${MACHINE} + oe_runmake DTC=/usr/bin/dtc KERNEL_DIR=${STAGING_KERNEL_DIR} KERNEL_BUILD_DIR=${KERNEL_PATH} ${MACHINE}_dtbos +} + +FILES_${PN} = "${dt_dir}" + +addtask install after do_compile + +do_install () { + # Copy files to /lib/dt-overlay/main (mtac cards will be in mtac) + if [ -e ${AT91BOOTSTRAP_MACHINE} ]; then + install -d ${D}/${dt_dir} + ( + cd ${MACHINE} + for f in *.dtbo ; do + if [[ -h $f ]] ; then + cp -df ${f} ${D}/${dt_dir} + else + install ${f} ${D}/${dt_dir} + fi + done + ) + fi; +} + diff --git a/recipes-bsp/multitech/mt-dt-overlay_1.0.1.bb b/recipes-bsp/multitech/mt-dt-overlay_1.0.1.bb new file mode 100644 index 0000000..2714705 --- /dev/null +++ b/recipes-bsp/multitech/mt-dt-overlay_1.0.1.bb @@ -0,0 +1,53 @@ +DESCRIPTION = "Compile MT board device tree overlays" +LICENSE = "(GPLv2+)" +LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f" +PACKAGE_ARCH = "${MACHINE_ARCH}" + +# By using an overlay, we should be able to support multiple pinouts +# using the same image. The overlays go into /lib/dtoverlays. +# There names are: [hw-version]-driver.dtbo +# e.g. /lib/dtoverlays/MTRV1-0.0-pps.dtbo +# The idea is that mts-io will search for the overlays, and install the +# appropriate device tree overlay for the current hw-version. + +dt_dir = "/lib/dtoverlays" + +PR = "r1" + +SRC_URI = "git://git.multitech.net/mt-dt-overlay.git;protocol=git" + +SRCREV = "${PV}" + +DEPENDS = "virtual/kernel u-boot-mkimage-native" + +S = "${WORKDIR}/git" + +do_compile[depends] += "virtual/kernel:do_deploy virtual/kernel:do_shared_workdir" +do_compile[nostamp] = "1" + +do_compile () { + echo MACHINE is ${MACHINE} + oe_runmake DTC=/usr/bin/dtc KERNEL_DIR=${STAGING_KERNEL_DIR} KERNEL_BUILD_DIR=${KERNEL_PATH} ${MACHINE}_dtbos +} + +FILES_${PN} = "${dt_dir}" + +addtask install after do_compile + +do_install () { + # Copy files to /lib/dt-overlay/main (mtac cards will be in mtac) + if [ -e ${AT91BOOTSTRAP_MACHINE} ]; then + install -d ${D}/${dt_dir} + ( + cd ${MACHINE} + for f in *.dtbo ; do + if [[ -h $f ]] ; then + cp -df ${f} ${D}/${dt_dir} + else + install ${f} ${D}/${dt_dir} + fi + done + ) + fi; +} + diff --git a/recipes-bsp/multitech/mtac-eth_1.1.0.bb b/recipes-bsp/multitech/mtac-eth_1.1.0.bb new file mode 100644 index 0000000..f05fc19 --- /dev/null +++ b/recipes-bsp/multitech/mtac-eth_1.1.0.bb @@ -0,0 +1,47 @@ +DESCRIPTION = "MTAC ETH (Ethernet) Card" +HOMEPAGE = "http://www.multitech.net/developer/products/multiconnect-conduit-platform/accessory-cards/mtac-eth/" +SECTION = "base" +PRIORITY = "optional" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f" +do_fetch[depends]+="virtual/kernel:do_shared_workdir" +DEPENDS = "virtual/kernel mtac mts-io" +RDEPENDS_${PN} = "kernel-module-mtac" +INC_PR = "r0" + +SRCREV = "${PV}" + +PR = "${INC_PR}.1${KERNEL_MODULE_PACKAGE_SUFFIX}" + +SRC_URI = " \ + git://git.multitech.net/mtac-eth.git;protocol=git \ +" +S = "${WORKDIR}/git" + +inherit module + +EXTRA_OEMAKE = " -C ${STAGING_KERNEL_DIR} \ + EXTRA_CFLAGS='-I${STAGING_INCDIR}/mts-kernel-headers' \ + KBUILD_VERBOSE=1 \ + M=${S} \ + modules \ + " + +do_compile () { + bbnote make "$@" + make "$@" + unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS + oe_runmake +} + +PACKAGES = "kernel-module-${PN}" + +FILES_kernel-module-${PN} = "${base_libdir}/modules/${KERNEL_VERSION}/extra/mtac_eth.ko" + +PARALLEL_MAKE = "" + +fakeroot do_install () { + install -m 0755 -d ${D}${base_libdir}/modules/${KERNEL_VERSION}/extra + # use cp instead of install so the driver doesn't get stripped + cp ${S}/mtac_eth.ko ${D}${base_libdir}/modules/${KERNEL_VERSION}/extra +} diff --git a/recipes-bsp/multitech/mtac-gpiob_1.1.2.bb b/recipes-bsp/multitech/mtac-gpiob_1.1.2.bb new file mode 100644 index 0000000..d00c5fa --- /dev/null +++ b/recipes-bsp/multitech/mtac-gpiob_1.1.2.bb @@ -0,0 +1,47 @@ +DESCRIPTION = "MTAC GPIOB Card" +HOMEPAGE = "http://www.multitech.net/developer/products/multiconnect-conduit-platform/accessory-cards/mtac-gpiob/" +SECTION = "base" +PRIORITY = "optional" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f" +do_fetch[depends]+="virtual/kernel:do_shared_workdir" +DEPENDS = "virtual/kernel mtac mts-io" +RDEPENDS_${PN} = "kernel-module-mtac" +INC_PR = "r0" + +SRCREV = "${AUTOREV}" + +PR = "${INC_PR}.1${KERNEL_MODULE_PACKAGE_SUFFIX}" + +SRC_URI = " \ + git://git.multitech.net/mtac-gpiob.git;protocol=git \ +" +S = "${WORKDIR}/git" + +inherit module + +EXTRA_OEMAKE = " -C ${STAGING_KERNEL_DIR} \ + EXTRA_CFLAGS='-I${STAGING_INCDIR}/mts-kernel-headers' \ + KBUILD_VERBOSE=1 \ + M=${S} \ + modules \ + " + +do_compile () { + bbnote make "$@" + make "$@" + unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS + oe_runmake +} + +PACKAGES = "kernel-module-${PN}" + +FILES_kernel-module-${PN} = "${base_libdir}/modules/${KERNEL_VERSION}/extra/mtac_gpiob.ko" + +PARALLEL_MAKE = "" + +fakeroot do_install () { + install -m 0755 -d ${D}${base_libdir}/modules/${KERNEL_VERSION}/extra + # use cp instead of install so the driver doesn't get stripped + cp ${S}/mtac_gpiob.ko ${D}${base_libdir}/modules/${KERNEL_VERSION}/extra +} diff --git a/recipes-bsp/multitech/mtac-lora_1.1.4.bb b/recipes-bsp/multitech/mtac-lora_1.1.4.bb new file mode 100644 index 0000000..ec4dd21 --- /dev/null +++ b/recipes-bsp/multitech/mtac-lora_1.1.4.bb @@ -0,0 +1,47 @@ +DESCRIPTION = "MTAC LoRa Card" +HOMEPAGE = "http://www.multitech.net/developer/products/multiconnect-conduit-platform/accessory-cards/mtac-lora/" +SECTION = "base" +PRIORITY = "optional" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f" +do_fetch[depends]+="virtual/kernel:do_shared_workdir" +DEPENDS = "virtual/kernel mtac mts-io" +RDEPENDS_${PN} = "kernel-module-mtac" +INC_PR = "r0" + +SRCREV = "${PV}" + +PR = "${INC_PR}.1${KERNEL_MODULE_PACKAGE_SUFFIX}" + +SRC_URI = " \ + git://git.multitech.net/mtac-lora.git;protocol=git \ +" +S = "${WORKDIR}/git" + +inherit module + +EXTRA_OEMAKE = " -C ${STAGING_KERNEL_DIR} \ + EXTRA_CFLAGS='-I${STAGING_INCDIR}/mts-kernel-headers' \ + KBUILD_VERBOSE=1 \ + M=${S} \ + modules \ + " + +do_compile () { + bbnote make "$@" + make "$@" + unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS + oe_runmake +} + +PACKAGES = "kernel-module-${PN}" + +FILES_kernel-module-${PN} = "${base_libdir}/modules/${KERNEL_VERSION}/extra/mtac_lora.ko" + +PARALLEL_MAKE = "" + +fakeroot do_install () { + install -m 0755 -d ${D}${base_libdir}/modules/${KERNEL_VERSION}/extra + # use cp instead of install so the driver doesn't get stripped + cp ${S}/mtac_lora.ko ${D}${base_libdir}/modules/${KERNEL_VERSION}/extra +} diff --git a/recipes-bsp/multitech/mtac-mfser_1.1.0.bb b/recipes-bsp/multitech/mtac-mfser_1.1.0.bb new file mode 100644 index 0000000..42640f5 --- /dev/null +++ b/recipes-bsp/multitech/mtac-mfser_1.1.0.bb @@ -0,0 +1,47 @@ +DESCRIPTION = "MTAC Multi-Function Serial Card" +HOMEPAGE = "http://www.multitech.net/developer/products/multiconnect-conduit-platform/accessory-cards/mtac-mfser/" +SECTION = "base" +PRIORITY = "optional" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f" +do_fetch[depends]+="virtual/kernel:do_shared_workdir" +DEPENDS = "virtual/kernel mtac mts-io" +RDEPENDS_${PN} = "kernel-module-mtac" +INC_PR = "r0" + +SRCREV = "${PV}" + +PR = "${INC_PR}.1${KERNEL_MODULE_PACKAGE_SUFFIX}" + +SRC_URI = " \ + git://git.multitech.net/mtac-mfser.git;protocol=git \ +" +S = "${WORKDIR}/git" + +inherit module + +EXTRA_OEMAKE = " -C ${STAGING_KERNEL_DIR} \ + EXTRA_CFLAGS='-I${STAGING_INCDIR}/mts-kernel-headers' \ + KBUILD_VERBOSE=1 \ + M=${S} \ + modules \ + " + +do_compile () { + bbnote make "$@" + make "$@" + unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS + oe_runmake +} + +PACKAGES = "kernel-module-${PN}" + +FILES_kernel-module-${PN} = "${base_libdir}/modules/${KERNEL_VERSION}/extra/mtac_mfser.ko" + +PARALLEL_MAKE = "" + +fakeroot do_install () { + install -m 0755 -d ${D}${base_libdir}/modules/${KERNEL_VERSION}/extra + # use cp instead of install so the driver doesn't get stripped + cp ${S}/mtac_mfser.ko ${D}${base_libdir}/modules/${KERNEL_VERSION}/extra +} diff --git a/recipes-bsp/multitech/mtac-pulse_1.1.0.bb b/recipes-bsp/multitech/mtac-pulse_1.1.0.bb new file mode 100644 index 0000000..4b0195f --- /dev/null +++ b/recipes-bsp/multitech/mtac-pulse_1.1.0.bb @@ -0,0 +1,47 @@ +DESCRIPTION = "MTAC PULSE Card" +HOMEPAGE = "http://www.multitech.net/developer/products/multiconnect-conduit-platform/accessory-cards/mtac-pulse/" +SECTION = "base" +PRIORITY = "optional" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f" +do_fetch[depends]+="virtual/kernel:do_shared_workdir" +DEPENDS = "virtual/kernel mtac mts-io" +RDEPENDS_${PN} = "kernel-module-mtac" +INC_PR = "r0" + +SRCREV = "${PV}" + +PR = "${INC_PR}.1${KERNEL_MODULE_PACKAGE_SUFFIX}" + +SRC_URI = " \ + git://git.multitech.net/mtac-pulse.git;protocol=git \ +" +S = "${WORKDIR}/git" + +inherit module + +EXTRA_OEMAKE = " -C ${STAGING_KERNEL_DIR} \ + EXTRA_CFLAGS='-I${STAGING_INCDIR}/mts-kernel-headers' \ + KBUILD_VERBOSE=1 \ + M=${S} \ + modules \ + " + +do_compile () { + bbnote make "$@" + make "$@" + unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS + oe_runmake +} + +PACKAGES = "kernel-module-${PN}" + +FILES_kernel-module-${PN} = "${base_libdir}/modules/${KERNEL_VERSION}/extra/mtac_pulse.ko" + +PARALLEL_MAKE = "" + +fakeroot do_install () { + install -m 0755 -d ${D}${base_libdir}/modules/${KERNEL_VERSION}/extra + # use cp instead of install so the driver doesn't get stripped + cp ${S}/mtac_pulse.ko ${D}${base_libdir}/modules/${KERNEL_VERSION}/extra +} diff --git a/recipes-bsp/multitech/mtac-xdot/xdot-util b/recipes-bsp/multitech/mtac-xdot/xdot-util new file mode 100755 index 0000000..f805305 --- /dev/null +++ b/recipes-bsp/multitech/mtac-xdot/xdot-util @@ -0,0 +1,72 @@ +#!/bin/bash + +function detect_hw { + if [ ! -d /sys/devices/platform/mts-io/xdot ]; then + echo "XDOT hardware not found" + exit + fi +} + +function detect_hw_dev { + if [ ! -h /dev/disk/by-label/XDOT ]; then + echo "XDOT dev hardware not found" + exit + fi +} + +function flash { + echo "Flashing new firmware" + cp $FIRMWARE_FILE $TEMP_DIR +} + +function mount_xdot { + TEMP_DIR=`mktemp -d` + mount /dev/disk/by-label/XDOT $TEMP_DIR +} + +function reset { + mts-io-sysfs store xdot/reset 0 + mts-io-sysfs store xdot/reset 1 + mts-io-sysfs store xdot/reset -- -1 &>/dev/null +} + +function usb_reset { + echo 0 > /sys/bus/usb/devices/1-2.1/authorized + sleep 1 + echo 1 > /sys/bus/usb/devices/1-2.1/authorized +} + +function clean_up { + umount $TEMP_DIR + rm -fr $TEMP_DIR +} + +case "$1" in +"flash") + detect_hw_dev + FIRMWARE_FILE=$2 + mts-io-sysfs store xdot/reset -- -1 &>/dev/null + mount_xdot + flash + clean_up + sleep 1 + reset + echo done + ;; +"mount") + detect_hw_dev + mount_xdot + echo Mounted at $TEMP_DIR + ;; +"reset") + detect_hw + reset + ;; +"usb-reset") + detect_hw + usb_reset + ;; +*) ## If no parameters are given, print which are avaiable. + echo "Usage: $0 {flash|mount|reset|usb-reset}" + ;; +esac diff --git a/recipes-bsp/multitech/mtac-xdot_1.1.0.bb b/recipes-bsp/multitech/mtac-xdot_1.1.0.bb new file mode 100644 index 0000000..988a491 --- /dev/null +++ b/recipes-bsp/multitech/mtac-xdot_1.1.0.bb @@ -0,0 +1,54 @@ +DESCRIPTION = "MTAC XDOT (LoRa) Card" +HOMEPAGE = "http://www.multitech.net/developer/products/multiconnect-conduit-platform/accessory-cards/mtac-xdot/" +SECTION = "base" +PRIORITY = "optional" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f" +do_fetch[depends]+="virtual/kernel:do_shared_workdir" +DEPENDS = "virtual/kernel mtac mts-io" +RDEPENDS_${PN} = "kernel-module-mtac" +INC_PR = "r2" + +SRCREV = "${PV}" + +PR = "${INC_PR}.1${KERNEL_MODULE_PACKAGE_SUFFIX}" + +SRC_URI = " \ + git://git.multitech.net/mtac-xdot.git;protocol=git \ + file://xdot-util \ +" +S = "${WORKDIR}/git" + +inherit module + +EXTRA_OEMAKE = " -C ${STAGING_KERNEL_DIR} \ + EXTRA_CFLAGS='-I${STAGING_INCDIR}/mts-kernel-headers' \ + KBUILD_VERBOSE=1 \ + M=${S} \ + modules \ + " + +do_compile () { + bbnote make "$@" + make "$@" + unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS + oe_runmake +} + + +PACKAGES = "kernel-module-${PN} ${PN}-util" + +FILES_kernel-module-${PN} = "${base_libdir}/modules/${KERNEL_VERSION}/extra/mtac_xdot.ko" + +FILES_${PN}-util += "${sbindir}/xdot-util" + +PARALLEL_MAKE = "" + +fakeroot do_install () { + install -m 0755 -d ${D}${base_libdir}/modules/${KERNEL_VERSION}/extra + # use cp instead of install so the driver doesn't get stripped + cp ${S}/mtac_xdot.ko ${D}${base_libdir}/modules/${KERNEL_VERSION}/extra + + install -m 0755 -d ${D}${sbindir} + install -m 0755 ${WORKDIR}/xdot-util ${D}${sbindir}/xdot-util +} diff --git a/recipes-bsp/multitech/mtac_4.0.3.bb b/recipes-bsp/multitech/mtac_4.0.3.bb new file mode 100644 index 0000000..376dfa1 --- /dev/null +++ b/recipes-bsp/multitech/mtac_4.0.3.bb @@ -0,0 +1,53 @@ +DESCRIPTION = "mtac drivers" +HOMEPAGE = "http://www.multitech.net/" +SECTION = "base" +PRIORITY = "optional" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f" +do_fetch[depends]+="virtual/kernel:do_shared_workdir" +DEPENDS = "virtual/kernel mts-io" +INC_PR = "r0" + +# SRCREV = "${PV}" +SRCREV = "${AUTOREV}" + +# Some packages depend on mtac +RPROVIDES_kernel-module-${PN} = "mtac" + +PR = "${INC_PR}.1${KERNEL_MODULE_PACKAGE_SUFFIX}" + +SRC_URI = " \ + git://git.multitech.net/mtac.git;protocol=git \ +" +S = "${WORKDIR}/git" + +inherit module + +EXTRA_OEMAKE = " -C ${STAGING_KERNEL_DIR} \ + EXTRA_CFLAGS='-I${STAGING_INCDIR}/mts-kernel-headers' \ + KBUILD_VERBOSE=1 \ + M=${S} \ + modules \ + " + +do_compile () { + bbnote make "$@" + make "$@" + unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS + oe_runmake +} + +PACKAGES = "kernel-module-${PN} ${PN}-dev" + +FILES_kernel-module-${PN} = "${base_libdir}/modules/${KERNEL_VERSION}/extra/mtac.ko" + +PARALLEL_MAKE = "" + +fakeroot do_install () { + install -m 0755 -d ${D}${base_libdir}/modules/${KERNEL_VERSION}/extra + # use cp instead of install so the driver doesn't get stripped + cp ${S}/mtac.ko ${D}${base_libdir}/modules/${KERNEL_VERSION}/extra + + install -d ${D}${includedir}/mts-kernel-headers/linux + install -m 0644 ${S}/mtac.h ${D}${includedir}/mts-kernel-headers/linux +} diff --git a/recipes-bsp/multitech/mts-io.inc b/recipes-bsp/multitech/mts-io.inc new file mode 100644 index 0000000..5b1dccc --- /dev/null +++ b/recipes-bsp/multitech/mts-io.inc @@ -0,0 +1,118 @@ +DESCRIPTION = "mts-io controller and sysfs wrapper" +HOMEPAGE = "http://www.multitech.net/" +SECTION = "base" +PRIORITY = "optional" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://io-module/COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \ + file://io-tool/COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \ +" +DEPENDS = "virtual/kernel" +INC_PR = "r1" + +SRCREV = "${PV}" + +PR = "${INC_PR}.1-${KERNEL_MODULE_PACKAGE_SUFFIX}" + +SRC_URI = " \ + git://git.multitech.net/mts-io.git;protocol=git \ + file://led-status_heartbeat_trigger \ + file://lora-led-updater \ + file://mts-io.init \ + file://mts-io.blacklist \ + file://mts-io.mtcap.init \ + file://mts-io.conf \ +" +S = "${WORKDIR}/git" + +inherit module +inherit update-rc.d +inherit autotools + +# add this since we aren't using module.bbclass +addtask make_scripts after do_patch before do_compile +do_make_scripts[lockfiles] = "${TMPDIR}/kernel-scripts.lock" +do_make_scripts[deptask] = "do_populate_sysroot" + +EXTRA_OEMAKE = " -C ${STAGING_KERNEL_DIR} \ + KBUILD_VERBOSE=1 \ + M=${S}/io-module \ + modules \ + " + +do_compile () { + bbnote make "$@" + make "$@" + unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS + oe_runmake +} + + +PACKAGES = "${PN}-noarch kernel-module-${PN} ${PN}-util ${PN}-util-dbg ${PN}-dev" + +FILES_kernel-module-${PN} = " \ + ${base_libdir}/modules/${KERNEL_VERSION}/extra/mts_io.ko \ + ${sysconfdir}/modprobe.d/mts-io.conf \ +" + +FILES_${PN}-noarch = "${sysconfdir}/init.d/mts-io \ + ${sysconfdir}/rc5.d/S95led-status_heartbeat_trigger \ + ${sysconfdir}/default/mts-io \ + ${sysconfdir}/init.d/led-status_heartbeat_trigger" + + +FILES_${PN}-noarch += "${libdir}/mts-io-sysfs*" +FILES_${PN}-noarch += "${sbindir}/mts-io-sysfs" +FILES_${PN}-noarch_append_mtcap += "${sbindir}/lora-led-updater" +FILES_${PN}-util += "${sbindir}/mts-util-lora2-reset" +FILES_${PN}-util-dbg += "/usr/src /usr/sbin/.debug" +FILES_${PN}-dev += "${includedir}/linux ${includedir}/mts-kernel-headers" + +INITSCRIPT_NAME = "mts-io" +INITSCRIPT_PARAMS = "start 39 S ." + +PARALLEL_MAKE = "" + +fakeroot do_install () { + make DESTDIR=${D} install + install -m 0755 -d ${D}${base_libdir}/modules/${KERNEL_VERSION}/extra + # use cp instead of install so the driver doesn't get stripped + cp ${S}/io-module/mts_io.ko ${D}${base_libdir}/modules/${KERNEL_VERSION}/extra + + # install headers for kernel modules + install -d ${D}${includedir}/mts-kernel-headers/linux + install -m 0644 ${S}/io-module/mts_io.h ${D}${includedir}/mts-kernel-headers/linux + install -m 0644 ${S}/io-module/mts_eeprom.h ${D}${includedir}/mts-kernel-headers/linux + install -m 0644 ${S}/io-module/at91gpio.h ${D}${includedir}/mts-kernel-headers/linux + + # install same headers for userspace applications + # Note this dupication can be avoided by adding the following into the recipes + # CFLAGS += ${STAGING_INCDIR}/mts-kernel-headers + # + install -d ${D}${includedir}/linux + install -m 0644 ${S}/io-module/mts_io.h ${D}${includedir}/linux + install -m 0644 ${S}/io-module/mts_eeprom.h ${D}${includedir}/linux + install -m 0644 ${S}/io-module/at91gpio.h ${D}${includedir}/linux + + install -d ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/mts-io.init ${D}${sysconfdir}/init.d/mts-io + install -m 0755 ${WORKDIR}/led-status_heartbeat_trigger ${D}/${sysconfdir}/init.d/ + install -d ${D}${sysconfdir}/default + install -m 0755 ${WORKDIR}/mts-io.conf ${D}${sysconfdir}/default/mts-io + install -d ${D}${sysconfdir}/modprobe.d + install -m 0644 ${WORKDIR}/mts-io.blacklist ${D}${sysconfdir}/modprobe.d/mts-io.conf + + # blink status LED after booted + install -d ${D}${sysconfdir}/rc5.d + ln -sf ${sysconfdir}/init.d/led-status_heartbeat_trigger ${D}/${sysconfdir}/rc5.d/S95led-status_heartbeat_trigger + + install -m 0755 -d ${D}${sbindir} + install -d ${D}${libdir}/mts-io-sysfs + install -m 0755 ${S}/io-tool/mts-io-sysfs-inc.sh ${D}${libdir}/mts-io-sysfs + install -m 0755 ${S}/io-tool/mts-io-sysfs ${D}${sbindir}/mts-io-sysfs +} + +fakeroot do_install_append_mtcap() { + # install MTCAP mts-io init script + install -m 0755 ${WORKDIR}/mts-io.mtcap.init ${D}${sysconfdir}/init.d/mts-io + install -m 0755 ${WORKDIR}/lora-led-updater ${D}${sbindir}/lora-led-updater +} diff --git a/recipes-bsp/multitech/mts-io/led-status_heartbeat_trigger b/recipes-bsp/multitech/mts-io/led-status_heartbeat_trigger new file mode 100755 index 0000000..88910df --- /dev/null +++ b/recipes-bsp/multitech/mts-io/led-status_heartbeat_trigger @@ -0,0 +1,6 @@ +#!/bin/bash + +TRIGGER="/sys/class/leds/led-status/trigger" + +echo "setting $TRIGGER to heartbeat" +echo "heartbeat" > $TRIGGER diff --git a/recipes-bsp/multitech/mts-io/lora-led-updater b/recipes-bsp/multitech/mts-io/lora-led-updater new file mode 100755 index 0000000..0e38310 --- /dev/null +++ b/recipes-bsp/multitech/mts-io/lora-led-updater @@ -0,0 +1,14 @@ +#!/bin/bash + +while true; do + # If driver is unloaded, stop. + [[ -d /sys/devices/platform/mts-io ]] || exit 0 + fuser /dev/spidev0.0 > /dev/null + if [ $? == 0 ]; then + mts-io-sysfs store led-lora 1 >/dev/null 2>&1 + else + mts-io-sysfs store led-lora 0 >/dev/null 2>&1 + fi + sleep 5 +done + diff --git a/recipes-bsp/multitech/mts-io/mts-io.blacklist b/recipes-bsp/multitech/mts-io/mts-io.blacklist new file mode 100644 index 0000000..7421ac4 --- /dev/null +++ b/recipes-bsp/multitech/mts-io/mts-io.blacklist @@ -0,0 +1 @@ +blacklist mts-io diff --git a/recipes-bsp/multitech/mts-io/mts-io.conf b/recipes-bsp/multitech/mts-io/mts-io.conf new file mode 100644 index 0000000..b5b4275 --- /dev/null +++ b/recipes-bsp/multitech/mts-io/mts-io.conf @@ -0,0 +1,9 @@ +# GPS GNSS reset when loading driver +# 1 Reset the GPS on driver load (default) +# 0 Do not reset +GPSGNSSRESET=1 + +# DEBUG +# 0 is off +# 1 is on +DEBUG=0 diff --git a/recipes-bsp/multitech/mts-io/mts-io.init b/recipes-bsp/multitech/mts-io/mts-io.init new file mode 100755 index 0000000..966d5ae --- /dev/null +++ b/recipes-bsp/multitech/mts-io/mts-io.init @@ -0,0 +1,405 @@ +#!/bin/bash +### BEGIN INIT INFO +# Provides: mts-io +# Default-Start: S +# Default-Stop: +# Short-Description: load the mts-io driver +# Description: mts-io driver initializes the Conduit hardware and +# provides user mode access through the driver to the +# Conduit features. +### END INIT INFO + +. /etc/default/mts-io + +i2c=/sys/bus/i2c/devices/ +GPSCONFIGTYPE="/var/run/config/gpstype" +DEVTREE="/sys/kernel/config/device-tree/overlays/" + +((fail=0)) +# To log debug, set LOGDBG to /usr/bin/LOGGER +if ((DEBUG)) ; then + LOGDBG=/usr/bin/logger + ${LOGDBG} -t "mts-io" -p daemon.info -s "LOGDBG turned on" +else + LOGDBG=":" +fi + +hw="" +hw_name="" +MTAC_MODULES="" +((HASAP=0)) + +sethwtype() { + # mts-io must be loaded before trying this + hw=$(${SYSFS} show hw-version) + hw_name=(${hw//-/ }) + + # Only MTCDT and MTCDTIP have accessory cards, and + # MTCDTIPHP does not have accessory cards. + ((HASAP==0)) + case $hw_name in + MTCDTIPHP) + ;; + MTCDT|MTCDTIP) + ((HASAP = 1)) + ;; + *) + ;; + esac + MTAC_MODULES=$(cd /lib/modules/$(uname -r)/extra/;ls mtac_* 2>/dev/null) +} + +setdevtree() { + # add device tree overlays, if they exist. + [[ -d /lib/dtoverlays ]] || return 1 + ( + cd /lib/dtoverlays + for f in $(ls ${hw}*) ; do + if ! [[ -d ${DEVTREE} ]] ; then + mount configfs + fi + f1=${f/#${hw}-/} + f2=${f1/%.dtbo} + # f2 is the extracted device name + /bin/mkdir ${DEVTREE}/$f2 + /bin/cat $f >${DEVTREE}/$f2/dtbo + done + ) +} + + +SYSFS="/usr/sbin/mts-io-sysfs" +LRST="/usr/sbin/mts-util-lora2-reset" + +${LOGDBG} -p daemon.info 'mts-io script' +sysdir=/sys/devices/platform/mts-io +gpiodir=/sys/class/gpio +port1=${sysdir}/ap1 +port2=${sysdir}/ap2 + +USBRST=${sysdir}/usbhub-reset +NEED_I2C_RESET=0 +HWVER="" +HWNAME="" +HWLVL="" + + +RST[0]="${sysdir}/wifi-bt-reset" +RST[1]="${sysdir}/mtq-reset" +RST[2]="${sysdir}/ap1/reset" +RST[3]="${sysdir}/ap1/creset" +RST[4]="${sysdir}/ap2/reset" +RST[5]="${sysdir}/ap2/creset" +RST[6]="${sysdir}/secure-reset" +RST[7]="${sysdir}/eth-reset" +RST[8]="${sysdir}/sm1-reset" + +# GPSGNSSRESET is now set low during boot and is special cased. +#if ((GPSGNSSRESET)) ; then +# RST[9]="${sysdir}/gnss-reset" +#fi + +WPIN[0]="${sysdir}/ap1/cdone" +WPIN[1]="${sysdir}/ap2/cdone" + +USLPTIME=60000 # 30 milliseconds from Redpine Signals Reset Spec +WAIT="/bin/busybox usleep ${USLPTIME}" + +# Wait 10 WAIT intervals for pins to come high +waitpins() { + ((i=0)) + while((i < ${#WPIN[@]})) ; do + ((j=0)) + while [[ -r ${WPIN[$i]} ]] && ! (($(cat ${WPIN[$i]}))) ; do + logger -t "mts-io" -p daemon.error -s "Wait on ${WPIN[$i]}" + ${WAIT} + ((j++)) + if ((j > 10)) ; then + ((fail++)) + ${LOGDBG} -t "mts-io" -p daemon.error -s "Ready failure on ${WPIN[$i]}" + break + fi + done + ((i++)) + done +} + +reset_path() { + pin=$1 + ${LOGDBG} -t "mts-io" -p daemon.info Reset $pin + if [[ -f ${pin} ]] ; then + if ! ( (echo 1 >${pin}) && ${WAIT} && (echo 0 >${pin}) && ${WAIT} && (echo 1 >${pin}) ) ; then + /usr/bin/logger -t "mts-io" -p daemon.error -s "Failed write to ${pin}" + return 1 + fi + sleep 2 + + ${LOGDBG} -t "mts-io" -p daemon.info Completeed reset $pin + else + ${LOGDBG} -t "mts-io" -p daemon.info "${pin} does not exist" + fi + return 0 +} +reset_array() { + ((i=${#RST[@]}-1)) + while ((i>=0)) ; do + if [[ -f ${RST[$i]} ]] ; then + if ! ( (echo 1 >${RST[i]}) ) ; then + /usr/bin/logger -t "mts-io" -p daemon.error -s "Failed write to ${RST[$i]}" + fail=1 + else + ${LOGDBG} -t "mts-io" -p daemon.error -s "Wrote 1 to ${RST[$i]}" + fi + else + ${LOGDBG} -t "mts-io" -p daemon.info "${RST[$i]} does not exist" + RST[$i]="" + fi + ((i--)) + done + ((DBG)) && (cd $sysdir ; head gnss-reset eth-reset wifi-bt-reset usbhub-reset | logger -p daemon.info) + ((i=${#RST[@]}-1)) + while ((i>=0)) ; do + ${LOGDBG} -s -p daemon.info "i value is $i RST is ${RST[$i]} count is ${#RST[$i]}" + if ((${#RST[$i]} > 0)) && [[ -f ${RST[$i]} ]] ; then + if ! ( (echo 0 >${RST[i]}) ) ; then + /usr/bin/logger -t "mts-io" -p daemon.error -s "Failed write to ${RST[$i]}" + fail=1 + else + ${LOGDBG} -t "mts-io" -p daemon.error -s "Wrote 0 to ${RST[$i]}" + : + fi + else + ${LOGDBG} -t "mts-io" -p daemon.info "${RST[$i]} does not exist" + fi + ((i--)) + done + ${WAIT} + ((DBG)) && (cd $sysdir ; head gnss-reset eth-reset wifi-bt-reset usbhub-reset | logger -p daemon.info) + ((i=${#RST[@]}-1)) + while ((i>=0)) ; do + if ((${#RST[$i]} > 0)) && [[ -f ${RST[$i]} ]] ; then + if ! ( (echo 1 >${RST[$i]}) ) ; then + /usr/bin/logger -t "mts-io" -p daemon.error -s "Failed write to ${RST[$i]}" + fail=1 + else + ${LOGDBG} -t "mts-io" -p daemon.error -s "Wrote 1 to ${RST[$i]}" + fi + else + ${LOGDBG} -t "mts-io" -p daemon.info "${RST[$i]} does not exist" + fi + ((i--)) + done + ((DBG)) && (cd $sysdir ; head gnss-reset eth-reset wifi-bt-reset usbhub-reset | logger -p daemon.info) + return $fail +} +read_card_info() { + ap1_product_id="" + ap2_product_id="" + + if [[ -d $sysdir/ap1 ]]; then + ap1_product_id=$(cat $sysdir/ap1/product-id) + fi + if [[ -d $sysdir/ap2 ]]; then + ap2_product_id=$(cat $sysdir/ap2/product-id) + fi + + lora_hw=$(${SYSFS} show lora/hw-version 2> /dev/null) + + if [ -d $port1 ] && [[ $(cat $port1/hw-version) = $lora_hw ]]; then + modprobe spidev + ln -sf /dev/spidev32766.2 /dev/spidev0.0 + elif [ -d $port2 ] && [[ $(cat $port2/hw-version) = $lora_hw ]]; then + modprobe spidev + ln -sf /dev/spidev32765.2 /dev/spidev0.0 + elif [[ ${hw_name} == MTCAP ]]; then + modprobe spidev + elif [[ ${hw_name} == MTCDTIPHP ]]; then + modprobe spidev + ln -sf /dev/spidev32766.2 /dev/spidev0.0 + fi +} + +mfser_init() { + found_ap1=0 + + if [[ $ap1_product_id =~ ^MTAC-MFSER- ]]; then + /usr/bin/logger -t "mts-io" -p daemon.info -s "Linking /dev/mfser to /dev/ttyAP1" + ln -sf /dev/ttyAP1 /dev/mfser + found_ap1=1 + fi + + if [[ $ap2_product_id =~ ^MTAC-MFSER- ]]; then + if [[ $found_ap1 = 1 ]]; then + /usr/bin/logger -t "mts-io" -p daemon.info -s "Linking /dev/mfser-2 to /dev/ttyAP2" + ln -sf /dev/ttyAP2 /dev/mfser-2 + else + /usr/bin/logger -t "mts-io" -p daemon.info -s "Linking /dev/mfser to /dev/ttyAP2" + ln -sf /dev/ttyAP2 /dev/mfser + fi + fi + +} + +set_gpslink() { + [[ -d /var/run/config ]] || mkdir /var/run/config + gpscap=$(cat ${sysdir}/capability/gps) + + # For all hardware except MTCDTIPHP, the gpscapability + # flag indicates whether or not we have a GPS. + if ! [[ ${hw_name} =~ ^MTCDTIPHP$ ]] && ((gpscap == 0)) ; then + return + fi + + # Oldest MTRV1 uses venuse on ttyS1. + if [[ ${hw_name} == MTRV1 ]] && [[ ${hw} != MTRV1-0.0 ]] ; then + ln -sf /dev/ttyXRUSB0 /dev/gps0 + echo "u-blox" >"$GPSCONFIGTYPE" + return + fi + + if [[ ${hw_name} == MTR ]] || [[ ${hw_name} == MTRV1 ]] || [[ ${hw_name} == MTHS ]] ; then + ln -sf /dev/ttyS1 /dev/gps0 + echo "venus" >"$GPSCONFIGTYPE" + return + fi + + if [[ ${hw} == MTCDT ]] && [[ ${HWLVL} == 0.0 ]] ; then + # No GPS + return + fi + if [[ ${hw_name} == MTCDTIPHP ]] ; then + NEED_I2C_RESET=1 + ln -sf /dev/ttyXRUSB0 /dev/gps0 + return + fi + # Default MTCDT-0.1 + echo "u-blox" >"$GPSCONFIGTYPE" + ln -sf /dev/ttyXRUSB2 /dev/gps0 +} + +case $1 in + start) + # Point the firmware API at our i2c EEPROMs + echo -n ${i2c} > /sys/module/firmware_class/parameters/path + + /usr/bin/logger -t "mts-io" -p daemon.info -s "Loading mts-io module" + if ! modprobe mts_io ; then + ((fail++)) + fi + + sethwtype + setdevtree + + if ((HASAP == 1)) ; then + # install mtac explicitly or any unused modules will cause + # junk to the log as mtac is loaded and unloaded each time. + modprobe mtac + for f in ${MTAC_MODULES} ; do + modprobe ${f//.ko} 2>&1 | grep -v 'No such device or address' + done + fi + set_gpslink # Set GPS symlink. + /usr/bin/logger -t "mts-io" -p daemon.info -s "Resetting system modules" + read_card_info + has_gnss_reset=0 + # On boot, gnss-reset will be low + if [[ -f ${sysdir}/gnss-reset ]] ; then + if (($(mts-io-sysfs show gnss-reset) == 1)) ; then + mts-io-sysfs store gnss-reset 0 + fi + has_gnss_reset=1 + fi + /bin/busybox usleep $USLPTIME + reset_array + if ((has_gnss_reset)) ; then + mts-io-sysfs store gnss-reset 1 + fi + # use radio-reset init script for radio-reset + mfser_init + + waitpins + # Fix Telit error -62 and Redpine wrong USB speed detection on reset. + sleep 1 + if ! reset_path $USBRST ; then + ((fail++)) + fi + + if ((${#lora_hw} > 0)) && [[ ${lora_hw} =~ ^MTCDTIPHP-LORA-2\.1 ]] ; then + if [[ -x ${LRST} ]] ; then + ${LRST} -g -f + else + /usr/bin/logger -t "mts-io" -p daemon.err -s "ERROR: Missing ${LRST} -- Cannot initialize LoRa." + fi + fi + + if [[ -d ${DEVTREE} ]] ; then + /bin/umount configfs + fi + + if ((fail == 0)) ; then + echo "OK" + else + echo "FAIL" + fi + exit $fail + ;; + + stop) + /usr/bin/logger -t "mts-io" -p daemon.info -s "Unloading mtac modules and mts-io module" + MTAC_MODULES=$(lsmod | grep '^mtac_' | sed -e 's/_/-/' -e 's/ .*//') + + for f in ${MTAC_MODULES} ; do + if ! modprobe -r "$f" ; then + rmmod "$f" + fi + done + if ! modprobe -r mtac ; then + rmmod mtac + fi + + if ! modprobe -r mts-io ; then + rmmod mtsio + fi + RETVAL=$? + if ((RETVAL == 0)) ; then + echo "OK" + else + echo "FAIL" + fi + ;; + restart) + $0 stop + sleep 1 + $0 start + ;; + reload) + /usr/bin/logger -t "mts-io" -p daemon.info -s "Resetting system modules" + if ! reset_path $USBRST ; then + ((fail++)) + fi + /bin/busybox usleep $USLPTIME + reset_array + # Use radio-reset init script for radio-reset + mfser_init + if ((fail == 0)) ; then + echo "OK" + else + echo "FAIL" + fi + exit $fail + ;; + status) + if [[ -d ${sysdir} ]] ; then + echo Driver is loaded + exit 0 + else + echo Driver is not loaded + exit 3 + fi + ;; + *) + echo "Usage: $0 {start|stop|status|restart}" + exit 2 + ;; +esac + diff --git a/recipes-bsp/multitech/mts-io/mts-io.mtcap.init b/recipes-bsp/multitech/mts-io/mts-io.mtcap.init new file mode 100644 index 0000000..2642de9 --- /dev/null +++ b/recipes-bsp/multitech/mts-io/mts-io.mtcap.init @@ -0,0 +1,122 @@ +#!/bin/bash + +sysdir=/sys/devices/platform/mts-io + +i2c=/sys/bus/i2c/devices/ + +DEVTREE="/sys/kernel/config/device-tree/overlays/" +SYSFS="/usr/sbin/mts-io-sysfs" + +setwificap() { + WIFICAP=0 + if [[ -f ${sysdir}/capability/wifi ]] && (($(cat ${sysdir}/capability/wifi) == 1)) ; then + WIFICAP=1 + fi +} + +lora_init() { + # reset lora chip + mts-io-sysfs store lora/reset 1 + mts-io-sysfs store lora/reset 0 + usleep 100000 + mts-io-sysfs store lora/reset 1 +} + +eth_init() { + # reset eth phy + mts-io-sysfs store eth-reset 1 + mts-io-sysfs store eth-reset 0 + usleep 100000 + mts-io-sysfs store eth-reset 1 +} + +# Normal state when powered up +wifi_init1() { + (($WIFICAP)) || return 0 + # reset wlan + mts-io-sysfs store wlan-rst 0 + # disable wlan + mts-io-sysfs store wlan-en 0 +} + +wifi_init2() { + (($WIFICAP)) || return 0 + mts-io-sysfs store wlan-en 1 + usleep 30000 # 30mS according to WILC1000 spec. + mts-io-sysfs store wlan-rst 1 +} + + +cell_init() { + # remove /dev/modem_at[0,1] symlinks + rm -f /dev/modem_at[0,1] + + if [ -w /sys/devices/platform/mts-io/radio-power ] ; then + # power down the cellular chip gracefully + mts-io-sysfs store radio-power 0 + # power up the cellular chip + mts-io-sysfs store radio-power 1 + fi +} + +start_lora_led_updater() { + lora-led-updater & +} + +setdevtree() { + hw=$(${SYSFS} show hw-version) + + # add device tree overlays, if they exist. + [[ -d /lib/dtoverlays ]] || return 1 + ( + cd /lib/dtoverlays + for f in $(ls ${hw}*) ; do + if ! [[ -d ${DEVTREE} ]] ; then + mount configfs + fi + f1=${f/#${hw}-/} + f2=${f1/%.dtbo} + # f2 is the extracted device name + /bin/mkdir ${DEVTREE}/$f2 + /bin/cat $f >${DEVTREE}/$f2/dtbo + done + ) +} + +case $1 in + start) + # SPI driver for LoRa + modprobe spidev + # Point the firmware API at our i2c EEPROMs + echo -n ${i2c} > /sys/module/firmware_class/parameters/path + echo "Loading mts-io module" + modprobe -r atmel_mci + # Point the firmware API at our i2c EEPROMs + echo -n ${i2c} > /sys/module/firmware_class/parameters/path + modprobe mts_io + setdevtree + setwificap + wifi_init1 + lora_init + eth_init + cell_init & + start_lora_led_updater + wifi_init2 + modprobe atmel_mci + (($WIFICAP)) && modprobe wilc1000 + (($WIFICAP)) && modprobe wilc1000-sdio + ;; + + stop) + echo "Unloading mts-io module" + wifi_init1 # Power down wifi + modprobe -r wilc1000 >/dev/null 2>&1 + modprobe -r wilc1000-sdio >/dev/null 2>&1 + modprobe -r mts_io >/dev/null 2>&1 + ;; + + *) + echo "Usage: $0 {start|stop}" + exit 2 + ;; +esac diff --git a/recipes-bsp/multitech/mts-io_4.1.4.bb.save b/recipes-bsp/multitech/mts-io_4.1.4.bb.save new file mode 100644 index 0000000..92937cd --- /dev/null +++ b/recipes-bsp/multitech/mts-io_4.1.4.bb.save @@ -0,0 +1,4 @@ +require mts-io.inc + +PR = "${INC_PR}.0-${MLINUX_KERNEL_VERSION}${MLINUX_KERNEL_EXTRA_VERSION}" + diff --git a/recipes-bsp/multitech/mts-io_4.3.2.bb.save b/recipes-bsp/multitech/mts-io_4.3.2.bb.save new file mode 100644 index 0000000..92937cd --- /dev/null +++ b/recipes-bsp/multitech/mts-io_4.3.2.bb.save @@ -0,0 +1,4 @@ +require mts-io.inc + +PR = "${INC_PR}.0-${MLINUX_KERNEL_VERSION}${MLINUX_KERNEL_EXTRA_VERSION}" + diff --git a/recipes-bsp/multitech/u-boot-linux-utils/DEFAULT_ENV.cfg b/recipes-bsp/multitech/u-boot-linux-utils/DEFAULT_ENV.cfg new file mode 100644 index 0000000..261fc86 --- /dev/null +++ b/recipes-bsp/multitech/u-boot-linux-utils/DEFAULT_ENV.cfg @@ -0,0 +1 @@ +"ethact=macb0\0" "stderr=serial\0" "stdin=serial\0" "stdout=serial\0" diff --git a/recipes-bsp/multitech/u-boot-linux-utils_0.2.1.bb b/recipes-bsp/multitech/u-boot-linux-utils_0.2.1.bb new file mode 100644 index 0000000..65ea852 --- /dev/null +++ b/recipes-bsp/multitech/u-boot-linux-utils_0.2.1.bb @@ -0,0 +1,25 @@ +DESCRIPTION = "U-Boot Linux Utilities" +HOMEPAGE = "http://www.multitech.net/" +SECTION = "console/utils" +PRIORITY = "optional" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f" + +# Defaults are different depending on machine type. +PACKAGE_ARCH = "${MACHINE_ARCH}" + +PR = "r1" + +DEPENDS = "mtd-utils u-boot" + +# tag 0.2.1 +SRCREV = "fce83ee60201d82ec22f14baac9fd7382a0ad4ac" + +SRC_URI = "git://git.multitech.net/u-boot-linux-utils.git;protocol=git \ + file://DEFAULT_ENV.cfg" + +S = "${WORKDIR}/git" +CFLAGS += "-idirafter ${STAGING_DIR_TARGET}/usr/include/u-boot" +inherit autotools + +PARALLEL_MAKE = "" |