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 08D51C433EF for ; Sat, 29 Jan 2022 21:21:42 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0F766837D2; Sat, 29 Jan 2022 22:21:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=benettiengineering.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=aruba.it header.i=@aruba.it header.b="fVcvfXJ2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 98EBF83689; Sat, 29 Jan 2022 22:21:38 +0100 (CET) Received: from smtpcmd13147.aruba.it (smtpcmd13147.aruba.it [62.149.156.147]) by phobos.denx.de (Postfix) with ESMTP id 39FAC836B9 for ; Sat, 29 Jan 2022 22:21:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=benettiengineering.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=giulio.benetti@benettiengineering.com Received: from [192.168.50.220] ([146.241.179.156]) by Aruba Outgoing Smtp with ESMTPSA id DvA4nBKehiF0aDvA5nhqV0; Sat, 29 Jan 2022 22:21:33 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aruba.it; s=a1; t=1643491293; bh=OfzosG2lKFOYNtJuEJC2kyZroO9KrOaMLI7eZFFKG2U=; h=Date:MIME-Version:Subject:To:From:Content-Type; b=fVcvfXJ26GJJNnZCWMgKjcO2aMSSP7PrHHtMH2cS3jw5jf3CcfIzonjja8xEOkA6c zpZgucEonefCSI+APAWWP8DkDxmMnTyTQ7aTHB65obPTc3ZNXIHpCc2hMjO4RK0JuQ EuGXEn5cg4qz0Zkeb3Wvz6UaGoNgO5XzPNQ7SrvjhRDWCGfhN3u6VAouzboUSbwFp2 bevHXaWrtHVDdymt/XpJ909fSQ8GcwgGQ2tnclxqQ6Zzb+1O/QgSAuvIOUQd9+brYB C/zxRonzNcoElsUynzp1rPVk4TtHnxUrEEYxfeb4/NVR3qC/IM8BEkn96g7kJhVhxl FONEZqIdwmC0g== Message-ID: <51e9bff7-9eba-75fb-1839-e5f8fa108159@benettiengineering.com> Date: Sat, 29 Jan 2022 22:21:32 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH 09/11] sunxi: Add support for SUNIV architecture Content-Language: en-US To: Jesse Taube , 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, 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> From: Giulio Benetti In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfDwRwzIPrVcYD7Nr3NdqENAGoHMbkxvIyhYtARGxEfbTRq4i0TfDbOGIzEH2EG2zdQqNFJ7DxM8ezzNjEIrY4VtzXXbsy8Evmzpgwailsng+SS/5fcCp a8Hiu4ioCEHj07OG515twOQz7/VYj7v6d2Z0UwEFrBKfvrg2jyx5DkXdFgODHz/nK57LxT/rUBpF7mNp3FSlezCFHsREHMurZTLnJyT9MFFgbmJzBk1Klvkb F/y1Wgae7IV9uux3o8dLcLEWeZ7W9rdqgQP4Am7zDgMV2vvnTOEPhfQX8WF1WKWXO2rXPdGcsjIpESNTO+vt2/zMbF+8mUUg/P6t7IQ6CEZsFmJXPx9txjb3 rZL+/sS4w6LcytlVH+lXNADF9az6/gqSDMoncXza0HqZRYj4ZCpjOm00ugJY3i7cUfoZDG4c6+LY8tmd3RWzqNDmCUArSpIPUrw+lWDc0oyeRN0rsiV+1Oj6 QIKldrIIBS3DzhFkqR5UD6ktlmEjUnyDWmvss/UF199C7OGd/QqrPhs5UTLN4JQsSFEQ0My94LpBdZSiymWpMbCyTEsoqO4xATZKbGe+Wf6FTUJShW8hciyX 8EXwwOUSf+Ngi9Wc3mfhnVqPoT8E7hSSulQzZcFtxN1oZG4Kz3NjLtpF5lrsYD9pAhclz/9c471mM5IMMC430By05A5FIwsdr/HIGPca2Art/Fzfi3r4On6M NNcNKMXTlLA5KRwdIKtvvkgvWDIL+NvXxaSmLp+SQR9ZNifJgxw52D49OQsmo99/uA8HplOFzjdv1CiRVMw+W+CrYF6MUaB+ 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 29/01/22 22:19, Jesse Taube wrote: > > > 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. I've been too late :-) So happy assembly coding Jesse! Best regards -- Giulio Benetti Benetti Engineering sas