[PATCH 0/3] arm: qemu: Enable Bochs, console buffering, USB keyboard

Now that the driver for the Bochs VGA card emulated by QEMU is no longer limited to x86 architectures [1], this series enables it on arm and arm64 virtual machines to provide a graphical interface. In line with that series this also enables console buffering and USB keyboard.
Tested with the Debian 12 installer using GRUB EFI:
$ tools/buildman/buildman -o build/qemu_arm64 --boards=qemu_arm64 -w $ cd build/qemu_arm64 $ curl -L -o debian.img \ https://cdimage.debian.org/debian-cd/current/arm64/iso-cd/debian-12.0.0-arm6... $ qemu-system-aarch64 \ -machine virt -cpu cortex-a53 -m 1G -smp 2 \ -bios u-boot.bin \ -serial stdio -device VGA \ -device qemu-xhci,id=xhci -device usb-kbd,bus=xhci.0 -device usb-mouse,bus=xhci.0 \ -drive if=virtio,file=debian.img,index=0,format=raw,readonly=on,media=cdrom
And with one using extlinux.conf:
$ [...] $ curl -L -o head.img.gz \ https://deb.debian.org/debian/dists/bookworm/main/installer-arm64/current/im... $ curl -L -o partition.img.gz \ https://deb.debian.org/debian/dists/bookworm/main/installer-arm64/current/im... $ zcat head.img.gz partition.img.gz >debian.img $ [...]
Both can get to a graphical installer just fine, in addition to U-Boot video console showing up in a GTK window.
[1] video: bochs: Remove the x86 limitation https://lore.kernel.org/u-boot/20230723044041.1089804-1-bmeng@tinylab.org/
Alper Nebi Yasak (3): arm: qemu: Enable Bochs video support arm: qemu: Enable PRE_CONSOLE_BUFFER arm: qemu: Enable usb keyboard as an input device
arch/arm/Kconfig | 10 ++++++++++ board/emulation/qemu-arm/Kconfig | 4 ++++ board/emulation/qemu-arm/qemu-arm.c | 5 +++++ board/emulation/qemu-arm/qemu-arm.env | 3 +++ configs/qemu_arm64_defconfig | 2 -- configs/qemu_arm_defconfig | 2 -- doc/board/emulation/qemu-arm.rst | 8 ++++++++ 7 files changed, 30 insertions(+), 4 deletions(-)
base-commit: a169438411f9277cc689c14078151aa1d1caae3c

Commit 716161663ec49 ("riscv: qemu: Enable Bochs video support") enables a video console for QEMU RISC-V virtual machines using an emulated Bochs VGA card. Similarly, enable it for ARM virtual machines as well.
Signed-off-by: Alper Nebi Yasak alpernebiyasak@gmail.com ---
arch/arm/Kconfig | 4 ++++ board/emulation/qemu-arm/qemu-arm.env | 3 +++ doc/board/emulation/qemu-arm.rst | 4 ++++ 3 files changed, 11 insertions(+)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 97c25b4f146d..0d4654fb9dfc 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1036,6 +1036,10 @@ config ARCH_QEMU imply DM_RTC imply RTC_PL031 imply OF_HAS_PRIOR_STAGE + imply VIDEO + imply VIDEO_BOCHS + imply SYS_WHITE_ON_BLACK + imply SYS_CONSOLE_IS_IN_ENV
config ARCH_RMOBILE bool "Renesas ARM SoCs" diff --git a/board/emulation/qemu-arm/qemu-arm.env b/board/emulation/qemu-arm/qemu-arm.env index e658d5ee7d63..86a99a2e8713 100644 --- a/board/emulation/qemu-arm/qemu-arm.env +++ b/board/emulation/qemu-arm/qemu-arm.env @@ -2,6 +2,9 @@
/* environment for qemu-arm and qemu-arm64 */
+stdin=serial +stdout=serial,vidconsole +stderr=serial,vidconsole fdt_high=0xffffffff initrd_high=0xffffffff fdt_addr=0x40000000 diff --git a/doc/board/emulation/qemu-arm.rst b/doc/board/emulation/qemu-arm.rst index b42d924cc66a..1108fe5f8184 100644 --- a/doc/board/emulation/qemu-arm.rst +++ b/doc/board/emulation/qemu-arm.rst @@ -67,6 +67,10 @@ Additional persistent U-Boot environment support can be added as follows: Additional peripherals that have been tested to work in both U-Boot and Linux can be enabled with the following command line parameters:
+- To add a video console, remove "-nographic" and add e.g.:: + + -serial stdio -device VGA + - To add a Serial ATA disk via an Intel ICH9 AHCI controller, pass e.g.::
-drive if=none,file=disk.img,format=raw,id=mydisk \

