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 BC53CC6FD1F for ; Thu, 16 Mar 2023 22:41:54 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C29DC85A4D; Thu, 16 Mar 2023 23:41:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1679006512; bh=w3hbC1YD5HUUJuH34tMc9eaahIxe7jVW09yazUSx6Cc=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=PeML1pLm1t7IDIbeeQvERtiEjvbeQe+bVdJCZcM1TWA1YIuu/3KtRzuRnABSYleAn 4W3asMSpwu+pfFXEE0bVUb0gvVEQlhlNPJhFyL+ujnVb9a4ansviU5ZKWwjZP8Xljk 3pcKDwi09+4JCAJ14CULrVBYx/88U6LU03iyU7/xiSFYDhHro59GVtOEB4rZGb4dCO ybenrXnk4AzgH6SmU6ZGAp0cZgDB7oKmucN+mVb48HVAmbu/HspfZ9cdRKM352/zUq 024LbM7kKlgY08CJQW514h3cyWlt2IidhHEeP1lXziuUAmHCpxDpvdbPMvEIk7bNse 3/se8ZCeRvL9A== Received: from [127.0.0.1] (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 589378596B; Thu, 16 Mar 2023 23:41:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1679006510; bh=w3hbC1YD5HUUJuH34tMc9eaahIxe7jVW09yazUSx6Cc=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Dy01XwpMfwXQhY8fCV+ANEHmiOnJYTP94xx/vh7vyYb27DD0K+FetdQwXUXgo3nTM K2o3xyfRsACz6U6CmVjMcpMrYCA4p6Rp7EBmnPcTeIHtpKppYM79759cZEcTOrKkFb fuCffX0K/ztxfgDtz/yp/AYwtxC/NZ8WNDFixhJYoDKTRvG0Ty9emv8x+fde5N/IGo n0f6qS7nnEmwTdTZGg9a4x6s4M87eiWzk0rIDmvun8AiaOJ0hB8dqZyWpv3nn3DZ20 OocvEOTZFXw6SLgPU4wxwnY4QZ5tc9t4O4ngNeVS2SoyF6C3oxgjT/aC43fL4bxNH9 spKxK9zTrPdew== Message-ID: <4ca33071-a017-13a5-9c37-eac5ebbd1c82@denx.de> Date: Thu, 16 Mar 2023 22:57:47 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: i.MX8MP SPL failures due to memory corruption/overflow? Content-Language: en-US To: Frieder Schrempf , "u-boot@lists.denx.de" Cc: Fabio Estevam , "Peng Fan (OSS)" , Marcel Ziswiler , Teresa Remmet , Tim Harvey References: <14d7d9f9-c71b-7825-33ce-e9d84fa4ef27@kontron.de> From: Marek Vasut In-Reply-To: <14d7d9f9-c71b-7825-33ce-e9d84fa4ef27@kontron.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 3/15/23 15:12, Frieder Schrempf wrote: > Hi, Hi, > I'm trying to bring up a new board based on the i.MX8MP and I have an > issue I'm hoping someone can help solving. > > I'm seeing failures in the early SPL code, usually in the DDR > initialization. Often they look like: > > U-Boot SPL 2023.04-rc3 (Mar 07 2023 - 14:32:34 +0000) > Training FAILED > Failed to initialize DDR RAM! > ### ERROR ### Please RESET the board ### > > But sometimes ddr_init() doesn't even return an error and only the > get_ram_size() afterwards which tries to allocate the memory fails. > > The strange thing is that the issues appear or disappear > deterministically on the binary level. This means I sometimes get a > U-Boot binary which runs just fine in 100% of cases. Then I change for > example one of the following: > > * Adding a single printf() somewhere in the boards spl.c > * Using the same binary but booting from SD card instead of USB loader > * Using the same source but switching from the OS cross compiler to the > one from Yocto/OE > > And afterwards I get 100% failure rate with an error as described above. > > My suspicion is that there is some memory corruption/conflict. My SPL is > quite large and I wonder if it exceeds some limit. > > SPL is loaded to 0x920000 and CONFIG_SPL_STACK is set to 0x960000, which > leaves 256 KiB in between for the SPL. But all i.MX8MP boards seem to > set CONFIG_SPL_MAX_SIZE=0x26000 (152 KiB) for some reason. My > u-boot-spl-ddr.bin currently has around 193 KiB but I don't get any > warning about exceeding the SPL_MAX_SIZE. > > My questions: > > * Why is CONFIG_SPL_MAX_SIZE set to 152 KiB? > * Why is there no warning in my case? > * Any other ideas or pointers? Does it help if you enable CONFIG_LTO=y ?