From patchwork Tue Jun 8 09:45:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1489256 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) 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=bombadil.20210309 header.b=GsR4avKI; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 4FzllY2QGKz9sSn for ; Tue, 8 Jun 2021 19:47:37 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QeBPap0u47/4kb4OjbLyYK09kXH5h4V26MhFupNUlUM=; b=GsR4avKIKUSlLw YQI30XN0dlWk9v5SgM6ZroTk6CjASroJTiUFnngcfuBPedk78lTU59mXgtH3n4UDymll1FQPdsTZL yILPaoK/MG4jx3jV6G+x6XkgLNeKp0MTQTCltNOO3Vd+ejPc24ZXqydmsBSOYIiqrqkFgpEGAbI14 iFPDpbsMm/SRa9IjHjDnw6xocrNbnQi0W+MUYL/JkUqCKYcPMlmbhiIHWZ19YZUIDwZE+/GRSzo63 2z1/sGxhb6ApbtdcRYip8pIp55C+6ROEqlw68LVsRngXD3uRxx/ppYMS/FGEQI0sUu0YBiPPsYsll 8uLz6mpFgwpJYqOJwkcg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqYIp-007UpQ-OS; Tue, 08 Jun 2021 09:45:43 +0000 Received: from smtp-out.xnet.cz ([178.217.244.18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqYIU-007Uht-P4 for openwrt-devel@lists.openwrt.org; Tue, 08 Jun 2021 09:45:26 +0000 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id 587AA18940; Tue, 8 Jun 2021 11:45:17 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id adae1c7e; Tue, 8 Jun 2021 11:44:51 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Cc: =?utf-8?q?Bj=C3=B8rn_Mork?= Subject: [PATCH 21.02 01/11] firmware-utils: zytrx: Add util for ZyXEL specific header Date: Tue, 8 Jun 2021 11:45:02 +0200 Message-Id: <20210608094512.29956-2-ynezz@true.cz> In-Reply-To: <20210608094512.29956-1-ynezz@true.cz> References: <20210608094512.29956-1-ynezz@true.cz> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210608_024523_055712_F21CD783 X-CRM114-Status: GOOD ( 27.44 ) X-Spam-Score: 0.0 (/) X-Spam-Report: =?unknown-8bit?q?Spam_detection_software=2C_running_on_the_sy?= =?unknown-8bit?q?stem_=22bombadil=2Einfradead=2Eorg=22=2C?= =?unknown-8bit?q?_has_NOT_identified_this_incoming_email_as_spam=2E__The_ori?= =?unknown-8bit?q?ginal?= =?unknown-8bit?q?_message_has_been_attached_to_this_so_you_can_view_it_or_la?= =?unknown-8bit?q?bel?= =?unknown-8bit?q?_similar_future_email=2E__If_you_have_any_questions=2C_see?= =?unknown-8bit?q?_the_administrator_of_that_system_for_details=2E?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_preview=3A__From=3A_Bj=C3=B8rn_Mork_=3Cbjorn=40mor?= =?unknown-8bit?q?k=2Eno=3E_The_ZyXEL_NR7101_prepend?= =?unknown-8bit?q?_an_additional_header_to_U-Boot_images=2E_This_header_use_t?= =?unknown-8bit?q?he_TRX_magic_0x30524448?= =?unknown-8bit?q?_=28HDR0=29=2C_but_is_incompatible_with_TRX_images=2E_This_?= =?unknown-8bit?q?code_is_reverse-engineered?= =?unknown-8bit?q?_based_on_matching_32_bit_numbers_found_in_the_header_with_?= =?unknown-8bit?q?lengths_and_different?= =?unknown-8bit?q?_checksum_calculations_of_the_vendor_images_found_on_the_de?= =?unknown-8bit?q?vice=2E_The_result?= =?unknown-8bit?b?IHdhcyBtYXRjaGVkIGEgWy4uLl0g?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_analysis_details=3A___=280=2E0_points=2C_5=2E0_req?= =?unknown-8bit?q?uired=29?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_pts_rule_name______________description?= =?unknown-8bit?q?_----_----------------------_------------------------------?= =?unknown-8bit?q?--------------------?= =?unknown-8bit?q?_0=2E0_SPF=5FNONE_______________SPF=3A_sender_does_not_publ?= =?unknown-8bit?q?ish_an_SPF_Record?= =?unknown-8bit?q?_0=2E0_SPF=5FHELO=5FNONE__________SPF=3A_HELO_does_not_publ?= =?unknown-8bit?q?ish_an_SPF_Record?= X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Bjørn Mork The ZyXEL NR7101 prepend an additional header to U-Boot images. This header use the TRX magic 0x30524448 (HDR0), but is incompatible with TRX images. This code is reverse-engineered based on matching 32 bit numbers found in the header with lengths and different checksum calculations of the vendor images found on the device. The result was matched against the validation output produced by the bootloader to name the associated header fields. Example bootloader validation output: Zyxel TRX Image 1 --> Found! Header Checksum OK ============ZyXEL header information================== chipId : MT7621A boardId : NR7101 modelId : 07 01 00 01 kernel_len : (14177560) kernelChksum : (0x8DD31F69) swVersionInt : 1.00(ABUV.0)D1 swVersionExt : 1.00(ABUV.0)D1 Zyxel TRX Image 2 --> Found! Header Checksum OK ============ZyXEL header information================== chipId : MT7621A boardId : NR7101 modelId : 07 01 00 01 kernel_len : (14176660) kernelChksum : (0x951A7637) swVersionInt : 1.00(ABUV.0)D0 swVersionExt : 1.00(ABUV.0)D0 ================================================= Check image validation: Image1 Header Magic Number --> OK Image2 Header Magic Number --> OK Image1 Header Checksum --> OK Image2 Header Checksum --> OK Image1 Data Checksum --> OK Image2 Data Checksum --> OK Image1 Stable Flag --> Stable Image1 Try Counter --> 0 Image1: OK Image2: OK The coverage and algorithm for the kernelChksum field is unknown. This field is not validated by the bootloader or the OEM firmware upgrade tool. It is therefore set to a static value for now. The swVersion fields contain free form string values. The OEM firmware use ZyXEL structured version numbers as shown above. The strings are not interpreted or validated on boot, so they can be repurposed for anything we want the bootloader to display to the user. But the OEM web GUI fails to flash images with freeform strings. The purpose of the other strings in the header is not known. The values appear to be static. We assume they are fixed for now, until we have other examples. One of these strings is the platform name, which is taken as an input parameter for support other members of the device family. Signed-off-by: Bjørn Mork (cherry picked from commit 48cad07a55246317d66fee4ced25cb62a2bae3d3) Tested-by: Bjørn Mork # ZyXEL NR7101 --- tools/firmware-utils/Makefile | 1 + tools/firmware-utils/src/zytrx.c | 226 +++++++++++++++++++++++++++++++ 2 files changed, 227 insertions(+) create mode 100644 tools/firmware-utils/src/zytrx.c diff --git a/tools/firmware-utils/Makefile b/tools/firmware-utils/Makefile index 28f8f0555a55..cec8398a27d5 100644 --- a/tools/firmware-utils/Makefile +++ b/tools/firmware-utils/Makefile @@ -97,6 +97,7 @@ define Host/Compile $(call cc,wrt400n cyg_crc32) $(call cc,xorimage) $(call cc,zyimage,-Wall) + $(call cc,zytrx,-Wall) $(call cc,zyxbcm) endef diff --git a/tools/firmware-utils/src/zytrx.c b/tools/firmware-utils/src/zytrx.c new file mode 100644 index 000000000000..302efc601065 --- /dev/null +++ b/tools/firmware-utils/src/zytrx.c @@ -0,0 +1,226 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * zytrx - add header to images for ZyXEL NR7101 + * + * Based on add_header.c - partially based on OpenWrt's + * motorola-bin.c + * + * Copyright (C) 2008 Imre Kaloz + * Gabor Juhos + * Copyright (C) 2021 Bjørn Mork + + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License, + * version 2 as published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BPB 8 /* bits/byte */ + +static uint32_t crc32[1<> 1)) : (crc >> 1); + crc32[n] = crc; + } +} + +static uint32_t crc32buf(const unsigned char *buf, size_t len) +{ + uint32_t crc = 0xFFFFFFFF; + + for (; len; len--, buf++) + crc = crc32[(uint8_t)crc ^ *buf] ^ (crc >> BPB); + return ~crc; +} + +/* HDR0 reversed, to be stored as BE */ +#define MAGIC 0x30524448 /* HDR0 reversed, to be stored as BE */ + +/* All numbers are stored as BE */ +struct zytrx_t { + uint32_t magic; + uint32_t len_h; /* Length of this header */ + uint32_t len_t; /* Total length of file */ + uint32_t crc32_p; /* Bit inverted 32-bit CRC of image payload */ + uint8_t verInt[32]; /* String "5.0.0.0\n" zero padded */ + uint8_t verExt[32]; /* String "\n" zero padded */ + uint32_t len_p; /* Length of image payload */ + uint8_t pad1[12]; /* zero padding(?) */ + uint8_t code[164]; /* string "3 6035 122 0\n" zero padded */ + uint8_t chipid[8]; /* string "MT7621A" zero padded */ + uint8_t boardid[16]; /* string "NR7101" zero padded */ + uint32_t modelid; /* modelid as 4 BCD digits: 0x07010001 */ + uint8_t pad2[8]; /* zero padding(?) */ + uint8_t swVersionInt[32]; /* ZyXEL version string: "1.00(ABUV.0)D0" zero padded */ + uint8_t swVersionExt[32]; /* identical to swVersionInt */ + uint8_t pad4[4]; /* zero padding(?) */ + uint32_t kernelChksum; /* no idea how this is computed - reported but not validated */ + uint8_t pad5[4]; /* zero padding(?) */ + uint32_t crc32_h; /* Bit inverted 32-bit CRC of this header payload */ + uint8_t pad6[4]; /* zero padding(?) */ +}; + +/* static?() field values of unknown meaning - maybe ove to board + * table when we know the significance + */ +#define VER_INT "5.0.0.0\n" +#define VER_EXT "\n" +#define CODE "3 6035 122 0\n" +#define KERNELCHKSUM 0x12345678 + +/* table of supported devices using this header format */ +static struct board_t { + uint8_t chipid[8]; + uint8_t boardid[16]; + uint32_t modelid; +} boards[] = { + { "MT7621A", "NR7101", 0x07010001 }, + {} +}; + +static int find_board(struct zytrx_t *h, char *board) +{ + struct board_t *p; + + for (p = boards; p->modelid; p++) { + if (strncmp((const char *)p->boardid, board, sizeof(p->boardid))) + continue; + memcpy(h->chipid, p->chipid, sizeof(h->chipid)); + memcpy(h->boardid, p->boardid, sizeof(h->boardid)); + h->modelid = htonl(p->modelid); + return 0; + } + return -1; +} + +static void usage(const char *name) +{ + struct board_t *p; + + fprintf(stderr, "Usage:\n"); + fprintf(stderr, " %s -B -v -i [-o ]\n\n", name); + fprintf(stderr, "Supported values:\n"); + for (p = boards; p->modelid; p++) + fprintf(stderr, "\t%-12s\n", p->boardid); + fprintf(stderr, "\nExample:\n"); + fprintf(stderr, " %s -B %s -v foobar-1.0 -i my.img -o out.img\n\n", name, + boards[0].boardid); + exit(EXIT_FAILURE); +} + +static void errexit(const char *msg) +{ + fprintf(stderr, "ERR: %s: %s\n", msg, errno ? strerror(errno) : "unknown"); + exit(EXIT_FAILURE); +} + +static void *map_input(const char *name, size_t *len) +{ + struct stat stat; + void *mapped; + int fd; + + fd = open(name, O_RDONLY); + if (fd < 0) + return NULL; + if (fstat(fd, &stat) < 0) { + close(fd); + return NULL; + } + *len = stat.st_size; + mapped = mmap(NULL, stat.st_size, PROT_READ, MAP_SHARED, fd, 0); + if (close(fd) < 0) + return NULL; + return mapped; +} + +int main(int argc, char **argv) +{ + int c, fdout = STDOUT_FILENO; + void *input_file = NULL; + size_t file_len, len; + uint32_t crc; + struct zytrx_t h = { + .magic = htonl(MAGIC), + .len_h = htonl(sizeof(h)), + .verInt = VER_INT, + .verExt = VER_EXT, + .code = CODE, + .kernelChksum = htonl(KERNELCHKSUM), + }; + + while ((c = getopt(argc, argv, "B:v:i:o:")) != -1) { + switch (c) { + case 'B': + if (find_board(&h, optarg) < 0) + errexit("unsupported board"); + break; + case 'v': + len = strlen(optarg); + if (len > sizeof(h.swVersionInt)) + errexit("version string too long"); + memcpy(h.swVersionInt, optarg, len); + memcpy(h.swVersionExt, optarg, len); + break; + case 'i': + input_file = map_input(optarg, &file_len); + if (!input_file) + errexit(optarg); + break; + case 'o': + fdout = open(optarg, O_WRONLY | O_CREAT, 0644); + if (fdout < 0) + errexit(optarg); + break; + default: + usage(argv[0]); + } + } + + /* required paremeters */ + if (!input_file || !h.modelid || !h.swVersionInt[0]) + usage(argv[0]); + + /* length fields */ + h.len_t = htonl(sizeof(h) + file_len); + h.len_p = htonl(file_len); + + /* crc fields */ + init_crc32(); + crc = crc32buf(input_file, file_len); + h.crc32_p = htonl(~crc); + crc = crc32buf((unsigned char *)&h, sizeof(h)); + h.crc32_h = htonl(~crc); + + /* dump new image */ + write(fdout, &h, sizeof(h)); + write(fdout, input_file, file_len); + + /* close files */ + munmap(input_file, file_len); + if (fdout != STDOUT_FILENO) + close(fdout); + + return EXIT_SUCCESS; +} From patchwork Tue Jun 8 09:45:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1489255 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) 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=bombadil.20210309 header.b=AImQF2bN; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 4FzllV6Dvjz9sWF for ; Tue, 8 Jun 2021 19:47:34 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tWKVqrcKYL48M/0ypH8fR43I8agiJezoiKmFjQOrlzg=; b=AImQF2bNiHU/GA j6i9sGO0P5pUPNdjmec1x7qtzmYachm9mLxOXvhg6Esb/4IQygK+hbsQAzNZEtnABp6hUAZaCguqU Z43aF9R1OOqa/G0T/HBCySbfW205qXU3U9AtLGAtvOjfuUmuL8LUHXvLbnx18xJaCwHpwBI5HzkEV gLTJsAud7k9WVEIAtGmsBDynqY2qJaYVoBqeNtPo96uVTw5UP4zP/963PHQYPAmt4jVEmjhe9CU/H RxqkuLAR9y2FkdupbEldTh4dBaS4ox90Wy0YJF107MbfZ8xGCjK+KHXDA+snQx7wCvnUs68BGabYp OzC91eEE248dK9VW6QsQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqYIZ-007Ukj-3y; Tue, 08 Jun 2021 09:45:27 +0000 Received: from smtp-out.xnet.cz ([178.217.244.18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqYIU-007Uhz-OA for openwrt-devel@lists.openwrt.org; Tue, 08 Jun 2021 09:45:24 +0000 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id D600F18941; Tue, 8 Jun 2021 11:45:17 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id f31d11f7; Tue, 8 Jun 2021 11:44:52 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Cc: Kevin Darbyshire-Bryant Subject: [PATCH 21.02 02/11] firmware-utils: fix coverity zytrx.c resource leak Date: Tue, 8 Jun 2021 11:45:03 +0200 Message-Id: <20210608094512.29956-3-ynezz@true.cz> In-Reply-To: <20210608094512.29956-1-ynezz@true.cz> References: <20210608094512.29956-1-ynezz@true.cz> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210608_024522_965954_63F7FA26 X-CRM114-Status: UNSURE ( 7.99 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Kevin Darbyshire-Bryant fix coverity resource leak warning: *len = stat.st_size; mapped = mmap(NULL, stat.st_size, PROT_READ, MAP_SHARED, fd, 0); if (close(fd) < 0) CID 1484880: Resource leaks (RESOURCE_LEAK) Variable "mapped" going out of scope leaks the sto [...] Content analysis details: (0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Kevin Darbyshire-Bryant fix coverity resource leak warning: *len = stat.st_size; mapped = mmap(NULL, stat.st_size, PROT_READ, MAP_SHARED, fd, 0); if (close(fd) < 0) CID 1484880: Resource leaks (RESOURCE_LEAK) Variable "mapped" going out of scope leaks the storage it points to. return NULL; return mapped; } Signed-off-by: Kevin Darbyshire-Bryant (cherry picked from commit baf2a50ef3cf34574e12d2ab1b23578310f0d527) --- tools/firmware-utils/src/zytrx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/firmware-utils/src/zytrx.c b/tools/firmware-utils/src/zytrx.c index 302efc601065..716767920657 100644 --- a/tools/firmware-utils/src/zytrx.c +++ b/tools/firmware-utils/src/zytrx.c @@ -150,8 +150,10 @@ static void *map_input(const char *name, size_t *len) } *len = stat.st_size; mapped = mmap(NULL, stat.st_size, PROT_READ, MAP_SHARED, fd, 0); - if (close(fd) < 0) + if (close(fd) < 0) { + (void) munmap(mapped, stat.st_size); return NULL; + } return mapped; } From patchwork Tue Jun 8 09:45:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1489260 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) 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=bombadil.20210309 header.b=YxgOK77K; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 4Fzlmh0Nttz9sCD for ; Tue, 8 Jun 2021 19:48:36 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xnPPMylo/xsU7sn53pEKrWzsfFJd6jIVUSQEJc9i4MY=; b=YxgOK77KA6g/Vb 7bAY6TWVmbmP8+RQ/VkVyBf3rkEMFHZQ+p8jPEWNeQPtHoOBqxbpRXSPO6i1JKwjfqNTFZl529EhN KqiXCedJU+bI0b2y3bR6wSwd3ADSEJrSplE3txHNtVtHnTeMs10ZzmM0XQEzNJCZsu5QCWaJX/CWC 7kx0Swakgq0pXKd7708GerV0PS8/QqpPBZDQ0hWN18kF/9+MrR8FlGfJctvaWQm9iYp67mS3AC4Tq iNH/8KIuTRHUZh38fDNXNfAv86zFAUQ8x6FXTP4PFv/oNnHbC55CRY6QqwJ9mMz6q1jsxQ1LfW6nW rJAw8X+WUON2xtnl64Rw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqYJk-007V4S-Oj; Tue, 08 Jun 2021 09:46:40 +0000 Received: from smtp-out.xnet.cz ([178.217.244.18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqYIU-007Ui0-P5 for openwrt-devel@lists.openwrt.org; Tue, 08 Jun 2021 09:45:29 +0000 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id F346518942; Tue, 8 Jun 2021 11:45:17 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id 11abeb33; Tue, 8 Jun 2021 11:44:52 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Cc: =?utf-8?q?Bj=C3=B8rn_Mork?= Subject: [PATCH 21.02 03/11] ramips: mt7621: Add support for ZyXEL NR7101 Date: Tue, 8 Jun 2021 11:45:04 +0200 Message-Id: <20210608094512.29956-4-ynezz@true.cz> In-Reply-To: <20210608094512.29956-1-ynezz@true.cz> References: <20210608094512.29956-1-ynezz@true.cz> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210608_024523_211901_6F6B0F84 X-CRM114-Status: GOOD ( 29.61 ) X-Spam-Score: 0.0 (/) X-Spam-Report: =?unknown-8bit?q?Spam_detection_software=2C_running_on_the_sy?= =?unknown-8bit?q?stem_=22bombadil=2Einfradead=2Eorg=22=2C?= =?unknown-8bit?q?_has_NOT_identified_this_incoming_email_as_spam=2E__The_ori?= =?unknown-8bit?q?ginal?= =?unknown-8bit?q?_message_has_been_attached_to_this_so_you_can_view_it_or_la?= =?unknown-8bit?q?bel?= =?unknown-8bit?q?_similar_future_email=2E__If_you_have_any_questions=2C_see?= =?unknown-8bit?q?_the_administrator_of_that_system_for_details=2E?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_preview=3A__From=3A_Bj=C3=B8rn_Mork_=3Cbjorn=40mor?= =?unknown-8bit?q?k=2Eno=3E_The_ZyXEL_NR7101_is_an_802=2E3at?= =?unknown-8bit?q?_PoE_powered_5G_outdoor_=28IP68=29_CPE_with_integrated_dire?= =?unknown-8bit?q?ctional_5G/LTE_antennas=2E?= =?unknown-8bit?q?_Specifications=3A_?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_analysis_details=3A___=280=2E0_points=2C_5=2E0_req?= =?unknown-8bit?q?uired=29?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_pts_rule_name______________description?= =?unknown-8bit?q?_----_----------------------_------------------------------?= =?unknown-8bit?q?--------------------?= =?unknown-8bit?q?_0=2E0_SPF=5FNONE_______________SPF=3A_sender_does_not_publ?= =?unknown-8bit?q?ish_an_SPF_Record?= =?unknown-8bit?q?_0=2E0_SPF=5FHELO=5FNONE__________SPF=3A_HELO_does_not_publ?= =?unknown-8bit?q?ish_an_SPF_Record?= =?unknown-8bit?q?_0=2E0_NUMERIC=5FHTTP=5FADDR______URI=3A_Uses_a_numeric_IP_?= =?unknown-8bit?q?address_in_URL?= X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Bjørn Mork The ZyXEL NR7101 is an 802.3at PoE powered 5G outdoor (IP68) CPE with integrated directional 5G/LTE antennas. Specifications: - SoC: MediaTek MT7621AT - RAM: 256 MB - Flash: 128 MB MB NAND (MX30LF1G18AC) - WiFi: MediaTek MT7603E - Switch: 1 LAN port (Gigabiti) - 5G/LTE: Quectel RG502Q-EA connected by USB3 to SoC - SIM: 2 micro-SIM slots under transparent cover - Buttons: Reset, WLAN under same cover - LEDs: Multicolour green/red/yellow under same cover (visible) - Power: 802.3at PoE via LAN port The device is built as an outdoor ethernet to 5G/LTE bridge or router. The Wifi interface is intended for installation and/or temporary management purposes only. UART Serial: 57600N1 Located on populated 5 pin header J5: [o] GND [ ] key - no pin [o] RX [o] TX [o] 3.3V Vcc Remove the SIM/button/LED cover, the WLAN button and 12 screws holding the back plate and antenna cover together. The GPS antenna is fixed to the cover, so be careful with the cable. Remove 4 screws fixing the antenna board to the main board, again being careful with the cables. A bluetooth TTL adapter is recommended for permanent console access, to keep the router water and dustproof. The 3.3V pin is able to power such an adapter. MAC addresses: OpenWrt OEM Address Found as lan eth2 08:26:97:*:*:BC Factory 0xe000 (hex), label wlan0 ra0 08:26:97:*:*:BD Factory 0x4 (hex) wwan0 usb0 random WARNING!! ISP managed firmware might at any time update itself to a version where all known workarounds have been disabled. Never boot an ISP managed firmware with a SIM in any of the slots if you intend to use the router with OpenWrt. The bootloader lock can only be disabled with root access to running firmware. The flash chip is physically inaccessible without soldering. Installation from OEM web GUI: - Log in as "supervisor" on https://172.17.1.1/ - Upload OpenWrt initramfs-recovery.bin image on the Maintenance -> Firmware page - Wait for OpenWrt to boot and ssh to root@192.168.1.1 - (optional) Copy OpenWrt to the recovery partition. See below - Sysupgrade to the OpenWrt sysupgrade image and reboot Installation from OEM ssh: - Log in as "root" on 172.17.1.1 port 22022 - scp OpenWrt initramfs-recovery.bin image to 172.17.1.1:/tmp - Prepare bootloader config by running: nvram setro uboot DebugFlag 0x1 nvram setro uboot CheckBypass 0 nvram commit - Run "mtd_write -w write initramfs-recovery.bin Kernel" and reboot - Wait for OpenWrt to boot and ssh to root@192.168.1.1 - (optional) Copy OpenWrt to the recovery partition. See below - Sysupgrade to the OpenWrt sysupgrade image and reboot Copying OpenWrt to the recovery partition: - Verify that you are running a working OpenWrt recovery image from flash - ssh to root@192.168.1.1 and run: fw_setenv CheckBypass 0 mtd -r erase Kernel2 - Wait while the bootloader mirrors Image1 to Image2 NOTE: This should only be done after successfully booting the OpenWrt recovery image from the primary partition during installation. Do not do this after having sysupgraded OpenWrt! Reinstalling the recovery image on normal upgrades is not required or recommended. Installation from Z-Loader: - Halt boot by pressing Escape on console - Set up a tftp server to serve the OpenWrt initramfs-recovery.bin image at 10.10.10.3 - Type "ATNR 1,initramfs-recovery.bin" at the "ZLB>" prompt - Wait for OpenWrt to boot and ssh to root@192.168.1.1 - Sysupgrade to the OpenWrt sysupgrade image NOTE: ATNR will write the recovery image to both primary and recovery partitions in one go. Booting from RAM: - Halt boot by pressing Escape on console - Type "ATGU" at the "ZLB>" prompt to enter the U-Boot menu - Press "4" to select "4: Entr boot command line interface." - Set up a tftp server to serve the OpenWrt initramfs-recovery.bin image at 10.10.10.3 - Load it using "tftpboot 0x88000000 initramfs-recovery.bin" - Boot with "bootm 0x8800017C" to skip the 380 (0x17C) bytes ZyXEL header This method can also be used to RAM boot OEM firmware. The warning regarding OEM applies! Never boot an unknown OEM firmware, or any OEM firmware with a SIM in any slot. NOTE: U-Boot configuration is incomplete (on some devices?). You may have to configure a working mac address before running tftp using "setenv eth0addr " Unlocking the bootloader: If you are unebale to halt boot, then the bootloader is locked. The OEM firmware locks the bootloader on every boot by setting DebugFlag to 0. Setting it to 1 is therefore only temporary when OEM firmware is installed. - Run "nvram setro uboot DebugFlag 0x1; nvram commit" in OEM firmware - Run "fw_setenv DebugFlag 0x1" in OpenWrt NOTE: OpenWrt does this automatically on first boot if necessary NOTE2: Setting the flag to 0x1 avoids the reset to 0 in known OEM versions, but this might change. WARNING: Writing anything to flash while the bootloader is locked is considered extremely risky. Errors might cause a permanent brick! Enabling management access from LAN: Temporary workaround to allow installing OpenWrt if OEM firmware has disabled LAN management: - Connect to console - Log in as "root" - Run "iptables -I INPUT -i br0 -j ACCEPT" Notes on the OEM/bootloader dual partition scheme The dual partition scheme on this device uses Image2 as a recovery image only. The device will always boot from Image1, but the bootloader might copy Image2 to Image1 under specific conditions. This scheme prevents repurposing of the space occupied by Image2 in any useful way. Validation of primary and recovery images is controlled by the variables CheckBypass, Image1Stable, and Image1Try. The bootloader sets CheckBypass to 0 and reboots if Image1 fails validation. If CheckBypass is 0 and Image1 is invalid then Image2 is copied to Image1. If CheckBypass is 0 and Image2 is invalid, then Image1 is copied to Image2. If CheckBypass is 1 then all tests are skipped and Image1 is booted unconditionally. CheckBypass is set to 1 after each successful validation of Image1. Image1Try is incremented if Image1Stable is 0, and Image2 is copied to Image1 if Image1Try is 3 or larger. But the bootloader only tests Image1Try if CheckBypass is 0, which is impossible unless the booted image sets it to 0 before failing. The system is therefore not resilient against runtime errors like failure to mount the rootfs, unless the kernel image sets CheckBypass to 0 before failing. This is not yet implemented in OpenWrt. Setting Image1Stable to 1 prevents the bootloader from updating Image1Try on every boot, saving unnecessary writes to the environment partition. Keeping an OpenWrt initramfs recovery as Image2 is recommended primarily to avoid unwanted OEM firmware boots on failure. Ref the warning above. It enables console-less recovery in case of some failures to boot from Image1. Signed-off-by: Bjørn Mork (cherry picked from commit 2449a632084b29632605e5a79ce5d73028eb15dd) Tested-by: Bjørn Mork --- package/boot/uboot-envtools/files/ramips | 5 + .../linux/ramips/dts/mt7621_zyxel_nr7101.dts | 164 ++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 22 +++ .../mt7621/base-files/etc/board.d/02_network | 3 + .../base-files/etc/board.d/03_gpio_switches | 3 + .../mt7621/base-files/etc/init.d/bootcount | 5 + .../mt7621/base-files/lib/upgrade/platform.sh | 6 + 7 files changed, 208 insertions(+) create mode 100644 target/linux/ramips/dts/mt7621_zyxel_nr7101.dts diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips index a47e2950d3ae..c153b6a4226b 100644 --- a/package/boot/uboot-envtools/files/ramips +++ b/package/boot/uboot-envtools/files/ramips @@ -54,6 +54,11 @@ xiaomi,mi-router-ac2100|\ xiaomi,redmi-router-ac2100) ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x20000" ;; +zyxel,nr7101) + idx="$(find_mtd_index Config)" + [ -n "$idx" ] && \ + ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x1000" "0x80000" + ;; esac config_load ubootenv diff --git a/target/linux/ramips/dts/mt7621_zyxel_nr7101.dts b/target/linux/ramips/dts/mt7621_zyxel_nr7101.dts new file mode 100644 index 000000000000..f6a42286f10e --- /dev/null +++ b/target/linux/ramips/dts/mt7621_zyxel_nr7101.dts @@ -0,0 +1,164 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621.dtsi" + +#include +#include + +/ { + compatible = "zyxel,nr7101", "mediatek,mt7621-soc"; + model = "ZyXEL NR7101"; + + aliases { + led-boot = &power; + led-failsafe = &power; + led-running = &power; + led-upgrade = &power; + label-mac-device = &gmac0; + }; + + leds { + compatible = "gpio-leds"; + + led@13 { + label = "yellow:system"; + gpios = <&gpio 13 GPIO_ACTIVE_HIGH>; + }; + + power: led@14 { + label = "green:system"; + gpios = <&gpio 14 GPIO_ACTIVE_HIGH>; + }; + + led@15 { + label = "red:system"; + gpios = <&gpio 15 GPIO_ACTIVE_HIGH>; + }; + }; + + keys { + compatible = "gpio-keys"; + + wps { + label = "wlan"; + gpios = <&gpio 8 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + reset { + label = "reset"; + gpios = <&gpio 6 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; +}; + +&gpio { + lte_pwrkey { + gpio-hog; + gpios = <4 GPIO_ACTIVE_HIGH>; + output-high; + line-name = "lte-pwrkey"; + }; + + lte_power { + gpio-hog; + gpios = <18 GPIO_ACTIVE_HIGH>; + output-high; + line-name = "lte-power"; + }; +}; + +&nand { + status = "okay"; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "Bootloader"; + reg = <0x0 0x80000>; + read-only; + }; + + partition@80000 { + label = "Config"; + reg = <0x80000 0x80000>; + }; + + factory: partition@100000 { + label = "Factory"; + reg = <0x100000 0x40000>; + read-only; + }; + + partition@140000 { + label = "Kernel"; + reg = <0x140000 0x1ec0000>; + }; + + partition@540000 { + label = "ubi"; + reg = <0x540000 0x1ac0000>; + }; + + partition@2140000 { + label = "Kernel2"; + reg = <0x2140000 0x1ec0000>; + }; + + partition@4000000 { + label = "wwan"; + reg = <0x4000000 0x100000>; + }; + + partition@4100000 { + label = "data"; + reg = <0x4100000 0x1000000>; + }; + + partition@5100000 { + label = "rom-d"; + reg = <0x5100000 0x100000>; + read-only; + }; + + partition@5200000 { + label = "reserve"; + reg = <0x5200000 0x80000>; + }; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + mt76@0,0 { + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0>; + }; +}; + +&gmac0 { + mtd-mac-address = <&factory 0xe000>; +}; + +&switch0 { + ports { + port@2 { + status = "okay"; + label = "lan"; + }; + }; +}; + +&state_default { + gpio { + groups = "i2c", "rgmii2", "uart3", "jtag", "wdt"; + function = "gpio"; + }; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index a8f558326d99..a7f6c80f40ff 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -79,6 +79,13 @@ define Build/ubnt-erx-factory-image fi endef +define Build/zytrx-header + $(eval board=$(word 1,$(1))) + $(eval version=$(word 2,$(1))) + $(STAGING_DIR_HOST)/bin/zytrx -B '$(board)' -v '$(version)' -i $@ -o $@.new + mv $@.new $@ +endef + define Device/dsa-migration DEVICE_COMPAT_VERSION := 1.1 DEVICE_COMPAT_MESSAGE := Config cannot be migrated from swconfig to DSA @@ -1504,6 +1511,21 @@ define Device/zio_freezio endef TARGET_DEVICES += zio_freezio +define Device/zyxel_nr7101 + $(Device/dsa-migration) + BLOCKSIZE := 128k + PAGESIZE := 2048 + UBINIZE_OPTS := -E 5 + DEVICE_VENDOR := ZyXEL + DEVICE_MODEL := NR7101 + DEVICE_PACKAGES := kmod-mt7603 kmod-usb3 uboot-envtools kmod-usb-net-qmi-wwan kmod-usb-serial-option uqmi + KERNEL := $(KERNEL_DTB) | uImage lzma | zytrx-header $$(DEVICE_MODEL) $$(VERSION_DIST)-$$(REVISION) + KERNEL_INITRAMFS := $(KERNEL_DTB) | uImage lzma | zytrx-header $$(DEVICE_MODEL) 9.99(ABUV.9)$$(VERSION_DIST)-recovery + KERNEL_INITRAMFS_SUFFIX := -recovery.bin + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata +endef +TARGET_DEVICES += zyxel_nr7101 + define Device/zyxel_wap6805 $(Device/dsa-migration) BLOCKSIZE := 128k diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network index 89e679be7cd8..f017e4782e0e 100755 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -64,6 +64,9 @@ ramips_setup_interfaces() ubnt,edgerouter-x-sfp) ucidef_set_interfaces_lan_wan "eth1 eth2 eth3 eth4 eth5" "eth0" ;; + zyxel,nr7101) + ucidef_set_interfaces_lan_wan "lan" "wan" + ;; zyxel,wap6805) ucidef_set_interface_lan "lan1 lan2 lan3 lan4" ucidef_set_interface "qtn" ifname "eth1" protocol "static" ipaddr "1.1.1.1" netmask "255.255.255.0" diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/03_gpio_switches b/target/linux/ramips/mt7621/base-files/etc/board.d/03_gpio_switches index 82bbdd24f674..8ef815634f08 100755 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/03_gpio_switches +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/03_gpio_switches @@ -23,6 +23,9 @@ ubnt,edgerouter-x-sfp) ucidef_add_gpio_switch "poe_power_port3" "PoE Power Port3" "403" ucidef_add_gpio_switch "poe_power_port4" "PoE Power Port4" "404" ;; +zyxel,nr7101) + ucidef_add_gpio_switch "lte_reset" "Reset LTE/5G modem" "483" + ;; zyxel,wap6805) ucidef_add_gpio_switch "qtn_power" "Quantenna Module Power" "496" "1" ;; diff --git a/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount b/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount index 7ef0053e6790..a155458d3f23 100755 --- a/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount +++ b/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount @@ -16,5 +16,10 @@ boot() { samknows,whitebox-v8) fw_setenv bootcount 0 ;; + zyxel,nr7101) + [ $(printf %d $(fw_printenv -n DebugFlag)) -gt 0 ] || fw_setenv DebugFlag 0x1 + [ $(printf %d $(fw_printenv -n Image1Stable)) -gt 0 ] || fw_setenv Image1Stable 1 + [ $(printf %d $(fw_printenv -n Image1Try)) -gt 0 ] && fw_setenv Image1Try 0 + ;; esac } diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh index c9152c5cf4d6..d30bc3db2edd 100755 --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh @@ -82,6 +82,12 @@ platform_do_upgrade() { ubnt,edgerouter-x-sfp) platform_upgrade_ubnt_erx "$1" ;; + zyxel,nr7101) + fw_setenv CheckBypass 0 + fw_setenv Image1Stable 0 + CI_KERNPART="Kernel" + nand_do_upgrade "$1" + ;; zyxel,wap6805) local kernel2_mtd="$(find_mtd_part Kernel2)" [ "$(hexdump -n 4 -e '"%x"' $kernel2_mtd)" = "56190527" ] &&\ From patchwork Tue Jun 8 09:45:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1489257 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) 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=bombadil.20210309 header.b=wONirtN3; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 4Fzlll4lyFz9sCD for ; Tue, 8 Jun 2021 19:47:47 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bNiuAsv/Te4oIgcO8gBDs6+tVVQstSxN7wrd/b3QKgM=; b=wONirtN3WeyBWc macXHbWQSswrrA2BMe3pxI9AZ2pYJ34tl6pCeT4+SQDWzigq+t+LJFMOs0C9BXaSAUIPLsTFFTdKF oeO8MeLcBGYwaUHhEZS0c2DP5Z57Al2e51lfRHoS9AkIXcMsVKD0XZ0Ke1xhhqJFSOhRoTMHK544g ZZbSuUFCbqju3Whm+skvjTuibSeQiPYC/qAm/uLe4YVjMV/p1hyAIySkIQ/1fCqvOTeOi9s3yGZRC ztVoXEez4x61BK71TsHK9FK03wUC1Q9wXbxpND5ITcxmSb+eF2fU4WZuUpei+Clb5dginDymZ5p49 iYRsjkTVof0pWfSZh3uQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqYJ3-007UsI-9h; Tue, 08 Jun 2021 09:45:57 +0000 Received: from smtp-out.xnet.cz ([178.217.244.18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqYIU-007Ui2-Mb for openwrt-devel@lists.openwrt.org; Tue, 08 Jun 2021 09:45:27 +0000 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id 358DB18943; Tue, 8 Jun 2021 11:45:18 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id e05caaa6; Tue, 8 Jun 2021 11:44:53 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Cc: Vinay Patil , David Bauer Subject: [PATCH 21.02 04/11] ramips: add support for TP-Link Archer A6 v3 Date: Tue, 8 Jun 2021 11:45:05 +0200 Message-Id: <20210608094512.29956-5-ynezz@true.cz> In-Reply-To: <20210608094512.29956-1-ynezz@true.cz> References: <20210608094512.29956-1-ynezz@true.cz> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210608_024522_931456_756ACDF5 X-CRM114-Status: GOOD ( 17.06 ) X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Vinay Patil The patch adds support for the TP-Link Archer A6 v3 The router is sold in US and India with FCC ID TE7A6V3 Specification MediaTek MT7621 SOC RAM: 128MB DDR3 SPI Flash: W25Q128 (16MB) Ethernet: MT7530 5x 1000Base-T WiFi 5GHz: Mediatek MT7613BE WiFi 2.4GHz: Mediatek MT7603E UART/Serial: 115200 [...] Content analysis details: (0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Vinay Patil The patch adds support for the TP-Link Archer A6 v3 The router is sold in US and India with FCC ID TE7A6V3 Specification ------------- MediaTek MT7621 SOC RAM: 128MB DDR3 SPI Flash: W25Q128 (16MB) Ethernet: MT7530 5x 1000Base-T WiFi 5GHz: Mediatek MT7613BE WiFi 2.4GHz: Mediatek MT7603E UART/Serial: 115200 8n1 Device Configuration & Serial Port Pins --------------------------------------- ETH Ports: LAN4 LAN3 LAN2 LAN1 WAN _______________________ | | Serial Pins: | VCC GND TXD RXD | |_____________________| LEDs: Power Wifi2G Wifi5G LAN WAN Build Output ------------ The build will generate following set of files [1] openwrt-ramips-mt7621-tplink_archer-a6-v3-initramfs-kernel.bin [2] openwrt-ramips-mt7621-tplink_archer-a6-v3-squashfs-factory.bin [3] openwrt-ramips-mt7621-tplink_archer-a6-v3-squashfs-sysupgrade.bin How to Use - Flashing from TP-Link Web Interface ------------------------------------------------ * Go to "Advanced/System Tools/Firmware Update". * Click "Browse" and upload the OpenWrt factory image: factory.bin[2] * Click the "Upgrade" button, and select "Yes" when prompted. TFTP Booting ------------ Setup a TFTP boot server with address 192.168.0.5. While starting U-boot press '4' key to stop autoboot. Copy the initramfs-kernel.bin[1] to TFTP server folder, rename as test.bin From u-boot command prompt run tftpboot followed by bootm. Recovery -------- Archer A6 V3 has recovery page activated if SPI booting from flash fails. Recovery page can be activated from serial console only. Press 'x' while u-boot is starting Note: TFTP boot can be activated only from u-boot serial console. Device recovery address: 192.168.0.1 Thanks to: Frankis for Randmon MAC address fix. Signed-off-by: Vinay Patil [remove superfluous factory image definition, whitespacing] Signed-off-by: David Bauer (cherry picked from commit f8f8935adb2be1ebce46a8d7058c76a8d3a9bd89) --- .../ramips/dts/mt7621_tplink_archer-a6-v3.dts | 188 ++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 13 ++ .../mt7621/base-files/etc/board.d/01_leds | 4 + tools/firmware-utils/src/tplink-safeloader.c | 40 +++- 4 files changed, 244 insertions(+), 1 deletion(-) create mode 100644 target/linux/ramips/dts/mt7621_tplink_archer-a6-v3.dts diff --git a/target/linux/ramips/dts/mt7621_tplink_archer-a6-v3.dts b/target/linux/ramips/dts/mt7621_tplink_archer-a6-v3.dts new file mode 100644 index 000000000000..46cb365da7de --- /dev/null +++ b/target/linux/ramips/dts/mt7621_tplink_archer-a6-v3.dts @@ -0,0 +1,188 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621.dtsi" + +#include +#include + +/ { + compatible = "tplink,archer-a6-v3", "mediatek,mt7621-soc"; + model = "TP-Link Archer A6 v3"; + + aliases { + label-mac-device = &gmac0; + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; + }; + + chosen { + bootargs = "console=ttyS0,115200n8"; + }; + + keys { + compatible = "gpio-keys"; + + wps { + label = "wps"; + gpios = <&gpio 28 GPIO_ACTIVE_LOW>; + debounce-interval = <60>; + linux,code = ; + }; + + reset { + label = "reset"; + gpios = <&gpio 8 GPIO_ACTIVE_LOW>; + debounce-interval = <60>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_power: power { + label = "green:power"; + gpios = <&gpio 4 GPIO_ACTIVE_LOW>; + }; + + wan_orange { + label = "orange:wan"; + gpios = <&gpio 14 GPIO_ACTIVE_LOW>; + }; + + lan { + label = "green:lan"; + gpios = <&gpio 15 GPIO_ACTIVE_LOW>; + }; + + wifi5g { + label = "green:wifi5g"; + gpios = <&gpio 16 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy1tpt"; + }; + + wifi2g { + label = "green:wifi2g"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0tpt"; + }; + + wan_green { + label = "green:wan"; + gpios = <&gpio 45 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&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 = "u-boot"; + reg = <0x0 0x40000>; + read-only; + }; + + partition@40000 { + label = "firmware"; + compatible = "denx,uimage"; + reg = <0x40000 0xf60000>; + }; + + config: partition@fa0000 { + label = "config"; + reg = <0xfa0000 0x50000>; + read-only; + }; + + radio: partition@ff0000 { + label = "radio"; + reg = <0xff0000 0x10000>; + read-only; + }; + }; + }; +}; + +&state_default { + gpio { + groups = "i2c", "uart2", "uart3", "jtag", "wdt"; + function = "gpio"; + }; +}; + +ðernet { + pinctrl-names = "default"; + pinctrl-0 = <&rgmii1_pins &mdio_pins>; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&radio 0x0>; + mtd-mac-address = <&config 0x8>; + mtd-mac-address-increment = <1>; + ieee80211-freq-limit = <2400000 2500000>; + }; +}; + +&pcie1 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&radio 0x8000>; + mtd-mac-address = <&config 0x8>; + mtd-mac-address-increment = <2>; + ieee80211-freq-limit = <5000000 6000000>; + }; +}; + +&gmac0 { + mtd-mac-address = <&config 0x8>; +}; + +&switch0 { + ports { + port@0 { + status = "okay"; + label = "wan"; + }; + + port@1 { + status = "okay"; + label = "lan1"; + }; + + port@2 { + status = "okay"; + label = "lan2"; + }; + + port@3 { + status = "okay"; + label = "lan3"; + }; + + port@4 { + status = "okay"; + label = "lan4"; + }; + }; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index a7f6c80f40ff..ce5adb9a8bb3 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -1132,6 +1132,19 @@ define Device/totolink_x5000r endef TARGET_DEVICES += totolink_x5000r +define Device/tplink_archer-a6-v3 + $(Device/dsa-migration) + $(Device/tplink-safeloader) + DEVICE_MODEL := Archer A6 + DEVICE_VARIANT := V3 + DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615e \ + kmod-mt7663-firmware-ap kmod-mt7663-firmware-sta + TPLINK_BOARD_ID := ARCHER-A6-V3 + KERNEL := $(KERNEL_DTB) | uImage lzma + IMAGE_SIZE := 15744k +endef +TARGET_DEVICES += tplink_archer-a6-v3 + define Device/tplink_eap235-wall-v1 $(Device/dsa-migration) $(Device/tplink-safeloader) diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds index 5fa9ad3fe81a..086658bbb61d 100755 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds @@ -79,6 +79,10 @@ netgear,r6800) ucidef_set_led_netdev "lan3" "LAN3" "white:lan3" "lan3" ucidef_set_led_netdev "lan4" "LAN4" "white:lan4" "lan4" ;; +tplink,archer-a6-v3) + ucidef_set_led_netdev "lan" "LAN" "green:lan" "br-lan" + ucidef_set_led_netdev "wan" "WAN" "green:wan" "wan" + ;; tplink,re350-v1) ucidef_set_led_netdev "wifi2g" "Wifi 2.4G" "blue:wifi2G" "wlan0" ucidef_set_led_netdev "wifi5g" "Wifi 5G" "blue:wifi5G" "wlan1" diff --git a/tools/firmware-utils/src/tplink-safeloader.c b/tools/firmware-utils/src/tplink-safeloader.c index 90027221b679..32d3c1d35e40 100644 --- a/tools/firmware-utils/src/tplink-safeloader.c +++ b/tools/firmware-utils/src/tplink-safeloader.c @@ -1059,7 +1059,44 @@ static struct device_info boards[] = { .first_sysupgrade_partition = "os-image", .last_sysupgrade_partition = "file-system", }, + /** Firmware layout for the Archer A6 v3 */ + { + .id = "ARCHER-A6-V3", + .vendor = "", + .support_list = + "SupportList:\n" + "{product_name:Archer A6,product_ver:3.0.0,special_id:55530000}\n" + "{product_name:Archer A6,product_ver:3.0.0,special_id:54570000}\n", + .part_trail = 0x00, + .soft_ver = "soft_ver:1.0.5\n", + .partitions = { + {"fs-uboot", 0x00000, 0x40000}, + {"firmware", 0x40000, 0xf60000}, + {"default-mac", 0xfa0000, 0x00200}, + {"pin", 0xfa0200, 0x00100}, + {"device-id", 0xfa0300, 0x00100}, + {"product-info", 0xfa0400, 0x0fc00}, + {"default-config", 0xfb0000, 0x08000}, + {"ap-def-config", 0xfb8000, 0x08000}, + {"user-config", 0xfc0000, 0x0a000}, + {"ag-config", 0xfca000, 0x04000}, + {"certificate", 0xfce000, 0x02000}, + {"ap-config", 0xfd0000, 0x06000}, + {"router-config", 0xfd6000, 0x06000}, + {"favicon", 0xfdc000, 0x02000}, + {"logo", 0xfde000, 0x02000}, + {"partition-table", 0xfe0000, 0x00800}, + {"soft-version", 0xfe0800, 0x00100}, + {"support-list", 0xfe0900, 0x00200}, + {"profile", 0xfe0b00, 0x03000}, + {"extra-para", 0xfe3b00, 0x00100}, + {"radio", 0xff0000, 0x10000}, + {NULL, 0, 0} + }, + .first_sysupgrade_partition = "os-image", + .last_sysupgrade_partition = "file-system", + }, /** Firmware layout for the C60v1 */ { .id = "ARCHER-C60-V1", @@ -2824,7 +2861,8 @@ static void build_image(const char *output, parts[4] = read_file("file-system", rootfs_image, add_jffs2_eof, file_system_partition); /* Some devices need the extra-para partition to accept the firmware */ - if (strcasecmp(info->id, "ARCHER-A7-V5") == 0 || + if (strcasecmp(info->id, "ARCHER-A6-V3") == 0 || + strcasecmp(info->id, "ARCHER-A7-V5") == 0 || strcasecmp(info->id, "ARCHER-C2-V3") == 0 || strcasecmp(info->id, "ARCHER-C7-V4") == 0 || strcasecmp(info->id, "ARCHER-C7-V5") == 0 || From patchwork Tue Jun 8 09:45:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1489262 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) 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=bombadil.20210309 header.b=LNyHo4C2; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 4FzlnS0DZFz9sSn for ; Tue, 8 Jun 2021 19:49:16 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cR/D4phJADtyDNCq2WaElN6ANwfak41O1hZf/sZWO08=; b=LNyHo4C2u5RsBK /ixeBafqUJiVLOHt/ZTyHbCUh9gtpiNsNj2w76QVqOJL4JUbEuuB7NG3HP5+OuwgFJQ2NCpXRNEJk ehbTQ2uYild4AutpXOwrOHvm8X86Shp0NmwDi9EKuUtGHrH5CfZfswXcWCQ43mTXO8uoKXF1nIVIs SpgfLNW0bFaQUBdj/fn3yWcMz1oZsWkPNtZjevTsrAF5Rhz/hMI+ylppUq8mwKhGiCbRjtdVCK2oT Uhmq8KGM7xKSGEuaE13wne/11l2SL14npaOX3KBfrV9V5YdtoTrJDxrKZnM0VR1UPn37kRBvXDxjU eerl9pLiNdpxcKzEVIfA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqYKT-007VM4-Al; Tue, 08 Jun 2021 09:47:25 +0000 Received: from smtp-out.xnet.cz ([178.217.244.18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqYIX-007UkA-Me for openwrt-devel@lists.openwrt.org; Tue, 08 Jun 2021 09:45:32 +0000 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id 6FCE218944; Tue, 8 Jun 2021 11:45:18 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id e524aea6; Tue, 8 Jun 2021 11:44:53 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Cc: Georgi Vlaev Subject: [PATCH 21.02 05/11] ramips: add support for TP-Link Archer C6U v1 (EU) Date: Tue, 8 Jun 2021 11:45:06 +0200 Message-Id: <20210608094512.29956-6-ynezz@true.cz> In-Reply-To: <20210608094512.29956-1-ynezz@true.cz> References: <20210608094512.29956-1-ynezz@true.cz> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210608_024525_934116_4E8A2902 X-CRM114-Status: GOOD ( 17.30 ) X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Georgi Vlaev This patch adds support for TP-Link Archer C6U v1 (EU). The device is also known in some market as Archer C6 v3. This patch supports only Archer C6U v1 (EU). Content analysis details: (0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Georgi Vlaev This patch adds support for TP-Link Archer C6U v1 (EU). The device is also known in some market as Archer C6 v3. This patch supports only Archer C6U v1 (EU). Specifications: -------------- * SoC: Mediatek MT7621AT 2C2T, 880MHz * RAM: 128MB DDR3 * Flash: 16MB SPI NOR flash (Winbond 25Q128) * WiFi 5GHz: Mediatek MT7613BEN (2x2:2) * WiFi 2.4GHz: Mediatek MT7603EN (2x2:2) * Ethernet: MT7630, 5x 1000Base-T. * LED: Power, WAN, LAN, WiFi 2GHz and 5GHz, USB * Buttons: Reset, WPS. * UART: Serial console (115200 8n1), J1(GND:3) * USB: One USB2 port. Installation: ------------ Install the OpenWrt factory image for C6U is from the TP-Link web interface. 1) Go to "Advanced/System Tools/Firmware Update". 2) Click "Browse" and upload the OpenWrt factory image: openwrt-ramips-mt7621-tplink_archer-c6u-v1-squashfs-factory.bin. 3) Click the "Upgrade" button, and select "Yes" when prompted. Recovery to stock firmware: -------------------------- The C6U bootloader has a failsafe mode that provides a web interface (running at 192.168.0.1) for reverting back to the stock TP-Link firmware. The failsafe interface is triggered from the serial console or on failed kernel boot. Unfortunately, there's no key combination that enables the failsafe mode. This gives us two options for recovery: 1) Recover using the serial console (J1 header). The recovery interface can be selected by hitting 'x' when prompted on boot. 2) Trigger the bootloader failsafe mode. A more dangerous option is force the bootloader into recovery mode by erasing the OpenWrt partition from the OpenWrt's shell - e.g "mtd erase firmware". Please be careful, since erasing the wrong partition can brick your device. MAC addresses: ------------- OEM firmware configuration: D8:07:B6:xx:xx:83 : 5G D8:07:B6:xx:xx:84 : LAN (label) D8:07:B6:xx:xx:84 : 2.4G D8:07:B6:xx:xx:85 : WAN Signed-off-by: Georgi Vlaev (cherry picked from commit a46ad596a3e076599f38a4132b5d6dfee8a3102a) --- .../dts/mt7621_tplink_archer-c6u-v1.dts | 213 ++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 14 ++ .../mt7621/base-files/etc/board.d/01_leds | 3 +- tools/firmware-utils/src/tplink-safeloader.c | 35 +++ 4 files changed, 264 insertions(+), 1 deletion(-) create mode 100644 target/linux/ramips/dts/mt7621_tplink_archer-c6u-v1.dts diff --git a/target/linux/ramips/dts/mt7621_tplink_archer-c6u-v1.dts b/target/linux/ramips/dts/mt7621_tplink_archer-c6u-v1.dts new file mode 100644 index 000000000000..7d38b7b0968d --- /dev/null +++ b/target/linux/ramips/dts/mt7621_tplink_archer-c6u-v1.dts @@ -0,0 +1,213 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621.dtsi" + +#include +#include + +/ { + compatible = "tplink,archer-c6u-v1", "mediatek,mt7621-soc"; + model = "TP-Link Archer C6U v1"; + + aliases { + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; + label-mac-device = &gmac0; + }; + + chosen { + bootargs = "console=ttyS0,115200"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio 8 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&gpio 10 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_power: power { + label = "green:power"; + gpios = <&gpio 4 GPIO_ACTIVE_LOW>; + }; + + usb { + label = "green:usb"; + gpios = <&gpio 13 GPIO_ACTIVE_LOW>; + trigger-sources = <&ehci_port2>; + linux,default-trigger = "usbport"; + }; + + wan-orange { + label = "orange:wan"; + gpios = <&gpio 14 GPIO_ACTIVE_LOW>; + }; + + lan { + label = "green:lan"; + gpios = <&gpio 15 GPIO_ACTIVE_LOW>; + }; + + wifi5g { + label = "green:wifi5g"; + gpios = <&gpio 16 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy1tpt"; + }; + + wifi2g { + label = "green:wifi2g"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0tpt"; + }; + + wan-green { + label = "green:wan"; + gpios = <&gpio 45 GPIO_ACTIVE_LOW>; + }; + }; + + reg_usb_vbus: regulator { + compatible = "regulator-fixed"; + regulator-name = "usb_vbus"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + gpio = <&gpio 3 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; +}; + +&spi0 { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <80000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x000000 0x040000>; + read-only; + }; + + partition@40000 { + compatible = "denx,uimage"; + label = "firmware"; + reg = <0x040000 0xf60000>; + }; + + config: partition@fa0000 { + label = "config"; + reg = <0xfa0000 0x010000>; + read-only; + }; + + partition@fb0000 { + label = "tplink"; + reg = <0xfb0000 0x040000>; + read-only; + }; + + radio: partition@ff0000 { + label = "radio"; + reg = <0xff0000 0x010000>; + read-only; + }; + }; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + mt76@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&radio 0x0>; + mtd-mac-address = <&config 0x8>; + ieee80211-freq-limit = <2400000 2500000>; + }; +}; + +&pcie1 { + mt76@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&radio 0x8000>; + mtd-mac-address = <&config 0x8>; + mtd-mac-address-increment = <(-1)>; + ieee80211-freq-limit = <5000000 6000000>; + }; +}; + +ðernet { + pinctrl-names = "default"; + pinctrl-0 = <&rgmii1_pins &mdio_pins>; +}; + +&gmac0 { + mtd-mac-address = <&config 0x8>; +}; + +&switch0 { + ports { + port@0 { + status = "okay"; + label = "wan"; + mtd-mac-address = <&config 0x8>; + mtd-mac-address-increment = <1>; + }; + + port@1 { + status = "okay"; + label = "lan1"; + }; + + port@2 { + status = "okay"; + label = "lan2"; + }; + + port@3 { + status = "okay"; + label = "lan3"; + }; + + port@4 { + status = "okay"; + label = "lan4"; + }; + }; +}; + +&state_default { + gpio { + groups = "i2c", "uart2", "uart3", "jtag", "wdt", "sdhci"; + function = "gpio"; + }; +}; + +&xhci { + vbus-supply = <®_usb_vbus>; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index ce5adb9a8bb3..d56067948e88 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -1145,6 +1145,20 @@ define Device/tplink_archer-a6-v3 endef TARGET_DEVICES += tplink_archer-a6-v3 +define Device/tplink_archer-c6u-v1 + $(Device/dsa-migration) + $(Device/tplink-safeloader) + DEVICE_MODEL := Archer C6U + DEVICE_VARIANT := v1 + DEVICE_PACKAGES := kmod-mt7603 \ + kmod-mt7615e kmod-mt7663-firmware-ap \ + kmod-usb3 kmod-usb-ledtrig-usbport + KERNEL := $(KERNEL_DTB) | uImage lzma + TPLINK_BOARD_ID := ARCHER-C6U-V1 + IMAGE_SIZE := 15744k +endef +TARGET_DEVICES += tplink_archer-c6u-v1 + define Device/tplink_eap235-wall-v1 $(Device/dsa-migration) $(Device/tplink-safeloader) diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds index 086658bbb61d..e3064ad5ffcc 100755 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds @@ -79,7 +79,8 @@ netgear,r6800) ucidef_set_led_netdev "lan3" "LAN3" "white:lan3" "lan3" ucidef_set_led_netdev "lan4" "LAN4" "white:lan4" "lan4" ;; -tplink,archer-a6-v3) +tplink,archer-a6-v3|\ +tplink,archer-c6u-v1) ucidef_set_led_netdev "lan" "LAN" "green:lan" "br-lan" ucidef_set_led_netdev "wan" "WAN" "green:wan" "wan" ;; diff --git a/tools/firmware-utils/src/tplink-safeloader.c b/tools/firmware-utils/src/tplink-safeloader.c index 32d3c1d35e40..d586b9cbd83c 100644 --- a/tools/firmware-utils/src/tplink-safeloader.c +++ b/tools/firmware-utils/src/tplink-safeloader.c @@ -1097,6 +1097,40 @@ static struct device_info boards[] = { .first_sysupgrade_partition = "os-image", .last_sysupgrade_partition = "file-system", }, + /** Firmware layout for the Archer C6U v1 */ + { + .id = "ARCHER-C6U-V1", + .vendor = "", + .support_list = + "SupportList:\n" + "{product_name:Archer C6U,product_ver:1.0.0,special_id:45550000}\n", + .part_trail = 0x00, + .soft_ver = "soft_ver:1.0.2\n", + + .partitions = { + {"fs-uboot", 0x00000, 0x40000}, + {"firmware", 0x40000, 0xf60000}, + {"default-mac", 0xfa0000, 0x00200}, + {"pin", 0xfa0200, 0x00100}, + {"device-id", 0xfa0300, 0x00100}, + {"product-info", 0xfa0400, 0x0fc00}, + {"default-config", 0xfb0000, 0x08000}, + {"ap-def-config", 0xfb8000, 0x08000}, + {"user-config", 0xfc0000, 0x0c000}, + {"certificate", 0xfcc000, 0x04000}, + {"ap-config", 0xfd0000, 0x08000}, + {"router-config", 0xfd8000, 0x08000}, + {"partition-table", 0xfe0000, 0x00800}, + {"soft-version", 0xfe0800, 0x00100}, + {"support-list", 0xfe0900, 0x00200}, + {"profile", 0xfe0b00, 0x03000}, + {"extra-para", 0xfe3b00, 0x00100}, + {"radio", 0xff0000, 0x10000}, + {NULL, 0, 0} + }, + .first_sysupgrade_partition = "os-image", + .last_sysupgrade_partition = "file-system", + }, /** Firmware layout for the C60v1 */ { .id = "ARCHER-C60-V1", @@ -2870,6 +2904,7 @@ static void build_image(const char *output, strcasecmp(info->id, "ARCHER-C59-V2") == 0 || strcasecmp(info->id, "ARCHER-C60-V2") == 0 || strcasecmp(info->id, "ARCHER-C60-V3") == 0 || + strcasecmp(info->id, "ARCHER-C6U-V1") == 0 || strcasecmp(info->id, "TLWR1043NV5") == 0) { const uint8_t extra_para[2] = {0x01, 0x00}; parts[5] = make_extra_para(info, extra_para, From patchwork Tue Jun 8 09:45:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1489261 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) 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=bombadil.20210309 header.b=oTmDPDkh; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 4Fzlmr2HNkz9sCD for ; Tue, 8 Jun 2021 19:48:44 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EXEtukFwrM5ux62uM3C+SH88ssa21KXwmADreRmLprY=; b=oTmDPDkhy7H1hd yEeKMF3k3jepyuKwFRt1lRknXaQgs5xwJl1eGuQwVjeydBZ3TWc8PtEFYfEc96wRbkGwqjP38WJq7 s4cS3ZRMj7/S8d3CxqAdm8USFr++tM1UDF72RkKQmaoLmOYs5jy0r5Viww37C3C8D2qC5N2IZuEXh +rg2UWYkuivRXZIaRMFjkupwCxB/ldVRC0Xt0AdbN+Yxh61gaAvmd0IOXlK6j3grJcZlX1t3a8M7o 8B5TIgWobfkpNa+SUOzchTnKdQVyi4h63WdAqpTK24dF4YEF359lnfM7d0te0I/UGjXNItcmtOqcu sbPG3g9Ro1WISLN6m0+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqYKA-007VEY-Hn; Tue, 08 Jun 2021 09:47:06 +0000 Received: from smtp-out.xnet.cz ([178.217.244.18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqYIX-007Uk9-LN for openwrt-devel@lists.openwrt.org; Tue, 08 Jun 2021 09:45:31 +0000 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id A98F518945; Tue, 8 Jun 2021 11:45:19 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id eddd9c78; Tue, 8 Jun 2021 11:44:54 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Cc: "Leon M. George" , David Bauer Subject: [PATCH 21.02 06/11] ramips: add support for cudy WR2100 Date: Tue, 8 Jun 2021 11:45:07 +0200 Message-Id: <20210608094512.29956-7-ynezz@true.cz> In-Reply-To: <20210608094512.29956-1-ynezz@true.cz> References: <20210608094512.29956-1-ynezz@true.cz> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210608_024525_893313_27D91CBF X-CRM114-Status: GOOD ( 13.44 ) X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: "Leon M. George" Specifications SoC: MT7621 CPU: 880 MHz Flash: 16 MiB RAM: 128 MiB WLAN: 2.4 GHz b/g/n, 5 GHz a/n/ac MT7603E / MT7615E Ethernet: 5x Gbit ports Content analysis details: (0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: "Leon M. George" Specifications SoC: MT7621 CPU: 880 MHz Flash: 16 MiB RAM: 128 MiB WLAN: 2.4 GHz b/g/n, 5 GHz a/n/ac MT7603E / MT7615E Ethernet: 5x Gbit ports Installation There are two known options: 1) The Luci-based UI. 2) Press and hold the reset button during power up. The router will request 'recovery.bin' from a TFTP server at 192.168.1.88. Both options require a signed firmware binary. The openwrt image supplied by cudy is signed and can be used to install unsigned images. R4 & R5 need to be shorted (0-100Ω) for the UART to work. Signed-off-by: Leon M. George [remove non-required switch-port node - remove trgmii phy-mode] Signed-off-by: David Bauer (cherry picked from commit 3501db9b9b4a71ae52c539b46af817783c327866) --- .../linux/ramips/dts/mt7621_cudy_wr2100.dts | 201 ++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 10 + .../mt7621/base-files/etc/board.d/01_leds | 7 + 3 files changed, 218 insertions(+) create mode 100644 target/linux/ramips/dts/mt7621_cudy_wr2100.dts diff --git a/target/linux/ramips/dts/mt7621_cudy_wr2100.dts b/target/linux/ramips/dts/mt7621_cudy_wr2100.dts new file mode 100644 index 000000000000..692c94da555f --- /dev/null +++ b/target/linux/ramips/dts/mt7621_cudy_wr2100.dts @@ -0,0 +1,201 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621.dtsi" + +#include +#include + +/ { + compatible = "cudy,wr2100", "mediatek,mt7621-soc"; + model = "Cudy WR2100"; + + aliases { + led-boot = &led_internet_blue; + led-failsafe = &led_internet_blue; + led-running = &led_internet_blue; + led-upgrade = &led_internet_blue; + label-mac-device = &gmac0; + }; + + chosen { + bootargs = "console=ttyS0,115200"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio 8 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&gpio 10 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_internet_blue: internet_blue { + label = "blue:internet"; + gpios = <&gpio 4 GPIO_ACTIVE_LOW>; + }; + + internet_red { + label = "red:internet"; + gpios = <&gpio 3 GPIO_ACTIVE_LOW>; + }; + + wan { + label = "green:wan"; + gpios = <&gpio 13 GPIO_ACTIVE_LOW>; + }; + + lan1 { + label = "green:lan1"; + gpios = <&gpio 14 GPIO_ACTIVE_LOW>; + }; + + lan2 { + label = "green:lan2"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + }; + + lan3 { + label = "green:lan3"; + gpios = <&gpio 16 GPIO_ACTIVE_LOW>; + }; + + lan4 { + label = "green:lan4"; + gpios = <&gpio 15 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&gmac0 { + mtd-mac-address = <&bdinfo 0xde00>; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0000>; + ieee80211-freq-limit = <2400000 2500000>; + }; +}; + +&pcie1 { + wifi@1,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x8000>; + ieee80211-freq-limit = <5000000 6000000>; + }; +}; + +&spi0 { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <50000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x30000>; + read-only; + }; + + partition@30000 { + label = "u-boot-env"; + reg = <0x30000 0x10000>; + read-only; + }; + + factory: partition@40000 { + label = "factory"; + reg = <0x40000 0x10000>; + read-only; + }; + + partition@50000 { + compatible = "denx,uimage"; + label = "firmware"; + reg = <0x50000 0xf80000>; + }; + + partition@fd0000 { + label = "debug"; + reg = <0xfd0000 0x10000>; + read-only; + }; + + partition@fe0000 { + label = "backup"; + reg = <0xfe0000 0x10000>; + read-only; + }; + + bdinfo: partition@ff0000 { + label = "bdinfo"; + reg = <0xff0000 0x10000>; + read-only; + }; + }; + }; +}; + +&state_default { + gpio { + groups = "i2c", "jtag", "uart2", "uart3", "wdt"; + function = "gpio"; + }; +}; + +&switch0 { + ports { + port@0 { + status = "okay"; + label = "lan1"; + }; + + port@1 { + status = "okay"; + label = "lan2"; + }; + + port@2 { + status = "okay"; + label = "lan3"; + }; + + port@3 { + status = "okay"; + label = "lan4"; + }; + + port@4 { + status = "okay"; + label = "wan"; + + mtd-mac-address = <&bdinfo 0xde00>; + mtd-mac-address-increment = <1>; + }; + }; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index d56067948e88..0ec283d74fb2 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -240,6 +240,16 @@ define Device/cudy_wr1300 endef TARGET_DEVICES += cudy_wr1300 +define Device/cudy_wr2100 + $(Device/dsa-migration) + DEVICE_VENDOR := Cudy + DEVICE_MODEL := WR2100 + IMAGE_SIZE := 15872k + UIMAGE_NAME := R11 + DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615e kmod-mt7615-firmware +endef +TARGET_DEVICES += cudy_wr2100 + define Device/dlink_dir-8xx-a1 $(Device/dsa-migration) IMAGE_SIZE := 16000k diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds index e3064ad5ffcc..2e280442bf1b 100755 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds @@ -12,6 +12,13 @@ asus,rt-n56u-b1) ucidef_set_led_netdev "lan" "LAN link" "blue:lan" "br-lan" ucidef_set_led_netdev "wan" "WAN link" "blue:wan" "wan" ;; +cudy,wr2100) + ucidef_set_led_netdev "lan1" "lan1" "green:lan1" "lan1" + ucidef_set_led_netdev "lan2" "lan2" "green:lan2" "lan2" + ucidef_set_led_netdev "lan3" "lan3" "green:lan3" "lan3" + ucidef_set_led_netdev "lan4" "lan4" "green:lan4" "lan4" + ucidef_set_led_netdev "wan" "wan" "green:wan" "wan" + ;; d-team,newifi-d2) ucidef_set_led_netdev "internet" "internet" "amber:internet" "wan" ucidef_set_led_netdev "wlan2g" "WiFi 2.4GHz" "blue:wlan2g" "wlan0" From patchwork Tue Jun 8 09:45:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1489267 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) 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=bombadil.20210309 header.b=UksyuVZ9; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 4FzlqG00zRz9sWD for ; Tue, 8 Jun 2021 19:50:49 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pnXK4IQDoaS5WclNVWz1wpShoZAP5OFeAwsXSL2ZGfE=; b=UksyuVZ9No6rGm etsSOjVeLfL4ztnSz3alPem6ZkTpD1qQs+8pJZ4v9qkOmAkHJvaonywzljZ+HyjbzgcjOlf/FgD+o Vr59SHYdR3u4QGiZOfuVrXwNrMutfs37xR5DbbpZLIAwDb1gpR8+q6UXDLOCHPswX/yVN4iBVOsp6 7+RABrJ+i+5uYk/mKSqr/zm7iuPwdeI/D+D6rLMOaUiW6EzNlSxKK4GqFpEbFesnR0hNGA1tcE1Fl oygnkn5zLTWlXg4ux/1mIWTj50Gq41gBjMHPgLhoX2E5+F6EP3TxT7NmYVh1QRXO4CNBAeINOTWs0 ujioRddx+44+OCeprlkg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqYLs-007W1u-77; Tue, 08 Jun 2021 09:48:52 +0000 Received: from smtp-out.xnet.cz ([178.217.244.18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqYIa-007Ukt-CO for openwrt-devel@lists.openwrt.org; Tue, 08 Jun 2021 09:45:34 +0000 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id E6D2E18946; Tue, 8 Jun 2021 11:45:19 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id ecfa9c53; Tue, 8 Jun 2021 11:44:54 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Cc: Chukun Pan Subject: [PATCH 21.02 07/11] ramips: add support for JCG Q20 Date: Tue, 8 Jun 2021 11:45:08 +0200 Message-Id: <20210608094512.29956-8-ynezz@true.cz> In-Reply-To: <20210608094512.29956-1-ynezz@true.cz> References: <20210608094512.29956-1-ynezz@true.cz> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210608_024529_259891_80DD94B8 X-CRM114-Status: GOOD ( 12.67 ) X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Chukun Pan JCG Q20 is an AX 1800M router. Hardware specs: SoC: MediaTek MT7621AT Flash: Winbond W29N01HV 128 MiB RAM: Winbond W632GU6NB-11 256 MiB WiFi: MT7915 2.4/5 GHz 2T2R Ethernet: 10/100/1000 Mbps x3 LED: Status (red / blue) Button: Rese [...] Content analysis details: (0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Chukun Pan JCG Q20 is an AX 1800M router. Hardware specs: SoC: MediaTek MT7621AT Flash: Winbond W29N01HV 128 MiB RAM: Winbond W632GU6NB-11 256 MiB WiFi: MT7915 2.4/5 GHz 2T2R Ethernet: 10/100/1000 Mbps x3 LED: Status (red / blue) Button: Reset, WPS Power: DC 12V,1A Flash instructions: Upload factory.bin in stock firmware's upgrade page, do not preserve settings. MAC addresses map: 0x00004 *:3e wlan2g/wlan5g 0x3fff4 *:3c lan/label 0x3fffa *:3c wan Signed-off-by: Chukun Pan (cherry picked from commit 57cb387cfeee2a07902a2f1383ca471ef47265f3) --- package/boot/uboot-envtools/files/ramips | 3 + target/linux/ramips/dts/mt7621_jcg_q20.dts | 175 ++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 17 ++ .../mt7621/base-files/etc/board.d/02_network | 1 + .../etc/hotplug.d/ieee80211/10_fix_wifi_mac | 4 + .../mt7621/base-files/lib/upgrade/platform.sh | 1 + 6 files changed, 201 insertions(+) create mode 100644 target/linux/ramips/dts/mt7621_jcg_q20.dts diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips index c153b6a4226b..5800a548e3e4 100644 --- a/package/boot/uboot-envtools/files/ramips +++ b/package/boot/uboot-envtools/files/ramips @@ -44,6 +44,9 @@ ravpower,rp-wd03) [ -n "$idx" ] && \ ubootenv_add_uci_config "/dev/mtd$idx" "0x4000" "0x1000" "0x1000" ;; +jcg,q20) + ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000" + ;; linksys,ea7300-v1|\ linksys,ea7300-v2|\ linksys,ea7500-v2|\ diff --git a/target/linux/ramips/dts/mt7621_jcg_q20.dts b/target/linux/ramips/dts/mt7621_jcg_q20.dts new file mode 100644 index 000000000000..f0e829393ce1 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_jcg_q20.dts @@ -0,0 +1,175 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621.dtsi" + +#include +#include + +/ { + compatible = "jcg,q20", "mediatek,mt7621-soc"; + model = "JCG Q20"; + + aliases { + led-boot = &led_status_red; + led-failsafe = &led_status_red; + led-running = &led_status_blue; + led-upgrade = &led_status_blue; + label-mac-device = &gmac0; + }; + + chosen { + bootargs = "console=ttyS0,115200"; + }; + + leds { + compatible = "gpio-leds"; + + led_status_red: status_red { + label = "red:status"; + gpios = <&gpio 14 GPIO_ACTIVE_HIGH>; + }; + + led_status_blue: status_blue { + label = "blue:status"; + gpios = <&gpio 15 GPIO_ACTIVE_LOW>; + }; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&gpio 16 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + ubi-concat { + compatible = "mtd-concat"; + devices = <&ubiconcat0 &ubiconcat1>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "ubi"; + reg = <0x0 0x5900000>; + }; + }; + }; +}; + +&nand { + status = "okay"; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "Bootloader"; + reg = <0x0 0x80000>; + read-only; + }; + + partition@80000 { + label = "Config"; + reg = <0x80000 0x80000>; + }; + + factory: partition@100000 { + label = "Factory"; + reg = <0x100000 0x80000>; + read-only; + }; + + partition@180000 { + label = "kernel"; + reg = <0x180000 0x400000>; + }; + + ubiconcat0: partition@580000 { + label = "ubiconcat0"; + reg = <0x580000 0x1c00000>; + }; + + partition@2180000 { + label = "firmware_backup"; + reg = <0x2180000 0x2000000>; + }; + + partition@4180000 { + label = "rootfs_data_back"; + reg = <0x4180000 0x80000>; + read-only; + }; + + partition@4200000 { + label = "nvram_config"; + reg = <0x4200000 0x80000>; + read-only; + }; + + ubiconcat1: partition@4280000 { + label = "ubiconcat1"; + reg = <0x4280000 0x3d00000>; + }; + + /* + * last 512 KiB are for the bad block table + */ + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie1 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0>; + }; +}; + +&gmac0 { + mtd-mac-address = <&factory 0x3fff4>; +}; + +&switch0 { + ports { + port@0 { + status = "okay"; + label = "wan"; + mtd-mac-address = <&factory 0x3fffa>; + }; + + port@1 { + status = "okay"; + label = "lan1"; + }; + + port@4 { + status = "okay"; + label = "lan2"; + }; + }; +}; + +&state_default { + gpio { + groups = "jtag", "wdt"; + function = "gpio"; + }; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 0ec283d74fb2..6edf6c0cd6a7 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -720,6 +720,23 @@ define Device/jcg_jhr-ac876m endef TARGET_DEVICES += jcg_jhr-ac876m +define Device/jcg_q20 + $(Device/dsa-migration) + BLOCKSIZE := 128k + PAGESIZE := 2048 + UBINIZE_OPTS := -E 5 + KERNEL_SIZE := 4096k + IMAGE_SIZE := 91136k + IMAGES += factory.bin + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \ + check-size + DEVICE_VENDOR := JCG + DEVICE_MODEL := Q20 + DEVICE_PACKAGES := kmod-mt7915e uboot-envtools +endef +TARGET_DEVICES += jcg_q20 + define Device/jcg_y2 $(Device/dsa-migration) $(Device/uimage-lzma-loader) diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network index f017e4782e0e..f5b075f1f4a8 100755 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -15,6 +15,7 @@ ramips_setup_interfaces() ;; asiarf,ap7621-nv1|\ glinet,gl-mt1300|\ + jcg,q20|\ lenovo,newifi-d1|\ mikrotik,routerboard-m33g|\ xiaomi,mi-router-3g|\ diff --git a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac index e7f778aaf88a..427bde4e38f7 100644 --- a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac +++ b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -14,6 +14,10 @@ case "$board" in [ "$PHYNBR" = "1" ] && \ macaddr_add "$(mtd_get_mac_binary factory 0x4)" 1 > /sys${DEVPATH}/macaddress ;; + jcg,q20) + [ "$PHYNBR" = "1" ] && \ + macaddr_setbit_la "$(mtd_get_mac_binary Factory 0x4)" > /sys${DEVPATH}/macaddress + ;; linksys,ea7300-v1|\ linksys,ea7300-v2|\ linksys,ea7500-v2) diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh index d30bc3db2edd..98e429fdbf42 100755 --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh @@ -49,6 +49,7 @@ platform_do_upgrade() { dlink,dir-2640-a1|\ dlink,dir-2660-a1|\ hiwifi,hc5962|\ + jcg,q20|\ linksys,ea7300-v1|\ linksys,ea7300-v2|\ linksys,ea7500-v2|\ From patchwork Tue Jun 8 09:45:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1489264 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) 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=bombadil.20210309 header.b=Ua4ALfju; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 4FzlpL5WVpz9sCD for ; Tue, 8 Jun 2021 19:50:02 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pFvgymZEN1OyBIOP+lfZM6H18CXnkJ0yMuV2xISOXEo=; b=Ua4ALfjuYkVyQ9 IpzFo277Vilu4GEO+Hqd8AbtisTJbzgFDYbgVdREE9uGAqJL0TVnZPInPyU7tL8GaqrN6iQZxZKGf K/RaFF1DMJpZEyk18wNchJd2g7a5btgouvT7k2CTZMxcu/ea6EFCdnjMzK0VkHL2VciOTIAfhk/cn emFX8Yl0W4q7GB1a1vaMr1kU5JgXGpY5mysASRzdzUzGVou8YDYubTddTPgQly6xQPkWUI1x6cA5l 8R01DKNJiwlZJw2q2mh6W8iIa1HGcsfHIU8cNZDOwoMyJkMo+0/3+eDIqCWbGBs6ys/qjFBJfeZFT js6vnJUYiyxhc187Bl2A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqYKq-007VXd-I5; Tue, 08 Jun 2021 09:47:48 +0000 Received: from smtp-out.xnet.cz ([178.217.244.18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqYIZ-007Uku-M4 for openwrt-devel@lists.openwrt.org; Tue, 08 Jun 2021 09:45:33 +0000 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id 283D018947; Tue, 8 Jun 2021 11:45:20 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id 65b8cedc; Tue, 8 Jun 2021 11:44:55 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Cc: Aashish Kulkarni , Sannihith Kinnera , Adrian Schmutzler Subject: [PATCH 21.02 08/11] ramips: add support for Linksys E5600 Date: Tue, 8 Jun 2021 11:45:09 +0200 Message-Id: <20210608094512.29956-9-ynezz@true.cz> In-Reply-To: <20210608094512.29956-1-ynezz@true.cz> References: <20210608094512.29956-1-ynezz@true.cz> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210608_024527_921680_817BFB77 X-CRM114-Status: GOOD ( 16.33 ) X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Aashish Kulkarni This submission relied heavily on the work of Linksys EA7300 v1/ v2. Specifications: Content analysis details: (0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Aashish Kulkarni This submission relied heavily on the work of Linksys EA7300 v1/ v2. Specifications: * SoC: MediaTek MT7621A (880 MHz 2c/4t) * RAM: 128M DDR3-1600 * Flash: 128M NAND * Eth: MediaTek MT7621A (10/100/1000 Mbps x5) * Radio: MT7603E/MT7613BE (2.4 GHz & 5 GHz) * Antennae: 2 internal fixed in the casing and 2 on the PCB * LEDs: Blue (x4 Ethernet) Blue+Orange (x2 Power + WPS and Internet) * Buttons: Reset (x1) WPS (x1) Installation: Flash factory image through GUI. This device has 2 partitions for the firmware called firmware and alt_firmware. To successfully flash and boot the device, the device should have been running from alt_firmware partition. To get the device booted through alt_firmware partition, download the OEM firmware from Linksys website and upgrade the firmware from web GUI. Once this is done, flash the OpenWrt Factory firmware from web GUI. Reverting to factory firmware: 1. Boot to 'alt_firmware'(where stock firmware resides) by doing one of the following: Press the "wps" button as soon as power LED turns on when booting. (OR) Hard-reset the router consecutively three times to force it to boot from 'alt_firmware'. 2. To remove any traces of OpenWRT from your router simply flash the OEM image at this point. Signed-off-by: Aashish Kulkarni [fix hanging indents and wrap to 74 characters per line, add kmod-mt7663-firmware-sta package for 5GHz STA mode to work, remove sysupgrade.bin and concatenate IMAGES instead in mt7621.mk, set default-state "on" for power LED] Signed-off-by: Sannihith Kinnera [move check-size before append-metadata, remove trailing whitespace] Signed-off-by: Adrian Schmutzler (cherry picked from commit 251c995cbb1ea5ad1de14775312c2bd19ed10439) Tested-by: Sannihith Kinnera --- .../linux/ramips/dts/mt7621_linksys_e5600.dts | 182 ++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 23 +++ .../mt7621/base-files/etc/board.d/01_leds | 3 + .../mt7621/base-files/etc/board.d/02_network | 1 + .../etc/hotplug.d/ieee80211/10_fix_wifi_mac | 1 + .../mt7621/base-files/etc/init.d/bootcount | 1 + .../mt7621/base-files/lib/upgrade/platform.sh | 1 + 7 files changed, 212 insertions(+) create mode 100644 target/linux/ramips/dts/mt7621_linksys_e5600.dts diff --git a/target/linux/ramips/dts/mt7621_linksys_e5600.dts b/target/linux/ramips/dts/mt7621_linksys_e5600.dts new file mode 100644 index 000000000000..91db315914e4 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_linksys_e5600.dts @@ -0,0 +1,182 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621.dtsi" + +#include +#include + +/ { + compatible = "linksys,e5600", "mediatek,mt7621-soc"; + model = "Linksys E5600"; + + aliases { + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; + }; + + chosen { + bootargs = "console=ttyS0,115200"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio 12 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&gpio 17 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + wps { + label = "amber:wps"; + gpios = <&gpio 5 GPIO_ACTIVE_HIGH>; + }; + + led_power: power { + label = "blue:power"; + gpios = <&gpio 10 GPIO_ACTIVE_HIGH>; + default-state = "on"; + }; + + wan_amber { + label = "amber:wan"; + gpios = <&gpio 13 GPIO_ACTIVE_HIGH>; + }; + + wan_blue { + label = "blue:wan"; + gpios = <&gpio 15 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&nand { + status = "okay"; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "boot"; + reg = <0x0 0x80000>; + read-only; + }; + + partition@80000 { + label = "u_env"; + reg = <0x80000 0x40000>; + read-only; + }; + + factory: partition@c0000 { + label = "factory"; + reg = <0xc0000 0x40000>; + read-only; + }; + + partition@100000 { + label = "s_env"; + reg = <0x100000 0x40000>; + }; + + partition@140000 { + label = "devinfo"; + reg = <0x140000 0x40000>; + read-only; + }; + + partition@180000 { + label = "kernel"; + reg = <0x180000 0x400000>; + }; + + partition@580000 { + label = "ubi"; + reg = <0x580000 0x1a00000>; + }; + + partition@1f80000 { + label = "alt_firmware"; + reg = <0x1f80000 0x1e00000>; + }; + + partition@3d80000 { + label = "gdata"; + reg = <0x3d80000 0x4200000>; + }; + }; +}; + +&state_default { + gpio { + groups = "uart2", "uart3", "jtag"; + function = "gpio"; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + mt76@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0000>; + }; +}; + +&pcie1 { + mt76@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x8000>; + }; +}; + +&switch0 { + ports { + port@0 { + status = "okay"; + label = "lan1"; + }; + + port@1 { + status = "okay"; + label = "lan2"; + }; + + port@2 { + status = "okay"; + label = "lan3"; + }; + + port@3 { + status = "okay"; + label = "lan4"; + }; + + port@4 { + status = "okay"; + label = "wan"; + }; + }; +}; + +&xhci { + status = "disabled"; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 6edf6c0cd6a7..44170b4c1a30 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -22,6 +22,10 @@ define Build/elecom-wrc-gs-factory mv $@.new $@ endef +define Build/gemtek-trailer + printf "%s%08X" ".GEMTEK." "$$(cksum $@ | cut -d ' ' -f1)" >> $@ +endef + define Build/iodata-factory $(eval fw_size=$(word 1,$(1))) $(eval fw_type=$(word 2,$(1))) @@ -762,6 +766,25 @@ define Device/lenovo_newifi-d1 endef TARGET_DEVICES += lenovo_newifi-d1 +define Device/linksys_e5600 + $(Device/dsa-migration) + $(Device/uimage-lzma-loader) + BLOCKSIZE := 128k + PAGESIZE := 2048 + KERNEL_SIZE := 4096k + IMAGE_SIZE := 26624k + DEVICE_VENDOR := Linksys + DEVICE_MODEL := E5600 + DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615e kmod-mt7663-firmware-ap \ + kmod-mt7663-firmware-sta uboot-envtools + UBINIZE_OPTS := -E 5 + IMAGES += factory.bin + IMAGE/sysupgrade.bin := sysupgrade-tar | check-size | append-metadata + IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | \ + append-ubi | check-size | gemtek-trailer +endef +TARGET_DEVICES += linksys_e5600 + define Device/linksys_ea7xxx $(Device/dsa-migration) $(Device/uimage-lzma-loader) diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds index 2e280442bf1b..89a56dff2a48 100755 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds @@ -47,6 +47,9 @@ gnubee,gb-pc2) ucidef_set_led_netdev "lan1" "lan1" "green:lan1" "lan1" ucidef_set_led_netdev "lan2" "lan2" "green:lan2" "lan2" ;; +linksys,e5600) + ucidef_set_led_netdev "wan" "wan link" "blue:wan" "wan" "link" + ;; linksys,ea7300-v1|\ linksys,ea7300-v2|\ linksys,ea7500-v2) diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network index f5b075f1f4a8..40f1bfaecd58 100755 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -128,6 +128,7 @@ ramips_setup_macs() zbtlink,zbt-wg3526-32m) label_mac=$(mtd_get_mac_binary factory 0x4) ;; + linksys,e5600|\ linksys,ea7300-v1|\ linksys,ea7300-v2|\ linksys,ea7500-v2) diff --git a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac index 427bde4e38f7..49b7f23ce914 100644 --- a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac +++ b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -18,6 +18,7 @@ case "$board" in [ "$PHYNBR" = "1" ] && \ macaddr_setbit_la "$(mtd_get_mac_binary Factory 0x4)" > /sys${DEVPATH}/macaddress ;; + linksys,e5600|\ linksys,ea7300-v1|\ linksys,ea7300-v2|\ linksys,ea7500-v2) diff --git a/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount b/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount index a155458d3f23..cfaa62485cea 100755 --- a/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount +++ b/target/linux/ramips/mt7621/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 - ;; + linksys,e5600|\ linksys,ea7300-v1|\ linksys,ea7300-v2|\ linksys,ea7500-v2) diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh index 98e429fdbf42..7b57ee7776c5 100755 --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh @@ -50,6 +50,7 @@ platform_do_upgrade() { dlink,dir-2660-a1|\ hiwifi,hc5962|\ jcg,q20|\ + linksys,e5600|\ linksys,ea7300-v1|\ linksys,ea7300-v2|\ linksys,ea7500-v2|\ From patchwork Tue Jun 8 09:45:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1489269 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) 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=bombadil.20210309 header.b=PsPQlX6A; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 4FzlrB1t2cz9sCD for ; Tue, 8 Jun 2021 19:51:38 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=eNLpVRN++/IKaa1geMDv56Sf7gWMDsVOdEsLhxWSFLQ=; b=PsPQlX6AQDsqDU JLckDUQYl+x4rSI+WD+ZY3FxzguaHql2JhIIOSLJRyxiwhNOeeU3PXabVhcu/qlKNDHQLWWFGoBvg 77y1YDrcInG/Ezh0kL4tOWBFevwKGckwIzBx0sZRIejO4+aN+MqCJtK4SwjTMp6eQQSVdA5zvxbnS wj18htSZObAsLmOzUAfs+SjmIWXKHC9P8JpppkoBC9OrvZrhI0xB0lPH17LfuYobZPv2yRTZtZVfA /3K2CmhsZsSn6nI6GmwXvcLdKy63jqE/utYHHwjHxknae8Wf0CkwrUOvKzQI1KjXb3m/9qJZQ00RS R7ZUctdhHJJ4/s3/yEWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqYMP-007WH4-LS; Tue, 08 Jun 2021 09:49:26 +0000 Received: from smtp-out.xnet.cz ([178.217.244.18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqYIa-007UlB-Ml for openwrt-devel@lists.openwrt.org; Tue, 08 Jun 2021 09:45:34 +0000 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id 6DD5E18949; Tue, 8 Jun 2021 11:45:21 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id 70e6931e; Tue, 8 Jun 2021 11:44:56 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Cc: Jonathan Sturges Subject: [PATCH 21.02 09/11] ramips: add support for Amped Wireless ALLY router and extender Date: Tue, 8 Jun 2021 11:45:10 +0200 Message-Id: <20210608094512.29956-10-ynezz@true.cz> In-Reply-To: <20210608094512.29956-1-ynezz@true.cz> References: <20210608094512.29956-1-ynezz@true.cz> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210608_024529_324496_1619C806 X-CRM114-Status: GOOD ( 28.13 ) X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Jonathan Sturges Amped Wireless ALLY is a whole-home WiFi kit, with a router (model ALLY-R1900K) and an Extender (model ALLY-00X19K). Both are devices are 11ac and based on MediaTek MT7621AT and MT7615N chips. The uni [...] Content analysis details: (0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 NUMERIC_HTTP_ADDR URI: Uses a numeric IP address in URL X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Jonathan Sturges Amped Wireless ALLY is a whole-home WiFi kit, with a router (model ALLY-R1900K) and an Extender (model ALLY-00X19K). Both are devices are 11ac and based on MediaTek MT7621AT and MT7615N chips. The units are nearly identical, except the Extender lacks a USB port and has a single Ethernet port. Specification: - SoC: MediaTek MT7621AT (2C/4T) @ 880MHz - RAM: 128MB DDR3 (Nanya NT5CC64M16GP-DI) - FLASH: 128MB NAND (Winbond W29N01GVSIAA) - WiFi: 2.4/5 GHz 4T4R - 2.4GHz MediaTek MT7615N bgn - 5GHz MediaTek MT7615N nac - Switch: SoC integrated Gigabit Switch - USB: 1x USB3 (Router only) - BTN: Reset, WPS - LED: single RGB - UART: through-hole on PCB. J1: pin1 (square pad, towards rear)=3.3V, pin2=RX, pin3=GND, pin4=TX. Settings: 57600/8N1. Note regarding dual system partitions ------------------------------------- The vendor firmware and boot loader use a dual partition scheme. The boot partition is decided by the bootImage U-boot environment variable: 0 for the 1st partition, 1 for the 2nd. OpenWrt does not support this scheme and will always use the first OS partition. It will set bootImage to 0 during installation, making sure the first partition is selected by the boot loader. Also, because we can't be sure which partition is active to begin with, a 2-step flash process is used. We first flash an initramfs image, then follow with a regular sysupgrade. Installation: Router (ALLY-R1900K) 1) Install the flashable initramfs image via the OEM web-interface. (Alternatively, you can use the TFTP recovery method below.) You can use WiFi or Ethernet. The direct URL is: http://192.168.3.1/07_06_00_firmware.html a. No login is needed, and you'll be in their setup wizard. b. You might get a warning about not being connected to the Internet. c. Towards the bottom of the page will be a section entitled "Or Manually Upgrade Firmware from a File:" where you can manually choose and upload a firmware file. d: Click "Choose File", select the OpenWRT "initramfs" image and click "Upload." 2) The Router will flash the OpenWrt initramfs image and reboot. After booting, LuCI will be available on 192.168.1.1. 3) Log into LuCI as root; there is no password. 4) Optional (but recommended) is to backup the OEM firmware before continuing; see process below. 5) Complete the Installation by flashing a full OpenWRT image. Note: you may use the sysupgrade command line tool in lieu of the UI if you prefer. a. Choose System -> Backup/Flash Firmware. b. Click "Flash Image..." under "Flash new firmware image" c. Click "Browse..." and then select the sysupgrade file. d. Click Upload to upload the sysupgrade file. e. Important: uncheck "Keep settings and retain the current configuration" for this initial installation. f. Click "Continue" to flash the firmware. g. The device will reboot and OpenWRT is installed. Extender (ALLY-00X19K) 1) This device requires a TFTP recovery procedure to do an initial load of OpenWRT. Start by configuring a computer as a TFTP client: a. Install a TFTP client (server not necessary) b. Configure an Ethernet interface to 192.168.1.x/24; don't use .1 or .6 c. Connect the Ethernet to the sole Ethernet port on the X19K. 2) Put the ALLY Extender in TFTP recovery mode. a. Do this by pressing and holding the reset button on the bottom while connecting the power. b. As soon as the LED lights up green (roughly 2-3 seconds), release the button. 3) Start the TFTP transfer of the Initramfs image from your setup machine. For example, from Linux: tftp -v -m binary 192.168.1.6 69 -c put initramfs.bin 4) The Extender will flash the OpenWrt initramfs image and reboot. After booting, LuCI will be available on 192.168.1.1. 5) Log into LuCI as root; there is no password. 6) Optional (but recommended) is to backup the OEM firmware before continuing; see process below. 7) Complete the Installation by flashing a full OpenWRT image. Note: you may use the sysupgrade command line tool in lieu of the UI if you prefer. a. Choose System -> Backup/Flash Firmware. b. Click "Flash Image..." under "Flash new firmware image" c. Click "Browse..." and then select the sysupgrade file. d. Click Upload to upload the sysupgrade file. e. Important: uncheck "Keep settings and retain the current configuration" for this initial installation. f. Click "Continue" to flash the firmware. g. The device will reboot and OpenWRT is installed. Backup the OEM Firmware: ----------------------- There isn't any downloadable firmware for the ALLY devices on the Amped Wireless web site. Reverting back to the OEM firmware is not possible unless we have a backup of the original OEM firmware. The OEM firmware may be stored on either /dev/mtd3 ("firmware") or /dev/mtd6 ("oem"). We can't be sure which was overwritten with the initramfs image, so backup both partitions to be safe. 1) Once logged into LuCI, navigate to System -> Backup/Flash Firmware. 2) Under "Save mtdblock contents," first select "firmware" and click "Save mtdblock" to download the image. 3) Repeat the process, but select "oem" from the pull-down menu. Revert to the OEM Firmware: -------------------------- * U-boot TFTP: Follow the TFTP recovery steps for the Extender, and use the backup image. * OpenWrt "Flash Firmware" interface: Upload the backup image and select "Force update" before continuing. Signed-off-by: Jonathan Sturges (cherry picked from commit 6d23e474ad9d0eba935696c66db4fb6e2037bb72) --- package/boot/uboot-envtools/files/ramips | 4 + .../dts/mt7621_ampedwireless_ally-00x19k.dts | 21 ++ .../dts/mt7621_ampedwireless_ally-r1900k.dts | 32 ++++ .../ramips/dts/mt7621_ampedwireless_ally.dtsi | 179 ++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 27 +++ .../mt7621/base-files/etc/board.d/02_network | 41 ++-- .../mt7621/base-files/lib/upgrade/platform.sh | 8 + 7 files changed, 297 insertions(+), 15 deletions(-) create mode 100644 target/linux/ramips/dts/mt7621_ampedwireless_ally-00x19k.dts create mode 100644 target/linux/ramips/dts/mt7621_ampedwireless_ally-r1900k.dts create mode 100644 target/linux/ramips/dts/mt7621_ampedwireless_ally.dtsi diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips index 5800a548e3e4..e1920303a990 100644 --- a/package/boot/uboot-envtools/files/ramips +++ b/package/boot/uboot-envtools/files/ramips @@ -26,6 +26,10 @@ allnet,all0256n-8m|\ allnet,all5002) ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000" ;; +ampedwireless,ally-00x19k|\ +ampedwireless,ally-r1900k) + ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x20000" "4" + ;; buffalo,wsr-1166dhp|\ buffalo,wsr-600dhp|\ mediatek,linkit-smart-7688|\ diff --git a/target/linux/ramips/dts/mt7621_ampedwireless_ally-00x19k.dts b/target/linux/ramips/dts/mt7621_ampedwireless_ally-00x19k.dts new file mode 100644 index 000000000000..51d41c7fb408 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_ampedwireless_ally-00x19k.dts @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621_ampedwireless_ally.dtsi" + +/ { + compatible = "ampedwireless,ally-00x19k", "mediatek,mt7621-soc"; + model = "Amped Wireless ALLY-00X19K"; +}; + +&switch0 { + ports { + port@2 { + status = "okay"; + label = "lan"; + }; + }; +}; + +&xhci { + status = "disabled"; +}; diff --git a/target/linux/ramips/dts/mt7621_ampedwireless_ally-r1900k.dts b/target/linux/ramips/dts/mt7621_ampedwireless_ally-r1900k.dts new file mode 100644 index 000000000000..cd2536e17906 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_ampedwireless_ally-r1900k.dts @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621_ampedwireless_ally.dtsi" + +/ { + compatible = "ampedwireless,ally-r1900k", "mediatek,mt7621-soc"; + model = "Amped Wireless ALLY-R1900K"; +}; + +&switch0 { + ports { + port@1 { + status = "okay"; + label = "wan"; + }; + + port@2 { + status = "okay"; + label = "lan1"; + }; + + port@3 { + status = "okay"; + label = "lan2"; + }; + + port@4 { + status = "okay"; + label = "lan3"; + }; + }; +}; diff --git a/target/linux/ramips/dts/mt7621_ampedwireless_ally.dtsi b/target/linux/ramips/dts/mt7621_ampedwireless_ally.dtsi new file mode 100644 index 000000000000..7736b06e4387 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_ampedwireless_ally.dtsi @@ -0,0 +1,179 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621.dtsi" + +#include +#include + +/ { + aliases { + led-boot = &led_status_amber; + led-failsafe = &led_status_amber; + led-running = &led_status_green; + led-upgrade = &led_status_red; + }; + + keys { + compatible = "gpio-keys"; + + led_switch { + label = "led_switch"; + gpios = <&gpio 13 GPIO_ACTIVE_HIGH>; + linux,code = ; + linux,input-type = ; + }; + + reset { + label = "reset"; + gpios = <&gpio 16 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&gpio 18 GPIO_ACTIVE_HIGH>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_status_green: status_green { + label = "green:status"; + gpios = <&gpio 7 GPIO_ACTIVE_HIGH>; + }; + + led_status_red: status_red { + label = "red:status"; + gpios = <&gpio 12 GPIO_ACTIVE_HIGH>; + }; + + led_status_amber: status_amber { + label = "amber:status"; + gpios = <&gpio 14 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + wifi@0,0 { + compatible = "pci14c3,7615"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0000>; + ieee80211-freq-limit = <2400000 2500000>; + }; +}; + +&pcie1 { + wifi@0,0 { + compatible = "pci14c3,7615"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x8000>; + ieee80211-freq-limit = <5000000 6000000>; + }; +}; + +&state_default { + gpio { + groups = "uart2", "uart3", "jtag", "wdt"; + function = "gpio"; + }; +}; + +&nand { + status = "okay"; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x80000>; + read-only; + }; + + partition@80000 { + label = "u-boot-env"; + reg = <0x80000 0x80000>; + }; + + factory: partition@100000 { + label = "factory"; + reg = <0x100000 0x40000>; + read-only; + }; + + /* + * uboot expects to find kernels at 0x140000 & 0x2140000, + * referred to as Uimage & Uimage1 in factory FW, respectively. + * U-boot variable 'bootImage' controls which is booted; + * 0 for the first, 1 for the 2nd. + * There's a 3rd partition, Uimage2 (0x4140000), which + * I expected to be a recovery image, but is actually blank. + * + * A kernel is considered suitable for handing control over + * if its linux magic number exists & uImage CRC are correct. + * If either of those conditions fail, 'bootImage' value + * is toggled in uboot env & a restart performed in the hope that the + * alternate kernel is okay. + * + * Note uboot's tftp flash install writes the transferred + * image to the active kernel partition. + */ + + partition@140000 { + label = "kernel"; + reg = <0x140000 0x400000>; + }; + + partition@540000 { + label = "ubi"; + reg = <0x540000 0x1c00000>; + }; + + partition@2140000 { + label = "oem"; + reg = <0x2140000 0x2000000>; + }; + + partition@4140000 { + label = "backup"; + reg = <0x4140000 0x2000000>; + }; + + partition@6140000 { + label = "chime"; + reg = <0x6140000 0xa00000>; + }; + + partition@6b40000 { + label = "data"; + reg = <0x6b40000 0xa00000>; + }; + + partition@7540000 { + label = "reserved"; + reg = <0x7540000 0x840000>; + read-only; + }; + + partition@7d80000 { + label = "nvram"; + reg = <0x7d80000 0x100000>; + read-only; + }; + + partition@7e80000 { + label = "hwconfig"; + reg = <0x7e80000 0x100000>; + read-only; + }; + }; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 44170b4c1a30..873011d2d8fe 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -126,6 +126,33 @@ define Device/alfa-network_quad-e4g endef TARGET_DEVICES += alfa-network_quad-e4g +define Device/ampedwireless_ally_common + $(Device/dsa-migration) + DEVICE_VENDOR := Amped Wireless + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware uboot-envtools + IMAGE_SIZE := 32768k + KERNEL_SIZE := 4096k + BLOCKSIZE := 128k + PAGESIZE := 2048 + UBINIZE_OPTS := -E 5 + KERNEL_INITRAMFS := $(KERNEL_DTB) | uImage lzma -n 'flashable-initramfs' |\ + edimax-header -s CSYS -m RN68 -f 0x001c0000 -S 0x01100000 + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata +endef + +define Device/ampedwireless_ally-r1900k + $(Device/ampedwireless_ally_common) + DEVICE_MODEL := ALLY-R1900K + DEVICE_PACKAGES += kmod-usb3 +endef +TARGET_DEVICES += ampedwireless_ally-r1900k + +define Device/ampedwireless_ally-00x19k + $(Device/ampedwireless_ally_common) + DEVICE_MODEL := ALLY-00X19K +endef +TARGET_DEVICES += ampedwireless_ally-00x19k + define Device/asiarf_ap7621-001 $(Device/dsa-migration) IMAGE_SIZE := 16000k diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network index 40f1bfaecd58..5d5923cc70de 100755 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -9,21 +9,7 @@ ramips_setup_interfaces() local board="$1" case $board in - asiarf,ap7621-001|\ - winstars,ws-wn583a6) - ucidef_set_interfaces_lan_wan "lan" "wan" - ;; - asiarf,ap7621-nv1|\ - glinet,gl-mt1300|\ - jcg,q20|\ - lenovo,newifi-d1|\ - mikrotik,routerboard-m33g|\ - xiaomi,mi-router-3g|\ - xiaomi,mi-router-3g-v2|\ - xiaomi,mi-router-4|\ - xiaomi,mi-router-4a-gigabit) - ucidef_set_interfaces_lan_wan "lan1 lan2" "wan" - ;; + ampedwireless,ally-00x19k|\ edimax,re23s|\ mikrotik,routerboard-m11g|\ netgear,ex6150|\ @@ -35,6 +21,7 @@ ramips_setup_interfaces() ubnt,unifi-nanohd) ucidef_set_interface_lan "lan" ;; + ampedwireless,ally-r1900k|\ gehua,ghl-r-001|\ hiwifi,hc5962|\ xiaomi,mi-router-3-pro|\ @@ -42,6 +29,21 @@ ramips_setup_interfaces() xiaomi,redmi-router-ac2100) ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan" ;; + asiarf,ap7621-001|\ + winstars,ws-wn583a6) + ucidef_set_interfaces_lan_wan "lan" "wan" + ;; + asiarf,ap7621-nv1|\ + glinet,gl-mt1300|\ + jcg,q20|\ + lenovo,newifi-d1|\ + mikrotik,routerboard-m33g|\ + xiaomi,mi-router-3g|\ + xiaomi,mi-router-3g-v2|\ + xiaomi,mi-router-4|\ + xiaomi,mi-router-4a-gigabit) + ucidef_set_interfaces_lan_wan "lan1 lan2" "wan" + ;; gnubee,gb-pc1|\ gnubee,gb-pc2) ucidef_set_interface_lan "lan1 lan2" @@ -86,6 +88,15 @@ ramips_setup_macs() local label_mac="" case $board in + ampedwireless,ally-00x19k) + lan_mac=$(mtd_get_mac_ascii hwconfig HW.LAN.MAC.Address) + label_mac=$lan_mac + ;; + ampedwireless,ally-r1900k) + lan_mac=$(mtd_get_mac_ascii hwconfig HW.LAN.MAC.Address) + wan_mac=$(mtd_get_mac_ascii hwconfig HW.WAN.MAC.Address) + label_mac=$lan_mac + ;; asus,rt-ac65p|\ asus,rt-ac85p) wan_mac=$(mtd_get_mac_ascii u-boot-env et1macaddr) diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh index 7b57ee7776c5..689a0e51ae00 100755 --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh @@ -27,6 +27,12 @@ platform_do_upgrade() { fi } ;; + ampedwireless,ally-00x19k|\ + ampedwireless,ally-r1900k) + if [ "$(fw_printenv --lock / -n bootImage 2>/dev/null)" != "0" ]; then + fw_setenv --lock / bootImage 0 || exit 1 + fi + ;; mikrotik,routerboard-750gr3|\ mikrotik,routerboard-760igs|\ mikrotik,routerboard-m11g|\ @@ -43,6 +49,8 @@ platform_do_upgrade() { esac case "$board" in + ampedwireless,ally-00x19k|\ + ampedwireless,ally-r1900k|\ asus,rt-ac65p|\ asus,rt-ac85p|\ dlink,dir-1960-a1|\ From patchwork Tue Jun 8 09:45:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1489265 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) 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=bombadil.20210309 header.b=y41z7y4A; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 4Fzlpd59TZz9sSn for ; Tue, 8 Jun 2021 19:50:17 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Pa4zQML4zkuLkLg5nxKwshYAfxphmxRvRRRzKtBnun4=; b=y41z7y4AavqMmq /UOxyQ9sE3MFlylzsQ2/38DcF9uaaRDYaXUc3menjMxG/wW6oBnsR/xOQx8FrWn1zQNwZmNVwx5ij W4OyHtDzGBB4DoPzWTVcfl36mIp8sDThQgdM9rvBmMypRReMkMS/iDzJeNlsiIbpV7OOcmTs7h3de 80P8VWBcE7tFQ90CPpNg2oKV+wJJq7k2f4XMcJJR+MkL8G9en4AAgzQwkMGGW3mKEklSP9XIvE5D+ x0DaenbZRdHZxRrpmNqOLaaJw1+j4J0eRhNHsxCppvNyjtLIQoJ42N9G3AgyX6ZoWKiE+eGhMYzw6 1Rvu03L2EikEVZxcW/iw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqYLK-007Vl9-GR; Tue, 08 Jun 2021 09:48:18 +0000 Received: from smtp-out.xnet.cz ([178.217.244.18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqYIa-007UlC-CM for openwrt-devel@lists.openwrt.org; Tue, 08 Jun 2021 09:45:33 +0000 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id 907E81894A; Tue, 8 Jun 2021 11:45:21 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id daa9ce38; Tue, 8 Jun 2021 11:44:56 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Cc: Tee Hao Wei , Adrian Schmutzler Subject: [PATCH 21.02 10/11] ramips: add support for Linksys EA8100 v1 Date: Tue, 8 Jun 2021 11:45:11 +0200 Message-Id: <20210608094512.29956-11-ynezz@true.cz> In-Reply-To: <20210608094512.29956-1-ynezz@true.cz> References: <20210608094512.29956-1-ynezz@true.cz> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210608_024529_247642_A971A4AC X-CRM114-Status: GOOD ( 15.76 ) X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Tee Hao Wei Specifications: - SoC: MT7621AT - RAM: 256MB - Flash: 128MB NAND - Ethernet: 5 Gigabit ports - WiFi: 2.4G/5G MT7615N - USB: 1 USB 3.0, 1 USB 2.0 This device is very similar to the EA7300 v1/v2 and EA7500 v2. Content analysis details: (0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Tee Hao Wei Specifications: - SoC: MT7621AT - RAM: 256MB - Flash: 128MB NAND - Ethernet: 5 Gigabit ports - WiFi: 2.4G/5G MT7615N - USB: 1 USB 3.0, 1 USB 2.0 This device is very similar to the EA7300 v1/v2 and EA7500 v2. Installation: Upload the generated factory image through the factory web interface. (following part taken from EA7300 v2 commit message:) This might fail due to the A/B nature of this device. When flashing, OEM firmware writes over the non-booted partition. If booted from 'A', flashing over 'B' won't work. To get around this, you should flash the OEM image over itself. This will then boot the router from 'B' and allow you to flash OpenWRT without problems. Reverting to factory firmware: Hard-reset the router three times to force it to boot from 'B.' This is where the stock firmware resides. To remove any traces of OpenWRT from your router simply flash the OEM image at this point. With thanks to Leon Poon (@LeonPoon) for the initial bringup. Signed-off-by: Tee Hao Wei [add missing entry in 10_fix_wifi_mac] Signed-off-by: Adrian Schmutzler (cherry picked from commit b232680f847f4ea8d058849a51dedebb8e398a01) --- package/boot/uboot-envtools/files/ramips | 1 + target/linux/ramips/dts/mt7621_linksys_ea8100-v1.dts | 8 ++++++++ target/linux/ramips/image/mt7621.mk | 8 ++++++++ target/linux/ramips/mt7621/base-files/etc/board.d/01_leds | 3 ++- .../linux/ramips/mt7621/base-files/etc/board.d/02_network | 3 ++- .../base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac | 3 ++- .../linux/ramips/mt7621/base-files/etc/init.d/bootcount | 3 ++- .../ramips/mt7621/base-files/lib/upgrade/platform.sh | 1 + 8 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 target/linux/ramips/dts/mt7621_linksys_ea8100-v1.dts diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips index e1920303a990..0de062bd8358 100644 --- a/package/boot/uboot-envtools/files/ramips +++ b/package/boot/uboot-envtools/files/ramips @@ -54,6 +54,7 @@ jcg,q20) linksys,ea7300-v1|\ linksys,ea7300-v2|\ linksys,ea7500-v2|\ +linksys,ea8100-v1|\ xiaomi,mi-router-3g|\ xiaomi,mi-router-3-pro|\ xiaomi,mi-router-4|\ diff --git a/target/linux/ramips/dts/mt7621_linksys_ea8100-v1.dts b/target/linux/ramips/dts/mt7621_linksys_ea8100-v1.dts new file mode 100644 index 000000000000..6cc2219aec92 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_linksys_ea8100-v1.dts @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621_linksys_ea7xxx.dtsi" + +/ { + compatible = "linksys,ea8100-v1", "mediatek,mt7621-soc"; + model = "Linksys EA8100"; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 873011d2d8fe..6645c7b06e5f 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -854,6 +854,14 @@ define Device/linksys_ea7500-v2 endef TARGET_DEVICES += linksys_ea7500-v2 +define Device/linksys_ea8100-v1 + $(Device/linksys_ea7xxx) + DEVICE_MODEL := EA8100 + DEVICE_VARIANT := v1 + LINKSYS_HWNAME := EA8100 +endef +TARGET_DEVICES += linksys_ea8100-v1 + define Device/linksys_re6500 $(Device/dsa-migration) IMAGE_SIZE := 7872k diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds index 89a56dff2a48..95cf120f2de9 100755 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds @@ -52,7 +52,8 @@ linksys,e5600) ;; linksys,ea7300-v1|\ linksys,ea7300-v2|\ -linksys,ea7500-v2) +linksys,ea7500-v2|\ +linksys,ea8100-v1) ucidef_set_led_netdev "lan1" "lan1 link" "green:lan1" "lan1" "link" ucidef_set_led_netdev "lan2" "lan2 link" "green:lan2" "lan2" "link" ucidef_set_led_netdev "lan3" "lan3 link" "green:lan3" "lan3" "link" diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network index 5d5923cc70de..c0c767306af7 100755 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -142,7 +142,8 @@ ramips_setup_macs() linksys,e5600|\ linksys,ea7300-v1|\ linksys,ea7300-v2|\ - linksys,ea7500-v2) + linksys,ea7500-v2|\ + linksys,ea8100-v1) lan_mac=$(mtd_get_mac_ascii devinfo hw_mac_addr) wan_mac=$lan_mac label_mac=$lan_mac diff --git a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac index 49b7f23ce914..bd0f0254c6c3 100644 --- a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac +++ b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -21,7 +21,8 @@ case "$board" in linksys,e5600|\ linksys,ea7300-v1|\ linksys,ea7300-v2|\ - linksys,ea7500-v2) + linksys,ea7500-v2|\ + linksys,ea8100-v1) hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr) [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress diff --git a/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount b/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount index cfaa62485cea..d3525ea0c938 100755 --- a/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount +++ b/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount @@ -11,7 +11,8 @@ boot() { linksys,e5600|\ linksys,ea7300-v1|\ linksys,ea7300-v2|\ - linksys,ea7500-v2) + linksys,ea7500-v2|\ + linksys,ea8100-v1) mtd resetbc s_env || true ;; samknows,whitebox-v8) diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh index 689a0e51ae00..4943ad130548 100755 --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh @@ -62,6 +62,7 @@ platform_do_upgrade() { linksys,ea7300-v1|\ linksys,ea7300-v2|\ linksys,ea7500-v2|\ + linksys,ea8100-v1|\ netgear,r6220|\ netgear,r6260|\ netgear,r6350|\ From patchwork Tue Jun 8 09:45:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1489271 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) 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=bombadil.20210309 header.b=Or661+Vb; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 4Fzlrw73DFz9sWD for ; Tue, 8 Jun 2021 19:52:16 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4yJK2JQCM01R+W9cdN2m0hn8i94K2mZ9Ba/eZUrU1Kg=; b=Or661+VbAOAzhJ oje84iCW5g57OYE5zHK7/Ild9+5AwcUcDTI3SPQw8JWo/LDRZPZP/h6WsgSmkhmU8YxfAM0Z5Ej2v RrdOjBsPsdmkKDTeiD5wvNi8MgfDosEvUItgOV3/UwW1H81gEQ0WqXzOUFp8bNhWmnGVUCRumtQpw yvAEU57T1/IwsaA2ZChSiLboRU2zdSaAr9yslTzFbgBbHdvF+XUyFhiaA0KiqBHVdLay5grYIMSSk GoeoFq+GSrlI7WlMisDkKehJ+ADurxZtwsXLjokH7qpoNG4USkeFhmgKwzRylF3PqTFdQPzw72B4G gQWdduVfEU54tc8Ydv7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqYNE-007WcY-Ph; Tue, 08 Jun 2021 09:50:17 +0000 Received: from smtp-out.xnet.cz ([178.217.244.18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqYIc-007UmK-CO for openwrt-devel@lists.openwrt.org; Tue, 08 Jun 2021 09:45:34 +0000 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id D3A1B1894E; Tue, 8 Jun 2021 11:45:22 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id f968d294; Tue, 8 Jun 2021 11:44:57 +0200 (CEST) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Cc: =?utf-8?q?Andreas_B=C3=B6hler?= , Adrian Schmutzler Subject: [PATCH 21.02 11/11] ramips: Add support for SERCOMM NA502 Date: Tue, 8 Jun 2021 11:45:12 +0200 Message-Id: <20210608094512.29956-12-ynezz@true.cz> In-Reply-To: <20210608094512.29956-1-ynezz@true.cz> References: <20210608094512.29956-1-ynezz@true.cz> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210608_024530_812407_E197A52E X-CRM114-Status: GOOD ( 13.81 ) X-Spam-Score: 0.0 (/) X-Spam-Report: =?unknown-8bit?q?Spam_detection_software=2C_running_on_the_sy?= =?unknown-8bit?q?stem_=22bombadil=2Einfradead=2Eorg=22=2C?= =?unknown-8bit?q?_has_NOT_identified_this_incoming_email_as_spam=2E__The_ori?= =?unknown-8bit?q?ginal?= =?unknown-8bit?q?_message_has_been_attached_to_this_so_you_can_view_it_or_la?= =?unknown-8bit?q?bel?= =?unknown-8bit?q?_similar_future_email=2E__If_you_have_any_questions=2C_see?= =?unknown-8bit?q?_the_administrator_of_that_system_for_details=2E?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_preview=3A__From=3A_Andreas_B=C3=B6hler_=3Cdev=40a?= =?unknown-8bit?q?boehler=2Eat=3E_The_SERCOMM_NA502?= =?unknown-8bit?q?_is_a_smart_home_gateway_manufactured_by_SERCOMM_and_sold_u?= =?unknown-8bit?q?nder_different_brands?= =?unknown-8bit?q?_=28among_others=2C_A1_Telekom_Austria_SmartHome_Gateway=29?= =?unknown-8bit?q?=2E_It_has_multi-protocol?= =?unknown-8bit?q?_radio_support_in_addition_=5B=2E=2E=2E=5D_?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_analysis_details=3A___=280=2E0_points=2C_5=2E0_req?= =?unknown-8bit?q?uired=29?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_pts_rule_name______________description?= =?unknown-8bit?q?_----_----------------------_------------------------------?= =?unknown-8bit?q?--------------------?= =?unknown-8bit?q?_0=2E0_SPF=5FNONE_______________SPF=3A_sender_does_not_publ?= =?unknown-8bit?q?ish_an_SPF_Record?= =?unknown-8bit?q?_0=2E0_SPF=5FHELO=5FNONE__________SPF=3A_HELO_does_not_publ?= =?unknown-8bit?q?ish_an_SPF_Record?= X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Andreas Böhler The SERCOMM NA502 is a smart home gateway manufactured by SERCOMM and sold under different brands (among others, A1 Telekom Austria SmartHome Gateway). It has multi-protocol radio support in addition to LAN and WiFi. Note: BLE is currently unsupported. Specifications -------------- - MT7621ST 880MHz, Single-Core, Dual-Thread - MT7603EN 2.4GHz WiFi - MT7662EN 5GHz WiFi + BLE - 128MiB NAND - 256MiB DDR3 RAM - SD3503 ZWave Controller - EM357 Zigbee Coordinator MAC address assignment ---------------------- LAN MAC is read from the config partition, WiFi 2.4GHz is LAN+2 and matches the OEM firmware. WiFi 5GHz with LAN+1 is an educated guess since the OEM firmware does not enable 5GHz WiFi. Installation ------------ Attach serial console, then boot the initramfs image via TFTP. Once inside OpenWrt, run sysupgrade -n with the sysupgrade file. Attention: The device has a dual-firmware design. We overwrite kernel2, since kernel1 contains an automatic recovery image. If you get NAND ECC errors and are stuck with bad eraseblocks, try to erase the mtd partition first with mtd unlock ubi mtd erase ubi This should only be needed once. Signed-off-by: Andreas Böhler [use kiB for IMAGE_SIZE] Signed-off-by: Adrian Schmutzler (cherry picked from commit a3d8c1295ed9eeceabd78ab86e73b151ae2868a9) --- .../linux/ramips/dts/mt7621_sercomm_na502.dts | 212 ++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 14 ++ .../mt7621/base-files/etc/board.d/02_network | 1 + .../mt7621/base-files/lib/upgrade/platform.sh | 1 + 4 files changed, 228 insertions(+) create mode 100644 target/linux/ramips/dts/mt7621_sercomm_na502.dts diff --git a/target/linux/ramips/dts/mt7621_sercomm_na502.dts b/target/linux/ramips/dts/mt7621_sercomm_na502.dts new file mode 100644 index 000000000000..af55d1058f6e --- /dev/null +++ b/target/linux/ramips/dts/mt7621_sercomm_na502.dts @@ -0,0 +1,212 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "mt7621.dtsi" + +#include +#include + +/ { + compatible = "sercomm,na502", "mediatek,mt7621-soc"; + model = "SERCOMM NA502"; + + aliases { + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; + }; + + leds { + compatible = "gpio-leds"; + + led_power: power { + label = "green:power"; + gpios = <&gpio 14 GPIO_ACTIVE_LOW>; + }; + + internet { + label = "green:internet"; + gpios = <&gpio 24 GPIO_ACTIVE_LOW>; + }; + + wifi { + label = "green:wifi"; + gpios = <&gpio 23 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0tpt"; + }; + + zwave { + label = "green:zwave"; + gpios = <&gpio 22 GPIO_ACTIVE_LOW>; + }; + + service { + label = "green:service"; + gpios = <&gpio 26 GPIO_ACTIVE_LOW>; + }; + + zigbee { + label = "green:zigbee"; + gpios = <&gpio 27 GPIO_ACTIVE_LOW>; + }; + + bluetooth { + label = "green:bluetooth"; + gpios = <&gpio 25 GPIO_ACTIVE_LOW>; + }; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio 28 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + select { + label = "select"; + gpios = <&gpio 0 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + sync { + label = "sync"; + gpios = <&gpio 32 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + gpio-export { + compatible = "gpio-export"; + + zwave_reset { + gpio-export,name = "zwave_reset"; + gpio-export,output = <1>; + gpios = <&gpio 13 GPIO_ACTIVE_LOW>; + }; + + zigbee_reset { + gpio-export,name = "zigbee_reset"; + gpio-export,output = <1>; + gpios = <&gpio 16 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&gmac0 { + mtd-mac-address = <&factory 0xe000>; +}; + +&nand { + status = "okay"; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x80000>; + read-only; + }; + + partition@80000 { + label = "config"; + reg = <0x80000 0x80000>; + read-only; + }; + + factory: partition@100000 { + label = "factory"; + reg = <0x100000 0x40000>; + }; + + partition@140000 { + label = "kernel1"; + reg = <0x140000 0x1400000>; + }; + + partition@1540000 { + label = "kernel"; + reg = <0x1540000 0x400000>; + }; + + partition@1940000 { + label = "ubi"; + reg = <0x1940000 0x1000000>; + }; + + partition@2940000 { + label = "user_storage"; + reg = <0x2940000 0x100000>; + }; + + partition@2a40000 { + label = "data"; + reg = <0x2a40000 0x1000000>; + }; + + partition@3a40000 { + label = "storage"; + reg = <0x3a40000 0x3200000>; + }; + + partition@6c40000 { + label = "backup"; + reg = <0x6c40000 0x1340000>; + }; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x8000>; + mtd-mac-address = <&factory 0xe000>; + mtd-mac-address-increment = <1>; + ieee80211-freq-limit = <5000000 6000000>; + }; +}; + +&pcie1 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0000>; + mtd-mac-address = <&factory 0xe000>; + mtd-mac-address-increment = <2>; + ieee80211-freq-limit = <2400000 2500000>; + }; +}; + +&state_default { + gpio { + groups = "jtag", "rgmii2"; + function = "gpio"; + }; +}; + +&switch0 { + ports { + port@4 { + status = "okay"; + label = "lan"; + }; + }; +}; + +&uartlite2 { + status = "okay"; +}; + +&uartlite3 { + status = "okay"; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 6645c7b06e5f..a3bc14d59d99 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -1167,6 +1167,20 @@ define Device/samknows_whitebox-v8 endef TARGET_DEVICES += samknows_whitebox-v8 +define Device/sercomm_na502 + $(Device/uimage-lzma-loader) + BLOCKSIZE := 128k + PAGESIZE := 2048 + IMAGE_SIZE := 20480k + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + UBINIZE_OPTS := -E 5 + KERNEL_SIZE := 4096k + DEVICE_VENDOR := SERCOMM + DEVICE_MODEL := NA502 + DEVICE_PACKAGES := kmod-mt76x2 kmod-mt7603 kmod-usb3 +endef +TARGET_DEVICES += sercomm_na502 + define Device/storylink_sap-g3200u3 $(Device/dsa-migration) IMAGE_SIZE := 7872k diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network index c0c767306af7..4b44669b8496 100755 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -13,6 +13,7 @@ ramips_setup_interfaces() edimax,re23s|\ mikrotik,routerboard-m11g|\ netgear,ex6150|\ + sercomm,na502|\ thunder,timecloud|\ tplink,re350-v1|\ tplink,re500-v1|\ diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh index 4943ad130548..c2ad4d3ed63e 100755 --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh @@ -72,6 +72,7 @@ platform_do_upgrade() { netgear,wac104|\ netgear,wac124|\ netis,wf2881|\ + sercomm,na502|\ xiaomi,mi-router-3g|\ xiaomi,mi-router-3-pro|\ xiaomi,mi-router-4|\