Hi Alper,
On Tue, 8 Aug 2023 at 13:19, Alper Nebi Yasak alpernebiyasak@gmail.com wrote:
Commit 716161663ec49 ("riscv: qemu: Enable Bochs video support") enables a video console for QEMU RISC-V virtual machines using an emulated Bochs VGA card. Similarly, enable it for ARM virtual machines as well.
Signed-off-by: Alper Nebi Yasak alpernebiyasak@gmail.com
arch/arm/Kconfig | 4 ++++ board/emulation/qemu-arm/qemu-arm.env | 3 +++ doc/board/emulation/qemu-arm.rst | 4 ++++ 3 files changed, 11 insertions(+)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 97c25b4f146d..0d4654fb9dfc 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1036,6 +1036,10 @@ config ARCH_QEMU imply DM_RTC imply RTC_PL031 imply OF_HAS_PRIOR_STAGE
imply VIDEO
imply VIDEO_BOCHS
imply SYS_WHITE_ON_BLACK
imply SYS_CONSOLE_IS_IN_ENV
config ARCH_RMOBILE bool "Renesas ARM SoCs" diff --git a/board/emulation/qemu-arm/qemu-arm.env b/board/emulation/qemu-arm/qemu-arm.env index e658d5ee7d63..86a99a2e8713 100644 --- a/board/emulation/qemu-arm/qemu-arm.env +++ b/board/emulation/qemu-arm/qemu-arm.env @@ -2,6 +2,9 @@
/* environment for qemu-arm and qemu-arm64 */
+stdin=serial +stdout=serial,vidconsole +stderr=serial,vidconsole fdt_high=0xffffffff initrd_high=0xffffffff fdt_addr=0x40000000 diff --git a/doc/board/emulation/qemu-arm.rst b/doc/board/emulation/qemu-arm.rst index b42d924cc66a..1108fe5f8184 100644 --- a/doc/board/emulation/qemu-arm.rst +++ b/doc/board/emulation/qemu-arm.rst @@ -67,6 +67,10 @@ Additional persistent U-Boot environment support can be added as follows: Additional peripherals that have been tested to work in both U-Boot and Linux can be enabled with the following command line parameters:
+- To add a video console, remove "-nographic" and add e.g.::
- -serial stdio -device VGA
To add a Serial ATA disk via an Intel ICH9 AHCI controller, pass e.g.::
-drive if=none,file=disk.img,format=raw,id=mydisk \
--
Could you also add info about running a distro? (from your cover letter)
Regards, Simon

On Wed, Aug 9, 2023 at 3:19 AM Alper Nebi Yasak alpernebiyasak@gmail.com wrote:
Commit 716161663ec49 ("riscv: qemu: Enable Bochs video support") enables a video console for QEMU RISC-V virtual machines using an emulated Bochs VGA card. Similarly, enable it for ARM virtual machines as well.
Signed-off-by: Alper Nebi Yasak alpernebiyasak@gmail.com
arch/arm/Kconfig | 4 ++++ board/emulation/qemu-arm/qemu-arm.env | 3 +++ doc/board/emulation/qemu-arm.rst | 4 ++++ 3 files changed, 11 insertions(+)
Reviewed-by: Bin Meng bmeng@tinylab.org

