diff --git a/hardware/omnia/omnia-5g-kit/Makefile b/hardware/omnia/omnia-5g-kit/Makefile new file mode 100644 index 000000000..f76401b38 --- /dev/null +++ b/hardware/omnia/omnia-5g-kit/Makefile @@ -0,0 +1,68 @@ +# +# Copyright (C) 2024 CZ.NIC z.s.p.o. (http://www.nic.cz/) +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=omnia-5g-kit +PKG_VERSION:=v0.1 +PKG_RELEASE:=$(AUTORELEASE) + +PKG_MAINTAINER:=CZ.NIC +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk + +define Package/omnia-5g-kit + TITLE:=Support for Turris Omnia 5G kit + DEPENDS:=@TARGET_mvebu_cortexa9_DEVICE_cznic_turris-omnia +nor-update + CONFLICTS:=modem-manager-autosetup modem-manager +endef + +define Package/omnia-5g-kit/description +This package switches internal mPCIe slot into USB3 mode, reconfigures GSM +network to work with our Quectell RM500U-EA 5G modem and also connects to the +internet on every boot. +endef + +define Build/Compile + true +endef + +define Package/omnia-5g-kit/install + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/5g-kit.init $(1)/etc/init.d/5g-kit +endef + +define Package/omnia-5g-kit/postinst +#!/bin/sh +[ -n "$$IPKG_INSTROOT" ] || { + /etc/init.d/5g-kit start + uci batch << EOF +delete network.gsm +set network.gsm=interface +set network.gsm.proto='dhcp' +set network.gsm.device='usb0' +set network.gsm.metric=2048 +set network.gsm.ip6ifaceid='eui64' +set network.gsm.ip6assign='64 +set network.gsm6=interface +set network.gsm6.device='@gsm' +set network.gsm6.proto='dhcpv6'' +EOF +} + + +define Package/omnia-5g-kit/prerm +#!/bin/sh +[ -n "$$IPKG_INSTROOT" ] || { + fw_setenv omnia_wwan_slot pcie + uci -q delete network.gsm + uci -q delete network.gsm6 +} +endef + +$(eval $(call BuildPackage,omnia-5g-kit)) diff --git a/hardware/omnia/omnia-5g-kit/files/5g-kit.init b/hardware/omnia/omnia-5g-kit/files/5g-kit.init new file mode 100644 index 000000000..e5299f8a8 --- /dev/null +++ b/hardware/omnia/omnia-5g-kit/files/5g-kit.init @@ -0,0 +1,28 @@ +#!/bin/sh /etc/rc.common + +START=95 +STOP=05 + +start() { + local limit=0 + if [ "$(fw_printenv omnia_wwan_slot)" != "omnia_wwan_slot=usb3" ]; then + nor-update + fw_setenv omnia_wwan_slot usb3 + create_notification -s restart "Please reboot your router to complete 5G kit installation" + return 0 + fi + while [ ! -e /dev/ttyUSB2 ] && [ "$limit" -lt 20 ]; do + sleep 1 + limit="$((limit + 1))" + done + if [ -e /dev/ttyUSB2 ]; then + echo -ne 'ATZ\r\n' > /dev/ttyUSB2 + echo -ne 'AT+CGDATA="M-ETHER",1\r\n' > /dev/ttyUSB2 + fi +} + +stop() { + if [ -e /dev/ttyUSB2 ]; then + echo -ne 'ATZ\r\n' > /dev/ttyUSB2 + fi +}