From patchwork Sun Nov 17 20:19:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Naour X-Patchwork-Id: 1196435 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=smile.fr Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=smile-fr.20150623.gappssmtp.com header.i=@smile-fr.20150623.gappssmtp.com header.b="CDKSAv4W"; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47GNjc1f0Xz9sP6 for ; Mon, 18 Nov 2019 07:19:47 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 2EBC187A14; Sun, 17 Nov 2019 20:19:43 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ModBLf9ClpSm; Sun, 17 Nov 2019 20:19:40 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id BE1F287A1D; Sun, 17 Nov 2019 20:19:39 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id CE4A31BF2CD for ; Sun, 17 Nov 2019 20:19:35 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id CBA6B85A57 for ; Sun, 17 Nov 2019 20:19:35 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id imCLecYGDS4m for ; Sun, 17 Nov 2019 20:19:34 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 5922D85B0A for ; Sun, 17 Nov 2019 20:19:34 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id i12so17040236wro.5 for ; Sun, 17 Nov 2019 12:19:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile-fr.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=V3ZqW+wztYvcLb68yW4qmq6+lJZvLb0kabncQj2PL40=; b=CDKSAv4W+zaSrPIogdZizpAV1Q3d96cr0+sdE2zj8WMuUmdBBcFuGGU2pnoE/lpeTF T2buPwwUvbBjjcQWGvpjZSrMO0ibHQ6rzpkd331cq45rltiFbegLWQj8gg+dFinkXnh5 wUkM3AJljPM0PIOKJYSjaJIKvTkEsF6S1VGhlD9Y7AnehQYH2GLTpINPzNDebIc0DhQ6 fNUWcVgloJrt0TBKT7EpjANVWS7qNI03NgNoz7APhe1UPi3BuwEg8v8tc2AbXVWhku4k fw0Kfx3rlVUOREn/ERAqIvHRJMd7qGNbpO3mPOBX4KiiJ1uTJPD5fqXMFsRJS59QKK2R 4FIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=V3ZqW+wztYvcLb68yW4qmq6+lJZvLb0kabncQj2PL40=; b=OZSMSzW2/T0CVQCJEiTZrmkhddC1DDqcArjGeW/THsC7hUCzKEwfkAZ56tUBMsweln tS1KYJoRYueeZkcbdzFReWfi3Uq3FMdaLNVlCco4JcWM+aVR1EOtjrtvoVVSBVWxsTYs rra7aCP/snXoKxgp6cFq/ghk6XDiu/w33FJJJwbpjz0QsqgyaOaT9xJFUyOHkjL2W15w cWWf9TW1uJa9kvZSkEb8QURn87tdT+RINhyzzOhYgubyI5Azz9Z3+TAWrmFF0BrkiQx+ 3K+/yFBU6rBnOCH9K7/EdvU2WeCo4n9V2JpdiyIOLbqR8/w4Q3iW6amV9az6cT9YQMM5 uXBQ== X-Gm-Message-State: APjAAAX2h4UDsLrpNlw48t8m24BJgApDeEcV7/qO/hwgVuQSTTvoqVtn E3YRy2yutXC+K5dzMKWEJgkl+vZUWBw= X-Google-Smtp-Source: APXvYqxjlF3XqtZIFZ7YvsXK2uKJaDC5UXNBy904qJzcLg0lgKEhja1y22w1pt/ntazozrgPr1raUw== X-Received: by 2002:a5d:5092:: with SMTP id a18mr5872568wrt.297.1574021972470; Sun, 17 Nov 2019 12:19:32 -0800 (PST) Received: from P-ASN-Evian.home (2a01cb0589880c00c543929d43aec786.ipv6.abo.wanadoo.fr. [2a01:cb05:8988:c00:c543:929d:43ae:c786]) by smtp.gmail.com with ESMTPSA id y8sm16974831wmi.9.2019.11.17.12.19.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Nov 2019 12:19:31 -0800 (PST) From: Romain Naour To: buildroot@buildroot.org Date: Sun, 17 Nov 2019 21:19:00 +0100 Message-Id: <20191117201909.12900-3-romain.naour@smile.fr> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191117201909.12900-1-romain.naour@smile.fr> References: <20191117201909.12900-1-romain.naour@smile.fr> MIME-Version: 1.0 Subject: [Buildroot] [PATCH v3 for-next 02/11] configs/qemu{x86, x86_64}: add a serial console X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Romain Naour Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" The current Buildroot defconfigs for qemu_x86 and qemu_x86_64 instantiate a console on tty1, which appears on QEMU's graphical window. Add a console on the serial port (ttyS0) to be used later for gitlab testing. This change is need since the script used for gitlab testing needs to use a serial output with pexpect. This change is similar to the one made for raspberrypi [1] to handle HDMI and serial console: This requires three changes: 1. have two 'console=' entries in the kernel command line: tty1, then ttyS0; 2. change BR2_TARGET_GENERIC_GETTY_PORT to "console", so it starts a getty on the last console= passed to the kernel, ttyS0; 3. add a new getty on tty1 to the generated inittab. Step 2 is actually obtained by removing BR2_TARGET_GENERIC_GETTY_PORT entirely from the defconfigs, since "console" is the default value. Step 3 requires a post-build script since the Buildroot makefiles can configure only one console. Note: instead of simply adding a new getty on ttyS0 (which would work) this patch actually changes BR2_TARGET_GENERIC_GETTY_PORT to instantiate a console on UART, then adds back tty1 via post-build.sh. This is done only to avoid the "GENERIC_SERIAL" comment where we instantiate a console on QEMU graphical window, then instantiate a really-serial console on another line. The result is these two inittab lines: console::respawn:/sbin/getty -L console 0 vt100 # GENERIC_SERIAL tty1::respawn:/sbin/getty -L tty1 0 vt100 # QEMU graphical window [1] 20878a1017e2bf7eb8c5f870dc6d2641493cb0f9 Signed-off-by: Romain Naour --- board/qemu/x86/post-build.sh | 11 +++++++++++ board/qemu/x86/readme.txt | 2 +- board/qemu/x86_64/post-build.sh | 11 +++++++++++ board/qemu/x86_64/readme.txt | 2 +- configs/qemu_x86_64_defconfig | 4 ++-- configs/qemu_x86_defconfig | 4 ++-- 6 files changed, 28 insertions(+), 6 deletions(-) create mode 100755 board/qemu/x86/post-build.sh create mode 100755 board/qemu/x86_64/post-build.sh diff --git a/board/qemu/x86/post-build.sh b/board/qemu/x86/post-build.sh new file mode 100755 index 0000000000..bf83a002c2 --- /dev/null +++ b/board/qemu/x86/post-build.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +set -u +set -e + +# Add a console on tty1 +if [ -e ${TARGET_DIR}/etc/inittab ]; then + grep -qE '^tty1::' ${TARGET_DIR}/etc/inittab || \ + sed -i '/GENERIC_SERIAL/a\ +tty1::respawn:/sbin/getty -L tty1 0 vt100 # QEMU graphical window' ${TARGET_DIR}/etc/inittab +fi diff --git a/board/qemu/x86/readme.txt b/board/qemu/x86/readme.txt index 42fc2439da..3bbafecf91 100644 --- a/board/qemu/x86/readme.txt +++ b/board/qemu/x86/readme.txt @@ -1,6 +1,6 @@ Run the emulation with: - qemu-system-i386 -M pc -kernel output/images/bzImage -drive file=output/images/rootfs.ext2,if=virtio,format=raw -append "rootwait root=/dev/vda" -net nic,model=virtio -net user + qemu-system-i386 -M pc -kernel output/images/bzImage -drive file=output/images/rootfs.ext2,if=virtio,format=raw -append "rootwait root=/dev/vda console=tty1 console=ttyS0" -serial stdio -net nic,model=virtio -net user Optionally add -smp N to emulate a SMP system with N CPUs. diff --git a/board/qemu/x86_64/post-build.sh b/board/qemu/x86_64/post-build.sh new file mode 100755 index 0000000000..bf83a002c2 --- /dev/null +++ b/board/qemu/x86_64/post-build.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +set -u +set -e + +# Add a console on tty1 +if [ -e ${TARGET_DIR}/etc/inittab ]; then + grep -qE '^tty1::' ${TARGET_DIR}/etc/inittab || \ + sed -i '/GENERIC_SERIAL/a\ +tty1::respawn:/sbin/getty -L tty1 0 vt100 # QEMU graphical window' ${TARGET_DIR}/etc/inittab +fi diff --git a/board/qemu/x86_64/readme.txt b/board/qemu/x86_64/readme.txt index 4a1c0c0ff5..93ac22a947 100644 --- a/board/qemu/x86_64/readme.txt +++ b/board/qemu/x86_64/readme.txt @@ -1,6 +1,6 @@ Run the emulation with: - qemu-system-x86_64 -M pc -kernel output/images/bzImage -drive file=output/images/rootfs.ext2,if=virtio,format=raw -append "rootwait root=/dev/vda" -net nic,model=virtio -net user + qemu-system-x86_64 -M pc -kernel output/images/bzImage -drive file=output/images/rootfs.ext2,if=virtio,format=raw -append "rootwait root=/dev/vda console=tty1 console=ttyS0" -serial stdio -net nic,model=virtio -net user Optionally add -smp N to emulate a SMP system with N CPUs. diff --git a/configs/qemu_x86_64_defconfig b/configs/qemu_x86_64_defconfig index c3c0991fcc..f9d868d169 100644 --- a/configs/qemu_x86_64_defconfig +++ b/configs/qemu_x86_64_defconfig @@ -3,11 +3,11 @@ BR2_x86_64=y # System BR2_SYSTEM_DHCP="eth0" -BR2_TARGET_GENERIC_GETTY_PORT="tty1" -# Filesystem +# Filesystem / image BR2_TARGET_ROOTFS_EXT2=y # BR2_TARGET_ROOTFS_TAR is not set +BR2_ROOTFS_POST_BUILD_SCRIPT="board/qemu/x86_64/post-build.sh" # Linux headers same as kernel, a 4.19 series BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_19=y diff --git a/configs/qemu_x86_defconfig b/configs/qemu_x86_defconfig index 6d68b7d71f..cb68b5f4ff 100644 --- a/configs/qemu_x86_defconfig +++ b/configs/qemu_x86_defconfig @@ -4,11 +4,11 @@ BR2_x86_pentiumpro=y # System BR2_SYSTEM_DHCP="eth0" -BR2_TARGET_GENERIC_GETTY_PORT="tty1" -# Filesystem +# Filesystem / image BR2_TARGET_ROOTFS_EXT2=y # BR2_TARGET_ROOTFS_TAR is not set +BR2_ROOTFS_POST_BUILD_SCRIPT="board/qemu/x86/post-build.sh" # Linux headers same as kernel, a 4.19 series BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_19=y