Commit 608b80b5b855 ("riscv: qemu: Enable PRE_CONSOLE_BUFFER") enables buffering console messages for QEMU RISC-V virtual machines so those printed before the video console is available will still show up on the display. Similarly, enable it for ARM virtual machines as well.
Signed-off-by: Alper Nebi Yasak alpernebiyasak@gmail.com --- Not sure about the address, here are select values from bdinfo and env:
DRAM bank = 0x0000000000000000 -> start = 0x0000000040000000 -> size = 0x0000000008000000 relocaddr = 0x00000000476d6000 fdt_blob = 0x0000000046595d90 lmb_dump_all: memory.cnt = 0x1 / max = 0x10 memory[0] [0x40000000-0x47ffffff], 0x08000000 bytes flags: 0 reserved.cnt = 0x2 / max = 0x10 reserved[0] [0x45591000-0x47ffffff], 0x02a6f000 bytes flags: 0 reserved[1] [0x46591760-0x47ffffff], 0x01a6e8a0 bytes flags: 0 TLB addr = 0x0000000047fe0000 irq_sp = 0x0000000046595d80 sp start = 0x0000000046595d80
fdt_addr = 0x40000000 scriptaddr = 0x40200000 loadaddr = 0x40200000 pxefile_addr_r = 0x40300000 kernel_addr_r = 0x40400000 ramdisk_addr_r = 0x44000000 fdtcontroladdr = 465e5ea0
arch/arm/Kconfig | 1 + board/emulation/qemu-arm/Kconfig | 4 ++++ 2 files changed, 5 insertions(+)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 0d4654fb9dfc..89b978797720 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1040,6 +1040,7 @@ config ARCH_QEMU imply VIDEO_BOCHS imply SYS_WHITE_ON_BLACK imply SYS_CONSOLE_IS_IN_ENV + imply PRE_CONSOLE_BUFFER
config ARCH_RMOBILE bool "Renesas ARM SoCs" diff --git a/board/emulation/qemu-arm/Kconfig b/board/emulation/qemu-arm/Kconfig index ed9949651c4b..09c95413a541 100644 --- a/board/emulation/qemu-arm/Kconfig +++ b/board/emulation/qemu-arm/Kconfig @@ -12,6 +12,10 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply VIRTIO_NET imply VIRTIO_BLK
+config PRE_CON_BUF_ADDR + hex + default 0x40100000 + endif
if TARGET_QEMU_ARM_64BIT && !TFABOOT

On Tue, 8 Aug 2023 at 13:19, Alper Nebi Yasak alpernebiyasak@gmail.com wrote:
Commit 608b80b5b855 ("riscv: qemu: Enable PRE_CONSOLE_BUFFER") enables buffering console messages for QEMU RISC-V virtual machines so those printed before the video console is available will still show up on the display. Similarly, enable it for ARM virtual machines as well.
Signed-off-by: Alper Nebi Yasak alpernebiyasak@gmail.com
Not sure about the address, here are select values from bdinfo and env:
DRAM bank = 0x0000000000000000 -> start = 0x0000000040000000 -> size = 0x0000000008000000 relocaddr = 0x00000000476d6000 fdt_blob = 0x0000000046595d90 lmb_dump_all: memory.cnt = 0x1 / max = 0x10 memory[0] [0x40000000-0x47ffffff], 0x08000000 bytes flags: 0 reserved.cnt = 0x2 / max = 0x10 reserved[0] [0x45591000-0x47ffffff], 0x02a6f000 bytes flags: 0 reserved[1] [0x46591760-0x47ffffff], 0x01a6e8a0 bytes flags: 0 TLB addr = 0x0000000047fe0000 irq_sp = 0x0000000046595d80 sp start = 0x0000000046595d80 fdt_addr = 0x40000000 scriptaddr = 0x40200000 loadaddr = 0x40200000 pxefile_addr_r = 0x40300000 kernel_addr_r = 0x40400000 ramdisk_addr_r = 0x44000000 fdtcontroladdr = 465e5ea0
arch/arm/Kconfig | 1 + board/emulation/qemu-arm/Kconfig | 4 ++++ 2 files changed, 5 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org

