[openwrt/openwrt] ath79: add support for Teltonika RUT230 v1

LEDE Commits lede-commits at lists.infradead.org
Wed Jun 30 12:39:57 PDT 2021


blocktrron pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/6cf1dfd7e1d6b5c6a94b87eb065408bb489574c0

commit 6cf1dfd7e1d6b5c6a94b87eb065408bb489574c0
Author: David Bauer <mail at david-bauer.net>
AuthorDate: Mon Jun 21 23:27:56 2021 +0200

    ath79: add support for Teltonika RUT230 v1
    
    This commit adds support for the Teltonika RUT230 v1, a Atheros AR9331
    based router with a Quectel UC20 UMTS modem.
    
    Hardware
    --------
    Atheros AR9331
    16 MB SPI-NOR XTX XT25F128B
    64M DDR2 memory
    Atheros AR9331 1T1R 802.11bgn Wireless
    Boootloader: pepe2k U-Boot mod
    
    Hardware-Revision
    -----------------
    There are two board revisions of the RUT230, a v0 and v1.
    
    A HW version is silkscreened on the top of the PCBs front side as well
    as shown in the Teltonika UI. However, this looks to be a different
    identifier, as the GPl dump shows this silkscreened / UI shown version
    are internally treated identically.
    
    Th following mapping has been obtained from the latest GPl dump.
    
    HW Ver   01 - 04 --> v0
    HW Ver > 05      --> v1
    
    My board was a HW Ver 09 and is treated as a v1.
    
    Installation
    ------------
    While attaching power, hold down the reset button and release it after
    the signal LEDs flashed 3 times.
    
    Attach your Computer with the devices LAN port and assign yourself the
    IPv4 address 192.168.1.10/24. Open a web browser, navigate to
    192.168.1.1. Upload the OpenWrt factory image.
    
    The device will install OpenWrt and automatically reboots afterwards.
    
    You can use the smae procedure with the stock firmware to return back to
    the vendor firmware.
    
    Signed-off-by: David Bauer <mail at david-bauer.net>
---
 .../linux/ath79/dts/ar9331_teltonika_rut230-v1.dts | 193 +++++++++++++++++++++
 .../ath79/generic/base-files/etc/board.d/01_leds   |   4 +
 target/linux/ath79/image/generic.mk                |  35 +++-
 3 files changed, 230 insertions(+), 2 deletions(-)

