From patchwork Mon Jul 15 11:25:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baruch Siach X-Patchwork-Id: 1131938 X-Patchwork-Delegate: sr@denx.de 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=tkos.co.il Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45nLny5PQbz9sDB for ; Mon, 15 Jul 2019 21:26:30 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 68FF2C21E02; Mon, 15 Jul 2019 11:26:13 +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=none 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 1AA17C21E60; Mon, 15 Jul 2019 11:25:59 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 977D8C21C29; Mon, 15 Jul 2019 11:25:57 +0000 (UTC) Received: from mx.tkos.co.il (guitar.tcltek.co.il [192.115.133.116]) by lists.denx.de (Postfix) with ESMTPS id 0E6D2C21C29 for ; Mon, 15 Jul 2019 11:25:57 +0000 (UTC) Received: from sapphire.lan (unknown [192.168.100.188]) by mx.tkos.co.il (Postfix) with ESMTP id D0D19440430; Mon, 15 Jul 2019 14:25:55 +0300 (IDT) From: Baruch Siach To: u-boot@lists.denx.de, Peng Fan , Stefan Roese Date: Mon, 15 Jul 2019 14:25:10 +0300 Message-Id: <15dbb36f263c768ab5f736211fce0c088b6a14b2.1563189912.git.baruch@tkos.co.il> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Cc: Baruch Siach , Dennis Gilmore , Gauthier Provost , Aditya Prayoga , Chris Packham Subject: [U-Boot] [PATCH 1/3] spl: mmc: support uboot image offset on main partition 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" On Armada 38x platforms the ROM code loads SPL from offset 0 of eMMC hardware boot partitions. When there are no boot partitions (i.e. SD card) the ROM skips the first sector that usually contains the (logical) partition table. Since the generated .kwb image contains the main U-Boot image in a fixed location (0x140 sectors by default), we end up with the main U-Boot image in offset of 1 sector. The current workaround is to manually set CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR to 0x141 to compensate for that. This patch uses the run-time detected boot partition to determine the right offset of the main U-Boot partition. The generated .kwb image is now compatible with both eMMC boot partition, and SD card main data partition. Signed-off-by: Baruch Siach --- common/spl/Kconfig | 12 ++++++++++++ common/spl/spl_mmc.c | 28 +++++++++++++++++++++------- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 9fe99681305c..47ee59118d27 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -280,6 +280,18 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR Address on the MMC to load U-Boot from, when the MMC is being used in raw mode. Units: MMC sectors (1 sector = 512 bytes). +config SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET + hex "U-Boot main hardware partition image offset" + depends on SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR + default 0x0 + help + On some platforms SPL location depends on hardware partition. The ROM + code skips the MBR sector when loading SPL from main hardware data + partition. This adds offset to the main U-Boot image. Set this symbol + to the number of skipped sectors. + + If unsure, leave the default. + config SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION bool "MMC Raw mode: by partition" help diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index 324d91c88404..7c7d9ccae4cf 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -49,6 +49,20 @@ static ulong h_spl_load_read(struct spl_load_info *load, ulong sector, return blk_dread(mmc_get_blk_desc(mmc), sector, count, buf); } +#if IS_ENABLED(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR) +static unsigned long spl_mmc_raw_uboot_sector(int part) +{ + unsigned long raw_sector = CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR; + + if (part == 0) + raw_sector += CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET; + + return raw_sector; +} +#else +static unsigned long spl_mmc_raw_uboot_sector(int part) { return 0; } +#endif + static __maybe_unused int mmc_load_image_raw_sector(struct spl_image_info *spl_image, struct mmc *mmc, unsigned long sector) @@ -307,7 +321,7 @@ int spl_mmc_load_image(struct spl_image_info *spl_image, struct mmc *mmc = NULL; u32 boot_mode; int err = 0; - __maybe_unused int part; + __maybe_unused int part = 0; err = spl_mmc_find_device(&mmc, bootdev->boot_device); if (err) @@ -364,12 +378,12 @@ int spl_mmc_load_image(struct spl_image_info *spl_image, if (!err) return err; #endif -#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR - err = mmc_load_image_raw_sector(spl_image, mmc, - CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR); - if (!err) - return err; -#endif + if (IS_ENABLED(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR)) { + err = mmc_load_image_raw_sector(spl_image, mmc, + spl_mmc_raw_uboot_sector(part)); + if (!err) + return err; + } /* If RAW mode fails, try FS mode. */ case MMCSD_MODE_FS: debug("spl: mmc boot mode: fs\n"); From patchwork Mon Jul 15 11:25:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baruch Siach X-Patchwork-Id: 1131937 X-Patchwork-Delegate: sr@denx.de 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=tkos.co.il Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45nLnY1dXxz9sDB for ; Mon, 15 Jul 2019 21:26:07 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id BD16DC21F34; Mon, 15 Jul 2019 11:26:00 +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=none 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 A25D5C21DFA; Mon, 15 Jul 2019 11:25:58 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8B9F7C21E16; Mon, 15 Jul 2019 11:25:57 +0000 (UTC) Received: from mx.tkos.co.il (guitar.tcltek.co.il [192.115.133.116]) by lists.denx.de (Postfix) with ESMTPS id 1BF9DC21DFA for ; Mon, 15 Jul 2019 11:25:57 +0000 (UTC) Received: from sapphire.lan (unknown [192.168.100.188]) by mx.tkos.co.il (Postfix) with ESMTP id 27CDE4405B7; Mon, 15 Jul 2019 14:25:56 +0300 (IDT) From: Baruch Siach To: u-boot@lists.denx.de, Peng Fan , Stefan Roese Date: Mon, 15 Jul 2019 14:25:11 +0300 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: <15dbb36f263c768ab5f736211fce0c088b6a14b2.1563189912.git.baruch@tkos.co.il> References: <15dbb36f263c768ab5f736211fce0c088b6a14b2.1563189912.git.baruch@tkos.co.il> MIME-Version: 1.0 Cc: Baruch Siach , Dennis Gilmore , Gauthier Provost , Aditya Prayoga , Chris Packham Subject: [U-Boot] [PATCH 2/3] arm: mvebu: clearfog: set uboot image SD card offset 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Armada 38x ROM skips the first SD card offset when loading SPL. This affects the location of the main U-Boot image. SPL MMC code now supports U-Boot image offset based on run-time detection of the boot partition. Use this feature to make the same generated image support both SD card and eMMC boot partition. Signed-off-by: Baruch Siach --- configs/clearfog_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/clearfog_defconfig b/configs/clearfog_defconfig index b7b886be4f7a..3609445c1e95 100644 --- a/configs/clearfog_defconfig +++ b/configs/clearfog_defconfig @@ -22,7 +22,7 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_SPL_TEXT_BASE=0x40000030 -CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x141 +CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET=0x1 CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_FLASH is not set CONFIG_CMD_GPIO=y From patchwork Mon Jul 15 11:25:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baruch Siach X-Patchwork-Id: 1131939 X-Patchwork-Delegate: sr@denx.de 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=tkos.co.il Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45nLpf0tmSz9sDB for ; Mon, 15 Jul 2019 21:27:06 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id BF63EC21F2F; Mon, 15 Jul 2019 11:26:26 +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=none 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 9A768C21EDC; Mon, 15 Jul 2019 11:25:59 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id ABFC1C21DFA; Mon, 15 Jul 2019 11:25:57 +0000 (UTC) Received: from mx.tkos.co.il (guitar.tcltek.co.il [192.115.133.116]) by lists.denx.de (Postfix) with ESMTPS id 5986FC21E02 for ; Mon, 15 Jul 2019 11:25:57 +0000 (UTC) Received: from sapphire.lan (unknown [192.168.100.188]) by mx.tkos.co.il (Postfix) with ESMTP id 704C54405D7; Mon, 15 Jul 2019 14:25:56 +0300 (IDT) From: Baruch Siach To: u-boot@lists.denx.de, Peng Fan , Stefan Roese Date: Mon, 15 Jul 2019 14:25:12 +0300 Message-Id: <36e33ce3a55140da9b40344bed9d5bf73156c5dd.1563189912.git.baruch@tkos.co.il> X-Mailer: git-send-email 2.20.1 In-Reply-To: <15dbb36f263c768ab5f736211fce0c088b6a14b2.1563189912.git.baruch@tkos.co.il> References: <15dbb36f263c768ab5f736211fce0c088b6a14b2.1563189912.git.baruch@tkos.co.il> MIME-Version: 1.0 Cc: Baruch Siach , Dennis Gilmore , Gauthier Provost , Aditya Prayoga , Chris Packham Subject: [U-Boot] [PATCH 3/3] arm: mvebu: clearfog: update eMMC documentation 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" SPL now automatically selects the correct U-Boot image offset for both eMMC and SD card. No need to tweak CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR anymore. Signed-off-by: Baruch Siach --- board/solidrun/clearfog/README | 6 ------ 1 file changed, 6 deletions(-) diff --git a/board/solidrun/clearfog/README b/board/solidrun/clearfog/README index 6171ce66f4f8..9375be84957a 100644 --- a/board/solidrun/clearfog/README +++ b/board/solidrun/clearfog/README @@ -20,12 +20,6 @@ of "/dev/sdX" here! Install U-Boot on eMMC: ----------------------- -The ROM loads the bootloader from eMMC first boot partition at offset 0. This -is unlike load from SD card that is at offset 512. As a result, the offset of -the main U-Boot image on the eMMC boot partition changes. Set -CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR to 0x140 for SPL to load U-Boot from -the correct location. - To make SPL load the main U-Boot image from the eMMC boot partition enable eMMC boot acknowledgement and boot partition with the following U-Boot command: