grub: embed per-SoC cmdline in efi.bin, keep rootfs generic - #231
Open
Phanendra Yarra (phanendra-qc) wants to merge 1 commit into
Open
grub: embed per-SoC cmdline in efi.bin, keep rootfs generic#231Phanendra Yarra (phanendra-qc) wants to merge 1 commit into
Phanendra Yarra (phanendra-qc) wants to merge 1 commit into
Conversation
Board-specific kernel parameters (e.g. arm64.nopauth for RB4) are now
carried by each board's BOOTAA64.EFI rather than baked into the rootfs
grub.cfg or resolved at runtime by a userspace service.
Problem with the previous approach
-----------------------------------
The earlier design used two grub.cfg menu entries (Generic / RB4) and a
grub-soc-select.service that ran at sysinit, read the Device Tree serial
number, and called grub-set-default to pick the right entry for the next
boot. This worked but had two drawbacks:
- The rootfs was not fully board-agnostic: it contained the RB4 menu
entry, grub-soc-map.conf, and the runtime selection service.
- The correct cmdline only took effect from the second boot (the service
runs after the kernel is already up).
New design: soc_extra_cmdline GRUB variable
-------------------------------------------
The ESP (efi.bin) is already per-board in gen-flash-dirs.sh (sector size,
VolatileVars.bin). BOOTAA64.EFI already embeds a bootstrap grub.cfg via
grub-mkstandalone. That bootstrap config is the natural place to carry
board identity — it is evaluated at GRUB stage, before the kernel loads,
and GRUB variables set there survive the configfile jump into the rootfs
grub.cfg.
build-efi-esp.sh --extra-cmdline "arm64.nopauth" → rb4/efi.bin
build-efi-esp.sh → generic/efi.bin
build-rootfs.sh → rootfs.img (shared)
Bootstrap config (baked into BOOTAA64.EFI):
set soc_extra_cmdline="arm64.nopauth" # RB4
set soc_extra_cmdline="" # generic
configfile ($root)/boot/grub/grub.cfg
rootfs grub.cfg linux line (single generic entry):
linux /boot/vmlinuz-... <base_cmdline> ${soc_extra_cmdline}
GRUB expands ${soc_extra_cmdline} at runtime from the bootstrap value.
The rootfs image is identical for all boards.
Changes
-------
bootloader/build-efi-esp.sh
- Add --extra-cmdline <params> argument (default empty).
- Embed 'set soc_extra_cmdline="<value>"' in the bootstrap config
written into BOOTAA64.EFI by grub-mkstandalone.
rootfs/scripts/build-rootfs.sh
- GRUB_DEFAULT reverted to 0 (single entry, no grubenv needed).
- Remove Step 7.6 (grub-soc-map.conf generation).
- Replace Step 9.4 (RB4 entry injection) with a sed pass that appends
'${soc_extra_cmdline}' to every linux line in grub.cfg.
flash/gen-flash-dirs.sh
- Read extra_cmdline from each board's JSON entry.
- When non-empty, rebuild efi.bin for that board via build-efi-esp.sh
--extra-cmdline before placing it in the flash directory.
boards.json example
-------------------
{ "name": "rb4", "ptool_platform": "qrb4210-rb2",
"extra_cmdline": "arm64.nopauth" }
{ "name": "rb5", "ptool_platform": "qrb5165-rb5" }
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Board-specific kernel parameters (e.g. arm64.nopauth for RB4) are now carried by each board's BOOTAA64.EFI rather than baked into the rootfs grub.cfg or resolved at runtime by a userspace service.
Design: soc_extra_cmdline GRUB variable
The ESP (efi.bin) is already per-board in gen-flash-dirs.sh (sector size, VolatileVars.bin). BOOTAA64.EFI already embeds a bootstrap grub.cfg via grub-mkstandalone. That bootstrap config is the natural place to carry board identity — it is evaluated at GRUB stage, before the kernel loads, and GRUB variables set there survive the configfile jump into the rootfs grub.cfg.
build-efi-esp.sh --extra-cmdline "arm64.nopauth" → rb4/efi.bin
build-efi-esp.sh → generic/efi.bin
build-rootfs.sh → rootfs.img (shared)
Bootstrap config (baked into BOOTAA64.EFI):
set soc_extra_cmdline="arm64.nopauth" # RB4
set soc_extra_cmdline="" # generic
configfile ($root)/boot/grub/grub.cfg
rootfs grub.cfg linux line (single generic entry):
linux /boot/vmlinuz-... <base_cmdline> ${soc_extra_cmdline}
GRUB expands ${soc_extra_cmdline} at runtime from the bootstrap value. The rootfs image is identical for all boards.
Changes
bootloader/build-efi-esp.sh
rootfs/scripts/build-rootfs.sh
flash/gen-flash-dirs.sh
boards.json example
{ "name": "rb4", "ptool_platform": "qrb4210-rb2",
"extra_cmdline": "arm64.nopauth" } { "name": "rb5", "ptool_platform": "qrb5165-rb5" }