diff --git a/target/linux/ath79/dts/ar9331_teltonika_rut230-v1.dts b/target/linux/ath79/dts/ar9331_teltonika_rut230-v1.dts
new file mode 100644
index 0000000000..c394cf1cb8
--- /dev/null
+++ b/target/linux/ath79/dts/ar9331_teltonika_rut230-v1.dts
@@ -0,0 +1,193 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include "ar9331.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+	model = "Teltonika RUT230 v1";
+	compatible = "teltonika,rut230-v1", "qca,ar9331";
+
+	aliases {
+		label-mac-device = &wmac;
+		led-boot = &led_ss0;
+		led-failsafe = &led_ss0;
+		led-upgrade = &led_ss0;
+	};
+
+	keys {
+		compatible = "gpio-keys";
+
+		reset {
+			label = "reset";
+			linux,code = <KEY_RESTART>;
+			gpios = <&gpio 22 GPIO_ACTIVE_HIGH>;
+			debounce-interval = <60>;
+		};
+
+		input {
+			label = "input";
+			linux,code = <BTN_0>;
+			gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
+			debounce-interval = <60>;
+		};
+
+		sim-tray {
+			label = "sim-tray";
+			linux,code = <BTN_1>;
+			gpios = <&gpio 20 GPIO_ACTIVE_LOW>;
+			debounce-interval = <60>;
+		};
+	};
+
+	leds {
+		compatible = "gpio-leds";
+		pinctrl-names = "default";
+		pinctrl-0 = <&switch_led_disable_pins>;
+
+		led_ss0: signal-strength-0 {
+			label = "green:signal-strength-0";
+			gpios = <&gpio 23 GPIO_ACTIVE_HIGH>;
+		};
+
+		signal-strength-1 {
+			label = "green:signal-strength-1";
+			gpios = <&gpio 7 GPIO_ACTIVE_HIGH>;
+		};
+
+		signal-strength-2 {
+			label = "green:signal-strength-2";
+			gpios = <&gpio 6 GPIO_ACTIVE_HIGH>;
+		};
+
+		signal-strength-3 {
+			label = "green:signal-strength-3";
+			gpios = <&gpio 26 GPIO_ACTIVE_HIGH>;
+		};
+
+		signal-strength-4 {
+			label = "green:signal-strength4";
+			gpios = <&gpio 27 GPIO_ACTIVE_HIGH>;
+		};
+
+		2g {
+			label = "green:2g";
+			gpios = <&gpio 8 GPIO_ACTIVE_HIGH>;
+		};
+
+		3g {
+			label = "green:3g";
+			gpios = <&gpio 24 GPIO_ACTIVE_HIGH>;
+		};
+
+		lan {
+			label = "green:lan";
+			gpios = <&gpio 14 GPIO_ACTIVE_LOW>;
+			/* GPIO 13 - ACTIVE HIGH for hwrev 0 */
+		};
+
+		wan {
+			label = "green:wan";
+			gpios = <&gpio 17 GPIO_ACTIVE_LOW>;
+			/* GPIO 14 - ACTIVE HIGH for hwrev 0 */
+		};
+
+		/* 4G LED - GPIO21 ACTIVE_HIGH for RUT240 */
+	};
+
+	reg_usb_vbus: reg_usb_vbus {
+		compatible = "regulator-fixed";
+		regulator-name = "usb_vbus";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		gpio = <&gpio 19 GPIO_ACTIVE_HIGH>;
+		enable-active-high;
+	};
+};
+
+&eth0 {
+	status = "okay";
+
+	mtd-mac-address = <&config 0x0>;
+};
+
+&eth1 {
+	status = "okay";
+
+	mtd-mac-address = <&config 0x0>;
+	mtd-mac-address-increment = <1>;
+};
+
+&spi {
+	status = "okay";
+
+	flash at 0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <30000000>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition at 0 {
+				label = "u-boot";
+				reg = <0x0 0x20000>;
+				read-only;
+			};
+
+			config: partition at 20000 {
+				label = "config";
+				reg = <0x20000 0x10000>;
+				read-only;
+			};
+
+			art: partition at 30000 {
+				label = "art";
+				reg = <0x30000 0x10000>;
+				read-only;
+			};
+
+			partition at 40000 {
+				compatible = "tplink,firmware";
+				label = "firmware";
+				reg = <0x40000 0xf30000>;
+			};
+
+			partition at f70000 {
+				label = "event-log";
+				reg = <0xf70000 0x90000>;
+				read-only;
+			};
+		};
+	};
+};
+
+&usb {
+	dr_mode = "host";
+	vbus-supply = <&reg_usb_vbus>;
+	status = "okay";
+};
+
+&gpio {
+	modem-power {
+		gpio-hog;
+		output-low;
+		gpios = <18 GPIO_ACTIVE_HIGH>;
+		line-name = "modem-power";
+	};
+};
+
+&usb_phy {
+	status = "okay";
+};
+
+&wmac {
+	status = "okay";
+
+	mtd-cal-data = <&art 0x1000>;
+	mtd-mac-address = <&config 0x0>;
+	mtd-mac-address-increment = <2>;
+};
diff --git a/target/linux/ath79/generic/base-files/etc/board.d/01_leds b/target/linux/ath79/generic/base-files/etc/board.d/01_leds
index d8e3d65967..c844c70e46 100644
--- a/target/linux/ath79/generic/base-files/etc/board.d/01_leds
+++ b/target/linux/ath79/generic/base-files/etc/board.d/01_leds
@@ -276,6 +276,10 @@ qihoo,c301)
 samsung,wam250)
 	ucidef_set_led_netdev "lan" "LAN" "white:lan" "eth0"
 	;;
