Okay, let’s refactor the provided Buildroot files (create_efi.sh
and sbnb_defconfig
) to permanently include the nomodeset
kernel parameter for the boot process initiated by the custom EFI executable.
The main challenge here is that your create_efi.sh
script builds a unified EFI executable and hardcodes the kernel command line within itself. This approach bypasses the standard Buildroot mechanism for setting the kernel command line via BR2_KERNEL_CMDLINE_*
options in the configuration, which are typically used by bootloaders like GRUB or Syslinux.
Therefore, to add nomodeset
, we must modify the script directly. Changes to the sbnb_defconfig
file will primarily involve ensuring other settings (like the initramfs format) are consistent with the script and adding comments for clarity.
1. Refactored board/sbnb/sbnb/scripts/create_efi.sh
This version adds nomodeset
to the command line string and includes a note about a potentially unused variable from the original script.
#!/bin/bash
set -euxo pipefail
# This script creates a custom bootable EFI binary by combining an EFI stub,
# Linux kernel, initrd, osrel and cmdline.
# Define variables
STUB=/usr/lib/systemd/boot/efi/linuxx64.efi.stub
KERNEL="${BINARIES_DIR}/bzImage"
# --- VERIFY THIS INITRD PATH ---
# Ensure this path correctly points to the CPIO archive you intend to use.
# Buildroot generates the CPIO in ${BINARIES_DIR}. Check if it's compressed
# (e.g., rootfs-sbnb.cpio.xz) or uncompressed (e.g., rootfs-sbnb.cpio)
# and adjust this variable and/or your Buildroot config accordingly.
# See notes in the defconfig section below.
INITRD="${BINARIES_DIR}/rootfs-sbnb.cpio"
OS_RELEASE="${TARGET_DIR}/etc/os-release"
# --- MODIFIED KERNEL COMMAND LINE ---
# Added 'nomodeset' to the end of the command line string.
# IMPORTANT: This command line is HARDCODED. Changes to BR2_KERNEL_CMDLINE_*
# in the Buildroot config will NOT affect the EFI file generated by this script.
CMDLINE="console=tty0 console=ttyS0 earlyprintk verbose intel_iommu=on module_blacklist=nouveau,nvidiafb,snd_hda_intel dyndbg=\"module firmware_class +p; module microcode +p; module ccp +p\" nomodeset"
# --- END MODIFICATION ---
CMDLINE_TMP=$(mktemp)
OUTPUT=sbnb.efi # Output filename in the current directory
# Write the command line to a temporary file
echo -n "${CMDLINE}" > "${CMDLINE_TMP}"
# Calculate alignment
align="$(objdump -p "${STUB}" | awk '{ if ($1 == "SectionAlignment"){print $2} }')"
align=$((16#$align))
# Calculate offsets for sections
stub_line=$(objdump -h "${STUB}" | tail -2 | head -1)
stub_size=0x$(echo "$stub_line" | awk '{print $3}')
stub_offs=0x$(echo "$stub_line" | awk '{print $4}')
osrel_offs=$((stub_size + stub_offs))
osrel_offs=$((osrel_offs + align - osrel_offs % align))
cmdline_offs=$((osrel_offs + $(stat -Lc%s "${OS_RELEASE}")))
cmdline_offs=$((cmdline_offs + align - cmdline_offs % align))
# --- NOTE: splash_offs Calculation ---
# The following offset is calculated but doesn't appear to be used in the
# objcopy command below in the original script. Verify if this is intended.
splash_offs=$((cmdline_offs + $(stat -Lc%s "${CMDLINE_TMP}")))
splash_offs=$((splash_offs + align - splash_offs % align))
# --- END NOTE ---
linux_offs=$((splash_offs)) # Original script sets linux_offs based on splash_offs
initrd_offs=$((linux_offs + $(stat -Lc%s "${KERNEL}")))
initrd_offs=$((initrd_offs + align - initrd_offs % align))
# Use objcopy to add sections to the EFI stub
# Ensure all required files exist before running objcopy
if [ ! -f "${OS_RELEASE}" ] || [ ! -f "${CMDLINE_TMP}" ] || [ ! -f "${KERNEL}" ] || [ ! -f "${INITRD}" ]; then
echo "Error: One or more input files for objcopy not found!" >&2
echo "OS_RELEASE: ${OS_RELEASE}" >&2
echo "CMDLINE_TMP: ${CMDLINE_TMP}" >&2
echo "KERNEL: ${KERNEL}" >&2
echo "INITRD: ${INITRD}" >&2
rm -f "${CMDLINE_TMP}" # Clean up temp file on error
exit 1
fi
objcopy \
--add-section .osrel="${OS_RELEASE}" --change-section-vma .osrel=$(printf 0x%x $osrel_offs) \
--add-section .cmdline="${CMDLINE_TMP}" --change-section-vma .cmdline=$(printf 0x%x $cmdline_offs) \
--add-section .linux="${KERNEL}" --change-section-vma .linux=$(printf 0x%x $linux_offs) \
--add-section .initrd="${INITRD}" --change-section-vma .initrd=$(printf 0x%x $initrd_offs) \
"${STUB}" "${OUTPUT}"
# Clean up temporary file
rm -f "${CMDLINE_TMP}"
# Output the result
echo "Unified EFI executable created: ${OUTPUT}"
# Move the final EFI file to the standard Buildroot images directory
# BR2_ROOTFS_POST_IMAGE_SCRIPT runs from the Buildroot top-level directory.
# ${BINARIES_DIR} correctly points to output/images in this context.
mv "${OUTPUT}" "${BINARIES_DIR}/"
echo "Moved ${OUTPUT} to ${BINARIES_DIR}/"
2. Refactored configs/sbnb_defconfig
This version includes comments explaining the implications of the custom script and provides guidance on CPIO and Syslinux settings.
BR2_x86_64=y
BR2_CCACHE=y
BR2_INIT_SYSTEMD=y
BR2_SYSTEM_DEFAULT_PATH="/bin:/sbin:/usr/bin:/usr/sbin"
BR2_GENERATE_LOCALE="en_US"
BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL_SBNB_PATH)/board/sbnb/sbnb/rootfs-overlay"
BR2_ROOTFS_PRE_BUILD_SCRIPT="$(BR2_EXTERNAL_SBNB_PATH)/board/sbnb/sbnb/pre_build.sh"
BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL_SBNB_PATH)/board/sbnb/sbnb/post_build.sh"
# --- Custom EFI Generation ---
# This post-image script creates a unified EFI executable (sbnb.efi)
# IMPORTANT: The kernel command line is HARDCODED inside the create_efi.sh script.
# Standard BR2_KERNEL_CMDLINE_* options below will NOT affect sbnb.efi.
BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL_SBNB_PATH)/board/sbnb/sbnb/scripts/create_efi.sh"
BR2_LINUX_KERNEL_GZIP=y
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
# Switch back to upstream kernel once Restricted Injection hypervisor support
# patches merged: https://lore.kernel.org/lkml/Z08J0EVu0VeA7Z%2FR@rli9-mobl/T/
BR2_LINUX_KERNEL_CUSTOM_GIT=y
BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/coconut-svsm/linux.git"
BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="svsm"
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_SBNB_PATH)/board/sbnb/sbnb/kernel-config"
BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="kernel-config-firmware"
BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF=y
# --- Kernel Command Line (Standard Bootloaders Only) ---
# These settings configure bootloaders like Syslinux or GRUB.
# They are NOT used by the custom create_efi.sh script.
# If Syslinux (enabled below) is actually used as a boot method,
# you SHOULD configure these options appropriately for it.
# Otherwise, the Syslinux boot entry might use an empty or default command line.
# Example:
# BR2_KERNEL_CMDLINE_EXTEND=y
# BR2_KERNEL_CMDLINE_FRAGMENT="nomodeset console=tty1"
BR2_KERNEL_CMDLINE_DEFAULT=y # Or choose custom/extend as needed for Syslinux
# BR2_KERNEL_CMDLINE_CUSTOM is not set
# BR2_KERNEL_CMDLINE_EXTEND is not set
# BR2_KERNEL_CMDLINE_FRAGMENT=""
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_11=y
# ... (other packages remain the same) ...
BR2_PACKAGE_LINUX_TOOLS_CPUPOWER=y
BR2_PACKAGE_XZ=y
BR2_PACKAGE_STRACE=y
BR2_PACKAGE_E2FSPROGS=y
BR2_PACKAGE_E2FSPROGS_DEBUGFS=y
BR2_PACKAGE_E2FSPROGS_E2IMAGE=y
BR2_PACKAGE_E2FSPROGS_E4DEFRAG=y
BR2_PACKAGE_E2FSPROGS_FUSE2FS=y
BR2_PACKAGE_E2FSPROGS_RESIZE2FS=y
BR2_PACKAGE_XORG7=y
BR2_PACKAGE_XLIB_LIBX11=y
BR2_PACKAGE_DMIDECODE=y
BR2_PACKAGE_HWDATA=y
BR2_PACKAGE_HWDATA_IAB_OUI_TXT=y
BR2_PACKAGE_HWDATA_PNP_IDS=y
# BR2_PACKAGE_HWDATA_USB_IDS is not set
BR2_PACKAGE_INTEL_MICROCODE=y
BR2_PACKAGE_IPMITOOL=y
BR2_PACKAGE_IPMITOOL_LANPLUS=y
BR2_PACKAGE_NVME=y
BR2_PACKAGE_PARTED=y
BR2_PACKAGE_SYSSTAT=y
BR2_PACKAGE_CA_CERTIFICATES=y
BR2_PACKAGE_LIBOPENSSL_BIN=y
BR2_PACKAGE_LIBCURL=y
BR2_PACKAGE_LIBCURL_CURL=y
BR2_PACKAGE_SLANG=y
BR2_PACKAGE_BIRD=y
BR2_PACKAGE_NETCAT_OPENBSD=y
BR2_PACKAGE_OPENSSH=y
BR2_PACKAGE_WIREGUARD_TOOLS=y
BR2_PACKAGE_SUDO=y
BR2_PACKAGE_TMUX=y
BR2_PACKAGE_DOCKER_CLI_BUILDX=y
BR2_PACKAGE_DOCKER_COMPOSE=y
BR2_PACKAGE_DOCKER_ENGINE=y
BR2_PACKAGE_DOCKER_ENGINE_DRIVER_BTRFS=y
BR2_PACKAGE_DOCKER_ENGINE_DRIVER_DEVICEMAPPER=y
BR2_PACKAGE_DOCKER_ENGINE_DRIVER_VFS=y
BR2_PACKAGE_EFIBOOTMGR=y
BR2_PACKAGE_UTIL_LINUX_WIPEFS=y
# --- Syslinux Bootloader ---
# Syslinux is enabled here for MBR and EFI.
# If you ONLY boot using the custom sbnb.efi generated by the script,
# you might consider disabling Syslinux to avoid confusion:
# # BR2_TARGET_SYSLINUX is not set
# If Syslinux IS used (e.g., for USB boot), ensure the standard kernel
# command line options above (BR2_KERNEL_CMDLINE_*) are set correctly for it.
BR2_TARGET_SYSLINUX=y
BR2_TARGET_SYSLINUX_MBR=y
BR2_TARGET_SYSLINUX_EFI=y
BR2_PACKAGE_HOST_KMOD_XZ=y
# ... (other host packages) ...
BR2_PACKAGE_HOST_PYTHON3=y
BR2_PACKAGE_HOST_PYTHON3_BZIP2=y
BR2_PACKAGE_HOST_PYTHON3_XZ=y
BR2_PACKAGE_HOST_PYTHON3_CURSES=y
BR2_PACKAGE_HOST_PYTHON3_SSL=y
BR2_PACKAGE_TAILSCALE=y
# --- Root Filesystem / Initramfs Generation ---
BR2_TARGET_ROOTFS_CPIO=y
# IMPORTANT: Verify CPIO format needed by create_efi.sh!
# The script uses INITRD="${BINARIES_DIR}/rootfs-sbnb.cpio".
# This implies an UNCOMPRESSED CPIO archive.
# Your original defconfig had BR2_TARGET_ROOTFS_CPIO_XZ=y, which creates
# a compressed file (e.g., rootfs.cpio.xz or rootfs-sbnb.cpio.xz).
#
# ACTION REQUIRED:
# 1. Determine if create_efi.sh truly needs an UNCOMPRESSED CPIO.
# 2. If YES: Use BR2_TARGET_ROOTFS_CPIO_NONE=y below.
# 3. If NO (it needs a compressed CPIO like XZ):
# a. Change the INITRD variable in create_efi.sh to the correct compressed filename
# (e.g., INITRD="${BINARIES_DIR}/rootfs-sbnb.cpio.xz").
# b. Use the corresponding compression option below (e.g., BR2_TARGET_ROOTFS_CPIO_XZ=y).
#
# Assuming UNCOMPRESSED based on script variable:
BR2_TARGET_ROOTFS_CPIO_NONE=y
# BR2_TARGET_ROOTFS_CPIO_GZIP is not set
# BR2_TARGET_ROOTFS_CPIO_BZIP2 is not set
# BR2_TARGET_ROOTFS_CPIO_LZMA is not set
# BR2_TARGET_ROOTFS_CPIO_LZO is not set
# BR2_TARGET_ROOTFS_CPIO_LZ4 is not set
# BR2_TARGET_ROOTFS_CPIO_XZ is not set # Make sure this is commented out if using NONE
# BR2_TARGET_ROOTFS_CPIO_ZSTD is not set
# Set the output filename to match the script variable:
BR2_TARGET_ROOTFS_CPIO_FILENAME="rootfs-sbnb.cpio"
BR2_TARGET_ROOTFS_CPIO_OPTS=""
BR2_TARGET_ROOTFS_CPIO_ARGS=""
# ... (rest of packages remain the same) ...
BR2_PACKAGE_SEVCTL=y
BR2_PACKAGE_SNPGUEST=y
BR2_PACKAGE_TPM2_TOOLS=y
BR2_PACKAGE_BUSYBOX_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_SBNB_PATH)/board/sbnb/sbnb/busybox.fragment"
BR2_TARGET_ROOTFS_SQUASHFS=y
BR2_TARGET_ROOTFS_SQUASHFS4_XZ=y
BR2_PACKAGE_OPENVMTOOLS=y
BR2_SHARED_STATIC_LIBS=y
BR2_PACKAGE_FATRESIZE=y
BR2_PACKAGE_MOKUTIL=y
BR2_PACKAGE_TCPDUMP=y
BR2_PACKAGE_DOSFSTOOLS=y
BR2_PACKAGE_DOSFSTOOLS_FATLABEL=y
BR2_PACKAGE_DOSFSTOOLS_FSCK_FAT=y
BR2_PACKAGE_DOSFSTOOLS_MKFS_FAT=y
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_PIP=y
BR2_PACKAGE_PYTHON3_ZLIB=y
BR2_PACKAGE_PYTHON_REQUESTS=y
BR2_PACKAGE_JQ=y
3. Explanation of Changes and Important Considerations:
create_efi.sh
:nomodeset
was added to theCMDLINE
variable.- A check was added to ensure input files exist before
objcopy
runs. - A comment was added regarding the
INITRD
variable path – you must verify if your script needs a compressed (e.g.,.xz
) or uncompressed CPIO file and adjust theINITRD
variable in the script and the CPIO settings in the defconfig accordingly. - A note was added about the
splash_offs
variable, which seems calculated but unused in theobjcopy
command of the original script. You may want to investigate this. - The
rm
command ensures the temporary command line file is deleted. - The
mv
command ensures the finalsbnb.efi
is placed inoutput/images/
.
sbnb_defconfig
:- CPIO Configuration: This is the most critical part to verify. The configuration is set up assuming the script needs an uncompressed CPIO named
rootfs-sbnb.cpio
, based on the script’sINITRD
variable. If your originalBR2_TARGET_ROOTFS_CPIO_XZ=y
setting was intentional and the script should use a compressed initrd, you need to:- Change
INITRD
in the script (e.g.,INITRD="${BINARIES_DIR}/rootfs-sbnb.cpio.xz"
). - Change the defconfig back to
BR2_TARGET_ROOTFS_CPIO_XZ=y
(and comment outBR2_TARGET_ROOTFS_CPIO_NONE=y
). - Ensure
BR2_TARGET_ROOTFS_CPIO_FILENAME
results in the correct name if needed (it might default correctly if compression is enabled).
- Change
- Kernel Command Line: Comments explicitly state that
BR2_KERNEL_CMDLINE_*
options are ignored by the script but are relevant for Syslinux. You need to decide:- If Syslinux is used: Configure
BR2_KERNEL_CMDLINE_*
appropriately for it. - If Syslinux is NOT used: Consider disabling
BR2_TARGET_SYSLINUX*
options to avoid confusion.
- If Syslinux is used: Configure
- Comments: Added comments to explain the hardcoded command line, the CPIO verification need, and the Syslinux interaction.
- CPIO Configuration: This is the most critical part to verify. The configuration is set up assuming the script needs an uncompressed CPIO named
4. Next Steps:
- Verify CPIO Requirement: Determine the exact initramfs file (compressed or uncompressed, exact name) that
create_efi.sh
is intended to embed. - Apply Changes: Replace your existing files with these refactored versions, making sure the CPIO settings in both the script (
INITRD
variable) and the defconfig (BR2_TARGET_ROOTFS_CPIO_*
) are consistent with your verified requirement. Adjust Syslinux settings as needed. - Rebuild: Navigate to your Buildroot top-level directory and run
make
. This will rebuild the necessary components and execute the post-image script. - Deploy: Use the updated
output/images/sbnb.efi
file to boot your GMKtec G5. - Verify: After booting, log in and run
cat /proc/cmdline
to confirm thatnomodeset
is present in the kernel command line arguments.
5. Further Considerations / Alternatives:
- Reading Command Line from Buildroot: Instead of hardcoding the command line in
create_efi.sh
, a more robust approach would be to modify the script to read the command line configured via Buildroot’sBR2_KERNEL_CMDLINE_*
options. This could involve reading the generated bootloader config file (likesyslinux.cfg
) or having Buildroot write the command line to a temporary file that the script reads. This makes configuration more centralized but requires more significant script changes. - Script Robustness: The provided
create_efi.sh
could benefit from more robust error checking (e.g., verifyingobjcopy
success).
By applying these changes and carefully verifying the CPIO configuration, you should successfully embed the nomodeset
parameter into your custom EFI boot process.
#second approach
Okay, let’s refine the approach for adding the nomodeset
kernel parameter to your Buildroot OS image, specifically addressing the interaction between your sbnb_defconfig
and the custom create_efi.sh
script.
Understanding the Context
Your setup uses a custom post-image script (board/sbnb/sbnb/scripts/create_efi.sh
) to generate a unified EFI executable (sbnb.efi
). The critical point is that, in its original form, this script hardcodes the kernel command line arguments within the script itself. This bypasses Buildroot’s standard mechanism for managing kernel parameters via the BR2_CMDLINE
variable (or older BR2_KERNEL_CMDLINE_*
options) in the configuration (defconfig
).
Therefore, simply setting BR2_CMDLINE
in your sbnb_defconfig
will not affect the sbnb.efi
file generated by the original script.
We need to modify the system so that nomodeset
is included in the command line embedded within sbnb.efi
. There are two main ways to achieve this:
- Solution A (Quick Fix): Modify the script to include
nomodeset
in its hardcoded command line string. This is simpler but less maintainable. - Solution B (Recommended): Modify the script to read the command line from the Buildroot environment variable
BR2_CMDLINE
and defineBR2_CMDLINE
in yoursbnb_defconfig
. This aligns with standard Buildroot practices and centralizes configuration.
We will also ensure the Buildroot configuration correctly generates the CPIO root filesystem expected by the script.
Rationale Recap: The nomodeset
parameter is being added as a troubleshooting step. It tells the kernel not to load video drivers and attempt display mode changes during initialization. This can prevent hangs or slowdowns caused by graphics driver issues on certain hardware, like the slow console output you observed.
Solution A: Modify Hardcoded Command Line in Script (Quick Fix)
This approach directly edits the CMDLINE
variable within create_efi.sh
.
1. Modify board/sbnb/sbnb/scripts/create_efi.sh
:
--- a/board/sbnb/sbnb/scripts/create_efi.sh
+++ b/board/sbnb/sbnb/scripts/create_efi.sh
@@ -10,8 +10,10 @@
KERNEL="${BINARIES_DIR}/bzImage"
INITRD="${BINARIES_DIR}/rootfs-sbnb.cpio"
OS_RELEASE="${TARGET_DIR}/etc/os-release"
-CMDLINE="console=tty0 console=ttyS0 earlyprintk verbose intel_iommu=on module_blacklist=nouveau,nvidiafb,snd_hda_intel dyndbg=\"module firmware_class +p; module microcode +p; module ccp +p\""
+# --- MODIFIED KERNEL COMMAND LINE (Hardcoded) ---
+# Added 'nomodeset'. Note: This bypasses standard Buildroot BR2_CMDLINE config.
+CMDLINE="console=tty0 console=ttyS0 earlyprintk verbose intel_iommu=on module_blacklist=nouveau,nvidiafb,snd_hda_intel dyndbg=\"module firmware_class +p; module microcode +p; module ccp +p\" nomodeset"
+# --- END MODIFICATION ---
CMDLINE_TMP=$(mktemp)
OUTPUT=sbnb.efi
@@ -41,8 +43,13 @@
--add-section .initrd="${INITRD}" --change-section-vma .initrd=$(printf 0x%x $initrd_offs) \
"${STUB}" "${OUTPUT}"
+# Clean up temporary file
+rm -f "${CMDLINE_TMP}"
+
# Output the result
echo "Output: ${OUTPUT}"
+
+# Move the final EFI file to the standard Buildroot images directory (BINARIES_DIR=output/images)
+mv "${OUTPUT}" "${BINARIES_DIR}/"
+echo "Moved ${OUTPUT} to ${BINARIES_DIR}/"
- Change: Added
nomodeset
to the end of theCMDLINE
variable string. - Added: Cleanup for the temporary file (
rm -f "${CMDLINE_TMP}"
). - Added:
mv "${OUTPUT}" "${BINARIES_DIR}/"
to place the final artifact in the correct Buildroot output directory (output/images
). Buildroot providesBINARIES_DIR
in the environment when running post-image scripts.
2. Modify configs/sbnb_defconfig
(CPIO Settings & Comments):
Ensure the CPIO settings match what the script expects (rootfs-sbnb.cpio
, likely uncompressed). Add comments clarifying the hardcoded nature.
--- a/configs/sbnb_defconfig
+++ b/configs/sbnb_defconfig
@@ -8,9 +8,10 @@
BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL_SBNB_PATH)/board/sbnb/sbnb/rootfs-overlay"
BR2_ROOTFS_PRE_BUILD_SCRIPT="$(BR2_EXTERNAL_SBNB_PATH)/board/sbnb/sbnb/pre_build.sh"
BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL_SBNB_PATH)/board/sbnb/sbnb/post_build.sh"
+# This post-image script creates a unified EFI executable (sbnb.efi)
+# IMPORTANT: With Solution A, the kernel command line is HARDCODED inside create_efi.sh
+# Standard BR2_CMDLINE options will NOT affect sbnb.efi in this case.
BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL_SBNB_PATH)/board/sbnb/sbnb/scripts/create_efi.sh"
-BR2_LINUX_KERNEL_GZIP=y
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
# Switch back to upstream kernel once Restricted Injection hypervisor support
@@ -20,6 +21,7 @@
BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="svsm"
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_SBNB_PATH)/board/sbnb/sbnb/kernel-config"
BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="kernel-config-firmware"
+# BR2_CMDLINE is not set here as it's bypassed by the script in Solution A
BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF=y
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_11=y
BR2_PACKAGE_LINUX_TOOLS_CPUPOWER=y
@@ -75,14 +77,11 @@
BR2_PACKAGE_HOST_PYTHON3_CURSES=y
BR2_PACKAGE_HOST_PYTHON3_SSL=y
BR2_PACKAGE_TAILSCALE=y
+# Configure CPIO rootfs generation to match the script's expectation
BR2_TARGET_ROOTFS_CPIO=y
-# BR2_TARGET_ROOTFS_CPIO_XZ is not set
-BR2_PACKAGE_SEVCTL=y
-BR2_PACKAGE_SNPGUEST=y
-BR2_PACKAGE_TPM2_TOOLS=y
-BR2_PACKAGE_BUSYBOX_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_SBNB_PATH)/board/sbnb/sbnb/busybox.fragment"
-BR2_TARGET_ROOTFS_SQUASHFS=y
-BR2_TARGET_ROOTFS_SQUASHFS4_XZ=y
+# Ensure CPIO is not compressed as the script uses the base name 'rootfs-sbnb.cpio'
+BR2_TARGET_ROOTFS_CPIO_NONE=y
+BR2_TARGET_ROOTFS_CPIO_FILENAME="rootfs-sbnb.cpio"
BR2_PACKAGE_OPENVMTOOLS=y
BR2_SHARED_STATIC_LIBS=y
BR2_PACKAGE_FATRESIZE=y
@@ -97,4 +96,10 @@
BR2_PACKAGE_PYTHON3_ZLIB=y
BR2_PACKAGE_PYTHON_REQUESTS=y
BR2_PACKAGE_JQ=y
+BR2_PACKAGE_SEVCTL=y
+BR2_PACKAGE_SNPGUEST=y
+BR2_PACKAGE_TPM2_TOOLS=y
+BR2_PACKAGE_BUSYBOX_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_SBNB_PATH)/board/sbnb/sbnb/busybox.fragment"
+BR2_TARGET_ROOTFS_SQUASHFS=y
+BR2_TARGET_ROOTFS_SQUASHFS4_XZ=y
- Changes: Added comments about the hardcoded command line. Explicitly set
BR2_TARGET_ROOTFS_CPIO_NONE=y
andBR2_TARGET_ROOTFS_CPIO_FILENAME="rootfs-sbnb.cpio"
to ensure the correct, uncompressed CPIO file is generated for the script. RemovedBR2_LINUX_KERNEL_GZIP=y
as the script usesbzImage
, implying bzip2 compression (which is the default for x86/x86_64bzImage
anyway, Buildroot handles this).
Drawbacks of Solution A:
- Kernel command line configuration is hidden within a script, not in the central Buildroot configuration.
- Harder to maintain and modify parameters later.
Solution B: Integrate Script with Buildroot BR2_CMDLINE
(Recommended)
This approach modifies the script to use the standard BR2_CMDLINE
variable defined in the defconfig. This is the preferred method for better integration and maintainability.
1. Modify board/sbnb/sbnb/scripts/create_efi.sh
:
--- a/board/sbnb/sbnb/scripts/create_efi.sh
+++ b/board/sbnb/sbnb/scripts/create_efi.sh
@@ -10,8 +10,10 @@
KERNEL="${BINARIES_DIR}/bzImage"
INITRD="${BINARIES_DIR}/rootfs-sbnb.cpio"
OS_RELEASE="${TARGET_DIR}/etc/os-release"
-CMDLINE="console=tty0 console=ttyS0 earlyprintk verbose intel_iommu=on module_blacklist=nouveau,nvidiafb,snd_hda_intel dyndbg=\"module firmware_class +p; module microcode +p; module ccp +p\""
+# --- MODIFIED KERNEL COMMAND LINE (Read from Buildroot Env) ---
+# Read command line from BR2_CMDLINE environment variable provided by Buildroot.
+CMDLINE="${BR2_CMDLINE:?Error: BR2_CMDLINE environment variable not set or empty. Check Buildroot kernel configuration (BR2_CMDLINE).}"
+# --- END MODIFICATION ---
CMDLINE_TMP=$(mktemp)
OUTPUT=sbnb.efi
@@ -41,8 +43,13 @@
--add-section .initrd="${INITRD}" --change-section-vma .initrd=$(printf 0x%x $initrd_offs) \
"${STUB}" "${OUTPUT}"
+# Clean up temporary file
+rm -f "${CMDLINE_TMP}"
+
# Output the result
echo "Output: ${OUTPUT}"
+
+# Move the final EFI file to the standard Buildroot images directory (BINARIES_DIR=output/images)
+mv "${OUTPUT}" "${BINARIES_DIR}/"
+echo "Moved ${OUTPUT} to ${BINARIES_DIR}/"
- Change: Replaced the hardcoded
CMDLINE
variable withCMDLINE="${BR2_CMDLINE:?...}"
. This reads the command line string from theBR2_CMDLINE
environment variable, which Buildroot sets based on the defconfig. The:?Error...
part ensures the script fails ifBR2_CMDLINE
isn’t properly set in the configuration, preventing silent errors. - Added: Cleanup and
mv
command as in Solution A.
2. Modify configs/sbnb_defconfig
:
Define BR2_CMDLINE
with all required parameters, including nomodeset
. Also ensure CPIO settings are correct.
--- a/configs/sbnb_defconfig
+++ b/configs/sbnb_defconfig
@@ -8,9 +8,9 @@
BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL_SBNB_PATH)/board/sbnb/sbnb/rootfs-overlay"
BR2_ROOTFS_PRE_BUILD_SCRIPT="$(BR2_EXTERNAL_SBNB_PATH)/board/sbnb/sbnb/pre_build.sh"
BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL_SBNB_PATH)/board/sbnb/sbnb/post_build.sh"
-# This post-image script creates a unified EFI executable (sbnb.efi)
-# IMPORTANT: The kernel command line is HARDCODED inside create_efi.sh
-# Standard BR2_KERNEL_CMDLINE_* options will NOT affect sbnb.efi
+# This post-image script creates a unified EFI executable (sbnb.efi).
+# With Solution B, the script reads the command line from BR2_CMDLINE below.
BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL_SBNB_PATH)/board/sbnb/sbnb/scripts/create_efi.sh"
-BR2_LINUX_KERNEL_GZIP=y
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
# Switch back to upstream kernel once Restricted Injection hypervisor support
@@ -20,6 +20,8 @@
BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="svsm"
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_SBNB_PATH)/board/sbnb/sbnb/kernel-config"
BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="kernel-config-firmware"
+# Define the kernel command line arguments (used by create_efi.sh in Solution B)
+BR2_CMDLINE="console=tty0 console=ttyS0 earlyprintk verbose intel_iommu=on module_blacklist=nouveau,nvidiafb,snd_hda_intel dyndbg=\"module firmware_class +p; module microcode +p; module ccp +p\" nomodeset"
BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF=y
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_6_11=y
BR2_PACKAGE_LINUX_TOOLS_CPUPOWER=y
@@ -75,14 +77,11 @@
BR2_PACKAGE_HOST_PYTHON3_CURSES=y
BR2_PACKAGE_HOST_PYTHON3_SSL=y
BR2_PACKAGE_TAILSCALE=y
+# Configure CPIO rootfs generation to match the script's expectation
BR2_TARGET_ROOTFS_CPIO=y
-# BR2_TARGET_ROOTFS_CPIO_XZ is not set
-BR2_PACKAGE_SEVCTL=y
-BR2_PACKAGE_SNPGUEST=y
-BR2_PACKAGE_TPM2_TOOLS=y
-BR2_PACKAGE_BUSYBOX_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_SBNB_PATH)/board/sbnb/sbnb/busybox.fragment"
-BR2_TARGET_ROOTFS_SQUASHFS=y
-BR2_TARGET_ROOTFS_SQUASHFS4_XZ=y
+# Ensure CPIO is not compressed as the script uses the base name 'rootfs-sbnb.cpio'
+BR2_TARGET_ROOTFS_CPIO_NONE=y
+BR2_TARGET_ROOTFS_CPIO_FILENAME="rootfs-sbnb.cpio"
BR2_PACKAGE_OPENVMTOOLS=y
BR2_SHARED_STATIC_LIBS=y
BR2_PACKAGE_FATRESIZE=y
@@ -97,4 +96,10 @@
BR2_PACKAGE_PYTHON3_ZLIB=y
BR2_PACKAGE_PYTHON_REQUESTS=y
BR2_PACKAGE_JQ=y
+BR2_PACKAGE_SEVCTL=y
+BR2_PACKAGE_SNPGUEST=y
+BR2_PACKAGE_TPM2_TOOLS=y
+BR2_PACKAGE_BUSYBOX_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_SBNB_PATH)/board/sbnb/sbnb/busybox.fragment"
+BR2_TARGET_ROOTFS_SQUASHFS=y
+BR2_TARGET_ROOTFS_SQUASHFS4_XZ=y
- Changes: Added the
BR2_CMDLINE
definition containing the full command string includingnomodeset
. Adjusted comments. Ensured CPIO settings are correct (same as Solution A). RemovedBR2_LINUX_KERNEL_GZIP=y
(same reason as Solution A).
Benefits of Solution B:
- Centralizes kernel command line configuration in the standard Buildroot
defconfig
. - Easier to manage and modify parameters using
make menuconfig
(underKernel -> Kernel command line string
). - Aligns with standard Buildroot practices.
Next Steps (Apply either Solution A or B):
- Apply Changes: Replace the content of your existing
board/sbnb/sbnb/scripts/create_efi.sh
andconfigs/sbnb_defconfig
with the versions from your chosen solution (Solution B is recommended). - Rebuild: Navigate to your Buildroot top-level directory in the terminal and run:
make
Buildroot will rebuild the necessary components and execute the post-image script, generating a new
output/images/sbnb.efi
. - Deploy: Copy the updated
output/images/sbnb.efi
to your target system’s EFI System Partition (ESP). - Boot: Boot your GMKtec G5 from the updated EFI file.
- Verify: Once the system has booted (even if slowly), log in to a console and run the following command to check if
nomodeset
was actually passed to the kernel:cat /proc/cmdline
Look for
nomodeset
within the output string.
Long-Term Alternative:
While outside the scope of simply adding nomodeset
, you might eventually consider whether the custom create_efi.sh
script is strictly necessary. Buildroot has built-in support for generating bootable images using standard bootloaders like GRUB2 or syslinux, which handle kernel parameters through their own configuration files managed by Buildroot based on BR2_CMDLINE
. Migrating to a standard bootloader setup could simplify your build process further, but would require more significant changes.