Skip to content

Commit

Permalink
Merge branch 'feature/5g' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
miska committed Sep 9, 2024
2 parents f3308f1 + 7ee2ba3 commit eaf4fc9
Show file tree
Hide file tree
Showing 12 changed files with 210 additions and 13 deletions.
103 changes: 103 additions & 0 deletions hardware/omnia/omnia-5g-kit/Makefile
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
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))
28 changes: 28 additions & 0 deletions hardware/omnia/omnia-5g-kit/files/5g-kit.init
Original file line number Diff line number Diff line change
@@ -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
}
52 changes: 52 additions & 0 deletions hardware/omnia/omnia-eeprom/Makefile
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
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))
8 changes: 4 additions & 4 deletions hardware/omnia/omnia-firmware/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
Expand All @@ -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

Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions hardware/omnia/omnia-firmware/files/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Binary file modified hardware/omnia/omnia-firmware/files/uboot
Binary file not shown.
5 changes: 2 additions & 3 deletions hardware/omnia/omnia-mcutool/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 2 additions & 0 deletions hardware/rescue-image/files/omnia.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion updater/pkglists/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
Expand Down
9 changes: 8 additions & 1 deletion updater/pkglists/files/definitions.json
Original file line number Diff line number Diff line change
@@ -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.",
Expand Down
2 changes: 1 addition & 1 deletion utils/firmware-updater/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
Expand Down
9 changes: 6 additions & 3 deletions utils/firmware-updater/files/firmware-updater.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit eaf4fc9

Please sign in to comment.