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 cbd0413a90..b561e42e51 100644 --- a/configs/qemu_x86_64_defconfig +++ b/configs/qemu_x86_64_defconfig @@ -3,12 +3,14 @@ BR2_x86_64=y # System BR2_SYSTEM_DHCP="eth0" -BR2_TARGET_GENERIC_GETTY_PORT="tty1" # Filesystem BR2_TARGET_ROOTFS_EXT2=y # BR2_TARGET_ROOTFS_TAR is not set +# Image +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 6ca3ab9627..52f1744344 100644 --- a/configs/qemu_x86_defconfig +++ b/configs/qemu_x86_defconfig @@ -4,12 +4,14 @@ BR2_x86_pentiumpro=y # System BR2_SYSTEM_DHCP="eth0" -BR2_TARGET_GENERIC_GETTY_PORT="tty1" # Filesystem BR2_TARGET_ROOTFS_EXT2=y # BR2_TARGET_ROOTFS_TAR is not set +# Image +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