From 0e5e35806337933b492267d782dd39a94cac88b9 Mon Sep 17 00:00:00 2001 From: Andrei Nistor Date: Thu, 3 Oct 2019 21:14:19 +0000 Subject: [PATCH] bootloader: make serial console configurable Currently, the serial console is hardcoded to ttyS0 in the bootloader element. This is a challenge for users that want to build images for some baremetal servers. Supermicro servers, for example, use ttyS1 for the serial over lan interface. This patch adds a new environment variable DIB_BOOTLOADER_SERIAL_CONSOLE that can be set to override the default. Change-Id: Ie8173be8690ac0b7164ce9e5b66d3c1c18f844d6 --- diskimage_builder/elements/bootloader/README.rst | 4 ++++ .../bootloader/environment.d/10-bootloader-default-cmdline | 1 + .../elements/bootloader/finalise.d/50-bootloader | 6 ++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/diskimage_builder/elements/bootloader/README.rst b/diskimage_builder/elements/bootloader/README.rst index 56e17076..1c2aefc5 100644 --- a/diskimage_builder/elements/bootloader/README.rst +++ b/diskimage_builder/elements/bootloader/README.rst @@ -16,3 +16,7 @@ Arguments * ``DIB_BOOTLOADER_DEFAULT_CMDLINE`` sets parameters that are appended to the ``GRUB_CMDLINE_LINUX_DEFAULT`` values in ``grub.cfg`` configuration. It defaults to ``nofb nomodeset vga=normal``. + +* ``DIB_BOOTLOADER_SERIAL_CONSOLE`` sets the serial device to be + used as a console. It defaults to ``hvc0`` for PowerPC, + ``ttyAMA0,115200`` for ARM64, otherwise ``ttyS0,115200``. diff --git a/diskimage_builder/elements/bootloader/environment.d/10-bootloader-default-cmdline b/diskimage_builder/elements/bootloader/environment.d/10-bootloader-default-cmdline index 902494b4..2e474f92 100644 --- a/diskimage_builder/elements/bootloader/environment.d/10-bootloader-default-cmdline +++ b/diskimage_builder/elements/bootloader/environment.d/10-bootloader-default-cmdline @@ -1 +1,2 @@ export DIB_BOOTLOADER_DEFAULT_CMDLINE=${DIB_BOOTLOADER_DEFAULT_CMDLINE:-"nofb nomodeset vga=normal"} +export DIB_BOOTLOADER_SERIAL_CONSOLE=${DIB_BOOTLOADER_SERIAL_CONSOLE:-""} \ No newline at end of file diff --git a/diskimage_builder/elements/bootloader/finalise.d/50-bootloader b/diskimage_builder/elements/bootloader/finalise.d/50-bootloader index 75dfd78c..26b861b8 100755 --- a/diskimage_builder/elements/bootloader/finalise.d/50-bootloader +++ b/diskimage_builder/elements/bootloader/finalise.d/50-bootloader @@ -174,8 +174,10 @@ function install_grub2 { echo 'GRUB_TERMINAL="serial console"' >>/etc/default/grub echo 'GRUB_GFXPAYLOAD_LINUX=auto' >>/etc/default/grub - # Serial console on Power is hvc0 - if [[ "powerpc ppc64 ppc64le" =~ "$ARCH" ]]; then + if [[ -n "${DIB_BOOTLOADER_SERIAL_CONSOLE}" ]]; then + SERIAL_CONSOLE="${DIB_BOOTLOADER_SERIAL_CONSOLE}" + elif [[ "powerpc ppc64 ppc64le" =~ "$ARCH" ]]; then + # Serial console on Power is hvc0 SERIAL_CONSOLE="hvc0" elif [[ "arm64" =~ "$ARCH" ]]; then SERIAL_CONSOLE="ttyAMA0,115200"