From 52e330e4aae41f05ed261b440d8caf351b644dcf Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Sun, 9 Apr 2023 21:21:05 -0700 Subject: [PATCH] factor out serial console device choice This commit generalizes the selection and activation of the serial console by promoting it to a top-level package-set member. The top-level package set is starting to attract clutter, so I will soon be moving all the non-package constitutents into a `config` attrset. --- src/coreboot/default.nix | 2 +- src/default.nix | 7 +++++++ src/platform/am1i/coreboot.config | 1 - src/platform/am1i/default.nix | 3 ++- src/platform/kevin/default.nix | 6 +++++- src/platform/kgpe/default.nix | 4 +++- 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/coreboot/default.nix b/src/coreboot/default.nix index 85a3d05..bfad27b 100644 --- a/src/coreboot/default.nix +++ b/src/coreboot/default.nix @@ -6,7 +6,7 @@ , initramfs_image # path to the initramfs `cpio` archive , iasl ? null # a specific iasl to use, if needed , console_loglevel ? "7" -, linux-command-line ? "" +, linux-command-line }: let version = "4.9"; diff --git a/src/default.nix b/src/default.nix index de173fe..e78bc9f 100644 --- a/src/default.nix +++ b/src/default.nix @@ -17,6 +17,13 @@ let coreboot-toolchain = final.callPackage ./coreboot-toolchain { }; + # TODO(amjoseph): move this into a `config` attrset + console-device = throw "platforms must override this (example: \"ttyS0\")"; + console-parameters = "115200n8"; + linux-command-line = + let console = "${final.console-device},${final.console-parameters}"; + in "console=${console} earlyprintk=${console}"; + iasl_20180531 = final.nixpkgsOnBuildForBuild.callPackage ./coreboot/iasl_20180531 { }; coreboot = final.callPackage ./coreboot { initramfs_image = final.initramfs; diff --git a/src/platform/am1i/coreboot.config b/src/platform/am1i/coreboot.config index d714606..0d6927a 100644 --- a/src/platform/am1i/coreboot.config +++ b/src/platform/am1i/coreboot.config @@ -96,7 +96,6 @@ CONFIG_TTYS0_BASE=0x3f8 # this is the back-panel connector, which exists only on the "more back-panel stuff" board variant #CONFIG_UART_FOR_CONSOLE=1 #CONFIG_TTYS0_BASE=0x2f8 -#CONFIG_LINUX_COMMAND_LINE="console=ttyS1,115200n8" CONFIG_LINUX_INITRD="" diff --git a/src/platform/am1i/default.nix b/src/platform/am1i/default.nix index 8e444b7..6c36025 100644 --- a/src/platform/am1i/default.nix +++ b/src/platform/am1i/default.nix @@ -16,13 +16,14 @@ ''; }); + console-device = "ttyS0"; + coreboot = final.lib.makeOverridable (prev.coreboot.override { iasl = final.iasl_20180531; payload = "${final.kernel}/bzImage"; coreboot-toolchain = with final.coreboot-toolchain; [ x64 i386 ]; fmap = ./custom.fmap; config = ./coreboot.config; - linux-command-line="console=ttyS0,115200n8"; }).overrideAttrs (a: { /* postConfigure = (a.postConfigure or "") + '' diff --git a/src/platform/kevin/default.nix b/src/platform/kevin/default.nix index 6729a03..3176199 100644 --- a/src/platform/kevin/default.nix +++ b/src/platform/kevin/default.nix @@ -59,6 +59,11 @@ in { modules = modules_insmod ++ modules_noinsmod; }; + # these pins are on the motherboard's "servo connector"; you'll + # need a breakout board like this: + # https://github.com/SolidHal/servo-v2-breakout-board + console-device = "ttyS2"; + coreboot = let atf = final.nixpkgsOnBuildForHost.callPackage (import ./atf) { buildArmTrustedFirmware = (final.nixpkgsOnBuildForHost.callPackage (import ) { @@ -74,7 +79,6 @@ in { fmap = ./custom.fmap; config = ./coreboot.config; coreboot-toolchain = with final.coreboot-toolchain; [ aarch64 ]; - linux-command-line="console=ttyS2,115200n8"; }).overrideAttrs (a: { postConfigure = '' echo CONFIG_ARM64_BL31_EXTERNAL_FILE=\"${atf}/bl31.elf\" >> .config diff --git a/src/platform/kgpe/default.nix b/src/platform/kgpe/default.nix index 20a3094..3dbb4ab 100644 --- a/src/platform/kgpe/default.nix +++ b/src/platform/kgpe/default.nix @@ -41,13 +41,15 @@ # TODO: use a NixOS-style structuredConfig for this. cmos-default = null; + console-device = "ttyS0"; # the DB9 connector on the rear panel + #console-device = "ttyS1"; # the IDC header on the motherboard + coreboot = final.lib.makeOverridable (prev.coreboot.override { iasl = final.iasl_20180531; payload = "${final.kernel}/bzImage"; fmap = ./custom.fmap; config = ./coreboot.config; coreboot-toolchain = with final.coreboot-toolchain; [ x64 i386 ]; - linux-command-line = "console=ttyS1,115200n8"; }).overrideAttrs (a: { postConfigure = if final.microcode-blob != null then '' echo CONFIG_CPU_MICROCODE_MULTIPLE_FILES=y >> .config