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 59105C433F5 for ; Sat, 29 Jan 2022 21:19:13 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9C59783677; Sat, 29 Jan 2022 22:19:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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=gmail.com header.i=@gmail.com header.b="TnyQKgmZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C263183677; Sat, 29 Jan 2022 22:19:10 +0100 (CET) Received: from mail-qv1-xf2f.google.com (mail-qv1-xf2f.google.com [IPv6:2607:f8b0:4864:20::f2f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E01298192A for ; Sat, 29 Jan 2022 22:19:06 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mr.bossman075@gmail.com Received: by mail-qv1-xf2f.google.com with SMTP id g13so9156733qvw.4 for ; Sat, 29 Jan 2022 13:19:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language :from:to:cc:references:in-reply-to:content-transfer-encoding; bh=lY4Zd979A6bnKU81lx/oE9C1dQgHbDicfBysT2WXhQ4=; b=TnyQKgmZesSMF/RwnqWca0gsmCHqij3WdD920LjbQ/XgpD+lHx847iePkD0TqmJhs0 oZQHpX5EXzAtSC2oS8XzbNISiEPYF5MXNH/oieSGuTTLVc1vqYKWJsYzW2qf6zhirpDz aTkIapGqrMxFo7wb11wrJgoLR2l0IjT8C6gyNpcoTqGygCUoNxPupXnZ7JTVuKpPHoOq X8/sy5nqGVrA/oihMJcgk9+JQd0x4wZ009g/X5vP8Z+LTG2mlYR7qpvVgadYGKik+8ht FtrN8bLHIjk0E8z84qxi98fWpip93YvgWfX8yJ6PxSX5Gq7ZM4GGIQczW4Ik4Zmkq9ap FSSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=lY4Zd979A6bnKU81lx/oE9C1dQgHbDicfBysT2WXhQ4=; b=eKJW42Bh3DtdyQtOtSTY5M4DZDu+jLegPgooLt7kRk3/ZQXogGyq7QqL+OsbKvJTY7 Dqy3m4rHMVUFpxgQxSBfcVZvexJXEa2oc94vt/fONMttHiNFLAcqScSoeLkXMtKrq0QU jzjHPAdWnkRLxRDl9kSqKhF95QSnTrvRAVQKdOy3ypCZFswxchUlIDB7R4euaCxp4hlG TnlCxK5535o+fTxIu+LF0mCwXGntF5T0wZq5NnQalaz1uwXCsZGT3gd2vXQXF2VB8ZvG MtWiHYwu5+2q7D9ExCQHEZAK86FC6Bwnt1lh4SrUo7fSL6vUIJ1P5tNkdtknyGuJvbsE IYNQ== X-Gm-Message-State: AOAM532fN/uhUwuRyLp1gRKNlk06JN4i9hdzwpFgu/0bJIgQNrkc4BmN vUv4uJlZyy4z9bTmwmtBmPs= X-Google-Smtp-Source: ABdhPJxqoonRflSm8rr/05B3JEjTxHI1BSLwroS6HMrm8MG1M687DcBZ37SUUBuyRVXIbkkO64NY7g== X-Received: by 2002:a05:6214:29ea:: with SMTP id jv10mr12034406qvb.46.1643491145630; Sat, 29 Jan 2022 13:19:05 -0800 (PST) Received: from [10.4.10.38] (146-115-144-188.s4282.c3-0.nwt-cbr1.sbo-nwt.ma.cable.rcncustomer.com. [146.115.144.188]) by smtp.gmail.com with ESMTPSA id i13sm6260441qko.91.2022.01.29.13.19.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 29 Jan 2022 13:19:05 -0800 (PST) Message-ID: Date: Sat, 29 Jan 2022 16:19:03 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH 09/11] sunxi: Add support for SUNIV architecture Content-Language: en-US From: Jesse Taube To: Samuel Holland , Andre Przywara Cc: u-boot@lists.denx.de, jagan@amarulasolutions.com, hdegoede@redhat.com, sjg@chromium.org, icenowy@aosc.io, marek.behun@nic.cz, festevam@denx.de, narmstrong@baylibre.com, tharvey@gateworks.com, christianshewitt@gmail.com, pbrobinson@gmail.com, jernej.skrabec@gmail.com, hs@denx.de, arnaud.ferraris@gmail.com, giulio.benetti@benettiengineering.com, thirtythreeforty@gmail.com, Chris Morgan References: <20220105003508.1143140-1-Mr.Bossman075@gmail.com> <20220105003508.1143140-10-Mr.Bossman075@gmail.com> <20220126141321.32c9fb22@donnerap.cambridge.arm.com> <2d608b9d-b8f0-8d5b-2b6c-493e1461a6e8@gmail.com> <20220129115118.5a0022ef@slackpad.fritz.box> <9ee45f2e-b29f-5bd3-3007-125cdcaf501c@sholland.org> <070afd08-3d4d-15b1-f16d-24662fb0b273@gmail.com> In-Reply-To: <070afd08-3d4d-15b1-f16d-24662fb0b273@gmail.com> 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.5 at phobos.denx.de X-Virus-Status: Clean On 1/29/22 16:05, Jesse Taube wrote: > > > On 1/29/22 15:59, Samuel Holland wrote: >> On 1/29/22 5:51 AM, Andre Przywara wrote: >>> On Fri, 28 Jan 2022 22:21:28 -0500 >>> Jesse Taube wrote: >>>> On 1/26/22 09:38, Jesse Taube wrote: >>>>> On 1/26/22 09:13, Andre Przywara wrote: >>>>>> On Tue, 4 Jan 2022 19:35:06 -0500 >>>>>> Jesse Taube wrote: >>>>>> >>>>>>> u32 spl_boot_device(void) >>>>>>> { >>>>>>> return sunxi_get_boot_device(); >>>>>>> } >>>>>>> +#else >>>>>>> +/* >>>>>>> + * suniv BROM do not pass the boot media type to SPL, so we try with the >>>>>>> + * boot sequence in BROM: mmc0->spinor->fail. >>>>>>> + */ >>>>>>> +void board_boot_order(u32 *spl_boot_list) >>>>>>> +{ >>>>>>> + /* >>>>>>> + * See the comments above in sunxi_get_boot_device() for information >>>>>>> + * about FEL boot. >>>>>>> + */ >>>>>>> + if (!is_boot0_magic(SPL_ADDR + 4)) { >>>>>>> + spl_boot_list[0] = BOOT_DEVICE_BOARD; >>>>>>> + return; >>>>>>> + } >>>>>>> + >>>>>>> + spl_boot_list[0] = BOOT_DEVICE_MMC1; >>>>>> >>>>>> So does that mean that it tries MMC first, even when booted via SPI? So if >>>>>> there is a *non*-bootable microSD card in, it will read something from >>>>>> sector 80, and will execute that if this is a FIT or legacy image? >>>>> yes >>>> Uh sorry to bother you again but I cant seem to find a way to find where >>>> the bootrom got the spl. I could check other periphirals like pinmux. I >>>> could also just have it configured at build. Are both these options >>>> okay? I will try to find a way to find the boot device at runtime first. >>> >>> Don't bother for this version, it's fine as it is now, we can refine >>> this later. It's only a problem if there is a non-valid SPL, but a >>> valid U-Boot proper legacy image on the SD card. >>> I don't want to have a build time option, we try to keep a single image >>> for all boot sources. >>> So eventually I'd prefer the pinmux/clock check, since that's cheaper. >>> The alternative would be to read the SPL (again), check for a valid >>> header and verify the checksum. You can look at this for inspiration: >>> https://patchwork.ozlabs.org/project/uboot/patch/20210712100651.6912-3-andre.przywara@arm.com/ >> >> I checked the boot ROM code (thanks Jesse!), and indeed it does not report where >> it loaded SPL from, or make any other changes to the loaded eGON image. The boot >> ROM also completely cleans up its clock and pinctrl changes, regardless of the >> success/failure of a specific boot device. >> >> There's a function which loads some value to r2, but that gets called before the >> "load eGON from storage" functions, so r2 will be clobbered. >> >> So as far as I can tell, the only way to determine the boot device, other than >> reimplementing the BROM in SPL, is to look at the return address on the top of >> the BROM's stack. These are the possible values (in order of execution): >> >> 0xffff40f8: mmc0 >> 0xffff4114: spi0 NAND >> 0xffff4130: spi0 NOR >> 0xffff4150: mmc1 > > If i save it in save_boot_params it does change when in a different boot > device. Ill look into it more. > the sp is also a good idea. Sry Im just dumb. it does change but it is because it doesn't clean the registers. Thanks sam, looking at the stack is the best option. Sorry, Jesse Taube >> Regards, >> Samuel