From patchwork Wed Sep 2 06:22:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuanhong Guo X-Patchwork-Id: 1355538 X-Patchwork-Delegate: gch981213@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=Z7ks03Kl; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=pqZxWqaf; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BhDSs2dtRz9sSJ for ; Wed, 2 Sep 2020 16:25:16 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ZjGklG2blEqSJy/FFdga6jS6HVMu0rbLJCl9ARlqyIc=; b=Z7ks03Kl+3LVuV6mVFA9vlcpR 24jtSOe0PT955LM86Z+TY/azYBdehPZmTY8Ly6IT5PznVJeUWPcTuSAMHCjZVB8+8f7eIlvVS8Gwm X9j/TXpmDz7koOtw7SUVwivjqETLertmRgjU/jC6RRHLRb243YLYs7bK5ZCpqmUTjpq5SZcCvOdOf 2ln1kENIIgG5yKBuQEDfoWoSTKvFtutYZhRm1EhKJVpB2IOV/aDRWd2XKwraS18ufcFSDSjPXIH1a rlzKlrKIEsnu8IxBldDOHj/UvABWXHIHDixHzRTrwDMagGxQ/EtZHrbT/aasB/uEOeDExFvqYSYus p+VKph5pg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDMAr-0008Q0-A0; Wed, 02 Sep 2020 06:23:13 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDMAm-0008OU-Br for openwrt-devel@lists.openwrt.org; Wed, 02 Sep 2020 06:23:09 +0000 Received: by mail-pg1-x541.google.com with SMTP id h12so2022154pgm.7 for ; Tue, 01 Sep 2020 23:23:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RjwPIapK0175qXchSjkmeynIDMXk5x6iUGqJtECMYec=; b=pqZxWqafNj+KPgVzdMZdNftwlKvREhzx7CJTnzqNTP5eXbLlbb9I8YGrmBFkE+CrqF jasuJnvZAz4cMT1FPURx7XX43WBHaXdNnw65+fytdViAyEPWCPriIFGBakzi1sHBuVLt PQYTYjthLbBtLmkXSie1LAqgpPoJSf8eieuu4A6Np5Y8YaU3V4gk48DgTyZaGRmju9gT wyoFhnPwuPTsCmHbHaP1KqL5q2Wa1Cdb8sdDfL1m7N0KDOtaglpR5tOjBFLF6hQkYHru hF7NncLsi7hseOkvP1Kon/9LFEt19m0tYJoH4IfqOrlFLkxO3eScBv3zJ8vDYPSoql80 v4Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RjwPIapK0175qXchSjkmeynIDMXk5x6iUGqJtECMYec=; b=ma7YrlSmAnY3+wtJ7cIZsX2tJ5dxqTPEugMRbAoTcLT5/e+aAUFAINCtNaSrXXsefU LVtE04n+LxT9d+WKhV90dwVGGbjgYlshVxscuq+MqeglS/+L4Q6SN6Q8E91OWnyk2S45 JNfGOzAhEDRSOmddII21036kcefsoYiqioZywCEqENH+toSSozVBMl5Lw4u1aNgYFrhy pVx7qC+gFq+3tda6FXj52ZJqrO16jf5uUrcrqQLjPFmEyONya0ZhQiJRE2AGwA7MFdb/ bbgLGWsV+nr5VBWYZGNEnCpXAXjGJUsq1f8aP2MrrcAt/REZKseuKwNee+Lhr0sBuKb+ cpVw== X-Gm-Message-State: AOAM531gjnevOzboW/daOoaCjQofrWNSDrCufO3K5mgghWuS6DKPu9la PfE5A508w+ejd8XaLDmgmO5WS6aEwG8CkQ== X-Google-Smtp-Source: ABdhPJzs0+4gwWMY6Rz2pPsCB5cEEKy2bXMjlWXlysTlAJTzF+4pXYOvUH0GRuuuR/KI+dWHJJLchQ== X-Received: by 2002:a63:9d0f:: with SMTP id i15mr754999pgd.413.1599027785703; Tue, 01 Sep 2020 23:23:05 -0700 (PDT) Received: from guoguo-omen.lan ([240e:379:969:6c74:93bb:530c:823:a456]) by smtp.gmail.com with ESMTPSA id u62sm4150929pfb.4.2020.09.01.23.23.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 23:23:05 -0700 (PDT) From: Chuanhong Guo To: openwrt-devel@lists.openwrt.org Subject: [PATCH 1/3] ramips: lzma-loader: make FLASH_START configurable Date: Wed, 2 Sep 2020 14:22:29 +0800 Message-Id: <20200902062231.2238353-2-gch981213@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200902062231.2238353-1-gch981213@gmail.com> References: <20200902062231.2238353-1-gch981213@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200902_022308_478373_7E7DF1EE X-CRM114-Status: GOOD ( 13.15 ) X-Spam-Score: 0.1 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:541 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [gch981213[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [gch981213[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chuanhong Guo Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org FLASH_START is supposed to point at the memory area where NOR flash are mapped. We currently have an incorrect FLASH_START copied from ar71xx back then and the loader doesn't work under OKLI mode. On ramips, mt7621 has it's flash mapped to 0x1fc00000 and other SoCs uses 0x1c000000. This commit makes FLASH_START a configurable value to handle both cases. Signed-off-by: Chuanhong Guo --- target/linux/ramips/image/lzma-loader/Makefile | 2 ++ target/linux/ramips/image/lzma-loader/src/Makefile | 5 +++++ target/linux/ramips/image/lzma-loader/src/loader.c | 5 +---- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/target/linux/ramips/image/lzma-loader/Makefile b/target/linux/ramips/image/lzma-loader/Makefile index f22151c9d7..4cf700d8c6 100644 --- a/target/linux/ramips/image/lzma-loader/Makefile +++ b/target/linux/ramips/image/lzma-loader/Makefile @@ -13,6 +13,7 @@ LOADER := loader.bin LOADER_NAME := $(basename $(notdir $(LOADER))) LOADER_DATA := TARGET_DIR := +FLASH_START := FLASH_OFFS := FLASH_MAX := BOARD := @@ -40,6 +41,7 @@ loader-compile: $(PKG_BUILD_DIR)/.prepared $(MAKE) -C $(PKG_BUILD_DIR) CROSS_COMPILE="$(TARGET_CROSS)" \ LZMA_TEXT_START=$(LZMA_TEXT_START) \ LOADER_DATA=$(LOADER_DATA) \ + FLASH_START=$(FLASH_START) \ FLASH_OFFS=$(FLASH_OFFS) \ FLASH_MAX=$(FLASH_MAX) \ BOARD="$(BOARD)" \ diff --git a/target/linux/ramips/image/lzma-loader/src/Makefile b/target/linux/ramips/image/lzma-loader/src/Makefile index d20cd77346..97fd6dad47 100644 --- a/target/linux/ramips/image/lzma-loader/src/Makefile +++ b/target/linux/ramips/image/lzma-loader/src/Makefile @@ -19,6 +19,7 @@ LOADADDR := LZMA_TEXT_START := 0x80a00000 LOADER_DATA := BOARD := +FLASH_START := FLASH_OFFS := FLASH_MAX := PLATFORM := @@ -64,6 +65,10 @@ ifneq ($(strip $(KERNEL_CMDLINE)),) CFLAGS += -DCONFIG_KERNEL_CMDLINE='"$(KERNEL_CMDLINE)"' endif +ifneq ($(strip $(FLASH_START)),) +CFLAGS += -DCONFIG_FLASH_START=$(FLASH_START) +endif + ifneq ($(strip $(FLASH_OFFS)),) CFLAGS += -DCONFIG_FLASH_OFFS=$(FLASH_OFFS) endif diff --git a/target/linux/ramips/image/lzma-loader/src/loader.c b/target/linux/ramips/image/lzma-loader/src/loader.c index c73b60b351..a3513eccf1 100644 --- a/target/linux/ramips/image/lzma-loader/src/loader.c +++ b/target/linux/ramips/image/lzma-loader/src/loader.c @@ -28,9 +28,6 @@ #include "printf.h" #include "LzmaDecode.h" -#define AR71XX_FLASH_START 0x1f000000 -#define AR71XX_FLASH_END 0x1fe00000 - #define KSEG0 0x80000000 #define KSEG1 0xa0000000 @@ -178,7 +175,7 @@ static void lzma_init_data(void) unsigned long kernel_ofs; unsigned long kernel_size; - flash_base = (unsigned char *) KSEG1ADDR(AR71XX_FLASH_START); + flash_base = (unsigned char *) KSEG1ADDR(CONFIG_FLASH_START); printf("Looking for OpenWrt image... ");