From patchwork Sun Apr 29 13:36:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 906334 X-Patchwork-Delegate: trini@ti.com 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.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40Ypd55Hhdz9s0t for ; Sun, 29 Apr 2018 23:37:29 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 42DD6C21E1E; Sun, 29 Apr 2018 13:37:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 60C77C21DD7; Sun, 29 Apr 2018 13:36:55 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6EF98C21C29; Sun, 29 Apr 2018 13:36:52 +0000 (UTC) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by lists.denx.de (Postfix) with ESMTPS id 248E1C21C2C for ; Sun, 29 Apr 2018 13:36:52 +0000 (UTC) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 40YpcM3tGPz1qv3Q; Sun, 29 Apr 2018 15:36:51 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 40YpcM3KGBz1qqlF; Sun, 29 Apr 2018 15:36:51 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id wdxpWeYozDtw; Sun, 29 Apr 2018 15:36:49 +0200 (CEST) X-Auth-Info: 5oqstUxN6uFs9/icJnTKt5YUM7joWY6e0bJ9AHmvpCk= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Sun, 29 Apr 2018 15:36:49 +0200 (CEST) From: Lukasz Majewski To: u-boot@lists.denx.de Date: Sun, 29 Apr 2018 15:36:27 +0200 Message-Id: <20180429133633.29509-2-lukma@denx.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180429133633.29509-1-lukma@denx.de> References: <20180429133633.29509-1-lukma@denx.de> Cc: Marek Vasut , Tom Rini , Tien Fong Chee , Stefan Roese Subject: [U-Boot] [PATCH v3 1/7] bootcount: spl: Enable bootcount support in SPL X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" New, SPL related config option - CONFIG_SPL_BOOTCOUNT_LIMIT has been added to allow drivers/bootcount code re-usage in SPL. This code is necessary to use and setup bootcount in SPL in the case of falcon boot mode. Signed-off-by: Lukasz Majewski Reviewed-by: Stefan Roese Reviewed-by: Tom Rini --- Changes in v3: - None Changes in v2: - None common/spl/Kconfig | 9 +++++++++ drivers/Makefile | 1 + 2 files changed, 10 insertions(+) diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 4d27565566..2a61d2364b 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -54,6 +54,15 @@ config SPL_BOOTROM_SUPPORT BOOT_DEVICE_BOOTROM (or fall-through to the next boot device in the boot device list, if not implemented for a given board) +config SPL_BOOTCOUNT_LIMIT + bool "Support bootcount in SPL" + depends on SPL_ENV_SUPPORT + help + On some boards, which use 'falcon' mode, it is necessary to check + and increment the number of boot attempts. Such boards do not + use proper U-Boot for normal boot flow and hence needs those + adjustments to be done in the SPL. + config SPL_RAW_IMAGE_SUPPORT bool "Support SPL loading and booting of RAW images" default n if (ARCH_MX6 && (SPL_MMC_SUPPORT || SPL_SATA_SUPPORT)) diff --git a/drivers/Makefile b/drivers/Makefile index 6846d181aa..061331eadd 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -20,6 +20,7 @@ obj-$(CONFIG_$(SPL_TPL_)TIMER) += timer/ ifndef CONFIG_TPL_BUILD ifdef CONFIG_SPL_BUILD +obj-$(CONFIG_SPL_BOOTCOUNT_LIMIT) += bootcount/ obj-$(CONFIG_SPL_CPU_SUPPORT) += cpu/ obj-$(CONFIG_SPL_CRYPTO_SUPPORT) += crypto/ obj-$(CONFIG_SPL_GPIO_SUPPORT) += gpio/ From patchwork Sun Apr 29 13:36:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 906335 X-Patchwork-Delegate: trini@ti.com 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.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40Ypft3mRpz9s0t for ; Sun, 29 Apr 2018 23:39:02 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 0C33DC21C2C; Sun, 29 Apr 2018 13:37:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 6B384C21E3E; Sun, 29 Apr 2018 13:36:58 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 96199C21C2C; Sun, 29 Apr 2018 13:36:53 +0000 (UTC) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by lists.denx.de (Postfix) with ESMTPS id 438CAC21C29 for ; Sun, 29 Apr 2018 13:36:53 +0000 (UTC) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 40YpcN6R70z1qsT2; Sun, 29 Apr 2018 15:36:52 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 40YpcN5hCqz1qqlD; Sun, 29 Apr 2018 15:36:52 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id 3g2wQ-uEOLfE; Sun, 29 Apr 2018 15:36:51 +0200 (CEST) X-Auth-Info: 2leUY6fyGhEytPy6UEf4VCgZDRKJvHoRq6XpTGk6ytI= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Sun, 29 Apr 2018 15:36:51 +0200 (CEST) From: Lukasz Majewski To: u-boot@lists.denx.de Date: Sun, 29 Apr 2018 15:36:28 +0200 Message-Id: <20180429133633.29509-3-lukma@denx.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180429133633.29509-1-lukma@denx.de> References: <20180429133633.29509-1-lukma@denx.de> Cc: Marek Vasut , Tom Rini , Stefan Roese Subject: [U-Boot] [PATCH v3 2/7] bootcount: Add include guards into bootcount.h file X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This patch adds missing include guards for bootcount.h file. Signed-off-by: Lukasz Majewski Reviewed-by: Stefan Roese Reviewed-by: Tom Rini --- Changes in v3: - None Changes in v2: - New patch include/bootcount.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/bootcount.h b/include/bootcount.h index 06fb4d3578..e3b3f7028e 100644 --- a/include/bootcount.h +++ b/include/bootcount.h @@ -4,6 +4,8 @@ * * SPDX-License-Identifier: GPL-2.0+ */ +#ifndef _BOOTCOUNT_H__ +#define _BOOTCOUNT_H__ #include #include @@ -38,3 +40,4 @@ static inline u32 raw_bootcount_load(volatile u32 *addr) return in_be32(addr); } #endif +#endif /* _BOOTCOUNT_H__ */ From patchwork Sun Apr 29 13:36:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 906338 X-Patchwork-Delegate: trini@ti.com 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.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40Yph70G4kz9s0t for ; Sun, 29 Apr 2018 23:40:06 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id AA6A6C21E3B; Sun, 29 Apr 2018 13:37:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 3EF68C21E26; Sun, 29 Apr 2018 13:36:59 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9B083C21DF8; Sun, 29 Apr 2018 13:36:54 +0000 (UTC) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by lists.denx.de (Postfix) with ESMTPS id 6FB1DC21C4A for ; Sun, 29 Apr 2018 13:36:54 +0000 (UTC) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 40YpcQ1zdbz1qqkR; Sun, 29 Apr 2018 15:36:54 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 40YpcQ1mlMz1qqlD; Sun, 29 Apr 2018 15:36:54 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id c8hl7rp1hHgt; Sun, 29 Apr 2018 15:36:53 +0200 (CEST) X-Auth-Info: FB7Np5BT19mZYtmnVd1T0mHc7a8tPMhqkeYHQqSqtm8= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Sun, 29 Apr 2018 15:36:53 +0200 (CEST) From: Lukasz Majewski To: u-boot@lists.denx.de Date: Sun, 29 Apr 2018 15:36:29 +0200 Message-Id: <20180429133633.29509-4-lukma@denx.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180429133633.29509-1-lukma@denx.de> References: <20180429133633.29509-1-lukma@denx.de> Cc: Marek Vasut , Tom Rini , Stefan Roese Subject: [U-Boot] [PATCH v3 3/7] bootcount: Add function wrappers to handle bootcount increment and error checking X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Those two functions can be used to provide easy bootcount management. Signed-off-by: Lukasz Majewski --- Changes in v3: - Unify those functions to also work with common/autoboot.c code - Add enum bootcount_context to distinguish between u-boot proper and SPL Changes in v2: - None include/bootcount.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/include/bootcount.h b/include/bootcount.h index e3b3f7028e..16fc657b2a 100644 --- a/include/bootcount.h +++ b/include/bootcount.h @@ -11,6 +11,13 @@ #include #include +enum bootcount_context { + SPL = 1, + UBOOT, +}; + +#if defined CONFIG_SPL_BOOTCOUNT_LIMIT || defined CONFIG_BOOTCOUNT_LIMIT + #if !defined(CONFIG_SYS_BOOTCOUNT_LE) && !defined(CONFIG_SYS_BOOTCOUNT_BE) # if __BYTE_ORDER == __LITTLE_ENDIAN # define CONFIG_SYS_BOOTCOUNT_LE @@ -40,4 +47,47 @@ static inline u32 raw_bootcount_load(volatile u32 *addr) return in_be32(addr); } #endif + +static inline int bootcount_error(enum bootcount_context bc) +{ + unsigned long bootcount = bootcount_load(); + unsigned long bootlimit = env_get_ulong("bootlimit", 10, 0); + + if (bootlimit && bootcount > bootlimit) { + printf("Warning: Bootlimit (%lu) exceeded.", bootlimit); + if (bc == UBOOT) + printf(" Using altbootcmd."); + printf("\n"); + + return 1; + } + + return 0; +} + +static inline void bootcount_inc(enum bootcount_context bc) +{ + unsigned long bootcount = bootcount_load(); + + if (bc == SPL) { + bootcount_store(++bootcount); + return; + } + + /* Only increment bootcount when no bootcount support in SPL */ +#ifndef CONFIG_SPL_BOOTCOUNT_LIMIT + bootcount++; +#endif + bootcount_store(bootcount); + env_set_ulong("bootcount", bootcount); +} + +#if defined CONFIG_SPL_BUILD && !defined CONFIG_SPL_BOOTCOUNT_LIMIT +void bootcount_store(ulong a) {}; +ulong bootcount_load(void) { return 0; } +#endif /* CONFIG_SPL_BUILD && !CONFIG_SPL_BOOTCOUNT_LIMIT */ +#else +static inline int bootcount_error(enum bootcount_context bc) { return 0; } +static inline void bootcount_inc(enum bootcount_context bc) {} +#endif /* CONFIG_SPL_BOOTCOUNT_LIMIT || CONFIG_BOOTCOUNT_LIMIT */ #endif /* _BOOTCOUNT_H__ */ From patchwork Sun Apr 29 13:36:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 906339 X-Patchwork-Delegate: trini@ti.com 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.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40YphK6F3Hz9s0t for ; Sun, 29 Apr 2018 23:40:17 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 84FE8C21E76; Sun, 29 Apr 2018 13:38:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 220FAC21E1D; Sun, 29 Apr 2018 13:37:09 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 48BD6C21E7E; Sun, 29 Apr 2018 13:36:59 +0000 (UTC) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by lists.denx.de (Postfix) with ESMTPS id F39C6C21E12 for ; Sun, 29 Apr 2018 13:36:55 +0000 (UTC) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 40YpcR5hgDz1qv3R; Sun, 29 Apr 2018 15:36:55 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 40YpcR5M1nz1qqlD; Sun, 29 Apr 2018 15:36:55 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id TxINwqdst3j0; Sun, 29 Apr 2018 15:36:54 +0200 (CEST) X-Auth-Info: pX4Df8MHcseWuab/34klUgcCqdfnNtBZcUk/JbTf0o8= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Sun, 29 Apr 2018 15:36:54 +0200 (CEST) From: Lukasz Majewski To: u-boot@lists.denx.de Date: Sun, 29 Apr 2018 15:36:30 +0200 Message-Id: <20180429133633.29509-5-lukma@denx.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180429133633.29509-1-lukma@denx.de> References: <20180429133633.29509-1-lukma@denx.de> Cc: Marek Vasut , Tom Rini , Martin Etnestad , Stefan Roese Subject: [U-Boot] [PATCH v3 4/7] bootcount: Rewrite autoboot to use wrapper functions from bootcount.h X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The code has been refactored to use common wrappers from bootcount.h header. Signed-off-by: Lukasz Majewski Reviewed-by: Stefan Roese Reviewed-by: Tom Rini --- Changes in v3: - New patch Changes in v2: - None common/autoboot.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/common/autoboot.c b/common/autoboot.c index 2eef7a04cc..bfe4bdcf50 100644 --- a/common/autoboot.c +++ b/common/autoboot.c @@ -14,6 +14,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -291,18 +292,8 @@ const char *bootdelay_process(void) { char *s; int bootdelay; -#ifdef CONFIG_BOOTCOUNT_LIMIT - unsigned long bootcount = 0; - unsigned long bootlimit = 0; -#endif /* CONFIG_BOOTCOUNT_LIMIT */ - -#ifdef CONFIG_BOOTCOUNT_LIMIT - bootcount = bootcount_load(); - bootcount++; - bootcount_store(bootcount); - env_set_ulong("bootcount", bootcount); - bootlimit = env_get_ulong("bootlimit", 10, 0); -#endif /* CONFIG_BOOTCOUNT_LIMIT */ + + bootcount_inc(UBOOT); s = env_get("bootdelay"); bootdelay = s ? (int)simple_strtol(s, NULL, 10) : CONFIG_BOOTDELAY; @@ -324,13 +315,9 @@ const char *bootdelay_process(void) s = env_get("failbootcmd"); } else #endif /* CONFIG_POST */ -#ifdef CONFIG_BOOTCOUNT_LIMIT - if (bootlimit && (bootcount > bootlimit)) { - printf("Warning: Bootlimit (%u) exceeded. Using altbootcmd.\n", - (unsigned)bootlimit); + if (bootcount_error(UBOOT)) s = env_get("altbootcmd"); - } else -#endif /* CONFIG_BOOTCOUNT_LIMIT */ + else s = env_get("bootcmd"); process_fdt_options(gd->fdt_blob); From patchwork Sun Apr 29 13:36:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 906337 X-Patchwork-Delegate: trini@ti.com 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.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40Ypgq6W3Sz9s0t for ; Sun, 29 Apr 2018 23:39:51 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 96273C21E1E; Sun, 29 Apr 2018 13:38:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id B64FBC21DF8; Sun, 29 Apr 2018 13:37:24 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9FC30C21E31; Sun, 29 Apr 2018 13:37:02 +0000 (UTC) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by lists.denx.de (Postfix) with ESMTPS id 1789DC21DF8 for ; Sun, 29 Apr 2018 13:36:59 +0000 (UTC) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 40YpcT60wpz1qqkR; Sun, 29 Apr 2018 15:36:57 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 40YpcT4bhrz1qqlD; Sun, 29 Apr 2018 15:36:57 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id p9rJ-L2LJgla; Sun, 29 Apr 2018 15:36:56 +0200 (CEST) X-Auth-Info: uPQR2sJICf6OI/QOfPbOsQH4lqhPFbVMh8/g9KIiNCo= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Sun, 29 Apr 2018 15:36:55 +0200 (CEST) From: Lukasz Majewski To: u-boot@lists.denx.de Date: Sun, 29 Apr 2018 15:36:31 +0200 Message-Id: <20180429133633.29509-6-lukma@denx.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180429133633.29509-1-lukma@denx.de> References: <20180429133633.29509-1-lukma@denx.de> Cc: Marek Vasut , Tom Rini , Andy Yan , Stefan Roese , B Ravi Subject: [U-Boot] [PATCH v3 5/7] bootcount: spl: Extend SPL to support bootcount incrementation X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This patch adds support for incrementation of the bootcount in SPL. Such feature is necessary when we do want to use this feature with 'falcon' boot mode (which loads OS directly in SPL). Signed-off-by: Lukasz Majewski Reviewed-by: Stefan Roese Reviewed-by: Tom Rini --- Changes in v3: - Remove not needed #ifdefs - Add enum bootcount_context parameter to bootcount_inc() function Changes in v2: - New patch - as suggested by Stefan Roese - bootcount_inc() is called in common SPL code (./common/spl/spl.c), so other boards can also reuse it without modification common/spl/spl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/spl/spl.c b/common/spl/spl.c index 61d3071324..2d10c84296 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -20,6 +20,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -417,6 +418,8 @@ void board_init_r(gd_t *dummy1, ulong dummy2) spl_board_init(); #endif + bootcount_inc(SPL); + memset(&spl_image, '\0', sizeof(spl_image)); #ifdef CONFIG_SYS_SPL_ARGS_ADDR spl_image.arg = (void *)CONFIG_SYS_SPL_ARGS_ADDR; From patchwork Sun Apr 29 13:36:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 906340 X-Patchwork-Delegate: trini@ti.com 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.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40YpjX3w4Vz9s0t for ; Sun, 29 Apr 2018 23:41:20 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 3AEE9C21D4A; Sun, 29 Apr 2018 13:38:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id BFD13C21E39; Sun, 29 Apr 2018 13:37:20 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E3DC1C21C29; Sun, 29 Apr 2018 13:37:02 +0000 (UTC) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by lists.denx.de (Postfix) with ESMTPS id 47040C21E62 for ; Sun, 29 Apr 2018 13:36:59 +0000 (UTC) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 40YpcW0XBdz1qsT2; Sun, 29 Apr 2018 15:36:59 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 40YpcW0HwGz1qqlD; Sun, 29 Apr 2018 15:36:59 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id Zc8TRuugVhHZ; Sun, 29 Apr 2018 15:36:58 +0200 (CEST) X-Auth-Info: wMEZRpOEEciM0QG8cT8an1pdEHSRNJXmPNsLupNncvU= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Sun, 29 Apr 2018 15:36:57 +0200 (CEST) From: Lukasz Majewski To: u-boot@lists.denx.de Date: Sun, 29 Apr 2018 15:36:32 +0200 Message-Id: <20180429133633.29509-7-lukma@denx.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180429133633.29509-1-lukma@denx.de> References: <20180429133633.29509-1-lukma@denx.de> Cc: Marek Vasut , Tom Rini , Stefan Roese Subject: [U-Boot] [PATCH v3 6/7] bootcount: display5: spl: Extend DISPLAY5 board SPL to support bootcount checking X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This patch is necessary for providing basic bootcount checking in the case of using "falcon" boot mode in that board. It forces u-boot proper boot, when we exceed the number of errors. Signed-off-by: Lukasz Majewski Reviewed-by: Stefan Roese --- Changes in v3: - The bootcount_error now accepts enum bootcount_error input parameter Changes in v2: - Remove bootcount_init() from SPL specific board code board/liebherr/display5/spl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/board/liebherr/display5/spl.c b/board/liebherr/display5/spl.c index 437963e225..147ea62683 100644 --- a/board/liebherr/display5/spl.c +++ b/board/liebherr/display5/spl.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "common.h" DECLARE_GLOBAL_DATA_PTR; @@ -214,7 +215,7 @@ void board_boot_order(u32 *spl_boot_list) env_load(); s = env_get("BOOT_FROM"); - if (s && strcmp(s, "ACTIVE") == 0) { + if (s && !bootcount_error(SPL) && strcmp(s, "ACTIVE") == 0) { spl_boot_list[0] = BOOT_DEVICE_MMC1; spl_boot_list[1] = spl_boot_device(); } From patchwork Sun Apr 29 13:36:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 906336 X-Patchwork-Delegate: trini@ti.com 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.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40Ypgl6gpjz9s0t for ; Sun, 29 Apr 2018 23:39:47 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 9EBF2C21C4A; Sun, 29 Apr 2018 13:38:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id EBEEEC21E7D; Sun, 29 Apr 2018 13:37:09 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AB266C21E4E; Sun, 29 Apr 2018 13:37:04 +0000 (UTC) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by lists.denx.de (Postfix) with ESMTPS id 7E10FC21E31 for ; Sun, 29 Apr 2018 13:37:00 +0000 (UTC) Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 40YpcX2N3lz1qsT2; Sun, 29 Apr 2018 15:37:00 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 40YpcX25dcz1qqlD; Sun, 29 Apr 2018 15:37:00 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id YETTXEXVq2TZ; Sun, 29 Apr 2018 15:36:59 +0200 (CEST) X-Auth-Info: EDmr4AAqW/pcs4fPwMiLHzmX9NLo8YrKV+i6jaqsJqQ= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Sun, 29 Apr 2018 15:36:59 +0200 (CEST) From: Lukasz Majewski To: u-boot@lists.denx.de Date: Sun, 29 Apr 2018 15:36:33 +0200 Message-Id: <20180429133633.29509-8-lukma@denx.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180429133633.29509-1-lukma@denx.de> References: <20180429133633.29509-1-lukma@denx.de> Cc: Marek Vasut , Tom Rini , Stefan Roese Subject: [U-Boot] [PATCH v3 7/7] bootcount: display5: config: Enable boot count feature in the display5 board X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The boot count is enabled in both SPL and proper u-boot. Signed-off-by: Lukasz Majewski Reviewed-by: Stefan Roese --- Changes in v3: - None Changes in v2: - None configs/display5_defconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configs/display5_defconfig b/configs/display5_defconfig index a5f1cf1e92..6a2408260f 100644 --- a/configs/display5_defconfig +++ b/configs/display5_defconfig @@ -16,6 +16,7 @@ CONFIG_SPL_LOAD_FIT=y CONFIG_OF_BOARD_SETUP=y CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg,MX6Q" CONFIG_SUPPORT_RAW_INITRD=y +CONFIG_SPL_BOOTCOUNT_LIMIT=y # CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR is not set CONFIG_SPL_DMA_SUPPORT=y CONFIG_SPL_ENV_SUPPORT=y @@ -53,6 +54,9 @@ CONFIG_EFI_PARTITION=y CONFIG_OF_CONTROL=y CONFIG_ENV_IS_IN_SPI_FLASH=y CONFIG_FSL_ESDHC=y +CONFIG_BOOTCOUNT_LIMIT=y +CONFIG_SYS_BOOTCOUNT_SINGLEWORD=y +CONFIG_SYS_BOOTCOUNT_ADDR=0x020CC068 CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_BAR=y CONFIG_SPI_FLASH_SPANSION=y