From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.6 Received: from atuin.qyliss.net (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id 03DDF65A78; Fri, 16 Sep 2022 05:29:10 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 496) id DAC60659E2; Fri, 16 Sep 2022 05:29:07 +0000 (UTC) Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by atuin.qyliss.net (Postfix) with ESMTPS id D6A01659E1 for ; Fri, 16 Sep 2022 05:29:03 +0000 (UTC) Received: by mail-lj1-x232.google.com with SMTP id l12so24717821ljg.9 for ; Thu, 15 Sep 2022 22:29:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unikie.com; s=google; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date; bh=GKPcL2kxritjcGKnzq1GzmrvMNtaT1w9owF817CxJSI=; b=dxetjHrzrXiKmdEtHRYwwvUJhRuqRu5ejkk6fVdGTg9XfQDKLtTtoZR3MLcDU0fedu 9A27hQq9VL54sPkhaAZAbcKzZbUedX1iq9+mKmuHV11tKsK0xJEmHar+InG88kN54Nxt 11jebFN4I097sGohcKmFdvJTGR+6xyTT0tCMKh9ZMERYSW3ZjBxCWr8e+4l5S1Mfwddw x94pTcBrn2DW0WKpHpwj5M5OFbeQehPEQ0AotFkl6WHCAecdrBxPYaXVI4RTuw/PR4YJ wd9tOQoT6DbCFbJuxNC+iaS3tJGQioQJz0bGfaI/0Jz+HOrlbWaQKYGb1AzURN4mGSOo uO+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=GKPcL2kxritjcGKnzq1GzmrvMNtaT1w9owF817CxJSI=; b=ik/7mzIVb05ywIkn5YtFZt0YTewnvfQHD8J/cB85Nw5RYEhmxE/ZLW6vN5Q+EN7Zs6 SepyTIlaOzXtSDEUfWZ3TWV8J2t5AprvSSMvj5oPu+pj+7FFSL8bLH972Xrjzvg0G8bk /c2XhiloBR6V5JFDg9lSrBrlV/qStJBeOQA8XsGkR51lD2iSRYbewaFvQux7HtQEy0kg EbAl6GCSy0tuQ3o7tTfU3wmseKqMMWKWKrqFflcZuqEOjXBM0iSU/EZlf72QKKnO7Ut0 IHzQZZgk2+8jibPRSOpE1rZdaF1YHz84iP1tvx/X/hYAb9S8K/zcbmleNRtxdi4fKA0n Wl9Q== X-Gm-Message-State: ACrzQf2KdQhwfNBGrvVtRlyjAyojMdz9mPDtBiVREuQRcuyI+3ak4oPx LoC21nKOevjHc0ULLw1oDulgyQ== X-Google-Smtp-Source: AMsMyM5Q99JyLG9XGPm8KpzbX/hAEL1GH0uPK37pHA0faK/DmkyiMtuY3vQYzLiIPKDGO3gr2LSpmg== X-Received: by 2002:a2e:7802:0:b0:26c:362e:c59f with SMTP id t2-20020a2e7802000000b0026c362ec59fmr936858ljc.440.1663306142595; Thu, 15 Sep 2022 22:29:02 -0700 (PDT) Received: from [192.168.1.26] (mobile-access-6df011-52.dhcp.inet.fi. [109.240.17.52]) by smtp.gmail.com with ESMTPSA id d30-20020a19385e000000b00492e98c27ebsm3298102lfj.91.2022.09.15.22.29.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Sep 2022 22:29:02 -0700 (PDT) Message-ID: <0ead7a33-4c9b-6eab-26df-5bbe02fc4649@unikie.com> Date: Fri, 16 Sep 2022 08:29:01 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 Subject: Re: Integrating Spectrum and platform firmware Content-Language: en-US To: Alyssa Ross , =?UTF-8?Q?Jos=c3=a9_Pekkarinen?= References: <20220915073515.47855-1-jose.pekkarinen@unikie.com> <87mtb1xd38.fsf@alyssa.is> <87h718yiuk.fsf@alyssa.is> <87zgf0vklc.fsf@alyssa.is> <302c49ae-fef5-2e36-f573-88b00f5af9cc@unikie.com> <87v8povisw.fsf@alyssa.is> <3b5ed1a7-571f-b653-3fb1-f388638b94a5@unikie.com> <87sfksvgm9.fsf@alyssa.is> From: Ville Ilvonen In-Reply-To: <87sfksvgm9.fsf@alyssa.is> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Message-ID-Hash: HR7AJATIFVUJNUF5JRBWIU7ZUGNSRJ5S X-Message-ID-Hash: HR7AJATIFVUJNUF5JRBWIU7ZUGNSRJ5S X-MailFrom: ville.ilvonen@unikie.com X-Mailman-Rule-Hits: header-match-devel.spectrum-os.org-0 X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1 CC: devel@spectrum-os.org X-Mailman-Version: 3.3.5 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On 9/15/22 17:47, Alyssa Ross wrote: > Ville Ilvonen writes: > >> On 9/15/22 17:00, Alyssa Ross wrote: >>> Ville Ilvonen writes: >>> >>>> On 9/15/22 16:22, Alyssa Ross wrote: >>>>> José Pekkarinen writes: >>>>> >>>>>> A mechanism to generate a full image from the nix generated artifacts >>>>>> putting together kernel, initrd, rootfs and ext partition so that the >>>>>> full image can be flashed in a sdcard of choice and use it. This would >>>>>> require to be configurable so that you can modify the partition table >>>>>> to suit vendor needs. >>>>> >>>>> We've had some discussion about that already on the list and on IRC. My >>>>> current view is that early boot firmware (U-Boot etc.) doesn't really >>>>> have anything to do with Spectrum. They both run at different times, >>>>> and they communicate over a standard interface (EBBR [1]), so the >>>>> specifics of the firmware aren't really in scope for Spectrum itself and >>>>> belong elsewhere. It doesn't make sense for Spectrum to be installing >>>>> U-Boot any more than it makes sense for U-Boot to be installing >>>>> Spectrum, or for Linux to be installing U-Boot — they are two separate >>>>> components. (This isn't an approach unique to Spectrum — Fedora is >>>>> doing something similar.) >>>>> >>>>> It can make sense to make an image that is a combination of U-Boot and >>>>> Spectrum, but that process should be part of an integration between the >>>>> two that exists one layer up, rather than part of either project. For >>>>> example, you could do something like this: >>>>> >>>>> let >>>>> spectrum = import { >>>>> # config could either be loaded using the standard mechanism >>>>> # or inlined here. >>>>> }; >>>>> # It would also be possible to import individual components of >>>>> # Spectrum and assemble them manually if even greater >>>>> # flexibility was required, but I doubt that would be common. >>>>> >>>>> inherit (spectrum) pkgs; >>>>> # I don't think a pkgs attribute currently exists on the >>>>> # spectrum-live.img derivation, but it might make sense to add >>>>> # for this sort of use case. >>>>> >>>>> uboot = pkgs.ubootRockPro64; >>>>> in >>>>> >>>>> pkgs.runCommand "uboot+spectrum.img" {} '' >>>>> # Use sfdisk (or maybe there's some better tool) >>>>> # to create a partition table, and copy the U-boot image >>>>> # and the Spectrum images into place. >>>>> # >>>>> # Spectrum is designed to accomodate this by not expecting >>>>> # any of its partitions to be at any particular location >>>>> # on disk. >>>>> '' >>>>> >>>>> Maybe this is another case where documentation and a worked example >>>>> would help? >>>> >>>> Documented example case would help. It's good to scope but in the big >>>> picture it's hard to see early boot firmware would have *nothing* to do >>>> with Spectrum. That's not the case with x86_64 either. >>>> >>>> Let me clarify. >>>> On x86 traditionally people can't change early bootloading. >>>> -> Spectrum assumes UEFI OS loading because UEFI is just there and can't >>>> be changed >>>> On arm traditionally people can and will change early bootloading. >>>> -> Spectrum has assumed UEFI but UEFI is just not there. It's must be >>>> put there - typically on device SD card or eMMC image. >>>> On riscv assumption is more like on arm. >>>> >>>> So the mechanism is essential, even when not *provided* by Spectrum it >>>> should be acknowledged. >>>> Documenting Spectrum reqs to boot itself with example determines how >>>> easily people can make their devices run Spectrum. >>> >>> Agreed, that's why I was pleased to discover the EBBR spec recently, >>> which defines exactly this: "an interface between platform firmware and >>> an operating system that is suitable for embedded platforms", designed >>> for U-Boot with UEFI like we were already targeting. So we can say >>> "Spectrum aims to implement EBBR on aarch64" (and on RISC-V when we get >>> there if that's the right thing to do), and that way there's a lovely >>> long document that explains what is Spectrum's responsibility to do, and >>> what is the firmware's responsibility to do. And when something goes >>> wrong, we'll be able to refer to the spec to determine whether it's a >>> problem with Spectrum, or with the platform firmware. >>> >>> And of course we can have some documentation that introduces EBBR to an >>> audience that's not necessarily familiar with it, and provides an >>> example of how an EBBR system comprising both Spectrum and U-Boot might >>> be put together, expanding on what I included as the example in my >>> previous message. That should be more than enough to acknowledge the >>> mechanism, right? >> >> Example with some device(s) defines the usefulness - to get Spectrum >> running on that device. Documentation with link to EBBR could be >> additional reading. The last practical question is where the device >> specific implementations of ebbr (e.g. u-boot) are stored. I'm reading >> out of Spectrum tree but the "glue" nix (your example of uboot+spectrum) >> would be needed somewhere. Could that be in Spectrum tree to be useful >> for Spectrum users? > > Well, there are a couple of things here: > > The first is that the glue Nix is only needed if you want to have the > firmware and the Spectrum partitions on the same image. This is > something that's supported, but recommended against (see the Firmware > Storage section of the EBBR spec [1] — that also mirrors the > recommendations I've heard from both the Tow-Boot and Fedora ARM > maintainers.) Yes, I've read the spec and it's a good spec. They also stress it's not an implementation. Technically the recommendation to store firmware separately is sound. In practice, many ARM devices will require separate OS to install/update the firmware WHEN OS chooses not to support it. That is of course a design decision that pushes firmware install/update out-of-tree. So having it that way not only leads to usability issues for people who just want to try the OS but also makes development more effort than it has to be. I really appreciate the Tow-Boot and Fedora ARM effort. And I kind of like generic NixOS aarch64 image in its' infancy. However, the ARM ecosystem constraints in device design and vendor BSP support are beyond their control. Maybe more devices in future will support vendor patched u-Boot in TowBoot package while still being able to support booting OS installation from another media like USB. As of today, that's not the case or is behind impractical development effort. > > That's not to say it's not a legitimate thing to do — I understand that > it's nice to be able to just download a single image and have everything > work, especially when Spectrum is one part of a bigger vision — so it's > not like it's unsupported, but the happy path that the community seems > to be heading towards (and therefore the one that I'd expect to > recommend to end users that are coming directly to Spectrum) is that > users should first install platform firmware if required (perhaps using > a distribution like Tow-Boot) onto dedicated storage as part of setting > up their device, and then install whatever EBBR-compliant distro they > want onto main storage. In the best case, where the hardware is well > supported by mainline Linux, they get a working device without needing > to track down or build a special image. If they're not quite so lucky, > they still don't need to worry about the specifics of combining firmware > and OS into a single image, and neither do we. Sure. This is nice vision of future. We've now got mechanism to combine FW and OS on single image for iMX8 dev boards - it's really user friendly for those devices. And EBBR compliant. Breaking it down and making separate installation processes/instructions for FW and OS maybe possible in future but not priority as of now. This goes to the area of bikeshedding vendor BSP supported mechanisms when what is needed is easy install. Many other more relevant virtualization and security related concepts to focus on first. > The second thing is that the Nix glue is board specific. It has to know > how to build U-Boot, and how to install it in the image at the correct > offset. But it isn't really specific to Spectrum at all. The only > interaction it needs to have with Spectrum is copying its partitions > into the right place, and the only implementation details of Spectrum it > needs to depend on are that Spectrum comes as a GPT image, and that it > doesn't mind if the offset of its partitions changes. So if you wanted > a reusable way to combine an OS image and a platform fimware image into > a single image with Nix, I think that would make more sense as a > seperate project outside of Spectrum, since it would also work with > almost any other OS. Ok. Out-of-tree it is then. -Ville > > I know there's been talk among NixOS aarch64 users/developers about > re-doing how NixOS builds SD card images, and this feels very relevant > to that conversation. This could, for example, be part of a future, > improved version of nixos-hardware, and as long as it didn't depend on > any NixOS specifics, it could work whether the OS being installed is > NixOS, Spectrum, Fedora, or anything else, as long as it implements > EBBR. > > [1]: https://arm-software.github.io/ebbr/index.html#firmware-storage