On Wed, Aug 9, 2023 at 3:19 AM Alper Nebi Yasak alpernebiyasak@gmail.com wrote:
Commit 608b80b5b855 ("riscv: qemu: Enable PRE_CONSOLE_BUFFER") enables buffering console messages for QEMU RISC-V virtual machines so those printed before the video console is available will still show up on the display. Similarly, enable it for ARM virtual machines as well.
Signed-off-by: Alper Nebi Yasak alpernebiyasak@gmail.com
Not sure about the address, here are select values from bdinfo and env:
DRAM bank = 0x0000000000000000 -> start = 0x0000000040000000 -> size = 0x0000000008000000 relocaddr = 0x00000000476d6000 fdt_blob = 0x0000000046595d90 lmb_dump_all: memory.cnt = 0x1 / max = 0x10 memory[0] [0x40000000-0x47ffffff], 0x08000000 bytes flags: 0 reserved.cnt = 0x2 / max = 0x10 reserved[0] [0x45591000-0x47ffffff], 0x02a6f000 bytes flags: 0 reserved[1] [0x46591760-0x47ffffff], 0x01a6e8a0 bytes flags: 0 TLB addr = 0x0000000047fe0000 irq_sp = 0x0000000046595d80 sp start = 0x0000000046595d80 fdt_addr = 0x40000000 scriptaddr = 0x40200000 loadaddr = 0x40200000 pxefile_addr_r = 0x40300000 kernel_addr_r = 0x40400000 ramdisk_addr_r = 0x44000000 fdtcontroladdr = 465e5ea0
arch/arm/Kconfig | 1 + board/emulation/qemu-arm/Kconfig | 4 ++++ 2 files changed, 5 insertions(+)
Reviewed-by: Bin Meng bmeng@tinylab.org

Commit 02be57caf730 ("riscv: qemu: Enable usb keyboard as an input device") adds PCI xHCI support to QEMU RISC-V virtual machines and enables using a USB keyboard as one of the input devices. Similarly, enable those for ARM virtual machines as well.
Signed-off-by: Alper Nebi Yasak alpernebiyasak@gmail.com ---
arch/arm/Kconfig | 5 +++++ board/emulation/qemu-arm/qemu-arm.c | 5 +++++ board/emulation/qemu-arm/qemu-arm.env | 2 +- configs/qemu_arm64_defconfig | 2 -- configs/qemu_arm_defconfig | 2 -- doc/board/emulation/qemu-arm.rst | 4 ++++ 6 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 89b978797720..1fd3ccd1607f 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1041,6 +1041,11 @@ config ARCH_QEMU imply SYS_WHITE_ON_BLACK imply SYS_CONSOLE_IS_IN_ENV imply PRE_CONSOLE_BUFFER + imply USB + imply USB_XHCI_HCD + imply USB_XHCI_PCI + imply USB_KEYBOARD + imply CMD_USB
config ARCH_RMOBILE bool "Renesas ARM SoCs" diff --git a/board/emulation/qemu-arm/qemu-arm.c b/board/emulation/qemu-arm/qemu-arm.c index dfea0d92a3c8..942f1fff5717 100644 --- a/board/emulation/qemu-arm/qemu-arm.c +++ b/board/emulation/qemu-arm/qemu-arm.c @@ -11,6 +11,7 @@ #include <fdtdec.h> #include <init.h> #include <log.h> +#include <usb.h> #include <virtio_types.h> #include <virtio.h>
@@ -114,6 +115,10 @@ int board_late_init(void) */ virtio_init();
+ /* start usb so that usb keyboard can be used as input device */ + if (CONFIG_IS_ENABLED(USB_KEYBOARD)) + usb_init(); + return 0; }
diff --git a/board/emulation/qemu-arm/qemu-arm.env b/board/emulation/qemu-arm/qemu-arm.env index 86a99a2e8713..fb4adef281ed 100644 --- a/board/emulation/qemu-arm/qemu-arm.env +++ b/board/emulation/qemu-arm/qemu-arm.env @@ -2,7 +2,7 @@
/* environment for qemu-arm and qemu-arm64 */
-stdin=serial +stdin=serial,usbkbd stdout=serial,vidconsole stderr=serial,vidconsole fdt_high=0xffffffff diff --git a/configs/qemu_arm64_defconfig b/configs/qemu_arm64_defconfig index 94bd96678443..f6b8ae530a4a 100644 --- a/configs/qemu_arm64_defconfig +++ b/configs/qemu_arm64_defconfig @@ -35,7 +35,6 @@ CONFIG_CMD_NVEDIT_EFI=y CONFIG_CMD_DFU=y CONFIG_CMD_MTD=y CONFIG_CMD_PCI=y -CONFIG_CMD_USB=y CONFIG_CMD_TPM=y CONFIG_CMD_MTDPARTS=y CONFIG_ENV_IS_IN_FLASH=y @@ -68,7 +67,6 @@ CONFIG_SYSRESET=y CONFIG_SYSRESET_CMD_POWEROFF=y CONFIG_SYSRESET_PSCI=y CONFIG_TPM2_MMIO=y -CONFIG_USB=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_PCI=y CONFIG_TPM=y diff --git a/configs/qemu_arm_defconfig b/configs/qemu_arm_defconfig index 7cb1e9f037ff..1347b86f34b1 100644 --- a/configs/qemu_arm_defconfig +++ b/configs/qemu_arm_defconfig @@ -36,7 +36,6 @@ CONFIG_CMD_NVEDIT_EFI=y CONFIG_CMD_DFU=y CONFIG_CMD_MTD=y CONFIG_CMD_PCI=y -CONFIG_CMD_USB=y CONFIG_CMD_TPM=y CONFIG_CMD_MTDPARTS=y CONFIG_ENV_IS_IN_FLASH=y @@ -69,7 +68,6 @@ CONFIG_SYSRESET=y CONFIG_SYSRESET_CMD_POWEROFF=y CONFIG_SYSRESET_PSCI=y CONFIG_TPM2_MMIO=y -CONFIG_USB=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_PCI=y CONFIG_TPM=y diff --git a/doc/board/emulation/qemu-arm.rst b/doc/board/emulation/qemu-arm.rst index 1108fe5f8184..8ec5349fc9ea 100644 --- a/doc/board/emulation/qemu-arm.rst +++ b/doc/board/emulation/qemu-arm.rst @@ -84,6 +84,10 @@ can be enabled with the following command line parameters:
-device usb-ehci,id=ehci
+- To add a USB keyboard attached to an emulated xHCI controller, pass e.g.:: + + -device qemu-xhci,id=xhci -device usb-kbd,bus=xhci.0 + - To add an NVMe disk, pass e.g.::
-drive if=none,file=disk.img,id=mydisk -device nvme,drive=mydisk,serial=foo

