diff --git a/kernel/morse-bundle/Makefile b/kernel/morse-bundle/Makefile new file mode 100644 index 0000000..744e402 --- /dev/null +++ b/kernel/morse-bundle/Makefile @@ -0,0 +1,54 @@ +# +# Copyright 2022 Morse Micro +# +# This is free software, licensed under the GPL 2 license. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=morse-bundle +PKG_RELEASE=2 + +PKG_MAINTAINER:=Morse Micro + +include $(INCLUDE_DIR)/package.mk + +define Package/morse-bundle + SECTION:=net + CATEGORY:=Network + TITLE:=Morse Micro HaLow Bundle + DEPENDS:= +morse-boot-prints \ + +gpiod-tools \ + +@BUSYBOX_CONFIG_PATCH + # patch is used by the bcm2711 specific init.d script which + # helps migrate our config to distroconfig.txt. +endef + +define Package/morse-bundle/description + This package contains minor config/scripts adaptations for + morse releases. +endef + +define Build/Compile +endef + +define Package/morse-bundle/install + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_DIR) $(1)/etc/board.d + $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_DIR) $(1)/etc/sysctl.d + $(INSTALL_DIR) $(1)/morse/scripts + $(if $(CONFIG_TARGET_bcm27xx_bcm2711), \ + $(INSTALL_BIN) ./files/etc/init.d_bcm2711/* $(1)/etc/init.d/.) + $(INSTALL_BIN) ./files/etc/uci-defaults/* $(1)/etc/uci-defaults/. + $(if $(CONFIG_TARGET_ramips_mt76x8), \ + $(INSTALL_BIN) ./files/etc/uci-defaults-ramips/* $(1)/etc/uci-defaults/. + ) + $(INSTALL_BIN) ./files/morse/scripts/* $(1)/morse/scripts/. + $(INSTALL_BIN) ./files/etc/board.d/* $(1)/etc/board.d/. + $(INSTALL_BIN) ./files/etc/init.d/* $(1)/etc/init.d/. + $(INSTALL_BIN) ./files/etc/sysctl.d/* $(1)/etc/sysctl.d/ +endef + +$(eval $(call BuildPackage,morse-bundle)) diff --git a/kernel/morse-bundle/README b/kernel/morse-bundle/README new file mode 100644 index 0000000..9fb4c2e --- /dev/null +++ b/kernel/morse-bundle/README @@ -0,0 +1,8 @@ +This package contains a number of configuration defaults and scripts +used by the MorseMicro EVKs. It is a bit of a non-kosher package to +centralise sometimes necessarily deployed components which don't yet +have a formal home. + +The longer term plan is for this package to disappear, as users +of the SDK should be able to pick and choose which functionality +they want without EVK specific configuration leaking in. \ No newline at end of file diff --git a/kernel/morse-bundle/files/etc/board.d/00_system b/kernel/morse-bundle/files/etc/board.d/00_system new file mode 100644 index 0000000..2786874 --- /dev/null +++ b/kernel/morse-bundle/files/etc/board.d/00_system @@ -0,0 +1,30 @@ +. /lib/functions/uci-defaults.sh +. /lib/functions/system.sh + +board=$(board_name) + +board_config_update + +. /etc/device_info + +mac_label="$(get_mac_label)" +if [ -z "$mac_label" ]; then + mac_label="$(cat /sys/class/net/eth0/address)" +fi + +if [ -n "$mac_label" ]; then + suffix="$(echo "$mac_label" | sed 's/.*:\(..\):\(..\)$/\1\2/')" +else + suffix="z$(tr -dc 'a-f0-9' /dev/kmsg 2>&1 +} diff --git a/kernel/morse-bundle/files/etc/init.d_bcm2711/upgrade_config b/kernel/morse-bundle/files/etc/init.d_bcm2711/upgrade_config new file mode 100644 index 0000000..5846193 --- /dev/null +++ b/kernel/morse-bundle/files/etc/init.d_bcm2711/upgrade_config @@ -0,0 +1,83 @@ +#!/bin/sh /etc/rc.common + +# WARNING: this script may reboot your device! +# +# This migrates our old static config to distroconfig.txt so it's preserved +# across upgrades, but we want to make sure that people who have +# a mostly default config.txt get migrated. +# However, it won't apply until the device has been rebooted, so we +# disable the script and reboot the device. +# +# Ideally, I guess there would be some kind of hook in platform_copy_config +# to handle this, but since we can't go back in time... +# +# It must be run after sysupgrade.tar.gz is applied _and deleted_, which +# happens in the 'done' script (at START=95). + + +START=96 + +boot() { + cd /boot; patch < /dev/kmsg + reboot + fi +} diff --git a/kernel/morse-bundle/files/etc/sysctl.d/1-panic.conf b/kernel/morse-bundle/files/etc/sysctl.d/1-panic.conf new file mode 100644 index 0000000..d3bd8c7 --- /dev/null +++ b/kernel/morse-bundle/files/etc/sysctl.d/1-panic.conf @@ -0,0 +1,2 @@ +# Enabling memory info, locks and cpu backtraces. +kernel.panic_print=74 diff --git a/kernel/morse-bundle/files/etc/sysctl.d/13-qdisc.conf b/kernel/morse-bundle/files/etc/sysctl.d/13-qdisc.conf new file mode 100644 index 0000000..8a07233 --- /dev/null +++ b/kernel/morse-bundle/files/etc/sysctl.d/13-qdisc.conf @@ -0,0 +1,3 @@ +# change default queue discipline from fq_codel to pfifo +# (to fix the excessive tcp retries in iperf3) +net.core.default_qdisc=pfifo diff --git a/kernel/morse-bundle/files/etc/uci-defaults-ramips/99-ekh03-sdhci-migration b/kernel/morse-bundle/files/etc/uci-defaults-ramips/99-ekh03-sdhci-migration new file mode 100755 index 0000000..c6bab0e --- /dev/null +++ b/kernel/morse-bundle/files/etc/uci-defaults-ramips/99-ekh03-sdhci-migration @@ -0,0 +1,34 @@ +#!/bin/sh + +. /lib/functions.sh + +fix_morse_path() { + local config="$1" + config_get type "$config" type + [ "morse" = "$type" ] || return 1 + uci get wireless."${config}".path | grep -q "platform/10130000.sdhci" || return 1 + uci set wireless."${config}".path="$(uci get wireless."${config}".path | sed "s|platform/10130000.sdhci|platform/10130000.mmc|")" +} + +remove_redundant_mmc() { + local config="$1" + config_get radio "$config" device + config_get type "$radio" type + + # quit if morse - don't want to nuke existing config + [ "morse" = "$type" ] && return 1 + uci get wireless."${radio}".path | grep -q "platform/10130000.mmc" || return 1 + + uci delete "wireless.$config" + uci delete "wireless.$radio" +} + +config_load wireless + +# we only bother doing this replacement if we now have the mt7620 mmc loaded +grep -q "mediatek,mt7620-mmc" "/sys/devices/platform/10130000.mmc/of_node/compatible" 2>/dev/null || return 0 + + +config_foreach fix_morse_path wifi-device +config_foreach remove_redundant_mmc wifi-iface +uci commit wireless \ No newline at end of file diff --git a/kernel/morse-bundle/files/etc/uci-defaults/00_password b/kernel/morse-bundle/files/etc/uci-defaults/00_password new file mode 100755 index 0000000..af8b691 --- /dev/null +++ b/kernel/morse-bundle/files/etc/uci-defaults/00_password @@ -0,0 +1,21 @@ +#!/bin/sh + +. /lib/functions.sh +. /lib/functions/uci-defaults.sh + +# Do not change the password if this is an upgrade. +if [ -f /sysupgrade.tgz ]; then + exit 0 +fi + +# NB persistent_vars_storage.sh may not be present, in which case +# this command will generate no output. This is expected. +password="$(persistent_vars_storage.sh READ device_password)" +if [ -n "$password" ]; then + passwd root > /dev/null 2> /dev/null </dev/null) +default_wifi_key="$(persistent_vars_storage.sh READ default_wifi_key)" +if [ -z "$default_wifi_key" ]; then + default_wifi_key=$(tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 8) +fi +mm_region="$(persistent_vars_storage.sh READ mm_region)" + +_get_iface() { + uci get "wireless.default_$1.$2" +} + +_change_device_defaults() { + local config="$1" + + # If the device is enabled, it's already mutated from its default config + # so we shouldn't touch it. + config_get disabled "$config" disabled + if [ "$disabled" != 1 ]; then + return + fi + + # Only setup one device in each band. + config_get device_band "$config" band + if eval "[ device_band_$device_band = 1 ]"; then + return 1 + fi + eval "device_band_$device_band=1" + + if [ "$device_band" = "s1g" ]; then + # It's probably been setup by our HaLow hotplug. + # Only change if it's in the default state + # (otherwise we're probably running on a sysupgrade). + if [ "$(_get_iface "$config" ssid)" = MorseMicro ] && + [ "$(_get_iface "$config" mode)" = ap ] && + [ "$(_get_iface "$config" encryption)" = sae ] && + [ "$(_get_iface "$config" key)" = 12345678 ]; then + # It's only safe to enable a morse device if we know what region it should be. + # If we do, set up the country and channel, otherwise leave it disable. + if [ -n "$mm_region" ]; then + # Start on the highest bandwidth channel for the country code. netifd + # does fill a channel automatically, but it may be for the wrong region. + # Channels can be queried from iwinfo or the driver, but not if the + # device is down, and the device is not up until we have a valid channel. + local channel="$(awk < /usr/share/morse-regdb/channels.csv -F, '$1 == "'"$mm_region"'" {print $2, $3}' \ + | sort -n | awk 'END {print $2}')" + + echo "uci-default-morse-wireless: setting $config to $mm_region on $channel" > /dev/kmsg + uci batch <<- END + delete wireless.$config.disabled + set wireless.$config.country='$mm_region' + set wireless.$config.channel='$channel' + END + fi + + uci batch <<- END + set wireless.default_$config.ssid='$default_ssid' + set wireless.default_$config.mesh_id='$default_ssid' + set wireless.default_$config.key='$default_wifi_key' + set wireless.default_$config.encryption='sae' + END + fi + else + # It's probably a 'normal' wifi-device. + # Only change if it's in the default state + # (otherwise we're probably running on a sysupgrade). + if [ "$(_get_iface "$config" ssid)" = OpenWrt ] && + [ "$(_get_iface "$config" mode)" = ap ] && + [ "$(_get_iface "$config" encryption)" = none ]; then + + uci batch <<- END + delete wireless.$config.disabled + set wireless.$config.country='$mm_region' + set wireless.default_$config.ssid='$default_ssid' + set wireless.default_$config.mesh_id='$default_ssid' + set wireless.default_$config.key='$default_wifi_key' + set wireless.default_$config.encryption='psk2' + END + fi + fi +} + +config_load wireless +config_foreach _change_device_defaults wifi-device diff --git a/kernel/morse-bundle/files/morse/scripts/chipreset.sh b/kernel/morse-bundle/files/morse/scripts/chipreset.sh new file mode 100755 index 0000000..3f70601 --- /dev/null +++ b/kernel/morse-bundle/files/morse/scripts/chipreset.sh @@ -0,0 +1,62 @@ +#!/bin/sh +# +# Copyright 2023-2024 Morse Micro +# + +remove_driver() { + modules="morse dot11ah" + + for module in morse dot11ah; do + rmmod "$module" > /dev/null + done +} + +reset_chip() { + # Timing is from reset.c in morse-ctrl + gpioset -m time -u 50000 $1=0 + # Force pin back to in. + gpioget $1 > /dev/null + sleep 0.05 +} + +# Find first MM_RESET pin +# (gpio-line-names are not guaranteed unique, but chances of more than one are low...) +reset_gpio="$(gpiofind MM_RESET | head -1)" + +if [ -z "$reset_gpio" ]; then + 2>&1 echo 'morsechipreset: unable to reset as MM_RESET not in gpio-line-names in device tree' + exit 1 +fi + +# This finds something like: +# /sys/devices/platform/10130000.mmc/mmc_host +# and extracts a driver location and the device (10130000.mmc). +sdio_device_path="$(find /sys/devices/platform -name mmc_host | head -1)" +if [ -n "$sdio_device_path" ]; then + sdio_driver_path="$(readlink -f "$sdio_device_path"/../driver)" + sdio_device="$(basename $(dirname "$sdio_device_path"))" +fi + +if [ -z "$sdio_device" ]; then + 2>&1 echo 'morsechipreset: unable to find sdio device/driver to unbind; proceeding anyway' +fi + +# Strictly speaking, this: +# (a) shouldn't be necessary, as unbind will remove (as long as sdio_device was found). +# (b) will perform a reset anyway during removal so calling may be pointless. +# But for avoidance of any issues, we leave it in for now. + +remove_driver + +# Resetting the chip also resets its sdio bus. Therefore we need to tell the sdio +# driver to take another look. + +if [ -n "$sdio_device_path" ]; then + echo -n "$sdio_device" > "$sdio_driver_path/unbind" +fi + +reset_chip "$reset_gpio" + +if [ -n "$sdio_device_path" ]; then + echo -n "$sdio_device" > "$sdio_driver_path/bind" +fi diff --git a/kernel/morse-bundle/files/morse/scripts/do_iperf.sh b/kernel/morse-bundle/files/morse/scripts/do_iperf.sh new file mode 100755 index 0000000..454a04f --- /dev/null +++ b/kernel/morse-bundle/files/morse/scripts/do_iperf.sh @@ -0,0 +1,142 @@ +#!/bin/sh + +function usage { + echo "Usage: $(basename $0) [-m MODE (udp/tcp)] [-s SERVER (IP ADDRESS)] [-p PORT] [-t duration] [-b MAXRATE] [-d DIRECTION] [-n DATASETNAME]" 2>&1 + echo 'Run iperf3 client and collect netlink data via mmnlspy' + echo ' -i INTERFACE network interface. (eg. wlan0) REQUIRED' + echo ' -m MODE Specify mode as udp or tcp REQUIRED' + echo ' -s SERVERIP iperf3 server IP address REQUIRED' + echo ' -p SERVERPORT iperf3 port' + echo ' -t DURATION iperf3 run duration in seconds REQUIRED' + echo ' -b RATE max throughput for udp (eg. 25m)' + echo ' -d DIRECTION up/down. run both if not specified' + echo ' -n prefix used for generated files REQUIRED' + exit 1 +} + +function print_out { + local MESSAGE="${@}" + if [[ "${VERBOSE}" == true ]];then + echo "${MESSAGE}" + fi +} + +if [[ ${#} -eq 0 ]]; then + usage +fi + +optstring=":i:m:s:p:t:b:d:n:" + +PORT=5201 +MAXRATE=25m +MODE="" +OPTCOUNT=0 +DATASETNAME= + +while getopts ${optstring} arg; do + case ${arg} in + i) + INTERFACE="${OPTARG}" + let OPTCOUNT++ + ;; + m) + MODE="${OPTARG}" + let OPTCOUNT++ + ;; + s) + SERVER="${OPTARG}" + let OPTCOUNT++ + ;; + p) + PORT="${OPTARG}" + ;; + t) + DURATION="${OPTARG}" + let OPTCOUNT++ + ;; + b) + MAXRATE="${OPTARG}" + ;; + d) + DIRECTION="${OPTARG}" + ;; + n) + DATASETNAME="${OPTARG}" + let OPTCOUNT++ + ;; + ?) + echo "Invalid option: -${OPTARG}." + echo + usage + ;; + esac +done + +if [ $OPTCOUNT -lt 5 ]; then + echo "Invalid options" + echo + usage +fi + +IPARAM="" + +case $MODE in + "udp") + IPARAM="-u -b $MAXRATE" + ;; + "tcp") + ;; + *) + echo "Invalid mode option. Please specify udp or tcp" + echo + usage + ;; +esac + +SPYDUR=$(($DURATION)) +DURATION=$(($DURATION+5)) + +function do_iperf() { + + echo "Traffic $MODE-$DIRECTION" + echo + + echo "Starting mmnlspy for $spydur seconds..." + mmnlspy -i $INTERFACE -r 1000 -fk -w 5000 -t $SPYDUR > $DATASETNAME-$DIRECTION-$MODE.spy & + + echo "Resetting stats" + morse_cli -i $INTERFACE stats -r + + echo "Starting iperf for $DURATION seconds..." + iperf3 -c $SERVER -p $PORT -fk -t $DURATION $IPARAM $DIR --forceflush | tee -a $DATASETNAME-$DIRECTION-$MODE.iperf + + echo "Collecting station dump information..." + iw $INTERFACE station dump > $DATASETNAME-$DIRECTION-$MODE.iw + + echo "Collecting stats" + morse_cli -i $INTERFACE stats > $DATASETNAME-$DIRECTION-$MODE.stats + + echo "Waiting for processes to end..." + echo + sleep 5 +} + + +case $DIRECTION in + "up") + DIR="" + do_iperf + ;; + "down") + DIR="-R" + do_iperf + ;; + *) + DIRECTION="up" + DIR="" + do_iperf + DIRECTION="down" + DIR="-R" + do_iperf + ;; +esac diff --git a/kernel/morse-bundle/files/morse/scripts/dpp_start.sh b/kernel/morse-bundle/files/morse/scripts/dpp_start.sh new file mode 100644 index 0000000..46a9702 --- /dev/null +++ b/kernel/morse-bundle/files/morse/scripts/dpp_start.sh @@ -0,0 +1,55 @@ +#!/bin/sh + +# This script is called by the button handler when the DPP button is pressed. +# The button can be pressed physically or via luci. + +. /lib/functions.sh +. /lib/functions/leds.sh + +start_wpa_event_listener() { + # Start the wpa_event_listener to listen for DPP events. The + # wpa_event_listener will write the config on the STA side and control the + # blinking led. On the STA side of DPP QR code, wpa_event_listener is + # started by netifd. + killall wpa_event_listener + wpa_event_listener "$@" -a /lib/netifd/morse/wpa_s1g_dpp_action.sh -B +} + +_maybe_press_dpp_button() { + # For a morse, not disabled, AP or STA, send the button press to hostap. + local section_name="$1" + config_get device "$section_name" device + if [ "$(uci -q get "wireless.$device.type")" != "morse" ]; then + return + fi + config_get disabled "$section_name" disabled 0 + if [ "$disabled" != 0 ]; then + return + fi + config_get mode "$section_name" mode + case "$mode" in + "ap") + echo "starting dpp due to button press" + start_wpa_event_listener -p /var/run/hostapd_s1g/ + hostapd_cli_s1g dpp_push_button + ;; + "sta") + echo "starting dpp due to button press" + start_wpa_event_listener + wpa_cli_s1g disconnect + wpa_cli_s1g dpp_push_button + ;; + esac 2>&1 | logger -t button -p daemon.notice +} + +# Check that the device is in a DPP mode (AP or STA) and tell hostap that the +# button is pressed if so. +maybe_press_dpp_button() { + if [ "$(uci -q get prplmesh.config.enable)" = '1' ]; then + return + fi + config_load wireless + config_foreach _maybe_press_dpp_button wifi-iface +} + +maybe_press_dpp_button diff --git a/kernel/morse-bundle/files/morse/scripts/mm_dumps.sh b/kernel/morse-bundle/files/morse/scripts/mm_dumps.sh new file mode 100755 index 0000000..4497466 --- /dev/null +++ b/kernel/morse-bundle/files/morse/scripts/mm_dumps.sh @@ -0,0 +1,320 @@ +#!/bin/sh +# +# Copyright (C) 2023 Morse Micro Pty Ltd. All rights reserved. +# + +INTERFACE="wlan0" +MORSE_DIR="/" +OUTPUT_PATH="." +DEBUG_DIR=$(date +"%F_%X") +COMPRESS=false +BUILD="OpenWRT" + +tear_down_tmp_iface() +{ + if [ "$tear_down_iface" == 1 ]; then + iw dev "$INTERFACE" del + fi +} + +find_morse_device() { + local device=$1 + local type_morse + config_get type_morse $device type + + if [ "$type_morse" == "morse" ]; then + morse_radio=$1 + config_get morse_path $device path + return 1 + fi +} + +create_tmp_iface() +{ + . /lib/functions.sh + config_load wireless + config_foreach find_morse_device wifi-device + + iwinfo_cmd="iwinfo nl80211 phyname \"path=$morse_path\"" + phy=$(eval $iwinfo_cmd) + INTERFACE=tmp_"$INTERFACE" + + iw phy "$phy" interface add "$INTERFACE" type managed + rc="$?" + if [ "$rc" = 0 ]; then + ip link set "$INTERFACE" up + tear_down_iface=1 + fi +} + +morse_iface_available() +{ + ubus_cmd="ubus call iwinfo info '{\"device\": \"$INTERFACE\"}'" + ubus_output=$(eval $ubus_cmd) + + . /usr/share/libubox/jshn.sh + json_init + json_load "$ubus_output" + json_get_var hwmode hwmode + + [ "$hwmode" == "ah" ] && return 1 + return 0 +} + +validate_morse_iface() +{ + if morse_iface_available; then + create_tmp_iface + fi +} + +get_dmesg() +{ + dmesg > dmesg.txt +} + +get_versions() +{ + "$MORSE_DIR"morse/scripts/versions.sh > versions.txt +} + +get_morsectrl_stats() +{ + morse_cli -i "$INTERFACE" stats -j > morsectrl_stats.json +} + +get_morsectrl_channel() +{ + morse_cli -i "$INTERFACE" channel > morsectrl_channel.txt +} + +get_iw_link() +{ + iw "$INTERFACE" link > iw_link.txt +} + +get_iw_station_dump() +{ + iw "$INTERFACE" station dump > iw_station_dump.txt +} + +get_iwinfo() +{ + iwinfo > iwinfo.txt +} + +get_ifconfig() +{ + ifconfig > ifconfig.txt +} + +get_morse_conf() +{ + cp "$MORSE_DIR"morse/configs/morse.conf . +} + +get_log_dump() +{ + cp -r /var/log var_log_dump +} + +get_bcf_binaries() +{ + cp -r /lib/firmware/morse binaries +} + +get_interrupts() +{ + cat /proc/interrupts > interrupts.txt +} + +get_gpios() +{ + cat /sys/kernel/debug/gpio > gpio.txt +} + +get_ps() +{ + ps > running_procs.txt +} + +get_kernel() +{ + cat /proc/version > kernel.txt +} + +get_morse_modparams() +{ + cp -r /sys/module/morse/parameters modparams +} + +get_cpu_and_mem_usage() +{ + top -n1 > cpu_and_mem_usage.txt +} + +get_meminfo() +{ + cat /proc/meminfo > meminfo.txt +} + +get_df() +{ + df -h > disk_usage.txt +} + +get_syslog() +{ + logread > syslog.txt +} + +get_etc_config() +{ + cp -r /etc/config etc_config +} + +get_sys_fs_pstore() +{ + cp -r /sys/fs/pstore sys_fs_pstore +} + +get_var_run_confs() +{ + mkdir var_run_confs + cp /var/run/*.conf var_run_confs/ +} + +get_mm_chip_uart_logs() +{ + cp /var/log/ttyAMA1.log ttyAMA1.log +} + +get_prplmesh_data_model() +{ + ubus call Device.WiFi.DataElements _get '{"depth":"10"}' > prplmesh_data_model.json +} + +get_prplmesh_conn_map() +{ + prplmesh_enable=$(uci get prplmesh.config.enable) + prplmesh_master=$(uci get prplmesh.config.master) + if [ "$prplmesh_enable" = 1 ] && [ "$prplmesh_master" = 1 ]; then + /opt/prplmesh/bin/beerocks_cli -c bml_conn_map > prplmesh_conn_map.txt + fi +} + +usage() +{ + echo " " + echo "Usage: $(basename $0) [-c] [-b build system] [-i interface] [-m morse directory path] [-o Output folder name] [-d Output file path]" + echo "Morse Micro file and information extraction tool" + echo " -c Compress output folder to .tar.gz. (default: disabled)" + echo " -b BUILD SYSTEM Build system used to compile. (default: OpenWRT)" + echo " Options:" + echo " 'buildroot'" + echo " 'OpenWRT'" + echo " -i INTERFACE Network interface. (default: wlan0)" + echo " -m MORSE DIRECTORY PATH Filepath to morse folder. (default: '/')" + echo " -o OUTPUT FOLDER NAME Name of folder to output debug files. (default: 'YYYY-MM-DD_hh:mm:ss')" + echo " -d OUTPUT FILE PATH Path to save output folder. (default: '.')" + exit 1 +} + +optstring="cb:i:m:o:d:" + +while getopts ${optstring} arg; do + case ${arg} in + c) + COMPRESS=true + ;; + b) + BUILD="$OPTARG" + ;; + i) + INTERFACE="$OPTARG" + ;; + m) + MORSE_DIR="$OPTARG" + ;; + o) + DEBUG_DIR="$OPTARG" + ;; + d) + OUTPUT_PATH="$OPTARG" + ;; + *) + usage + ;; + esac +done + +cd "$OUTPUT_PATH" || exit 1 ; +mkdir "$DEBUG_DIR" ; cd "$DEBUG_DIR" || exit 1 + + +case $BUILD in + "buildroot") + get_iw_link + get_etc_config + get_iw_station_dump + get_morsectrl_channel + get_dmesg + get_ps + get_meminfo + get_cpu_and_mem_usage + get_versions + get_morsectrl_stats + get_iwinfo + get_ifconfig + get_morse_conf + get_log_dump + get_bcf_binaries + get_interrupts + get_gpios + get_kernel + get_morse_modparams + get_df + ;; + "OpenWRT") + validate_morse_iface + get_syslog + get_sys_fs_pstore + get_var_run_confs + get_iw_link + get_etc_config + get_iw_station_dump + get_morsectrl_channel + get_dmesg + get_ps + get_meminfo + get_cpu_and_mem_usage + get_morsectrl_stats + get_iwinfo + get_ifconfig + get_log_dump + get_bcf_binaries + get_interrupts + get_gpios + get_kernel + get_df + get_morse_modparams + get_mm_chip_uart_logs + get_prplmesh_data_model + get_prplmesh_conn_map + tear_down_tmp_iface + ;; + *) + echo "Invalid BUILD option. Exiting..." + cd ../ + rm -rf "$DEBUG_DIR" + exit 1 +esac + + + + +if $COMPRESS; then + cd ../ + tar -czvf "$DEBUG_DIR".tar.gz "$DEBUG_DIR" + rm -rf "$DEBUG_DIR" +fi diff --git a/kernel/morse-bundle/files/morse/scripts/start_rtspserver.sh b/kernel/morse-bundle/files/morse/scripts/start_rtspserver.sh new file mode 100644 index 0000000..fb6dfd2 --- /dev/null +++ b/kernel/morse-bundle/files/morse/scripts/start_rtspserver.sh @@ -0,0 +1,9 @@ + +#start rtsp server +v4l2rtspserver -I 10.42.1.1 -u morse -Q5 -G 640x480x25 /dev/video0 + +#can be played with mpv. +#mpv --profile=low-latency --stream-buffer-size=524288 rtsp://10.42.1.1:8554/morse + +#disable cache, near real-time but not as resilient to network drops +#mpv --untimed --no-cache --cache-secs=0 --demuxer-readahead-secs=0 --profile=low-latency rtsp://10.42.1.1:8554/morse diff --git a/kernel/morse-bundle/files/morse/scripts/versions.sh b/kernel/morse-bundle/files/morse/scripts/versions.sh new file mode 100755 index 0000000..98bf199 --- /dev/null +++ b/kernel/morse-bundle/files/morse/scripts/versions.sh @@ -0,0 +1,169 @@ +#!/bin/sh + +get_morse_iface() +{ + if [ -d "/sys/class/morse/morse_io/device/net/" ]; then + local morse_iface=$(basename "/sys/class/morse/morse_io/device/net/"*) + printf $morse_iface + fi +} + +get_fw_ver() +{ + local m_iface=$(get_morse_iface) + if [ -z "$m_iface" ];then + printf "N/A" + return + fi + + local output=`morse_cli -i $m_iface version | grep FW` + if [ "$output" ];then + printf "$output" | sed 's/.*: //g' + else + printf "N/A" + fi +} + +get_drv_ver() +{ + local output=`strings /lib/modules/$(uname -r)/morse.ko | grep "^0-" | head -n 1` + if [ "$output" ];then + printf "$output" + else + printf "N/A" + fi +} + +get_d11_ver() +{ + local output=`strings /lib/modules/$(uname -r)/dot11ah.ko | grep "^0-" | head -n 1` + if [ "$output" ];then + printf "$output" + else + printf "N/A" + fi +} + +get_mcli_ver() +{ + local m_iface=$(get_morse_iface) + if [ -z "$m_iface" ];then + printf "N/A" + return + fi + + local output=`morse_cli -i $m_iface version | grep Morse_cli` + if [ "$output" ];then + printf "$output" | sed 's/.*: //g' + else + printf "N/A" + fi +} + +get_mctrl_ver() +{ + local m_iface=$(get_morse_iface) + if [ -z "$m_iface" ];then + printf "N/A" + return + fi + + if [ ! -x "/sbin/morsectrl" ]; then + printf "N/A" + return + fi + + local output=`morsectrl -i $m_iface version | grep Morsectrl` + if [ "$output" ];then + printf "$output" | sed 's/.*: //g' + else + printf "N/A" + fi +} + +get_hapd_ver() +{ + local output=`hostapd_s1g -v 2>&1 | grep hostapd` + if [ "$output" ];then + printf "$output" | sed 's/hostapd v//g' + else + printf "N/A" + fi +} + +get_supl_ver() +{ + local output=`wpa_supplicant_s1g -v | grep wpa_supplicant` + if [ "$output" ];then + printf "$output" | sed 's/wpa_supplicant v//g' + else + printf "N/A" + fi +} + +get_wvmn_ver() +{ + local output=`wavemon -v | grep wavemon` + if [ "$output" ];then + printf "$output" | sed 's/wavemon //g' + else + printf "N/A" + fi +} + +get_iprf_ver() +{ + local output=`iperf3 --version | grep iperf` + if [ "$output" ];then + printf "$output" | sed 's/iperf //g' + else + printf "N/A" + fi +} + +get_iw_ver() +{ + local output=`iw --version | grep "iw version"` + if [ "$output" ];then + printf "$output" | sed 's/iw version //g' + else + printf "N/A" + fi +} + +get_snp_ver() +{ + local output=`test -e /usr/sbin/morse-snapshot.sh && cat /usr/sbin/morse-snapshot.sh | grep SCRIPT_VER=` + if [ "$output" ];then + printf "$output" | sed "s/SCRIPT_VER='v\(.*\)'/\1/" + else + printf "N/A" + fi +} + +get_owrt_ver() +{ + # This is actually VERSION_CODE, which is the Morse OpenWrt version + # rather than the upstream OpenWrt version. + local output=`cat /etc/openwrt_version` + if [ "$output" ];then + printf "$output" + else + printf "N/A" + fi +} + +echo -ne "Morse Versions: +- Firmware = `get_fw_ver` +- Morse Driver = `get_drv_ver` +- Dot11ah Driver = `get_d11_ver` +- morse_cli = `get_mcli_ver` +- Morsectrl = `get_mctrl_ver` +- Hostapd = `get_hapd_ver` +- WPA_Supplicant = `get_supl_ver` +- Wavemon = `get_wvmn_ver` +- Iperf3 = `get_iprf_ver` +- IW = `get_iw_ver` +- Snapshot = `get_snp_ver` +- OpenWRT = `get_owrt_ver` +"