+teltonika,rut230-v1)
+	ucidef_set_led_netdev "wan" "WAN" "green:wan" "eth1"
+	ucidef_set_led_switch "lan" "LAN" "green:lan" "switch0" "0x04"
+	;;
 tplink,archer-a7-v5|\
 tplink,archer-c7-v4|\
 tplink,archer-c7-v5)
diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk
index 9d0be2b86b..ab875bd220 100644
--- a/target/linux/ath79/image/generic.mk
+++ b/target/linux/ath79/image/generic.mk
@@ -142,11 +142,20 @@ define Build/teltonika-fw-fake-checksum
 	# from begin of the firmware file) with 16 bytes stored just before
 	# 0xdeadc0de marker. Values are only compared, MD5 sum is not verified.
 	let \
-		offs="$$(stat -c%s $@) - 20"; \
+		offs="$$(stat -c%s $@) - $(1)"; \
 		dd if=$@ bs=1 count=16 skip=76 |\
 		dd of=$@ bs=1 count=16 seek=$$offs conv=notrunc
 endef
 
+define Build/teltonika-v1-header
+	$(STAGING_DIR_HOST)/bin/mktplinkfw \
+		-c -H $(TPLINK_HWID) -W $(TPLINK_HWREV) -L $(KERNEL_LOADADDR) \
+		-E $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
+		-m $(TPLINK_HEADER_VERSION) -N "$(VERSION_DIST)" -V "RUT2xx      " \
+		-k $@ -o $@.new $(1)
+	@mv $@.new $@
+endef
+
 define Build/wrgg-pad-rootfs
 	$(STAGING_DIR_HOST)/bin/padjffs2 $(IMAGE_ROOTFS) -c 64 >>$@
 endef
@@ -2182,6 +2191,28 @@ define Device/telco_t1
 endef
 TARGET_DEVICES += telco_t1
 
+define Device/teltonika_rut230-v1
+  SOC := ar9331
+  DEVICE_VENDOR := Teltonika
+  DEVICE_MODEL := RUT230
+  DEVICE_VARIANT := v1
+  DEVICE_PACKAGES := kmod-usb-chipidea2 kmod-usb-acm kmod-usb-net-qmi-wwan \
+	uqmi -uboot-envtools
+  IMAGE_SIZE := 15552k
+  TPLINK_HWID := 0x32200002
+  TPLINK_HWREV := 0x1
+  TPLINK_HEADER_VERSION := 1
+  KERNEL := kernel-bin | append-dtb | lzma | teltonika-v1-header
+  KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | uImage lzma
+  IMAGES += factory.bin
+  IMAGE/factory.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs |\
+	pad-rootfs | pad-extra 64 | teltonika-fw-fake-checksum 54 | check-size
+  IMAGE/sysupgrade.bin := append-kernel | pad-to $$$$(BLOCKSIZE) |\
+	append-rootfs | pad-rootfs | append-metadata |\
+	check-size
+endef
+TARGET_DEVICES += teltonika_rut230-v1
+
 define Device/teltonika_rut955
   SOC := ar9344
   DEVICE_VENDOR := Teltonika
@@ -2196,7 +2227,7 @@ define Device/teltonika_rut955
   KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | uImage lzma
   IMAGES += factory.bin
   IMAGE/factory.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs |\
-	pad-rootfs | teltonika-fw-fake-checksum | append-string master |\
+	pad-rootfs | teltonika-fw-fake-checksum 20 | append-string master |\
 	append-md5sum-bin | check-size
   IMAGE/sysupgrade.bin := append-kernel | pad-to $$$$(BLOCKSIZE) |\
 	append-rootfs | pad-rootfs | append-metadata |\



More information about the lede-commits mailing list