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 F090EC6FD1D for ; Sat, 1 Apr 2023 16:43:59 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5CB0885935; Sat, 1 Apr 2023 18:43:56 +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="hBBgegmo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 74862856B2; Sat, 1 Apr 2023 18:43:53 +0200 (CEST) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) (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 55F68858FF for ; Sat, 1 Apr 2023 18:43:50 +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 ams.source.kernel.org (Postfix) with ESMTPS id CE085B80D3A; Sat, 1 Apr 2023 16:43:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A47DC433EF; Sat, 1 Apr 2023 16:43:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680367428; bh=7PuET/l+BZVS6cm2CQSwusbwpXKbvMRL9/w85tcc1Wo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hBBgegmooMsF1IB9oIKVnle/eaztJwahnjz5kzhwm74zB9trybxsTkITwaZ0/F9Uu DIEGayg7Q5/kFdTjIAGXPdij4d1T5Yu0EJpgdEOZc1EPp+zi/WFT6j6Gs2NJXcesqf t/5Ha0yjt3Yx1aziX27KWCi9C7Lxb3LZ5bxIs5gf3E+s5GeiHnBnzWTyVmUiTaDJJ0 hqvES6gF5wLRLgVoHmLvjFFDqjZMo1hDFD6lM4C59lTUb3/KJfvxQg93aCq2/+w2Ag Man43mruXycO9kGbCaaILD1sksSU2wjef8m+4oBuxBz6JZeIyRGgDiMxi7H3vzTdqn jX16bS3mYI2gg== Received: by pali.im (Postfix) id 7F39FA47; Sat, 1 Apr 2023 18:43:45 +0200 (CEST) Date: Sat, 1 Apr 2023 18:43:45 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: u-boot@lists.denx.de Cc: Peng Fan , Jaehoon Chung , Martin Rowe Subject: Re: A38x BootROM MMC_CMD_SEND_STATUS timeouts Message-ID: <20230401164345.iwfu7nd5jgbjtpzl@pali> References: <20230321080758.5cmlygv63idaecth@pali> <20230322175945.xitcqqxojkaeko2n@pali> <20230322190901.d6rmwdnkrpiaj7ba@pali> <20230323190056.662enozwqslzujql@pali> <20230325122506.yoopsks4voy6wiv5@pali> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230325122506.yoopsks4voy6wiv5@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 Can anybody help with this? 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. > > 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.