On Tue, 8 Aug 2023 at 13:19, Alper Nebi Yasak alpernebiyasak@gmail.com wrote:
Commit 02be57caf730 ("riscv: qemu: Enable usb keyboard as an input device") adds PCI xHCI support to QEMU RISC-V virtual machines and enables using a USB keyboard as one of the input devices. Similarly, enable those for ARM virtual machines as well.
Signed-off-by: Alper Nebi Yasak alpernebiyasak@gmail.com
arch/arm/Kconfig | 5 +++++ board/emulation/qemu-arm/qemu-arm.c | 5 +++++ board/emulation/qemu-arm/qemu-arm.env | 2 +- configs/qemu_arm64_defconfig | 2 -- configs/qemu_arm_defconfig | 2 -- doc/board/emulation/qemu-arm.rst | 4 ++++ 6 files changed, 15 insertions(+), 5 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

On Wed, Aug 9, 2023 at 3:19 AM Alper Nebi Yasak alpernebiyasak@gmail.com wrote:
Commit 02be57caf730 ("riscv: qemu: Enable usb keyboard as an input device") adds PCI xHCI support to QEMU RISC-V virtual machines and enables using a USB keyboard as one of the input devices. Similarly, enable those for ARM virtual machines as well.
Signed-off-by: Alper Nebi Yasak alpernebiyasak@gmail.com
arch/arm/Kconfig | 5 +++++ board/emulation/qemu-arm/qemu-arm.c | 5 +++++ board/emulation/qemu-arm/qemu-arm.env | 2 +- configs/qemu_arm64_defconfig | 2 -- configs/qemu_arm_defconfig | 2 -- doc/board/emulation/qemu-arm.rst | 4 ++++ 6 files changed, 15 insertions(+), 5 deletions(-)
Reviewed-by: Bin Meng bmeng@tinylab.org
participants (3)
-
Alper Nebi Yasak
-
Bin Meng
-
Simon Glass