udev for spir0
This commit is contained in:
parent
07a98a9c62
commit
8a74720fb5
43
Makefile
43
Makefile
@ -88,49 +88,35 @@ dependencies:
|
||||
# Install SpiriLink driver
|
||||
.PHONY: spirilink-driver
|
||||
spirilink-driver:
|
||||
@$(SUDO) mkdir -p /tmp/spirilink
|
||||
$(SUDO) mkdir -p ~/tmp
|
||||
@if [ "$(DRIVER_TYPE)" = "EU" ]; then \
|
||||
echo "Installing SpiriLink 8812EU driver..."; \
|
||||
$(SUDO) wget -O /tmp/spirilink/8812eu.ko https://git.spirirobotics.com/aepko/SpiriLink-Drivers/raw/branch/main/Raspberry%20Pi/8812EU/8812eu.ko && \
|
||||
$(SUDO) cp /tmp/spirilink/8812eu.ko /lib/modules/$(shell uname -r)/kernel/drivers/net/wireless/ && \
|
||||
$(SUDO) depmod -a; \
|
||||
git clone -b v5.15.0.1 https://github.com/svpcom/rtl8812eu.git ~/tmp/rtl8812eu && \
|
||||
cd ~/tmp/rtl8812eu && $(SUDO) ./dkms-install.sh; \
|
||||
elif [ "$(DRIVER_TYPE)" = "AU" ]; then \
|
||||
echo "Installing SpiriLink 8812AU driver..."; \
|
||||
$(SUDO) wget -O /tmp/spirilink/8812au.ko https://git.spirirobotics.com/aepko/SpiriLink-Drivers/raw/branch/main/Raspberry%20Pi/8812AU/8812au.ko && \
|
||||
$(SUDO) cp /tmp/spirilink/8812au.ko /lib/modules/$(shell uname -r)/kernel/drivers/net/wireless/ && \
|
||||
$(SUDO) depmod -a; \
|
||||
git clone -b v5.2.20 https://github.com/svpcom/rtl8812au.git ~/tmp/rtl8812au && \
|
||||
cd ~/tmp/rtl8812au && $(SUDO) ./dkms-install.sh; \
|
||||
else \
|
||||
echo "Unknown driver type: $(DRIVER_TYPE). Skipping driver installation."; \
|
||||
fi;
|
||||
@echo "\nSpiriLink driver installation complete."
|
||||
@echo "SpiriLink driver installation complete."
|
||||
|
||||
# Configure SpiriLink interface
|
||||
.PHONY: configure-spirilink
|
||||
configure-spirilink:
|
||||
@echo "\nConfiguring SpiriLink interface as spir0..."
|
||||
@if [ "$(DRIVER_TYPE)" = "EU" ]; then \
|
||||
echo "Loading 8812EU module..."; \
|
||||
$(SUDO) modprobe 8812eu || (echo "Error loading 8812EU module" && exit 1); \
|
||||
elif [ "$(DRIVER_TYPE)" = "AU" ]; then \
|
||||
echo "Loading 8812AU module..."; \
|
||||
$(SUDO) modprobe 8812au || (echo "Error loading 8812AU module" && exit 1); \
|
||||
else \
|
||||
echo "Error: Unknown driver type. Ensure DRIVER_TYPE is set to EU or AU."; \
|
||||
exit 1; \
|
||||
fi;
|
||||
|
||||
# Identify the wireless interface
|
||||
@echo "Configuring SpiriLink interface as spir0..."
|
||||
spirilink_iface=$$(iw dev | awk '$$1=="Interface"{print $$2}' | head -n 1); \
|
||||
if [ -z "$$spirilink_iface" ]; then \
|
||||
echo "Error: SpiriLink interface not detected."; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
echo "Detected SpiriLink interface: $$spirilink_iface"; \
|
||||
$(SUDO) ip link set $$spirilink_iface down; \
|
||||
$(SUDO) ip link set $$spirilink_iface name spir0; \
|
||||
$(SUDO) ip link set spir0 up;
|
||||
|
||||
# Add spir0 to unmanaged devices in NetworkManager
|
||||
mac_address=$$(cat /sys/class/net/$$spirilink_iface/address); \
|
||||
echo "Detected MAC address: $$mac_address"; \
|
||||
echo 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="'$$mac_address'", NAME="spir0"' | $(SUDO) tee /etc/udev/rules.d/99-spirilink.rules; \
|
||||
$(SUDO) udevadm control --reload-rules; \
|
||||
$(SUDO) udevadm trigger;
|
||||
@echo "Adding spir0 to unmanaged devices in NetworkManager..."
|
||||
$(SUDO) mkdir -p /etc/NetworkManager
|
||||
$(SUDO) touch /etc/NetworkManager/NetworkManager.conf
|
||||
@ -141,12 +127,9 @@ configure-spirilink:
|
||||
echo "unmanaged-devices=interface-name:spir0" | $(SUDO) tee -a /etc/NetworkManager/NetworkManager.conf > /dev/null; \
|
||||
fi
|
||||
$(SUDO) systemctl restart NetworkManager
|
||||
|
||||
# Configure wifibroadcast to use spir0
|
||||
@echo "Configuring wifibroadcast default interface..."
|
||||
$(SUDO) bash -c 'echo "WFB_NICS=\"spir0\"" > /etc/default/wifibroadcast'
|
||||
|
||||
@echo "\nSpiriLink configuration complete."
|
||||
@echo "SpiriLink configuration complete."
|
||||
|
||||
# Install SpiriLink software
|
||||
.PHONY: spirilink-software
|
||||
|
Loading…
Reference in New Issue
Block a user