2024-10-20 13:23:16 -03:00
|
|
|
# Makefile for installation of echomav_deploy on EchoPilot AI hardware
|
2024-10-20 17:48:13 -03:00
|
|
|
# This is installation of mavlink-router, cockpit, and network setup
|
2024-10-20 14:17:07 -03:00
|
|
|
# Spiri modified to install additional features
|
2024-10-20 13:23:16 -03:00
|
|
|
.DEFAULT_GOAL := default
|
|
|
|
SHELL := /bin/bash
|
|
|
|
SUDO := $(shell test $${EUID} -ne 0 && echo "sudo")
|
|
|
|
.EXPORT_ALL_VARIABLES:
|
|
|
|
SYSCFG = /etc/mavlink-router
|
|
|
|
CONFIG ?= /var/local
|
|
|
|
LIBSYSTEMD=/lib/systemd/system
|
2024-10-20 14:17:07 -03:00
|
|
|
SERVICES=mavlink-router.service temperature.service wifibroadcast@drone fpv-camera.service
|
2024-10-20 13:23:16 -03:00
|
|
|
DRY_RUN=false
|
|
|
|
LOCAL=/usr/local
|
|
|
|
LOCAL_SCRIPTS=temperature.sh cockpitScript.sh
|
|
|
|
|
2024-10-20 17:48:13 -03:00
|
|
|
.PHONY: enable install see uninstall static default no-static verify_spir0 interactive set_network_manager_config configure_wifibroadcast
|
|
|
|
|
|
|
|
default: interactive install static set_network_manager_config configure_wifibroadcast
|
|
|
|
|
|
|
|
# New interactive target
|
|
|
|
interactive:
|
|
|
|
@clear
|
|
|
|
@echo " "
|
|
|
|
@echo " _____ _____ _____ _____ _____ "
|
|
|
|
@echo " / ____|| __ \|_ _|| __ \ |_ _| "
|
|
|
|
@echo " | (___ | |__) | | | | |__) | | | "
|
|
|
|
@echo " \___ \ | ___/ | | | _ / | | "
|
|
|
|
@echo " ____) || | _| |_ | | \ \ _| |_ "
|
|
|
|
@echo " |_____/ |_| __|_____||_|__\_\|_____| "
|
|
|
|
@echo " | \/ || | | ||__ \ "
|
|
|
|
@echo " | \ / || | | | ) | "
|
|
|
|
@echo " | |\/| || | | | / / "
|
|
|
|
@echo " | | | || |__| | / /_ "
|
|
|
|
@echo " |_| |_| \____/ |____| "
|
|
|
|
@echo " "
|
|
|
|
@echo "Installing Mu2 Default Settings/Programs "
|
|
|
|
@echo ""
|
|
|
|
@read -p "Do you want to set a static IP address? (Y/N): " set_ip; \
|
|
|
|
if [ "$$set_ip" = "Y" ] || [ "$$set_ip" = "y" ]; then \
|
|
|
|
echo ""; \
|
|
|
|
echo "Please enter the last segment of the IP address for this setup (between 15-250)"; \
|
|
|
|
read -p "IP Address: 192.168.10. " ip_address; \
|
|
|
|
$(MAKE) explicit-ip ip=192.168.10.$$ip_address; \
|
|
|
|
else \
|
|
|
|
echo "Proceeding without setting a static IP address."; \
|
|
|
|
fi
|
2024-10-20 13:23:16 -03:00
|
|
|
|
|
|
|
explicit-ip:
|
|
|
|
@$(MAKE) --no-print-directory install
|
|
|
|
@$(SUDO) ./static-network.sh -i eth0 -a $(ip)
|
|
|
|
|
2024-10-20 17:48:13 -03:00
|
|
|
# New target to configure NetworkManager to ignore spir0
|
|
|
|
set_network_manager_config:
|
|
|
|
@echo ""
|
|
|
|
@echo "Configuring NetworkManager to ignore SpiriLink interface (spir0)..."
|
|
|
|
@echo ""
|
|
|
|
@$(SUDO) mkdir -p /etc/NetworkManager
|
|
|
|
@$(SUDO) touch /etc/NetworkManager/NetworkManager.conf
|
|
|
|
@if ! grep -q "\[keyfile\]" /etc/NetworkManager/NetworkManager.conf; then \
|
|
|
|
echo "[keyfile]" | $(SUDO) tee -a /etc/NetworkManager/NetworkManager.conf > /dev/null; \
|
|
|
|
fi
|
|
|
|
@if ! grep -q "unmanaged-devices=interface-name:spir0" /etc/NetworkManager/NetworkManager.conf; then \
|
|
|
|
echo "unmanaged-devices=interface-name:spir0" | $(SUDO) tee -a /etc/NetworkManager/NetworkManager.conf > /dev/null; \
|
|
|
|
fi
|
|
|
|
@$(SUDO) systemctl restart NetworkManager
|
|
|
|
@echo "NetworkManager has been configured to ignore spir0."
|
|
|
|
|
|
|
|
# New target to configure wifibroadcast settings
|
|
|
|
configure_wifibroadcast:
|
|
|
|
@echo ""
|
|
|
|
@echo "Configuring /etc/default/wifibroadcast with interface spir0..."
|
|
|
|
@echo ""
|
|
|
|
@$(SUDO) bash -c "echo 'WFB_NICS=\"spir0\"' > /etc/default/wifibroadcast"
|
|
|
|
@echo "Configuration updated: /etc/default/wifibroadcast has been set with WFB_NICS=\"spir0\"."
|
|
|
|
|
2024-10-20 13:23:16 -03:00
|
|
|
no-static:
|
|
|
|
@$(MAKE) --no-print-directory install
|
|
|
|
|
|
|
|
disable:
|
|
|
|
@( for c in stop disable ; do $(SUDO) systemctl $${c} $(SERVICES) ; done ; true )
|
|
|
|
|
|
|
|
enable:
|
|
|
|
@( for c in stop disable ; do $(SUDO) systemctl $${c} $(SERVICES) ; done ; true )
|
|
|
|
@( for s in $(SERVICES) ; do $(SUDO) install -Dm644 $${s%.*}.service $(LIBSYSTEMD)/$${s%.*}.service ; done ; true )
|
|
|
|
@if [ ! -z "$(SERVICES)" ] ; then $(SUDO) systemctl daemon-reload ; fi
|
|
|
|
@( for s in $(SERVICES) ; do $(SUDO) systemctl enable $${s%.*} ; done ; true )
|
|
|
|
@echo ""
|
|
|
|
@echo "Service is installed. To run now use sudo systemctl start mavlink-router and sudo systemctl start cockpit.socket"
|
|
|
|
@echo "Inspect output with sudo journalctl -fu mavlink-router"
|
|
|
|
@echo ""
|
|
|
|
|
|
|
|
static:
|
|
|
|
# set up static ip address on eth0
|
|
|
|
@$(SUDO) ./static-network.sh -i eth0 -a auto
|
|
|
|
|
2024-10-20 17:48:13 -03:00
|
|
|
install: verify_spir0
|
2024-10-20 13:23:16 -03:00
|
|
|
# install helper apps
|
|
|
|
@$(SUDO) apt update
|
2024-10-20 17:54:57 -03:00
|
|
|
@$(SUDO) apt install -y nano nload htop picocom sshpass
|
2024-10-20 13:23:16 -03:00
|
|
|
|
|
|
|
# install mavlink-router
|
|
|
|
@rm -rf ~/tmp/mavlink-router-source
|
2024-10-20 17:54:57 -03:00
|
|
|
@git clone https://github.com/EchoMAV/mavlink-router-src ~/tmp/mavlink-router-source && \
|
|
|
|
cd ~/tmp/mavlink-router-source && git submodule update --init --recursive && \
|
|
|
|
$(SUDO) apt -y install git ninja-build pkg-config gcc g++ systemd && \
|
|
|
|
$(SUDO) apt -y install python3-pip && \
|
|
|
|
$(SUDO) pip3 install meson smbus && \
|
|
|
|
meson setup build . && $(SUDO) ninja -C build install
|
2024-10-20 13:23:16 -03:00
|
|
|
|
|
|
|
# install the config file
|
|
|
|
@$(SUDO) mkdir -p $(SYSCFG)
|
|
|
|
@$(SUDO) cp main.conf $(SYSCFG)/.
|
|
|
|
|
2024-10-20 18:02:40 -03:00
|
|
|
# make ensure-cockpit.sh executable and run it
|
2024-10-20 21:24:47 -03:00
|
|
|
$(SUDO) chmod +x $(CURDIR)/ensure-cockpit.sh
|
2024-10-20 17:58:49 -03:00
|
|
|
@if [ -x "$(CURDIR)/ensure-cockpit.sh" ]; then \
|
|
|
|
$(SUDO) $(CURDIR)/ensure-cockpit.sh; \
|
|
|
|
else \
|
|
|
|
echo "Error: ensure-cockpit.sh not found or not executable"; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
2024-10-20 13:23:16 -03:00
|
|
|
|
|
|
|
# set up cockpit files
|
|
|
|
@$(SUDO) rm -rf /usr/share/cockpit/general/
|
|
|
|
@$(SUDO) mkdir /usr/share/cockpit/general/
|
|
|
|
@$(SUDO) cp -rf ui/general/* /usr/share/cockpit/general/
|
|
|
|
@$(SUDO) cp -rf ui/branding-ubuntu/* /usr/share/cockpit/branding/ubuntu/
|
|
|
|
@$(SUDO) cp -rf ui/static/* /usr/share/cockpit/static/
|
|
|
|
@$(SUDO) cp -rf ui/base1/* /usr/share/cockpit/base1/
|
|
|
|
@[ -d $(LOCAL)/echopilot ] || $(SUDO) mkdir $(LOCAL)/echopilot
|
2024-10-20 17:54:57 -03:00
|
|
|
@for s in $(LOCAL_SCRIPTS); do $(SUDO) install -Dm755 $${s} $(LOCAL)/echopilot/$${s}; done
|
2024-10-20 13:23:16 -03:00
|
|
|
|
2024-10-20 14:17:07 -03:00
|
|
|
# install modified 8812EU drivers
|
2024-10-20 17:54:57 -03:00
|
|
|
@git clone https://github.com/libc0607/rtl88x2eu-20230815 ~/tmp/rtl88x2eu && \
|
|
|
|
cd ~/tmp/rtl88x2eu && git submodule update --init --recursive && \
|
|
|
|
$(SUDO) sed -i 's/CONFIG_PLATFORM_I386_PC = y/CONFIG_PLATFORM_I386_PC = n/g' Makefile && \
|
|
|
|
$(SUDO) sed -i 's/CONFIG_PLATFORM_ARM64_RPI = n/CONFIG_PLATFORM_ARM64_RPI = y/g' Makefile && \
|
2024-10-20 21:24:47 -03:00
|
|
|
$(SUDO) chmod +x ./dkms-install.sh && \
|
2024-10-20 17:54:57 -03:00
|
|
|
$(SUDO) apt -y install dkms && \
|
|
|
|
$(SUDO) ./dkms-install.sh
|
2024-10-20 14:17:07 -03:00
|
|
|
|
2024-10-20 17:48:13 -03:00
|
|
|
# Install WFB-NG dependencies and compile deb
|
2024-10-20 17:54:57 -03:00
|
|
|
@git clone -b stable https://github.com/svpcom/wfb-ng.git ~/tmp/wfb-ng && \
|
|
|
|
cd ~/tmp/wfb-ng && \
|
|
|
|
$(SUDO) apt -y install python3-all libpcap-dev libsodium-dev python3-pip python3-pyroute2 python3-future python3-twisted python3-serial python3-all-dev iw virtualenv debhelper dh-python build-essential && \
|
|
|
|
$(SUDO) make deb && \
|
|
|
|
$(SUDO) dpkg -i /deb_dist/wfb*.deb
|
2024-10-20 14:17:07 -03:00
|
|
|
|
|
|
|
# create initial WFB-NG config file
|
|
|
|
@$(SUDO) cp wifibroadcast.cfg /etc/
|
|
|
|
|
|
|
|
# move drone encryption key to /etc/
|
|
|
|
@$(SUDO) cp drone.key /etc/
|
|
|
|
|
2024-10-20 13:23:16 -03:00
|
|
|
# stop any running services we care about
|
2024-10-20 17:54:57 -03:00
|
|
|
@for c in stop disable; do $(SUDO) systemctl $${c} $(SERVICES); done; true
|
2024-10-20 13:23:16 -03:00
|
|
|
|
|
|
|
# install and enable services
|
2024-10-20 17:54:57 -03:00
|
|
|
@for s in $(SERVICES); do $(SUDO) install -Dm644 $${s%.*}.service $(LIBSYSTEMD)/$${s%.*}.service; done
|
|
|
|
@if [ ! -z "$(SERVICES)" ]; then $(SUDO) systemctl daemon-reload; fi
|
|
|
|
@for s in $(SERVICES); do $(SUDO) systemctl enable $${s%.*}; done
|
2024-10-20 13:23:16 -03:00
|
|
|
|
|
|
|
# set up the system permissions, stop/disable nvgetty etc
|
|
|
|
@$(SUDO) systemctl stop nvgetty
|
|
|
|
@$(SUDO) systemctl disable nvgetty
|
|
|
|
@$(SUDO) usermod -aG dialout $${USER}
|
|
|
|
@$(SUDO) usermod -aG tty $${USER}
|
|
|
|
@echo ""
|
|
|
|
|
|
|
|
see:
|
|
|
|
$(SUDO) cat $(SYSCFG)/main.conf
|
|
|
|
|
|
|
|
serial:
|
|
|
|
-@$(SUDO) python3 serial_number.py 0 || true
|
|
|
|
-@$(SUDO) python3 serial_number.py 1 || true
|
|
|
|
|
|
|
|
uninstall:
|
|
|
|
@$(MAKE) --no-print-directory disable
|
2024-10-20 17:54:57 -03:00
|
|
|
@for s in $(SERVICES); do $(SUDO) rm $(LIBSYSTEMD)/$${s%.*}.service; done; true
|
|
|
|
@if [ ! -z "$(SERVICES)" ]; then $(SUDO) systemctl daemon-reload; fi
|