Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1B334C64ED8 for ; Fri, 24 Feb 2023 22:33:17 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1A8B78572C; Fri, 24 Feb 2023 23:33:15 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="CJY1JA4E"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8AF9B856E5; Fri, 24 Feb 2023 23:33:13 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 31D268572C for ; Fri, 24 Feb 2023 23:33:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 343A26197C; Fri, 24 Feb 2023 22:33:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46974C433D2; Fri, 24 Feb 2023 22:33:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677277986; bh=86Ld3ENoHAWtu9/8Jc+HtkNKmjIHEw6gE6pAVDtXI5o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CJY1JA4EbzTEi1N1nchXXIrOx9jlFF0z12NTZIV7VfroXqzgA/Og/Ja2L5lilj7Lv UiJOTxcawmJu/ZCVEujjY5UY2EN2ALnE+8f/76QvuLaXYwMP9UnQ1eTRgw2rQZYove pxaaOUsmVegzWEAvBEZpM1Raf/d5gVfsi8cCS28laL9A92WS8xR5Y/pKwNGTlDVkTt Sa9gEfz03LU/pMUt//7pQUY9+sMH6en/tAMoyh6fo3DYM79bO40lazrR9Usce9y7nQ 0eP1czQWJHumnjosE9MZ+MEmuDjaoGhB2NzEmLoVah+9au4s8TwjgkjqbrpUpJdOdW iLVxbkKZ/csgA== Received: by pali.im (Postfix) id 225F972C; Fri, 24 Feb 2023 23:33:03 +0100 (CET) Date: Fri, 24 Feb 2023 23:33:03 +0100 From: Pali =?utf-8?B?Um9ow6Fy?= To: Martin Rowe Cc: Tony Dinh , u-boot@lists.denx.de, Stefan Roese , Josua Mayer Subject: Re: [PATCH RFC u-boot-mvebu 00/59] arm: mvebu: Various fixes Message-ID: <20230224223303.dcr4x2xgs5dnexgc@pali> References: <20230221231405.ln5fvxuvgzmwmbl5@pali> <20230222075819.6f3vl7nlnpqwpg6e@pali> <20230222180307.7sxot7ivfx3elunx@pali> <20230222212356.abfhl7omg35hwizc@pali> <20230223180223.g6fy72hjttgbhdmb@pali> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean On Friday 24 February 2023 06:27:49 Martin Rowe wrote: > > > boot0 - zeroed > > > boot1 - u-boot (with local version 'boot1') > > > user - u-boot (with local version 'user') > > Can you check if boot_ack argument has some effect on the initial > > choice? Or if completely disabling boot partitions (boot_enable to 0) > > have some effect? > > boot_ack doesn't appear to do anything. I can only set 0 or 1 and > there's no noticeable change to the boot process. Ok. > Setting `mmc partconf 0 0 0 0` with the same setup as described above > results in the same BootROM fallback from BOOT0 to BOOT1, then SPL in > BOOT1 loads u-boot from the user area, which is identical to the `mmc > partconf 0 0 7 0` flow. Ok. > > If really EXT_CSD[179] register is completely ignored we may change SPL > > to always boot from BOOT0 (when eMMC with boot partitions is used) and > > if it fails then fallback to BootROM booting. > > Is there a way of knowing where the SPL was loaded from? I was trying to figure it out but it looks like that bootrom stores this information into variable on the bootrom stack. So I think that this is impossible. > Because it > would make sense to me that if SPL was loaded from BOOT1 to try and > load u-boot from BOOT1 as well, or from BOOT0 if SPL was loaded from > BOOT0, etc. Having u-boot loaded from a different location is not what > I expected and seems like it would cause a lot of confusion, > especially in a failed A/B rollout. Exactly, I want to avoid it. > BootROM seems to completely ignore > the setting, so I agree that SPL should ignore it as well, but > hardcoding BOOT0 (or even setting the partition as a compile-time > option) is probably not a great outcome. It is a solution and nice trick to how to fix it. Reason is that if SPL fails to load U-Boot from selected partition then it fallbacks to the BootROM, which loads U-Boot from the correct location. So if we hardcode partition to BOOT0 then it obviously works correctly when SPL+U-Boot is on BOOT0. And if it is stored on BOOT1 or USER then BootROM already has to fail load it from BOOT0, which means that on BOOT0 is not valid U-Boot and when SPL tries to load main U-Boot from BOOT0 it fails too, and it returns control to the BootROM which knows that it should load it from BOOT0. And this would work also for DATA. > Two observations that might help here: > 1. After reset, running `mmc partconf 0` always shows PARTITION_ACCESS > is set to 0x0, even it it was set to something else prior to reset Ok, so access permissions are reset. I do not know if this is in MMC standard or not. > 2. With the same setup as described above and `mmc partconf 0 0 1 1` > the SPL eventually times out trying to load from the zeroed BOOT0 and > returns to BootROM, which results in u-boot being loaded from BOOT1: Access permissions can disable access to particular partition. So it makes sense that it timeouts. And BootROM can always load and run main u-boot from the correct location. We are using SPL for loading main u-boot because this is way how it was first implemented and return to bootrom was broken in the past. Anyway, if you completely disable MMC support in SPL then SPL just returns control to BootROM which loads main U-Boot. Reading main u-boot via BootROM is slower as from SPL for SPI-NOR booting because SPL can use faster SPI transfers than BootROM. So this is the reason why we want in SPL to use native load method and not just BootROM. But maybe for MMC it would make sense? > ================================================= > BootROM - 1.73 > > Booting from MMC > BootROM: Bad header at offset 00000000 > BootROM: Bad header at offset 00200000 > Switching BootPartitions. > > U-Boot SPL 2023.04-rc2boot1-00098-g93408c61cd-dirty (Feb 23 2023 - > 19:43:59 +1000) > High speed PHY - Version: 2.0 > EEPROM TLV detection failed: Using static config for Clearfog Pro. > Detected Device ID 6828 > board SerDes lanes topology details: > | Lane # | Speed | Type | > -------------------------------- > | 0 | 3 | SATA0 | > | 1 | 0 | SGMII1 | > | 2 | 5 | PCIe1 | > | 3 | 5 | USB3 HOST1 | > | 4 | 5 | PCIe2 | > | 5 | 0 | SGMII2 | > -------------------------------- > High speed PHY - Ended Successfully > mv_ddr: 14.0.0 > DDR3 Training Sequence - Switching XBAR Window to FastPath Window > mv_ddr: completed successfully > Trying to boot from MMC1 > ERROR: Invalid kwbimage v1 > mmc_load_image_raw_sector: mmc block read error > spl: mmc: wrong boot mode > Trying to boot from BOOTROM > Returning to BootROM (return address 0xffff05c4)... > Timeout waiting card ready > BootROM: Image checksum verification PASSED > > > U-Boot 2023.04-rc2boot1-00098-g93408c61cd-dirty (Feb 23 2023 - 19:43:59 +1000) > > SoC: MV88F6828-A0 at 1600 MHz > DRAM: 1 GiB (800 MHz, 32-bit, ECC not enabled) > Core: 38 devices, 22 uclasses, devicetree: separate > MMC: mv_sdh: 0 > Loading Environment from MMC... *** Warning - bad CRC, using default environment > > Model: SolidRun Clearfog A1 > Board: SolidRun Clearfog Pro > Net: > Warning: ethernet@70000 (eth1) using random MAC address - be:13:3f:c3:c2:19 > eth1: ethernet@70000 > Warning: ethernet@30000 (eth2) using random MAC address - be:4c:72:3e:eb:bc > , eth2: ethernet@30000 > Warning: ethernet@34000 (eth3) using random MAC address - 86:e7:dd:8d:c5:c1 > , eth3: ethernet@34000 > Hit any key to stop autoboot: 0 > => > ================================================= > > > Seems that something in mmc initialization code is buggy. You can try to > > debug it by starting disabling parts of initialization code until you > > find the line/function which makes those BootROM messages "Timeout for > > status update!". > > > Hm... Yes, "offset" string is not in your output, so that function is > > not called in SPL. Only in main U-Boot. > > > > What is in SPL called is board_early_init_f() function or > > fdtdec_board_setup() function or also board_late_init() function. > > Pointer to blob is in global variable gd->fdt_blob. > > > > Note that adding new properties/nodes into fdt blob may fail. So always > > check for return values of fdt_*() function! You would probably need to > > call fdt_increase_size() first to make a place for new properties. > > > Yes, it has a hook. It is called ft_board_setup() and is called > > immediately before booting linux kernel. Basically in this hook you > > should check if u-boot's blob was patched for eMMC and if yes then patch > > also blob passed as argument in that function, as this blob would be > > used for linux. See Turris Omnia hook for inspiration which fixups > > ethernet node for linux blob based on what is in u-boot blob: > > https://source.denx.de/u-boot/u-boot/-/blob/master/board/CZ.NIC/turris_omnia/turris_omnia.c > > Lots of great ideas to look into, plus the bubt and defconfig stuff. > I'll let you know how I go or if I get stuck again. Ok!