diff --git a/hardware/omnia/omnia-5g-kit/Makefile b/hardware/omnia/omnia-5g-kit/Makefile new file mode 100644 index 000000000..213af5750 --- /dev/null +++ b/hardware/omnia/omnia-5g-kit/Makefile @@ -0,0 +1,103 @@ +# +# 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 \ + +turris-nor-update \ + +mwan3 +watchcat \ + +luci-app-mwan3 +luci-app-watchcat \ + +kmod-usb-net-cdc-ncm +kmod-usb-serial-option + 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 -q delete network.gsm || : + uci batch << EOF +set network.gsm=interface +set network.gsm.proto='dhcp' +set network.gsm.device='usb0' +set network.gsm.metric=2048 +set network.gsm6=interface +set network.gsm6.device='@gsm' +set network.gsm6.proto='dhcpv6' +set network.gsm6.ip6ifaceid='eui64' +set network.gsm6.ip6assign='64' +set watchcat.5gkit='watchcat' +set watchcat.5gkit.period='30s' +set watchcat.5gkit.mode='restart_iface' +set watchcat.5gkit.pinghosts='1.1.1.1 8.8.8.8 9.9.9.9' +set watchcat.5gkit.interface='usb0' +EOF + uci commit network + uci commit watchcat + zone="$$(uci show firewall | sed -n 's|^\(firewall\.@zone.*\)\.name=.wan.$$|\1|p')" + if [ -n "$$zone" ]; then + if uci show "$$zone.network" | grep "='[^[:blank:]']\\+[[:blank:]][^[:blank:]']\\+.*'"; then + uci set "$$zone.network='$$(uci get "$$zone.network") gsm gsm6'" + else + uci add_list "$$zone.network=gsm" + uci add_list "$$zone.network=gsm6" + fi + uci commit firewall + fi +} +endef + + +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 || : + uci -q delete watchcat.5gkit || : + uci commit network + uci commit watchcat + zone="$$(uci show firewall | sed -n 's|^\(firewall\.@zone.*\)\.name=.wan.$$|\1|p')" + if [ -n "$$zone" ]; then + if uci show "$$zone.network" | grep "='[^[:blank:]']\\+[[:blank:]][^[:blank:]']\\+.*'"; then + uci set "$$zone.network='$$(uci get "$$zone.network" | sed 's| gsm gsm6||')'" + else + uci del_list "$$zone.network=gsm" + uci del_list "$$zone.network=gsm6" + fi + uci commit firewall + fi +} +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 +} diff --git a/hardware/omnia/omnia-eeprom/Makefile b/hardware/omnia/omnia-eeprom/Makefile new file mode 100644 index 000000000..f99f57d62 --- /dev/null +++ b/hardware/omnia/omnia-eeprom/Makefile @@ -0,0 +1,52 @@ +# +# 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-eeprom +PKG_VERSION:=v0.1 +PKG_RELEASE:=$(AUTORELEASE) + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 +PKG_SOURCE_URL:=https://gitlab.nic.cz/turris/$(PKG_NAME)/-/archive/$(PKG_VERSION)/ +PKG_HASH:=6f949d0b8080adca8bae088774ce615b563ba6ec2807cce97ee6769b4eee7bbf + +PKG_MAINTAINER:=CZ.NIC +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk + +define Package/omnia-eeprom + TITLE:=Utility to print / set EEPROM fields on Turris Omnia + DEPENDS:=@TARGET_mvebu_cortexa9_DEVICE_cznic_turris-omnia +endef + +define Package/omnia-eeprom/description +This package contains the omnia-eeprom utility, which allows you to display +and update EEPROM fields on the Turris Omnia router. +The EEPROM is normally not meant to be updated by users, but there are some +exceptions where it might be useful. +One such example is to change the DDR3 speed from the default 1600K mode to +1333H mode, in order to solve random crashes that occur on some boards with +newer versions of the U-Boot bootloader (because of bugs in newer versions of +the DDR training algorithm). +endef + +define Build/Compile + $(MAKE) -C $(PKG_BUILD_DIR) \ + CC="$(TARGET_CC)" \ + CFLAGS="$(TARGET_CFLAGS) -Wall" \ + LDFLAGS="$(TARGET_LDFLAGS)" \ + OMNIA_EEPROM_VERSION="$(PKG_VERSION)" +endef + +define Package/omnia-eeprom/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/omnia-eeprom $(1)/usr/bin/ +endef + +$(eval $(call BuildPackage,omnia-eeprom)) diff --git a/hardware/omnia/omnia-firmware/Makefile b/hardware/omnia/omnia-firmware/Makefile index bdca18682..dfab0c9d6 100644 --- a/hardware/omnia/omnia-firmware/Makefile +++ b/hardware/omnia/omnia-firmware/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=turris-omnia-firmware -PKG_VERSION:=1.2.1 +PKG_VERSION:=1.4 PKG_RELEASE:=$(AUTORELEASE) PKG_MAINTAINER:=CZ.NIC @@ -17,7 +17,7 @@ include $(INCLUDE_DIR)/package.mk define Package/turris-omnia-firmware TITLE:=Firmware for Turris Omnia - DEPENDS:=@TARGET_mvebu_cortexa9_DEVICE_cznic_turris-omnia + DEPENDS:=@TARGET_mvebu_cortexa9_DEVICE_cznic_turris-omnia +omnia-eeprom PROVIDES:=turris-nor-update-firmware endef @@ -27,10 +27,10 @@ endef define Package/turris-omnia-devel-firmware TITLE:=Data files for nor-update (development version) - DEPENDS:=+turris-nor-update +rescue-image +u-boot-omnia @TARGET_mvebu_cortexa9_DEVICE_cznic_turris-omnia + DEPENDS:=+turris-nor-update +rescue-image +u-boot-omnia @TARGET_mvebu_cortexa9_DEVICE_cznic_turris-omnia +turris-omnia-firmware PROVIDES:=turris-nor-update-devel-firmware VERSION:=0.0 - RELEASE:=1 + RELEASE:=2 endef define Package/turris-omnia-devel-firmware/description diff --git a/hardware/omnia/omnia-firmware/files/config.sh b/hardware/omnia/omnia-firmware/files/config.sh index 95dfc8c00..8b79b4b20 100644 --- a/hardware/omnia/omnia-firmware/files/config.sh +++ b/hardware/omnia/omnia-firmware/files/config.sh @@ -5,4 +5,7 @@ UBOOT_DEVEL="/usr/share/omnia/uboot-devel" board_ubootenv_hook() { sed -i 's|btr\(load[[:blank:]]\+[^[:blank:]]\+[[:blank:]]\+[^[:blank:]]\+[[:blank:]]\+[^[:blank:]]\+[[:blank:]]\+\)\([^[:blank:]]\+\)[[:blank:]]\+\([^[:blank:];]\+\)|\1\3/\2|g' \ "$BACKUP_UBOOT_ENV" + if grep -q 'U-Boot 2015.10-rc2' /dev/mtd0; then + omnia-eeprom set ddr_speed 1333H + fi } diff --git a/hardware/omnia/omnia-firmware/files/uboot b/hardware/omnia/omnia-firmware/files/uboot index d382a3fc6..23f9966ac 100644 Binary files a/hardware/omnia/omnia-firmware/files/uboot and b/hardware/omnia/omnia-firmware/files/uboot differ diff --git a/hardware/omnia/omnia-mcutool/Makefile b/hardware/omnia/omnia-mcutool/Makefile index cbb886078..3ce818b18 100644 --- a/hardware/omnia/omnia-mcutool/Makefile +++ b/hardware/omnia/omnia-mcutool/Makefile @@ -22,8 +22,7 @@ include $(INCLUDE_DIR)/package.mk define Package/omnia-mcutool TITLE:=Tool to manage MCU on Turris Omnia - DEPENDS:=+omnia-mcu-firmware @TARGET_mvebu_cortexa9_DEVICE_cznic_turris-omnia - DEPENDS+=+libopenssl + DEPENDS:=+omnia-mcu-firmware +libopenssl @TARGET_mvebu_cortexa9_DEVICE_cznic_turris-omnia endef define Package/omnia-mcutool/description @@ -40,7 +39,7 @@ define Build/Compile $(MAKE) -C $(PKG_BUILD_DIR) \ CC="$(TARGET_CC)" \ CFLAGS="$(TARGET_CFLAGS) -Wall" \ - LDFLAGS="$(TARGET_LDFLAGS)" \ + LDFLAGS="$(TARGET_LDFLAGS) -lssl -lcrypto" \ MCUTOOL_VERSION="$(PKG_VERSION)" endef diff --git a/hardware/rescue-image/files/omnia.sh b/hardware/rescue-image/files/omnia.sh index 7299e304a..d6056412a 100644 --- a/hardware/rescue-image/files/omnia.sh +++ b/hardware/rescue-image/files/omnia.sh @@ -19,6 +19,8 @@ board_init() { idx="$(find_mtd_index u-boot-env)" if [ -n "$idx" ]; then echo "/dev/mtd${idx} 0x0 0x10000 0x10000" > /etc/fw_env.config + elif grep -q 'U-Boot 2015.10-rc2' /dev/mtd0; then + echo "/dev/mtd0 0xc0000 0x10000 0x40000" > /etc/fw_env.config else echo '/dev/mtd0 0xF0000 0x10000 0x10000' > /etc/fw_env.config fi diff --git a/updater/pkglists/Makefile b/updater/pkglists/Makefile index 494555c81..1a631f27a 100644 --- a/updater/pkglists/Makefile +++ b/updater/pkglists/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=pkglists -PKG_VERSION:=1.12 +PKG_VERSION:=1.13 PKG_RELEASE:=$(AUTORELEASE) PKG_MAINTAINER:=CZ.NIC diff --git a/updater/pkglists/files/definitions.json b/updater/pkglists/files/definitions.json index b6c402b3d..18c701dce 100644 --- a/updater/pkglists/files/definitions.json +++ b/updater/pkglists/files/definitions.json @@ -1,10 +1,17 @@ { "3g": { - "title": "Extensions of network protocols for 3G/4G/5G", + "title": "Extensions of network protocols for 3G/4G", "description": "Support for Turris Omnia and Turris MOX LTE pack. Nowadays installed automatically whenever needed.", "url": "https://wiki.turris.cz/doc/en/howto/lte_modem_install", "labels": ["deprecated"] }, +ifdef(`OMNIA',` + "5g-kit": { + "title": "Support for Turris Omnia 5G kit", + "description": "Support for Turris Omnia 5G kit. Reroutes front USB 3.0 to the internal slot to support it.", + "url": "https://docs.turris.cz/hw/omnia/5g", + "labels": ["experimental"] + },') "datacollect": { "title": "Advanced security & analytics - Turris Sentinel", "description": "Software for participation in threat detection program which provides distributed adaptive firewall and statistics.", diff --git a/utils/firmware-updater/Makefile b/utils/firmware-updater/Makefile index d4ed3e2f2..23798a55e 100644 --- a/utils/firmware-updater/Makefile +++ b/utils/firmware-updater/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=firmware-updater -PKG_VERSION:=1.1 +PKG_VERSION:=1.2 PKG_RELEASE:=$(AUTORELEASE) PKG_MAINTAINER:=CZ.NIC diff --git a/utils/firmware-updater/files/firmware-updater.sh b/utils/firmware-updater/files/firmware-updater.sh index 71bebf27e..b0be89628 100755 --- a/utils/firmware-updater/files/firmware-updater.sh +++ b/utils/firmware-updater/files/firmware-updater.sh @@ -2,9 +2,12 @@ [ -z "$ROOT_DIR" ] || [ "$ROOT_DIR" = "/" ] || exit 0 [ "0$(uci get pkglists.firmware_update.nor)" -ne 1 ] || \ nor-update -[ "0$(uci get pkglists.firmware_update.mcu)" -ne 1 ] || \ - [ ! -x /usr/bin/omnia-mcutool ] || \ - omnia-mcutool --upgrade +if [ "0$(uci get pkglists.firmware_update.mcu)" -eq 1 ] && \ + [ -x /usr/bin/omnia-mcutool ]; then + if ! omnia-mcutool --upgrade | grep -q 'Application firmware is up to date.'; then + create_notification -s restart "MCU firmware updated, please reboot the router!" + fi +fi [ "0$(uci get pkglists.firmware_update.factory)" -ne 1 ] || \ [ "$(schnapps factory-version | cut -f 1,2 -d .)" == "$(cut -f 1,2 -d . /etc/turris-version)" ] || \ schnapps update-factory > /dev/null 2>&1