From patchwork Fri Mar 9 19:17:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Spreckels X-Patchwork-Id: 883955 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=Informatik.Uni-Oldenburg.DE Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="JMTk2uyr"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zycZr6QVDz9scN for ; Sat, 10 Mar 2018 06:17:24 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:Message-Id:Date:To: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Ce5lDu99j0be0NEbWaKyMk5SV3gsyU4XoyKsRI+EI+4=; b=JMTk2uyr6xF95e 1suMN7/268IIc7gPGLllZBtHn7R3B1iHiWSXUFAdgsxFiCE9oc9h/HL/ciQNjrzRSyrebv2gr3dj7 LaqsV2LogAbNhkLcXRl2DkZyGL4jMm9oweuZzKbGtW+Nqq6+VstSyLJgJGMJa5OrAl6fqG57d7/4V 38fejjJMESyWU1OxvwelppBOXv5TiSmwEtICbfk/fzJ6kJu37+aMQlIVwQu6lu9/tu0BJ6GKxf2Ri 9yjRkCNPctxIAe0807QAcl8bO/HXvwICyjoUhYjdHC6j+Zqy61csuRyQJ9JpMWVZ3vnhbLf4aDCc5 eGjRbq6G5NVQOeV5bzvA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1euNVx-0001Rh-DX; Fri, 09 Mar 2018 19:17:13 +0000 Received: from arbi.informatik.uni-oldenburg.de ([134.106.1.7]) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1euNVD-00010T-92 for lede-dev@lists.infradead.org; Fri, 09 Mar 2018 19:16:32 +0000 Received: from weser.Informatik.Uni-Oldenburg.DE ([134.106.11.83]) by arbi.Informatik.Uni-Oldenburg.DE (Exim 4.72) id 1euNV5-0007N7-PL; Fri, 09 Mar 2018 20:16:19 +0100 Received: from ahi.Informatik.Uni-Oldenburg.DE. ([134.106.9.61]) by weser.Informatik.Uni-Oldenburg.DE (Exim 4.80.1) id 1euNUx-000JWv-EU; Fri, 09 Mar 2018 20:16:11 +0100 From: "Valentin Spreckels" To: lede-dev@lists.infradead.org Date: Fri, 9 Mar 2018 20:17:15 +0100 Message-Id: <20180309191717.19545-1-Valentin.Spreckels@Informatik.Uni-Oldenburg.DE> X-Mailer: git-send-email 2.13.6 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180309_111628_191498_A5A1A4A1 X-CRM114-Status: GOOD ( 19.38 ) X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [134.106.1.7 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Subject: [LEDE-DEV] [PATCH 1/3] fritz-tools: add fritz_tffs_nand_read tool X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This tool reads informations from AVM TFFS 3.0 filesystems on nand flash. AVM uses this on newer FRITZ!Boxes (e.g. 7412) without SPI or nor flash. Signed-off-by: Valentin Spreckels --- package/utils/fritz-tools/Makefile | 15 + package/utils/fritz-tools/src/CMakeLists.txt | 3 +- .../utils/fritz-tools/src/fritz_tffs_nand_read.c | 558 +++++++++++++++++++++ 3 files changed, 575 insertions(+), 1 deletion(-) create mode 100644 package/utils/fritz-tools/src/fritz_tffs_nand_read.c diff --git a/package/utils/fritz-tools/Makefile b/package/utils/fritz-tools/Makefile index 7c547e6f97..a4d69bdf71 100644 --- a/package/utils/fritz-tools/Makefile +++ b/package/utils/fritz-tools/Makefile @@ -21,6 +21,15 @@ define Package/fritz-tffs/description Utility to partially read the TFFS filesystems. endef +define Package/fritz-tffs-nand + $(call Package/fritz-tools/Default) + TITLE:=Utility to partially read the TFFS filesystems on NAND flash +endef + +define Package/fritz-tffs-nand/description + Utility to partially read the TFFS filesystems on NAND flash. +endef + define Package/fritz-caldata $(call Package/fritz-tools/Default) DEPENDS:=+zlib @@ -36,10 +45,16 @@ define Package/fritz-tffs/install $(INSTALL_BIN) $(PKG_BUILD_DIR)/fritz_tffs_read $(1)/usr/bin/fritz_tffs endef +define Package/fritz-tffs-nand/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/fritz_tffs_nand_read $(1)/usr/bin/fritz_tffs_nand +endef + define Package/fritz-caldata/install $(INSTALL_DIR) $(1)/usr/bin $(INSTALL_BIN) $(PKG_BUILD_DIR)/fritz_cal_extract $(1)/usr/bin/ endef $(eval $(call BuildPackage,fritz-tffs)) +$(eval $(call BuildPackage,fritz-tffs-nand)) $(eval $(call BuildPackage,fritz-caldata)) diff --git a/package/utils/fritz-tools/src/CMakeLists.txt b/package/utils/fritz-tools/src/CMakeLists.txt index 021dc7733a..85b815712e 100644 --- a/package/utils/fritz-tools/src/CMakeLists.txt +++ b/package/utils/fritz-tools/src/CMakeLists.txt @@ -9,7 +9,8 @@ FIND_PATH(zlib_include_dir zlib.h) INCLUDE_DIRECTORIES(${zlib_include_dir}) ADD_EXECUTABLE(fritz_tffs_read fritz_tffs_read.c) +ADD_EXECUTABLE(fritz_tffs_nand_read fritz_tffs_nand_read.c) ADD_EXECUTABLE(fritz_cal_extract fritz_cal_extract.c) TARGET_LINK_LIBRARIES(fritz_cal_extract z) -INSTALL(TARGETS fritz_tffs_read fritz_cal_extract RUNTIME DESTINATION bin) +INSTALL(TARGETS fritz_tffs_read fritz_tffs_nand_read fritz_cal_extract RUNTIME DESTINATION bin) diff --git a/package/utils/fritz-tools/src/fritz_tffs_nand_read.c b/package/utils/fritz-tools/src/fritz_tffs_nand_read.c new file mode 100644 index 0000000000..6f30c2bbdb --- /dev/null +++ b/package/utils/fritz-tools/src/fritz_tffs_nand_read.c @@ -0,0 +1,558 @@ +/* + * A tool for reading the TFFS partitions (a name-value storage usually + * found in AVM Fritz!Box based devices) on nand flash. + * + * Copyright (c) 2018 Valentin Spreckels + * + * Based on the fritz_tffs_read tool: + * Copyright (c) 2015-2016 Martin Blumenstingl + * and on the TFFS 2.0 kernel driver from AVM: + * Copyright (c) 2004-2007 AVM GmbH + * and the TFFS 3.0 kernel driver from AVM: + * Copyright (C) 2004-2014 AVM GmbH + * and the OpenWrt TFFS kernel driver: + * Copyright (c) 2013 John Crispin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DEFAULT_TFFS_SIZE (256 * 1024) + +#define TFFS_ID_END 0xffffffff +#define TFFS_ID_TABLE_NAME 0x000001ff + +#define TFFS_BLOCK_HEADER_MAGIC 0x41564d5f54464653ULL +#define TFFS_VERSION 0x0003 +#define TFFS_ENTRY_HEADER_SIZE 0x18 +#define TFFS_MAXIMUM_SEGMENT_SIZE (0x800 - TFFS_ENTRY_HEADER_SIZE) + +#define TFFS_SECTOR_SIZE 0x0800 +#define TFFS_SECTOR_OOB_SIZE 0x0040 +#define TFFS_SECTORS_PER_PAGE 2 + +#define TFFS_SEGMENT_CLEARED 0xffffffff + +static char *progname; +static char *mtddev; +static char *name_filter = NULL; +static bool show_all = false; +static bool print_all_key_names = false; +static bool swap_bytes = false; +static uint8_t readbuf[TFFS_SECTOR_SIZE]; +static uint8_t oobbuf[TFFS_SECTOR_OOB_SIZE]; +static uint32_t blocksize; +static int mtdfd; +struct tffs_sectors *sectors; + +struct tffs_sectors { + uint32_t num_sectors; + uint8_t sectors[0]; +}; + +static inline void sector_mark_bad(int num) { + sectors->sectors[num / 8] &= ~(0x80 >> (num % 8)); +}; + +static inline uint8_t sector_get_good(int num) { + return sectors->sectors[num / 8] & 0x80 >> (num % 8); +}; + +struct tffs_entry_segment { + uint32_t len; + void *val; +}; + +struct tffs_entry { + uint32_t len; + void *val; +}; + +struct tffs_name_table_entry { + uint32_t id; + char *val; +}; + +struct tffs_key_name_table { + uint32_t size; + struct tffs_name_table_entry *entries; +}; + +static inline uint8_t read_uint8(void *buf, ptrdiff_t off) { + return *(uint8_t *)(buf + off); +} + +static inline uint32_t read_uint32(void *buf, ptrdiff_t off) { + uint32_t tmp = *(uint32_t *)(buf + off); + if (swap_bytes) { + tmp = be32toh(tmp); + } + return tmp; +} + +static inline uint64_t read_uint64(void *buf, ptrdiff_t off) { + uint64_t tmp = *(uint64_t *)(buf + off); + if (swap_bytes) { + tmp = be64toh(tmp); + } + return tmp; +} + +static int read_sector(off_t pos) { + if (pread(mtdfd, readbuf, TFFS_SECTOR_SIZE, pos) != TFFS_SECTOR_SIZE) { + return -1; + } + + return 0; +} + +static int read_sectoroob(off_t pos) { + struct mtd_oob_buf oob = { + .start = pos, + .length = TFFS_SECTOR_OOB_SIZE, + .ptr = oobbuf + }; + + if (ioctl(mtdfd, MEMREADOOB, &oob) < 0) { + return -1; + } + + return 0; +} + +static inline uint32_t get_walk_size(uint32_t entry_len) +{ + return (entry_len + 3) & ~0x03; +} + +static void print_entry_value(const struct tffs_entry *entry) +{ + /* These are NOT NULL terminated. */ + fwrite(entry->val, 1, entry->len, stdout); +} + +static int find_entry(uint32_t id, struct tffs_entry *entry) +{ + uint32_t rev = 0; + uint32_t num_segments = 0; + struct tffs_entry_segment *segments = NULL; + + off_t pos = 0; + uint8_t block_ended = 0; + for (uint32_t sector = 0; sector < sectors->num_sectors; sector++, pos += TFFS_SECTOR_SIZE) { + if (block_ended) { + if (pos % blocksize == 0) { + block_ended = 0; + } + } else if (sector_get_good(sector)) { + if (read_sectoroob(pos) || read_sector(pos)) { + fprintf(stderr, "ERROR: sector isn't readable, but has been previously!\n"); + exit(EXIT_FAILURE); + } + uint32_t oob_id = read_uint32(oobbuf, 0x02); + uint32_t oob_len = read_uint32(oobbuf, 0x06); + uint32_t oob_rev = read_uint32(oobbuf, 0x0a); + uint32_t read_id = read_uint32(readbuf, 0x00); + uint32_t read_len = read_uint32(readbuf, 0x04); + uint32_t read_rev = read_uint32(readbuf, 0x0c); + if (oob_id != read_id || oob_len != read_len || oob_rev != read_rev) { + fprintf(stderr, "Warning: sector has inconsistent metadata\n"); + continue; + } + if (read_id == TFFS_ID_END) { + // no more entries in this block + block_ended = 1; + continue; + } + if (read_len > TFFS_MAXIMUM_SEGMENT_SIZE) { + fprintf(stderr, "Warning: segment is longer than possible\n"); + continue; + } + if (read_id == id) { + if (read_rev < rev) { + // obsolete revision => ignore this + continue; + } + if (read_rev > rev) { + // newer revision => clear old data + for (uint32_t i = 0; i < num_segments; i++) { + free(segments[i].val); + } + free (segments); + rev = read_rev; + num_segments = 0; + segments = NULL; + } + + uint32_t seg = read_uint32(readbuf, 0x10); + + if (seg == TFFS_SEGMENT_CLEARED) { + continue; + } + + uint32_t next_seg = read_uint32(readbuf, 0x14); + + uint32_t new_num_segs = next_seg == 0 ? seg + 1 : next_seg + 1; + if (new_num_segs > num_segments) { + segments = realloc(segments, new_num_segs * sizeof(struct tffs_entry_segment)); + memset(segments + (num_segments * sizeof(struct tffs_entry_segment)), 0x0, + (new_num_segs - num_segments) * sizeof(struct tffs_entry_segment)); + num_segments = new_num_segs; + } + segments[seg].len = read_len; + segments[seg].val = malloc(read_len); + memcpy(segments[seg].val, readbuf + TFFS_ENTRY_HEADER_SIZE, read_len); + } + } + } + + if (num_segments == 0) { + return 0; + } + + assert (segments != NULL); + + uint32_t len = 0; + for (uint32_t i = 0; i < num_segments; i++) { + if (segments[i].val == NULL) { + // missing segment + return 0; + } + + len += segments[i].len; + } + + void *p = malloc(len); + entry->val = p; + entry->len = len; + for (uint32_t i = 0; i < num_segments; i++) { + memcpy(p, segments[i].val, segments[i].len); + p += segments[i].len; + } + + return 1; +} + +static void parse_key_names(struct tffs_entry *names_entry, + struct tffs_key_name_table *key_names) +{ + uint32_t pos = 0, i = 0; + struct tffs_name_table_entry *name_item; + + key_names->entries = NULL; + + do { + key_names->entries = realloc(key_names->entries, + sizeof(struct tffs_name_table_entry) * (i + 1)); + if (key_names->entries == NULL) { + fprintf(stderr, "ERROR: memory allocation failed!\n"); + exit(EXIT_FAILURE); + } + name_item = &key_names->entries[i]; + + name_item->id = read_uint32(names_entry->val, pos); + pos += sizeof(uint32_t); + name_item->val = strdup((const char *)(names_entry->val + pos)); + + /* + * There is no "length" field because the string values are + * simply NULL-terminated -> strlen() gives us the size. + */ + pos += get_walk_size(strlen(name_item->val) + 1); + + ++i; + } while (pos < names_entry->len); + + key_names->size = i; +} + +static void show_all_key_names(struct tffs_key_name_table *key_names) +{ + for (uint32_t i = 0; i < key_names->size; i++) + printf("%s\n", key_names->entries[i].val); +} + +static int show_all_key_value_pairs(struct tffs_key_name_table *key_names) +{ + uint8_t has_value = 0; + struct tffs_entry tmp; + + for (uint32_t i = 0; i < key_names->size; i++) { + if (find_entry(key_names->entries[i].id, &tmp)) { + printf("%s=", (const char *)key_names->entries[i].val); + print_entry_value(&tmp); + printf("\n"); + has_value++; + free(tmp.val); + } + } + + if (!has_value) { + fprintf(stderr, "ERROR: no values found!\n"); + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} + +static int show_matching_key_value(struct tffs_key_name_table *key_names) +{ + struct tffs_entry tmp; + const char *name; + + for (uint32_t i = 0; i < key_names->size; i++) { + name = key_names->entries[i].val; + + if (strncmp(name, name_filter, strlen(name)) == 0) { + if (find_entry(key_names->entries[i].id, &tmp)) { + print_entry_value(&tmp); + printf("\n"); + free(tmp.val); + return EXIT_SUCCESS; + } else { + fprintf(stderr, + "ERROR: no value found for name %s!\n", + name); + return EXIT_FAILURE; + } + } + } + + fprintf(stderr, "ERROR: Unknown key name %s!\n", name_filter); + return EXIT_FAILURE; +} + +static int check_sector(off_t pos) +{ + if (read_sectoroob(pos)) { + return 0; + } + if (read_uint8(oobbuf, 0x00) != 0xff) { + // block is bad + return 0; + } + if (read_uint8(oobbuf, 0x01) != 0xff) { + // sector is bad + return 0; + } + return 1; +} + +static int check_block(off_t pos, uint32_t sector) +{ + if (!check_sector(pos)) { + return 0; + } + if (read_sector(pos)) { + return 0; + } + if (read_uint64(readbuf, 0x00) != TFFS_BLOCK_HEADER_MAGIC) { + fprintf(stderr, "Warning: block without magic header. Skipping block\n"); + return 0; + } + if (read_uint32(readbuf, 0x0c) != TFFS_SECTORS_PER_PAGE) { + fprintf(stderr, "Warning: block with wrong number of sectors per page. Skipping block\n"); + return 0; + } + + uint32_t num_hdr_bad = read_uint32(readbuf, 0x0c); + for (uint32_t i = 0; i < num_hdr_bad; i++) { + uint32_t bad = sector + read_uint64(readbuf, 0x1c + sizeof(uint64_t)*i); + sector_mark_bad(bad); + } + + return 1; +} + +static int scan_mtd() +{ + struct mtd_info_user info; + + if (ioctl(mtdfd, MEMGETINFO, &info)) { + return 0; + } + + blocksize = info.erasesize; + + sectors = malloc(sizeof(*sectors) + (info.size / TFFS_SECTOR_SIZE + 7) / 8); + if (sectors == NULL) { + fprintf(stderr, "ERROR: memory allocation failed!\n"); + exit(EXIT_FAILURE); + } + sectors->num_sectors = info.size / TFFS_SECTOR_SIZE; + memset(sectors->sectors, 0xff, (info.size / TFFS_SECTOR_SIZE + 7) / 8); + + uint32_t sector = 0, valid_blocks = 0; + uint8_t block_ok = 0; + for (off_t pos = 0; pos < info.size; sector++, pos += TFFS_SECTOR_SIZE) { + if (pos % info.erasesize == 0) { + block_ok = check_block(pos, sector); + // first sector of the block contains metadata + // => handle it like a bad sector + sector_mark_bad(sector); + if (block_ok) { + valid_blocks++; + } + } else if (!block_ok || !sector_get_good(sector) || !check_sector(pos)) { + sector_mark_bad(sector); + } + } + + return valid_blocks; +} + +static void usage(int status) +{ + FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout; + + fprintf(stream, "Usage: %s [OPTIONS...]\n", progname); + fprintf(stream, + "\n" + "Options:\n" + " -a list all key value pairs found in the TFFS file/device\n" + " -d inspect the TFFS on mtd device \n" + " -h show this screen\n" + " -l list all supported keys\n" + " -n display the value of the given key\n" + ); + + exit(status); +} + +static void parse_options(int argc, char *argv[]) +{ + while (1) + { + int c; + + c = getopt(argc, argv, "abd:hln:"); + if (c == -1) + break; + + switch (c) { + case 'a': + show_all = true; + name_filter = NULL; + print_all_key_names = false; + break; + case 'b': + swap_bytes = 1; + break; + case 'd': + mtddev = optarg; + break; + case 'h': + usage(EXIT_SUCCESS); + break; + case 'l': + print_all_key_names = true; + show_all = false; + name_filter = NULL; + break; + case 'n': + name_filter = optarg; + show_all = false; + print_all_key_names = false; + break; + default: + usage(EXIT_FAILURE); + break; + } + } + + if (!mtddev) { + fprintf(stderr, "ERROR: No input file (-d ) given!\n"); + usage(EXIT_FAILURE); + } + + if (!show_all && !name_filter && !print_all_key_names) { + fprintf(stderr, + "ERROR: either -l, -a or -n is required!\n"); + usage(EXIT_FAILURE); + } +} + +int main(int argc, char *argv[]) +{ + int ret = EXIT_FAILURE; + struct tffs_entry name_table; + struct tffs_key_name_table key_names; + + progname = basename(argv[0]); + + parse_options(argc, argv); + + mtdfd = open(mtddev, O_RDONLY); + if (mtdfd < 0) { + fprintf(stderr, "ERROR: Failed to open tffs device %s\n", + mtddev); + goto out; + } + + if (!scan_mtd()) { + fprintf(stderr, "ERROR: Parsing blocks from tffs device %s failed\n", mtddev); + fprintf(stderr," Is byte-swapping (-b) required?\n"); + goto out_close; + } + + if (!find_entry(TFFS_ID_TABLE_NAME, &name_table)) { + fprintf(stderr,"ERROR: No name table found on tffs device %s\n", + mtddev); + goto out_free_sectors; + } + + parse_key_names(&name_table, &key_names); + if (key_names.size < 1) { + fprintf(stderr, "ERROR: No name table found on tffs device %s\n", + mtddev); + goto out_free_entry; + } + + if (print_all_key_names) { + show_all_key_names(&key_names); + ret = EXIT_SUCCESS; + } else if (show_all) { + ret = show_all_key_value_pairs(&key_names); + } else { + ret = show_matching_key_value(&key_names); + } + + free(key_names.entries); +out_free_entry: + free(name_table.val); +out_free_sectors: + free(sectors); +out_close: + close(mtdfd); +out: + return ret; +} From patchwork Fri Mar 9 19:17:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Spreckels X-Patchwork-Id: 883953 X-Patchwork-Delegate: openwrt@kresin.me Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=Informatik.Uni-Oldenburg.DE Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MsvxilGy"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zycZ953Mfz9scC for ; Sat, 10 Mar 2018 06:16:49 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=hMlv2k0wkxreCvXkPQj8OkKWTU/0DNfOygyeNPQO/j4=; b=MsvxilGyzGAMYOjC9UxkapECJ1 frPJPfwJZ38MZe6/WrELh0z8RDMLYJOhGiGLPFKlUmXfU/u2dmnHEY5ySJITAsbLtiyEKydFVgmdu oDwKquZe40vuxfwjwpkfX1E9rMMw4PXn+mItfA3N9ws1m2ZsYprnruHtYY6uiZ/x4yODpfwDLTJ3o tXQ0J9DGtL77WL7kzenWKy9X5DKFcVgm/7mLux/7zuRZTfCJZteC90I1oYaQiIFqE9sdwUcdnA2kV tRuAjjZh7C6JyIrvoNEg8IsjMFgDqqWTdJVeW3Oh9vi0ODgX5CIwLDykKS7TVgpyl+MdR1g7vUmy1 3nEWomtQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1euNVI-00012N-KL; Fri, 09 Mar 2018 19:16:32 +0000 Received: from arbi.informatik.uni-oldenburg.de ([134.106.1.7]) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1euNVD-00010U-4f for lede-dev@lists.infradead.org; Fri, 09 Mar 2018 19:16:29 +0000 Received: from weser.Informatik.Uni-Oldenburg.DE ([134.106.11.83]) by arbi.Informatik.Uni-Oldenburg.DE (Exim 4.72) id 1euNV5-000520-Pr; Fri, 09 Mar 2018 20:16:19 +0100 Received: from ahi.Informatik.Uni-Oldenburg.DE. ([134.106.9.61]) by weser.Informatik.Uni-Oldenburg.DE (Exim 4.80.1) id 1euNUx-000JWv-IJ; Fri, 09 Mar 2018 20:16:11 +0100 From: "Valentin Spreckels" To: lede-dev@lists.infradead.org Date: Fri, 9 Mar 2018 20:17:16 +0100 Message-Id: <20180309191717.19545-2-Valentin.Spreckels@Informatik.Uni-Oldenburg.DE> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180309191717.19545-1-Valentin.Spreckels@Informatik.Uni-Oldenburg.DE> References: <20180309191717.19545-1-Valentin.Spreckels@Informatik.Uni-Oldenburg.DE> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180309_111627_570866_9299E0AD X-CRM114-Status: UNSURE ( 9.98 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [134.106.1.7 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Subject: [LEDE-DEV] [PATCH 2/3] scripts: add EVA ramboot script X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The bootloader on the FRITZ!Box 7412 crashes when flashing images. Thus the AVM recovery tool uses another approach: It uses the bootloader to load a small linux system into the ram and boot it from there. This system will then flash the image. This script mimics the behavior: It loads an openwrt initramfs image. After this a sysupgrade can be done to persistently install openwrt. Signed-off-by: Valentin Spreckels Acked-by: John Crispin --- scripts/flashing/eva_ramboot.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 scripts/flashing/eva_ramboot.py diff --git a/scripts/flashing/eva_ramboot.py b/scripts/flashing/eva_ramboot.py new file mode 100755 index 0000000000..b825d2768b --- /dev/null +++ b/scripts/flashing/eva_ramboot.py @@ -0,0 +1,37 @@ +#!/usr/bin/python + +from ftplib import FTP +from sys import argv +from os import stat + +assert len(argv) == 3 +ip = argv[1] +image = argv[2] + +size = stat(image).st_size +# arbitrary size limit, to prevent the address calculations from overflows etc. +assert size < 0x2000000 + +# We need to align the address. A page boundary seems to be sufficient on 7362sl +# and 7412 +addr = ((0x8000000 - size) & ~0xfff) +haddr = 0x80000000 + addr +img = open(image, "rb") + +ftp = FTP(ip, 'adam2', 'adam2') + +def adam(cmd): + print("> %s"%(cmd)) + resp = ftp.sendcmd(cmd) + print("< %s"%(resp)) + assert resp[0:3] == "200" + +ftp.set_pasv(True) +# The following parameters allow booting the avm recovery system with this +# script. +adam('SETENV memsize 0x%08x'%(addr)) +adam('SETENV kernel_args_tmp mtdram1=0x%08x,0x88000000'%(haddr)) +adam('MEDIA SDRAM') +ftp.storbinary('STOR 0x%08x 0x88000000'%(haddr), img) +img.close() +ftp.close() From patchwork Fri Mar 9 19:17:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentin Spreckels X-Patchwork-Id: 883954 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=Informatik.Uni-Oldenburg.DE Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="d9NlO1uN"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zycZP2Yccz9scC for ; Sat, 10 Mar 2018 06:17:01 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=UQ1xxJNI4RijMDNFAhYEcxwpfWYNP4qQ2e2Laco0FCQ=; b=d9NlO1uNBISmQkTedb/9pGQ61G phg9F1luRAhfpcjwndDG+37G28i9MnZk247KbqVrH/W3U9D7gFpH07FPQHbEVc3VPcg9QH2Vz9frd QNdiyA0uqy9m43fKF93IfkWZPhm45H+h60nKiKo9lhyacqZtSjHSenFwmXzuESEU803jrGlPpj4On bf362RJWqbbCTSnv0MTX4hv3cTglVVj3DWlWdIYb2Z//bfOU9ZNlQFbnZpcWI20fx8asaQ0ky4FwK QoI5Ip0BCiVv5uFc6BDPJ4fEZ186tEN3yPFXrdFl4hktuv/RodioW8QOzxupNoIbug3t9KFN7/VPw c5HrR2Mg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1euNVZ-0001Bm-V7; Fri, 09 Mar 2018 19:16:50 +0000 Received: from arbi.informatik.uni-oldenburg.de ([134.106.1.7]) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1euNVD-00010V-93 for lede-dev@lists.infradead.org; Fri, 09 Mar 2018 19:16:30 +0000 Received: from weser.Informatik.Uni-Oldenburg.DE ([134.106.11.83]) by arbi.Informatik.Uni-Oldenburg.DE (Exim 4.72) id 1euNV6-00056f-0m; Fri, 09 Mar 2018 20:16:20 +0100 Received: from ahi.Informatik.Uni-Oldenburg.DE. ([134.106.9.61]) by weser.Informatik.Uni-Oldenburg.DE (Exim 4.80.1) id 1euNUx-000JWv-Ij; Fri, 09 Mar 2018 20:16:11 +0100 From: "Valentin Spreckels" To: lede-dev@lists.infradead.org Date: Fri, 9 Mar 2018 20:17:17 +0100 Message-Id: <20180309191717.19545-3-Valentin.Spreckels@Informatik.Uni-Oldenburg.DE> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180309191717.19545-1-Valentin.Spreckels@Informatik.Uni-Oldenburg.DE> References: <20180309191717.19545-1-Valentin.Spreckels@Informatik.Uni-Oldenburg.DE> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180309_111628_185727_624AC925 X-CRM114-Status: GOOD ( 17.46 ) X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [134.106.1.7 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Subject: [LEDE-DEV] [PATCH 3/3] lantiq: add support for AVM FRITZ!Box 7412 X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Specification: - SoC: Lantiq VRX 220 - CPU Cores: 2x MIPS 34Kc at 500 MHz - RAM: 128 MiB 250 MHz - Storage: 128 MiB NAND flash - Ethernet: built-in Fast Ethernet switch, only port 2 is used - Wireless: Atheros AR9287-BL1A b/g/n with 2 pcb antennas - Modem: built-in A/VDSL2 modem - DECT: Dialog SC14441 - LEDs: 1 two-color, 4 one-color - Buttons: 2 - FXS: 1 port via TAE or RJ12 connector Working: - ethernet - wifi - leds - buttons - dsl Not working: - Second cpu core - FXS - DECT Installation: 1. Use the eva_ramboot.py script to load an initramfs image on the device. Run it a few seconds after turning the device on. $ scripts/flashing eva_ramboot 192.168.178.1 bin/targets/lantiq/xrx200/openwrt-lantiq-xrx200-avm_fritz7412-initramfs-kernel.bin If it fails to find the device try the ip address 169.254.120.1. (Firmware updates or the recovery tool apparently change it.) 2. The device will load it in ram and boot it. You can reach it under the openwrt default ip address 192.168.1.1. 3. Check if the key linux_fs_start is not set to 1 in tffs: $ fritz_tffs_nand -d /dev/mtd1 -n linux_fs_start If it is set to 1, the bootloader will select the wrong set of partitions. Restart the box and install an FritzOS upgrade or do a recovery. Afterwards start again at step 1. 4. Run sysupgrade to persistently install OpenWRT. Signed-off-by: Valentin Spreckels --- .../linux/lantiq/base-files/etc/board.d/02_network | 8 + .../etc/hotplug.d/firmware/12-ath9k-eeprom | 3 + .../lantiq/base-files/lib/upgrade/platform.sh | 2 +- .../files-4.14/arch/mips/boot/dts/FRITZ7412.dts | 241 ++++++++++++++++++++ .../files-4.9/arch/mips/boot/dts/FRITZ7412.dts | 242 +++++++++++++++++++++ .../lantiq/files-4.9/arch/mips/boot/dts/vr9.dtsi | 2 +- target/linux/lantiq/image/Makefile | 13 ++ 7 files changed, 509 insertions(+), 2 deletions(-) create mode 100644 target/linux/lantiq/files-4.14/arch/mips/boot/dts/FRITZ7412.dts create mode 100644 target/linux/lantiq/files-4.9/arch/mips/boot/dts/FRITZ7412.dts diff --git a/target/linux/lantiq/base-files/etc/board.d/02_network b/target/linux/lantiq/base-files/etc/board.d/02_network index ca974b071e..defdc1a94d 100755 --- a/target/linux/lantiq/base-files/etc/board.d/02_network +++ b/target/linux/lantiq/base-files/etc/board.d/02_network @@ -154,6 +154,14 @@ avm,fritz7360sl) "0:lan:3" "1:lan:4" "2:lan:2" "4:lan:1" "6t@eth0" ;; +avm,fritz7412) + tffsdev=$(find_mtd_chardev "nand-tffs") + annex="b" + lan_mac=$(/usr/bin/fritz_tffs_nand -d $tffsdev -n maca) + wan_mac=$(/usr/bin/fritz_tffs_nand -d $tffsdev -n macdsl) + ucidef_set_interface_lan 'eth0' + ;; + siemens,gigaset-sx76x) annex="b" ucidef_add_switch "switch0" \ diff --git a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom index 498a509012..68181c7b87 100644 --- a/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom +++ b/target/linux/lantiq/base-files/etc/hotplug.d/firmware/12-ath9k-eeprom @@ -141,6 +141,9 @@ case "$FIRMWARE" in avm,fritz3370|avm,fritz7320|avm,fritz7360sl) ath9k_eeprom_extract "urlader" 2437 0 ;; + avm,fritz7412) + /usr/bin/fritz_cal_extract -i 1 -s 0x1e000 -e 0x207 -l 4096 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader") + ;; tplink,tdw8970|tplink,tdw8980) ath9k_eeprom_extract "boardconfig" 135168 0 ;; diff --git a/target/linux/lantiq/base-files/lib/upgrade/platform.sh b/target/linux/lantiq/base-files/lib/upgrade/platform.sh index 2e58cb799a..7a43e7e12e 100755 --- a/target/linux/lantiq/base-files/lib/upgrade/platform.sh +++ b/target/linux/lantiq/base-files/lib/upgrade/platform.sh @@ -9,7 +9,7 @@ platform_do_upgrade() { local board=$(board_name) case "$board" in - bt,homehub-v2b|bt,homehub-v3a|bt,homehub-v5a|zyxel,p-2812hnu-f1|zyxel,p-2812hnu-f3) + avm,fritz7412|bt,homehub-v2b|bt,homehub-v3a|bt,homehub-v5a|zyxel,p-2812hnu-f1|zyxel,p-2812hnu-f3) nand_do_upgrade $1 ;; *) diff --git a/target/linux/lantiq/files-4.14/arch/mips/boot/dts/FRITZ7412.dts b/target/linux/lantiq/files-4.14/arch/mips/boot/dts/FRITZ7412.dts new file mode 100644 index 0000000000..5bcd140520 --- /dev/null +++ b/target/linux/lantiq/files-4.14/arch/mips/boot/dts/FRITZ7412.dts @@ -0,0 +1,241 @@ +/dts-v1/; + +#include "vr9.dtsi" + +#include +#include + +/ { + compatible = "avm,fritz7412", "lantiq,xway", "lantiq,vr9"; + model = "1&1 DSL-Modem / 1&1 WLAN-Router"; + + chosen { + bootargs = "console=ttyLTQ0,115200 mem=126M vpe1_load_addr=0x87e00000 vpe1_mem=2M maxvpes=1 maxtcs=1 nosmp"; + }; + + aliases { + led-boot = &power_green; + led-failsafe = &power_red; + led-running = &power_green; + + led-dsl = &info; + led-wifi = &wifi; + }; + + memory@0 { + reg = <0x0 0x8000000>; + }; + + gpio-keys-polled { + compatible = "gpio-keys-polled"; + #address-cells = <1>; + #size-cells = <0>; + poll-interval = <100>; + wps { + label = "wps"; + gpios = <&gpio 1 GPIO_ACTIVE_HIGH>; + linux,code = ; + }; + dect { + label = "dect"; + gpios = <&gpio 2 GPIO_ACTIVE_HIGH>; + linux,code = ; + }; + }; + + gpio-leds { + compatible = "gpio-leds"; + + power_green: power_green { + label = "fritz7412:green:power"; + gpios = <&gpio 6 GPIO_ACTIVE_LOW>; + default-state = "keep"; + }; + power_red: power_red { + label = "fritz7412:red:power"; + gpios = <&gpio 5 GPIO_ACTIVE_LOW>; + }; + fon { + label = "fritz7412:green:fon"; + gpios = <&gpio 34 GPIO_ACTIVE_LOW>; + }; + dect { + label = "fritz7412:green:dect"; + gpios = <&gpio 15 GPIO_ACTIVE_LOW>; + }; + wifi: wifi { + label = "fritz7412:green:wifi"; + gpios = <&gpio 0 GPIO_ACTIVE_LOW>; + }; + info: info { + label = "fritz7412:green:info"; + gpios = <&gpio 35 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&localbus { + nand-parts@0 { + compatible = "lantiq,nand-xway"; + bank-width = <2>; + reg = <1 0x0 0x2000000>; + #address-cells = <1>; + #size-cells = <1>; + lantiq,cs = <1>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "urlader"; + reg = <0x0 0x40000>; + read-only; + }; + + partition@40000 { + label = "nand-tffs"; + reg = <0x40000 0x400000>; + read-only; + }; + + partition@440000 { + label = "kernel"; + reg = <0x440000 0x400000>; + }; + + partition@840000 { + label = "ubi"; + reg = <0x840000 0x3000000>; + }; + + partition@3840000 { + label = "reserved-kernel"; + reg = <0x3840000 0x400000>; + read-only; + }; + + partition@3c40000 { + label = "reserved-filesystem"; + reg = <0x3c40000 0x3000000>; + read-only; + }; + + partition@6c40000 { + label = "config"; + reg = <0x6c40000 0x400000>; + read-only; + }; + + partition@6e40000 { + label = "nand-filesystem"; + reg = <0x6e40000 0x400000>; + read-only; + }; + }; + }; +}; + +&pcie0 { + status = "okay"; + gpio-reset = <&gpio 11 GPIO_ACTIVE_HIGH>; + + pcie@0 { + reg = <0 0 0 0 0>; + #interrupt-cells = <1>; + #size-cells = <2>; + #address-cells = <3>; + device_type = "pci"; + + wifi@168c,002e { + compatible = "pci168c,002e"; + reg = <0 0 0 0 0>; + qca,no-eeprom; /* load from ath9k-eeprom-pci-0000:01:00.0.bin */ + }; + }; +}; + +&gpio { + pinctrl-names = "default"; + pinctrl-0 = <&state_default>; + + state_default: pinmux { + mdio { + lantiq,groups = "mdio"; + lantiq,function = "mdio"; + }; + pcie-rst { + lantiq,pins = "io11"; + lantiq,open-drain = <1>; + lantiq,output = <1>; + }; + nand-mux { + lantiq,groups = "nand cle", "nand ale", + "nand rd", "nand cs1", + "nand rdy"; + lantiq,function = "ebu"; + }; + nand-pins { + lantiq,pins = "io13", "io24", "io49"; + lantiq,pull = <1>; + }; + + /* + other gpios: + + dect reset: 33 output open drain + dect rd: 8 active low push pull + + tdm fsc: 9 input + pull-up + tdm/spi do: 16 output + tdm/spi di: 17 input + pull-up + tdm dcl/spi clk: 18 output active low + tdm clk enable: 7 output active high + tdm/spi cs: 10 output active low/high + spi wp: 12 output active low + + boot sel2: 23 active high + boot sel3: 38 active high + boot sel4: 49 active high (also nand rd) + */ + }; +}; + +&gphy0 { + lantiq,gphy-mode = ; +}; + +ð0 { + lantiq,phys = <&gphy0>; + + interface@0 { + compatible = "lantiq,xrx200-pdi"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + mac-address = [ 00 11 22 33 44 55 ]; + lantiq,switch; + + ethernet@2 { + compatible = "lantiq,xrx200-pdi-port"; + reg = <2>; + phy-mode = "gmii"; + phy-handle = <&phy11>; + }; + }; + + mdio@0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "lantiq,xrx200-mdio"; + phy11: ethernet-phy@11 { + reg = <0x11>; + compatible = "lantiq,phy11g", "ethernet-phy-ieee802.3-c22"; + }; + }; +}; + +&vmmc { + status = "okay"; +}; diff --git a/target/linux/lantiq/files-4.9/arch/mips/boot/dts/FRITZ7412.dts b/target/linux/lantiq/files-4.9/arch/mips/boot/dts/FRITZ7412.dts new file mode 100644 index 0000000000..23f80db121 --- /dev/null +++ b/target/linux/lantiq/files-4.9/arch/mips/boot/dts/FRITZ7412.dts @@ -0,0 +1,242 @@ +/dts-v1/; + +#include "vr9.dtsi" + +#include + +/ { + compatible = "avm,fritz7412", "lantiq,xway", "lantiq,vr9"; + model = "1&1 DSL-Modem / 1&1 WLAN-Router"; + + chosen { + bootargs = "console=ttyLTQ0,115200 mem=126M vpe1_load_addr=0x87e00000 vpe1_mem=2M maxvpes=1 maxtcs=1 nosmp"; + }; + + aliases { + led-boot = &power_green; + led-failsafe = &power_red; + led-running = &power_green; + + led-dsl = &info; + led-wifi = &wifi; + }; + + memory@0 { + reg = <0x0 0x8000000>; + }; + + fpi@10000000 { + localbus@0 { + nand-parts@0 { + compatible = "lantiq,nand-xway"; + bank-width = <2>; + reg = <1 0x0 0x2000000>; + #address-cells = <1>; + #size-cells = <1>; + lantiq,cs = <1>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "urlader"; + reg = <0x0 0x40000>; + read-only; + }; + + partition@40000 { + label = "nand-tffs"; + reg = <0x40000 0x400000>; + read-only; + }; + + partition@440000 { + label = "kernel"; + reg = <0x440000 0x400000>; + }; + + partition@840000 { + label = "ubi"; + reg = <0x840000 0x3000000>; + }; + + partition@3840000 { + label = "reserved-kernel"; + reg = <0x3840000 0x400000>; + read-only; + }; + + partition@3c40000 { + label = "reserved-filesystem"; + reg = <0x3c40000 0x3000000>; + read-only; + }; + + partition@6c40000 { + label = "config"; + reg = <0x6c40000 0x400000>; + read-only; + }; + + partition@6e40000 { + label = "nand-filesystem"; + reg = <0x6e40000 0x400000>; + read-only; + }; + }; + }; + }; + }; + + gphy-xrx200 { + compatible = "lantiq,phy-xrx200"; + firmware = "lantiq/xrx200_phy11g_a22.bin"; + phys = [ 00 ]; + }; + + gpio-keys-polled { + compatible = "gpio-keys-polled"; + #address-cells = <1>; + #size-cells = <0>; + poll-interval = <100>; + wps { + label = "wps"; + gpios = <&gpio 1 GPIO_ACTIVE_HIGH>; + linux,code = ; + }; + dect { + label = "dect"; + gpios = <&gpio 2 GPIO_ACTIVE_HIGH>; + linux,code = ; + }; + }; + + gpio-leds { + compatible = "gpio-leds"; + + power_green: power_green { + label = "fritz7412:green:power"; + gpios = <&gpio 6 GPIO_ACTIVE_LOW>; + default-state = "keep"; + }; + power_red: power_red { + label = "fritz7412:red:power"; + gpios = <&gpio 5 GPIO_ACTIVE_LOW>; + }; + fon { + label = "fritz7412:green:fon"; + gpios = <&gpio 34 GPIO_ACTIVE_LOW>; + }; + dect { + label = "fritz7412:green:dect"; + gpios = <&gpio 15 GPIO_ACTIVE_LOW>; + }; + wifi: wifi { + label = "fritz7412:green:wifi"; + gpios = <&gpio 0 GPIO_ACTIVE_LOW>; + }; + info: info { + label = "fritz7412:green:info"; + gpios = <&gpio 35 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&pcie0 { + status = "okay"; + gpio-reset = <&gpio 11 GPIO_ACTIVE_HIGH>; + + pcie@0 { + reg = <0 0 0 0 0>; + #interrupt-cells = <1>; + #size-cells = <2>; + #address-cells = <3>; + device_type = "pci"; + + wifi@168c,002e { + compatible = "pci168c,002e"; + reg = <0 0 0 0 0>; + qca,no-eeprom; /* load from ath9k-eeprom-pci-0000:01:00.0.bin */ + }; + }; +}; + +&gpio { + pinctrl-names = "default"; + pinctrl-0 = <&state_default>; + + state_default: pinmux { + mdio { + lantiq,groups = "mdio"; + lantiq,function = "mdio"; + }; + pcie-rst { + lantiq,pins = "io11"; + lantiq,open-drain = <1>; + lantiq,output = <1>; + }; + nand-mux { + lantiq,groups = "nand cle", "nand ale", + "nand rd", "nand cs1", + "nand rdy"; + lantiq,function = "ebu"; + }; + nand-pins { + lantiq,pins = "io13", "io24", "io49"; + lantiq,pull = <1>; + }; + + /* + other gpios: + + dect reset: 33 output open drain + dect rd: 8 active low push pull + + tdm fsc: 9 input + pull-up + tdm/spi do: 16 output + tdm/spi di: 17 input + pull-up + tdm dcl/spi clk: 18 output active low + tdm clk enable: 7 output active high + tdm/spi cs: 10 output active low/high + spi wp: 12 output active low + + boot sel2: 23 active high + boot sel3: 38 active high + boot sel4: 49 active high (also nand rd) + */ + }; +}; + +ð0 { + interface@0 { + compatible = "lantiq,xrx200-pdi"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + mac-address = [ 00 11 22 33 44 55 ]; + lantiq,switch; + + ethernet@2 { + compatible = "lantiq,xrx200-pdi-port"; + reg = <2>; + phy-mode = "gmii"; + phy-handle = <&phy11>; + }; + }; + + mdio@0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "lantiq,xrx200-mdio"; + phy11: ethernet-phy@11 { + reg = <0x11>; + compatible = "lantiq,phy11g", "ethernet-phy-ieee802.3-c22"; + }; + }; +}; + +&vmmc { + status = "okay"; +}; diff --git a/target/linux/lantiq/files-4.9/arch/mips/boot/dts/vr9.dtsi b/target/linux/lantiq/files-4.9/arch/mips/boot/dts/vr9.dtsi index dbcbb3dcec..f787ad7e4d 100644 --- a/target/linux/lantiq/files-4.9/arch/mips/boot/dts/vr9.dtsi +++ b/target/linux/lantiq/files-4.9/arch/mips/boot/dts/vr9.dtsi @@ -82,7 +82,7 @@ reg = <0x106a00 0x200>; }; - vmmc@107000 { + vmmc: vmmc@103000 { status = "disabled"; compatible = "lantiq,vmmc-xway"; reg = <0x103000 0x400>; diff --git a/target/linux/lantiq/image/Makefile b/target/linux/lantiq/image/Makefile index e52e43c6e5..6a3c8aef0f 100644 --- a/target/linux/lantiq/image/Makefile +++ b/target/linux/lantiq/image/Makefile @@ -103,6 +103,7 @@ define Device/AVM KERNEL := kernel-bin | append-dtb | lzma | eva-image IMAGE/sysupgrade.bin := append-kernel | pad-to 64k | append-avm-fakeroot | \ append-rootfs | pad-rootfs | append-metadata | check-size $$$$(IMAGE_SIZE) + KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | eva-image endef ifeq ($(SUBTARGET),ase) @@ -630,6 +631,18 @@ define Device/avm_fritz7360sl endef TARGET_DEVICES += avm_fritz7360sl +define Device/avm_fritz7412 + $(Device/AVM) + $(Device/NAND) + BOARD_NAME := FRITZ7412 + DEVICE_DTS := FRITZ7412 + KERNEL_SIZE := 4096k + IMAGE_SIZE := 49152k + DEVICE_TITLE := 1&1 DSL-Modem / WLAN-Router - FRITZ7412 + DEVICE_PACKAGES := kmod-ath9k kmod-owl-loader wpad-mini kmod-ltq-tapi kmod-ltq-vmmc fritz-tffs-nand fritz-caldata +endef +TARGET_DEVICES += avm_fritz7412 + define Device/arcadyan_vg3503j IMAGE_SIZE := 8000k DEVICE_DTS := VG3503J