From: Alyssa Ross <hi@alyssa.is>
To: "Ville Ilvonen" <ville.ilvonen@unikie.com>,
"José Pekkarinen" <jose.pekkarinen@unikie.com>
Cc: devel@spectrum-os.org
Subject: Integrating Spectrum and platform firmware
Date: Thu, 15 Sep 2022 14:47:58 +0000 [thread overview]
Message-ID: <87sfksvgm9.fsf@alyssa.is> (raw)
In-Reply-To: <3b5ed1a7-571f-b653-3fb1-f388638b94a5@unikie.com>
[-- Attachment #1: Type: text/plain, Size: 8075 bytes --]
Ville Ilvonen <ville.ilvonen@unikie.com> writes:
> On 9/15/22 17:00, Alyssa Ross wrote:
>> Ville Ilvonen <ville.ilvonen@unikie.com> writes:
>>
>>> On 9/15/22 16:22, Alyssa Ross wrote:
>>>> José Pekkarinen <jose.pekkarinen@unikie.com> 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 <spectrum/img/live> {
>>>> # 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.)
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.
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.
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
next prev parent reply other threads:[~2022-09-15 14:48 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-15 7:35 [PATCH] Add image configuration option José Pekkarinen
2022-09-15 8:21 ` Alyssa Ross
2022-09-15 10:42 ` José Pekkarinen
2022-09-15 11:31 ` Alyssa Ross
2022-09-15 12:31 ` José Pekkarinen
2022-09-15 13:22 ` Alyssa Ross
2022-09-15 13:48 ` Ville Ilvonen
2022-09-15 14:00 ` Alyssa Ross
2022-09-15 14:09 ` Ville Ilvonen
2022-09-15 14:47 ` Alyssa Ross [this message]
2022-09-16 5:29 ` Integrating Spectrum and platform firmware Ville Ilvonen
2022-09-16 4:59 ` [PATCH] Add image configuration option José Pekkarinen
2022-09-16 7:25 ` Alyssa Ross
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sfksvgm9.fsf@alyssa.is \
--to=hi@alyssa.is \
--cc=devel@spectrum-os.org \
--cc=jose.pekkarinen@unikie.com \
--cc=ville.ilvonen@unikie.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://spectrum-os.org/git/crosvm
https://spectrum-os.org/git/doc
https://spectrum-os.org/git/mktuntap
https://spectrum-os.org/git/nixpkgs
https://spectrum-os.org/git/spectrum
https://spectrum-os.org/git/ucspi-vsock
https://spectrum-os.org/git/www
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).