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 16774C7EE23 for ; Sun, 11 Jun 2023 22:46:41 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CDC9484704; Mon, 12 Jun 2023 00:46:38 +0200 (CEST) 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="mKblJcHP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 96D7B8476C; Mon, 12 Jun 2023 00:46:36 +0200 (CEST) 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 102BC8469F for ; Mon, 12 Jun 2023 00:46:33 +0200 (CEST) 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 A7D0860EEA; Sun, 11 Jun 2023 22:46:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8AF2C433EF; Sun, 11 Jun 2023 22:46:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686523591; bh=8hia7Vb7e2P1tQFj6kUw40+vNilTfR6kwBuewEV5gRc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mKblJcHPnSI6yTbIg6QupkBLO7umJEtYg+HA4EutesED5XAvkvvQkTyHRWUnV/8wz 9g62YrtXtNDMpp37yXiU6+FMuyp1WdLCsS2Jmzig304Gk5CF30XzsrzZyHVibxqUGC g7sxnWsxppA19ga9d56DZrWOf9/lJNtmtDt1uf4KTRPK7GWVnUMsZ/Pwxusp+TY47w /4Ut44qrkGuFM2Cjm3UcaL7u0vSemJIxWTn8LDEitHd9o1H7eAtpUfRRAIvYIAJzeL X0mYwyRe4tg9Fys+bazMAgxPg+trU+jO+Q47kAatS7Tme0zkJXQFH7C/x7+WQwD1Aj IBUHqA9VjyIhg== Received: by pali.im (Postfix) id 47C527FD; Mon, 12 Jun 2023 00:46:27 +0200 (CEST) Date: Mon, 12 Jun 2023 00:46:27 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Peng Fan , Peng Fan , Jaehoon Chung , Martin Rowe Cc: u-boot@lists.denx.de Subject: Re: A38x BootROM MMC_CMD_SEND_STATUS timeouts Message-ID: <20230611224627.5krsfgqwm5m7pqo7@pali> References: <20230322175945.xitcqqxojkaeko2n@pali> <20230322190901.d6rmwdnkrpiaj7ba@pali> <20230323190056.662enozwqslzujql@pali> <20230325122506.yoopsks4voy6wiv5@pali> <20230401164345.iwfu7nd5jgbjtpzl@pali> <5bfc1a94-ba15-1393-1be9-b24c57689ebf@oss.nxp.com> <20230428083008.zhvg2ojzy6jc7zix@pali> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230428083008.zhvg2ojzy6jc7zix@pali> 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.8 at phobos.denx.de X-Virus-Status: Clean On Friday 28 April 2023 10:30:08 Pali Rohár wrote: > On Friday 28 April 2023 15:39:20 Peng Fan wrote: > > On 4/2/2023 12:43 AM, Pali Rohár wrote: > > > Can anybody help with this? > > > > I expected Jaehoon would say some words. Just a reminder... > > > > > > > > On Saturday 25 March 2023 13:25:06 Pali Rohár wrote: > > > > CCing MMC maintainers (Peng Fan & Jaehoon Chung). Could you help us with > > > > this issue? Expected usage is following: BootROM reads and execute SPL > > > > from eMMC (BootROM has its own code for reading eMMC), SPL initialize > > > > mmc driver and after SPL finish its work it returns control back to > > > > BootROM and BootROM reads and execute proper U-Boot from eMMC. And issue > > > > is that after SPL returns control back to BootROM it looks like that > > > > BootROM is sending MMC_CMD_SEND_STATUS command to eMMC but it timeouts > > > > (timeout takes 5 minutes!) and after it correctly reads proper U-Boot > > > > from eMMC and continues booting proper U-Boot. I guess that there is an > > > > issue that SPL's mmc driver changes eMMC state into something which > > > > BootROM does not expect. > > > > A general question is since BootROM will still using eMMC, why let > > SPL to initialize eMMC? SPL's configuration may not match ROM's expection. > > Requirement is ENV access which is stored on eMMC too and without > initializing SPL eMMC driver, SPL cannot access ENV. > > Another thing is that loading proper U-Boot via SPL eMMC driver is > sometimes faster than via BootROM eMMC code. I guess this is BootROM > does not full speed. > > Also another fact is that SPL on mvebu works in this "hybrid" mode > (initialize and access boot device; plus let BootROM to use it) for all > other bootable storages. > > > For example i.MX, there is ROM API, SPL use ROM API to ask ROM to ask > > ROM help loading images, and SPL not touch relevant USB/EMMC. > > Unfortunately there is no BootROM API for these processors. All issues > which are being resolved in this (and also other) discussions are done > by inspecting BootROM code and trying to understand how it behaves and > how it choose the eMMC boot partition. As this stuff has poor > documentation and even this documentation has documented erratas... So > nobody knows what exactly is and what not supported. > > What we need to do is to write mvebu specific SPL code which is > compatible with BootROM. > > > Regards, > > Peng. > > > > > > > > > > On Friday 24 March 2023 02:55:55 Martin Rowe wrote: > > > > > On Thu, 23 Mar 2023 at 19:01, Pali Rohár wrote: > > > > > > There is issue with that 5 minutes delay. But I think it should be fixed > > > > > > by the patch which I sent earlier, which restore partition config based > > > > > > on mmc->part_config in board_return_to_bootrom(). Could you test it? > > > > > > https://lore.kernel.org/u-boot/20230305160416.xc7wlzmkaociwcf7@pali/ > > > > > > Now when mmc->part_config is correctly initialized it should restore > > > > > > configuration and BootROM does not have to get that "Timeout waiting > > > > > > card ready" error. > > > > > > > > > > Still takes about 5 minutes. The output is below with MMC tracing. I > > > > > confirmed the value of mmc->part_config used for > > > > > restore_emmc_boot_part_config is the same as what is initially > > > > > detected early in SPL (both are 10 with mmc partconf 0 0 1 1 and > > > > > zeroed boot0). > > > > > > > > > > ERROR: Invalid kwbimage v1 > > > > > mmc_load_image_raw_sector: mmc block read error > > > > > spl: mmc: wrong boot mode > > > > > Trying to boot from BOOTROM > > > > > CMD_SEND:6 > > > > > ARG 0x03b30a00 > > > > > MMC_RSP_R1b 0x00000900 > > > > > CMD_SEND:13 > > > > > ARG 0x00010000 > > > > > MMC_RSP_R1,5,6,7 0x00000900 > > > > > CURR STATE:4 > > > > > Returning to BootROM (return address 0xffff05c4)... > > > > > > > > I looked at the BootROM disassembled code and error message > > > > "Timeout waiting card ready" is printed when following mmc command > > > > cmdidx=0xd, resptype=0x15, cmdarg=(something)<<0x10 timeouts. > > > > > > > > 0xd is in U-Boot MMC_CMD_SEND_STATUS > > > > > > > > 0x15 is in U-Boot MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC|MMC_RSP_BUSY > > > > which looks like U-Boot's MMC_RSP_R2 with BUSY bit set > > > > > > > > It looks like U-Boot function mmc_send_status() where that "something" > > > > in cmdarg is mmc->rca. > > > > > > > > If command does not timeout then BootROM next checks if response has > > > > BIT(8) set and if response mask 0x1e00 matches value 0xe00. If both are > > > > truth then BootROM mark call as successful. > > > > > > > > If response ANDed with mask 0xfdf94080 is non-zero then BootROM prints > > > > "Status Error: " with hex response value and mark call as unsuccessful. > > > > > > > > I'm looking at the U-Boot code and this BootROM logic looks very similar > > > > to U-Boot function mmc_poll_for_busy(), just without first call > > > > mmc_wait_dat0(). > > > > > > > > BIT(8) is MMC_STATUS_RDY_FOR_DATA > > > > 0x1e00 is MMC_STATUS_CURR_STATE > > > > 0xe00 is MMC_STATE_PRG > > > > 0xfdf94080 is MMC_STATUS_MASK > > > > > > > > I'm not mmc expert, but this looks like MMC_CMD_SEND_STATUS is failing > > > > in BootROM after U-Boot returns control back to the BootROM.