unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Vagrant Cascadian <vagrant@debian.org>
To: guix-devel@gnu.org
Subject: Supporting *multiple* bootloaders for arm64 on a single install?
Date: Sun, 06 Jun 2021 14:38:27 -0700	[thread overview]
Message-ID: <87y2bmznak.fsf@ponder> (raw)

[-- Attachment #1: Type: text/plain, Size: 3679 bytes --]

So, I've managed to get a single image that supports booting both the
Pinebook and Pinebook Pro reasonably well! I can pop the microSD card
out of one and put it into the other, and it boots!

Maybe this is not a big deal to those used to x86, but in the ARM world,
it is unfortunately more complicated than one would hope:

  https://archive.fosdem.org/2019/schedule/event/one_image_to_rule_them_all/

The only problem with my single image for multiple pinebooks variants is
it requires manually installing u-boot to different offsets for Pinebook
Pro (e.g. idbloader.img at sector 2112 rather than sector 64), as parts
of the Pinebook bootloader are installed at overlapping offsets.

I don't think it would be terribly hard to create an image that also
supports booting EFI! And as u-boot can provide an EFI implementation,
it would not be totally unreasonable to want to install both u-boot and
EFI in the same system configuration...

But as I understand it, guix only supports a single bootloader entry. To
support all of the above, I would need three separate bootloader
instances... one for Pinebook, one for Pinebook Pro, and lastly a
grub-efi bootloader.

Installing u-boot-pinebook uses:

(define install-allwinner64-u-boot
  #~(lambda (bootloader root-index image)
      (let ((spl (string-append bootloader "/libexec/u-boot-sunxi-with-spl.bin"))
            (u-boot (string-append bootloader "/libexec/u-boot-sunxi-with-spl.fit.itb")))
        (write-file-on-device spl (stat:size (stat spl))
                              image (* 8 1024))
        (write-file-on-device u-boot (stat:size (stat u-boot))
                              image (* 40 1024)))))

Installing u-boot-pinebook-pro-rk3399 uses:

(define install-rockpro64-rk3399-u-boot
  #~(lambda (bootloader root-index image)
      (let ((idb (string-append bootloader "/libexec/idbloader.img"))
            (u-boot (string-append bootloader "/libexec/u-boot.itb")))
        (write-file-on-device idb (stat:size (stat idb))
                              image (* 64 512))
        (write-file-on-device u-boot (stat:size (stat u-boot))
                              image (* 16384 512)))))

(define install-pinebook-pro-rk3399-u-boot install-rockpro64-rk3399-u-boot)

;; yes, these could be refactored into a single function!

But now I need to figure out how to pass a non-default offset for the
"idb" part for rockchip platforms.

In a system config.scm, you'd define it like so:

  (bootloader (bootloader-configuration
               (bootloader u-boot-pinebook-pro-rk3399-bootloader)
               (target "/dev/mmcblk0")))

u-boot-pinebook-pro-rk3399-bootloader is defined in
gnu/bootloader/u-boot.scm, which inherits from u-boot-bootloader, which
inherits from extlinux-bootloader in gnu/bootloader/extlinux.scm...

And somewhere along the way I've lost track of how we get to
install-pinebook-pro-rk3399-u-boot...


Is it possible to definte multiple bootloaders currently, or if not,
what would need to change to be able to support that? Where would one
pass non-default offsets for a given platform?


Strictly speaking, the extlinux.conf generation would be optional for an
EFI generated image(as u-boot can load grub-efi), although at the moment
I'd prefer using extlinux.conf if available as it makes for more
consistent matching of device-tree/.dtb file with the running kernel...


A related idea would be to generate an EFI bootable image with
sufficient emtpy space before the first partition (16MB) and then one
could manually install the appropriate u-boot, maybe with some helper
scripts to avoid having to do it completely manually...


Thoughts, advice, help? :)


live well,
  vagrant

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]

             reply	other threads:[~2021-06-06 21:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-06 21:38 Vagrant Cascadian [this message]
2021-06-19 12:16 ` Supporting *multiple* bootloaders for arm64 on a single install? Danny Milosavljevic
2021-06-19 15:11   ` Stefan
2021-06-19 21:03     ` Vagrant Cascadian
2021-06-20  6:00     ` Bengt Richter
2021-06-20 12:57       ` Stefan
2021-06-19 20:42   ` Vagrant Cascadian

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

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y2bmznak.fsf@ponder \
    --to=vagrant@debian.org \
    --cc=guix-devel@gnu.org \
    /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://git.savannah.gnu.org/cgit/guix.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).