From: Richard Sent <richard@freakingpenguin.com>
To: Vagrant Cascadian <vagrant@debian.org>
Cc: help-guix@gnu.org
Subject: Re: How does system-disk-image work with embedded-style boot loaders?
Date: Sat, 11 May 2024 23:44:09 -0400 [thread overview]
Message-ID: <875xvjheye.fsf@freakingpenguin.com> (raw)
In-Reply-To: <87v83jsya8.fsf@wireframe> (Vagrant Cascadian's message of "Sat, 11 May 2024 16:51:11 -0700")
>> 2) install-rockpro64-rk3399-u-boot writes u-boot.itb at (* 16384 512),
>> or 8,388,608, past the 2^20 offset in the image type. (Likely not
>> coincidentally 8,388,608 / 8 = 1,048,576. I don't know what to make of this
>> because it feels weird that bytes are used in one situation while
>> another uses bits.)
>
> Hopefully this is just a bit of confusion, or some of the images are
> broken and nobody noticed!
>
> I would suggest to inspect the partition table of a generated image to
> confirm if there is an empty space or blank/reserved partition(s)
> falling in that range...
Hi Vagrant!
Thanks for the response! I looked at the code again and I did realize I
missed one thing regarding point 2. pinebook-pro-image-type isn't using
a 1,048,576 offset, but a 9,437,184 offset. There's a *9 I missed,
oopsie.
Alas, there's still some confusion. We place the u-boot.itb image at an
offset of 16384*512, or 8,388,608. When building the u-boot image—part
of the output from the u-boot-pinebook-pro-rk3399-2024.01 derivation
built as part of $ guix system image gnu/system/images/pinebook-pro.scm
--system=aarch64-linux—the u-boot.itb file is 1,089,024 bytes long. Our
raw image offset is system offset is 9 * 2^20, or 9,437,184 (AKA 9 MiB).
So that means writing a 1,089,024 byte image to 8,388,608 spills over to
9,477,632. This is beyond the 9 MiB offset, so our u-boot image should
be overwriting the root FS.
Running fdisk on the image produces (emulated build due to
cross-compilation failures):
--8<---------------cut here---------------start------------->8---
gibraltar :( guix$ fdisk -l $(guix system image gnu/system/images/pinebook-pro.scm --system=aarch64-linux)
Disk /gnu/store/832w3d7dh2vdfdm2qdv5025w8sfm8zrl-pinebook-pro-barebones-raw-image: 1.62 GiB, 1741840384 bytes, 3402032 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000
Device Boot Start End Sectors Size Id Type
/gnu/store/832w3d7dh2vdfdm2qdv5025w8sfm8zrl-pinebook-pro-barebones-raw-image1 * 18432 3402031 3383600 1.6G 83 Linux
--8<---------------cut here---------------end--------------->8---
I can't figure out where that 18432 offset is coming from. Also, based
on the genimage configuration used to create this image, I'd expect at
least two partitions:
--8<---------------cut here---------------start------------->8---
;; /gnu/store/2ah9p62crpar2iq2jcni85i4fz4yx9x4-genimage.cfg
image image {
hdimage {
partition-table-type = "mbr"
}
partition GNU-ESP {
partition-type = 0xEF
image = "/gnu/store/d8irqwcay0w1wm54l1ydrs3kp6vcdd1a-partition.img"
offset = "1048576"
bootable = "false"
}
partition Guix_image {
partition-type = 0x83
image = "/gnu/store/823mxbjirpcqgjkybkq60vc34p6nc218-partition.img"
offset = "0"
bootable = "true"
}
}
--8<---------------cut here---------------end--------------->8---
I do find it surprisingly we split "generate base image with genimage"
and "copy bootloader into base image" into different steps. From what I
see at https://github.com/pengutronix/genimage genimage is entirely
capable of placing the bootloader itself. Perhaps there is some value in
reworking the direct bootloader installers (mostly u-boot I think?) to
use genimage.
--8<---------------cut here---------------start------------->8---
;; example from README
partition bootloader {
in-partition-table = false
offset = 0
image = "/path/to/bootloader.img"
}
--8<---------------cut here---------------end--------------->8---
If we are indeed deleting part of our Linux partition due to an overly
large u-boot image (perhaps the image grew over time?), having genimage
be in charge of copying both the partition images AND the bootloader
file would presumably catch that error. At least, I assume genimage
performs those kinds of sanity checks.
I may very well be missing something here, particularly with
interpreting the fdisk output. Sorry if I didn't make sense. This stuff
is hard! :)
I haven't even started looking into what, if any, logic is done on the
Guix side for u-boot to find the Linux kernel. Spooky. 👻
--
Take it easy,
Richard Sent
Making my computer weirder one commit at a time.
next prev parent reply other threads:[~2024-05-12 3:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-11 21:15 How does system-disk-image work with embedded-style boot loaders? Richard Sent
2024-05-11 23:51 ` Vagrant Cascadian
2024-05-12 3:44 ` Richard Sent [this message]
2024-05-19 19:44 ` Richard Sent
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=875xvjheye.fsf@freakingpenguin.com \
--to=richard@freakingpenguin.com \
--cc=help-guix@gnu.org \
--cc=vagrant@debian.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 external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.