From patchwork Wed Aug 19 02:34:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ataberk_=C3=96zen?= X-Patchwork-Id: 1347409 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=Pc+GGqPM; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=hCao9djk; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BWX3Q0T8yz9sPf for ; Wed, 19 Aug 2020 12:36:33 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=cxAOSem3bzifte+El7mAJeDOom72cK8h6deOp2yFCbU=; b=Pc+GGqPM+fz2BEjitrlTyd4r/G fuKmxUmFQL9XV+o/TsmCDLnUjbekx5y8OTrVnq8UXqW37cgS8uKkC2963qUsF8nZbpRNdGvoLubgk nwQf1n4WB/LzFK1UHHkLegWfhqgKDPBLVCHM7738keHrvftoKkk9/h/cKWmifbxJAdjiK6fa7yBab 2eNpjTgiYhAWfJJ4COlR82Phncm0FdbIEK42c8UuSMpkKLyHMAPaB62EQtlTcitEjDpXj6TnAXGpg TMYkAPk916YL51/OTROVZ84vGgxSuaYk+D+HYl8oOriHC7KahrNGM2hJhOLZd3Dhnkbyjlvhgo6yL C7Czl8Pg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k8Dw4-00054k-RP; Wed, 19 Aug 2020 02:34:44 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k8Dw2-00054D-8z for openwrt-devel@lists.openwrt.org; Wed, 19 Aug 2020 02:34:43 +0000 Received: by mail-wm1-x343.google.com with SMTP id c80so673625wme.0 for ; Tue, 18 Aug 2020 19:34:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pz3u47HaBFRYvpTejCvTnrUuXCPWjgbO7ZsJUn8uk0Y=; b=hCao9djkcyi5Ro4rlp3Er9Zn4gzSPf2zLFQHCoimwfuPDJGmD6z8S/AZq+H7LL7Y7O UY9yuedRcUBadPwS1JD0AoGJjhufStO+zRycvbmG/+jvmL7zIaEZ57oN8GY5YRluzfHO QNtbtMfn52wl3JiE41CNklSA8XFvwhmkUtpX6BVDmXXO17r4/ElgG1v+USp+qevgnu7c 0KR/oLatwFuYGhZCKRhUtgsTW3vs2qJE9btazBmDhqiP5Z78uDBNpFYRtkXN+sSO84UW VIPOyinDaSFzvM6/dctYvbXeS4kHAdUDkLtOvUkwdtcspX0CxfapNetvFPxq+9Z8eYBl qdQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pz3u47HaBFRYvpTejCvTnrUuXCPWjgbO7ZsJUn8uk0Y=; b=hSpg6zpC78w+pXTCPUy4r8mILqkm0djTcFIsfGVVsGNXjrUX6Zd0VTEdGjik5zf8fI iwWgEsmtx0FZzZVpDEPpBi7IyrOHrCxv0mVw5ky/aDmtCNOduG+lNrNwd1q7v6BUfsRO S5YBsggfQh4/on5iK43LZA7e2+Y22uT4+tOps7BKaHQNfTO4crVPUT38DNwfSBQFxJ+2 ujaRGCPoi8UETiYsTSfRZcRxa7z1+MF6n8mvEl6kKxuoX8NwKJj9aVPOT77x60Ij05Dr S9+rZ8x40hoZwBVLkhkfD6A8qHGP/EWMb4+69VqRGE6T+6CbO54/RudkQEDGqza1+myF 50Tw== X-Gm-Message-State: AOAM5335a8RgUjCojOvfp0JUV9WWz4/qRwzfUMVu2tMQ2yEuSP5+tfn9 O9Ry6Q7fq8c8Lg48zrX9K7WPjGi91QthTfK/ X-Google-Smtp-Source: ABdhPJzSB6V0xdLvAIyMCKv8dVWBFUWxEinx4VP2a5XjKanANbU2hUulw8ucMf185ELBjEo63wk+jw== X-Received: by 2002:a1c:2e42:: with SMTP id u63mr2529181wmu.27.1597804480816; Tue, 18 Aug 2020 19:34:40 -0700 (PDT) Received: from DESKTOP-0R2U9KO.localdomain ([212.125.17.5]) by smtp.gmail.com with ESMTPSA id f16sm38429590wro.34.2020.08.18.19.34.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Aug 2020 19:34:40 -0700 (PDT) From: ataberkozen123@gmail.com To: openwrt-devel@lists.openwrt.org Subject: [PATCH v3] ramips: add support for Xiaomi Mi Router 4C Date: Wed, 19 Aug 2020 05:34:34 +0300 Message-Id: <1597804474-2661-1-git-send-email-ataberkozen123@gmail.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200818_223442_328742_7FD88900 X-CRM114-Status: GOOD ( 17.48 ) X-Spam-Score: 0.1 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:343 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [ataberkozen123[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [ataberkozen123[at]gmail.com] -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Ataberk_=C3=96zen?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Ataberk Özen This commit adds support for Xiaomi's Mi Router 4C device. Specifications: - CPU: MediaTek MT7628AN (580MHz) - Flash: 16MB - RAM: 64MB DDR2 - 2.4 GHz: IEEE 802.11b/g/n with Integrated LNA and PA - Antennas: 4x external single band antennas - WAN: 1x 10/100M - LAN: 2x 10/100M - LEDs: 2x yellow/blue. Programmable (labelled as power on case) - Non-programmable (shows WAN activity) - Button: Reset How to install: 1- Use OpenWRTInvasion to gain telnet and ftp access. 2- Push openwrt firmware to /tmp/ using ftp. 3- Connect to router using telnet. (IP: 192.168.31.1 - Username: root - No password) 4- Use command "mtd -r write /tmp/firmware.bin OS1" to flash into the router.. 5- It takes around 2 minutes. After that router will restart itself to OpenWrt. Signed-off-by: Ataberk Özen --- package/boot/uboot-envtools/files/ramips | 1 + .../ramips/dts/mt7628an_xiaomi_mi-router-4c.dts | 134 +++++++++++++++++++++ target/linux/ramips/image/mt76x8.mk | 8 ++ .../mt76x8/base-files/etc/board.d/02_network | 7 +- .../ramips/mt76x8/base-files/etc/init.d/bootcount | 1 + 5 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 target/linux/ramips/dts/mt7628an_xiaomi_mi-router-4c.dts diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips index 80a91f0..18edc5a 100644 --- a/package/boot/uboot-envtools/files/ramips +++ b/package/boot/uboot-envtools/files/ramips @@ -29,6 +29,7 @@ buffalo,wsr-1166dhp|\ buffalo,wsr-600dhp|\ mediatek,linkit-smart-7688|\ samknows,whitebox-v8|\ +xiaomi,mi-router-4c|\ xiaomi,miwifi-nano|\ zbtlink,zbt-wg2626) ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x10000" diff --git a/target/linux/ramips/dts/mt7628an_xiaomi_mi-router-4c.dts b/target/linux/ramips/dts/mt7628an_xiaomi_mi-router-4c.dts new file mode 100644 index 0000000..0ff88fe --- /dev/null +++ b/target/linux/ramips/dts/mt7628an_xiaomi_mi-router-4c.dts @@ -0,0 +1,134 @@ +//SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include "mt7628an.dtsi" + +#include +#include + +/ { + compatible = "xiaomi,mi-router-4c", "mediatek,mt7628an-soc"; + model = "Xiaomi Mi Router 4C"; + + aliases { + led-boot = &led_power_yellow; + led-failsafe = &led_power_yellow; + led-running = &led_power_blue; + led-upgrade = &led_power_yellow; + label-mac-device = ðernet; + }; + + chosen { + bootargs = "console=ttyS0,115200"; + }; + + leds { + compatible = "gpio-leds"; + + led_power_blue: power_blue { + label = "mi-router-4c:blue:power"; + gpios = <&gpio 11 GPIO_ACTIVE_LOW>; + }; + + led_power_yellow: power_yellow { + label = "mi-router-4c:yellow:power"; + gpios = <&gpio 44 GPIO_ACTIVE_LOW>; + }; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio 38 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; +}; + +&state_default { + gpio { + groups = "gpio", "wdt", "wled_an"; + function = "gpio"; + }; +}; + +&ehci { + status = "disabled"; +}; + +&ohci { + status = "disabled"; +}; + +&esw { + mediatek,portmap = <0x3d>; + mediatek,portdisable = <0x29>; +}; + +&wmac { + status = "okay"; +}; + +ðernet { + mtd-mac-address = <&factory 0x28>; +}; + +&spi0 { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <40000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "bootloader"; + reg = <0x0 0x20000>; + read-only; + }; + + partition@20000 { + label = "config"; + reg = <0x20000 0x10000>; + read-only; + }; + + factory: partition@30000 { + label = "factory"; + reg = <0x30000 0x10000>; + read-only; + }; + + partition@40000 { + label = "crash"; + reg = <0x40000 0x10000>; + read-only; + }; + + partition@50000 { + label = "cfg_bak"; + reg = <0x50000 0x10000>; + read-only; + }; + + partition@60000 { + label = "overlay"; + reg = <0x60000 0x100000>; + read-only; + }; + + partition@160000 { + label = "firmware"; + reg = <0x160000 0xea0000>; + compatible = "denx,uimage"; + }; + }; + }; +}; diff --git a/target/linux/ramips/image/mt76x8.mk b/target/linux/ramips/image/mt76x8.mk index 908e2df..f35b332 100644 --- a/target/linux/ramips/image/mt76x8.mk +++ b/target/linux/ramips/image/mt76x8.mk @@ -680,6 +680,14 @@ define Device/xiaomi_mir4a-100m endef TARGET_DEVICES += xiaomi_mir4a-100m +define Device/xiaomi_mi-router-4c + IMAGE_SIZE := 14976k + DEVICE_VENDOR := Xiaomi + DEVICE_MODEL := Mi Router 4C + DEVICE_PACKAGES := uboot-envtools +endef +TARGET_DEVICES += xiaomi_mi-router-4c + define Device/xiaomi_miwifi-nano IMAGE_SIZE := 16064k DEVICE_VENDOR := Xiaomi diff --git a/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network index 5a5ba58..8295d92 100755 --- a/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network @@ -124,7 +124,11 @@ ramips_setup_interfaces() ;; xiaomi,mir4a-100m) ucidef_add_switch "switch0" \ - "4:lan:1" "2:lan:2" "0:wan" "6@eth0" + "2:lan:2" "4:lan:1" "1:wan" "6@eth0" + ;; + xiaomi,mi-router-4c) + ucidef_add_switch "switch0" \ + "4:lan:1" "2:lan:2" "1:wan" "6@eth0" ;; xiaomi,miwifi-nano) ucidef_add_switch "switch0" \ @@ -222,6 +226,7 @@ ramips_setup_macs() label_mac=$(mtd_get_mac_binary factory 0x4) wan_mac=$(mtd_get_mac_binary factory 0x28) ;; + xiaomi,mi-router-4c|\ xiaomi,mir4a-100m) wan_mac=$(mtd_get_mac_binary factory 0x4) ;; diff --git a/target/linux/ramips/mt76x8/base-files/etc/init.d/bootcount b/target/linux/ramips/mt76x8/base-files/etc/init.d/bootcount index 3c21433..23f1e71 100755 --- a/target/linux/ramips/mt76x8/base-files/etc/init.d/bootcount +++ b/target/linux/ramips/mt76x8/base-files/etc/init.d/bootcount @@ -8,6 +8,7 @@ boot() { [ -n "$(fw_printenv bootcount bootchanged 2>/dev/null)" ] &&\ echo -e "bootcount\nbootchanged\n" | /usr/sbin/fw_setenv -s - ;; + xiaomi,mi-router-4c|\ xiaomi,miwifi-nano) fw_setenv flag_boot_success 1 ;;