0006-arm-qemu-Enable-Bochs-console-buffering-USB-keyboard.patch 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. From 2957e8bf43edf8de6e579ce1ed7f95e5bb4a1437 Mon Sep 17 00:00:00 2001
  2. From: Alper Nebi Yasak <alpernebiyasak@gmail.com>
  3. Date: Mon, 14 Aug 2023 20:39:41 +0300
  4. Subject: [PATCH 1/4] arm: qemu: Enable Bochs video support
  5. Commit 716161663ec49 ("riscv: qemu: Enable Bochs video support") enables
  6. a video console for QEMU RISC-V virtual machines using an emulated Bochs
  7. VGA card. Similarly, enable it for ARM virtual machines as well.
  8. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
  9. Reviewed-by: Bin Meng <bmeng@tinylab.org>
  10. Link: https://lore.kernel.org/u-boot/20230814173944.288356-2-alpernebiyasak@gmail.com/
  11. ---
  12. arch/arm/Kconfig | 4 ++++
  13. board/emulation/qemu-arm/qemu-arm.env | 3 +++
  14. doc/board/emulation/qemu-arm.rst | 4 ++++
  15. 3 files changed, 11 insertions(+)
  16. diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
  17. index 328e2ddc33af..d96e230e9ee8 100644
  18. --- a/arch/arm/Kconfig
  19. +++ b/arch/arm/Kconfig
  20. @@ -1036,6 +1036,10 @@ config ARCH_QEMU
  21. imply DM_RTC
  22. imply RTC_PL031
  23. imply OF_HAS_PRIOR_STAGE
  24. + imply VIDEO
  25. + imply VIDEO_BOCHS
  26. + imply SYS_WHITE_ON_BLACK
  27. + imply SYS_CONSOLE_IS_IN_ENV
  28. config ARCH_RMOBILE
  29. bool "Renesas ARM SoCs"
  30. diff --git a/board/emulation/qemu-arm/qemu-arm.env b/board/emulation/qemu-arm/qemu-arm.env
  31. index e658d5ee7d63..86a99a2e8713 100644
  32. --- a/board/emulation/qemu-arm/qemu-arm.env
  33. +++ b/board/emulation/qemu-arm/qemu-arm.env
  34. @@ -2,6 +2,9 @@
  35. /* environment for qemu-arm and qemu-arm64 */
  36. +stdin=serial
  37. +stdout=serial,vidconsole
  38. +stderr=serial,vidconsole
  39. fdt_high=0xffffffff
  40. initrd_high=0xffffffff
  41. fdt_addr=0x40000000
  42. diff --git a/doc/board/emulation/qemu-arm.rst b/doc/board/emulation/qemu-arm.rst
  43. index 7291fa4a3150..c423fce76edd 100644
  44. --- a/doc/board/emulation/qemu-arm.rst
  45. +++ b/doc/board/emulation/qemu-arm.rst
  46. @@ -67,6 +67,10 @@ Additional persistent U-Boot environment support can be added as follows:
  47. Additional peripherals that have been tested to work in both U-Boot and Linux
  48. can be enabled with the following command line parameters:
  49. +- To add a video console, remove "-nographic" and add e.g.::
  50. +
  51. + -serial stdio -device VGA
  52. +
  53. - To add a Serial ATA disk via an Intel ICH9 AHCI controller, pass e.g.::
  54. -drive if=none,file=disk.img,format=raw,id=mydisk \
  55. --
  56. 2.42.0
  57. From 5330bc1c2ad84ba9ecc473f8c24d6e15b366adf9 Mon Sep 17 00:00:00 2001
  58. From: Alper Nebi Yasak <alpernebiyasak@gmail.com>
  59. Date: Mon, 14 Aug 2023 20:39:42 +0300
  60. Subject: [PATCH 2/4] arm: qemu: Enable PRE_CONSOLE_BUFFER
  61. Commit 608b80b5b855 ("riscv: qemu: Enable PRE_CONSOLE_BUFFER") enables
  62. buffering console messages for QEMU RISC-V virtual machines so those
  63. printed before the video console is available will still show up on the
  64. display. Similarly, enable it for ARM virtual machines as well.
  65. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
  66. Reviewed-by: Simon Glass <sjg@chromium.org>
  67. Reviewed-by: Bin Meng <bmeng@tinylab.org>
  68. Link: https://lore.kernel.org/u-boot/20230814173944.288356-3-alpernebiyasak@gmail.com/
  69. ---
  70. arch/arm/Kconfig | 1 +
  71. board/emulation/qemu-arm/Kconfig | 4 ++++
  72. 2 files changed, 5 insertions(+)
  73. diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
  74. index d96e230e9ee8..1cc2be55140a 100644
  75. --- a/arch/arm/Kconfig
  76. +++ b/arch/arm/Kconfig
  77. @@ -1040,6 +1040,7 @@ config ARCH_QEMU
  78. imply VIDEO_BOCHS
  79. imply SYS_WHITE_ON_BLACK
  80. imply SYS_CONSOLE_IS_IN_ENV
  81. + imply PRE_CONSOLE_BUFFER
  82. config ARCH_RMOBILE
  83. bool "Renesas ARM SoCs"
  84. diff --git a/board/emulation/qemu-arm/Kconfig b/board/emulation/qemu-arm/Kconfig
  85. index ed9949651c4b..09c95413a541 100644
  86. --- a/board/emulation/qemu-arm/Kconfig
  87. +++ b/board/emulation/qemu-arm/Kconfig
  88. @@ -12,6 +12,10 @@ config BOARD_SPECIFIC_OPTIONS # dummy
  89. imply VIRTIO_NET
  90. imply VIRTIO_BLK
  91. +config PRE_CON_BUF_ADDR
  92. + hex
  93. + default 0x40100000
  94. +
  95. endif
  96. if TARGET_QEMU_ARM_64BIT && !TFABOOT
  97. --
  98. 2.42.0
  99. From 7f666214855d062dc939ff54a0fa52fbde9f0391 Mon Sep 17 00:00:00 2001
  100. From: Alper Nebi Yasak <alpernebiyasak@gmail.com>
  101. Date: Mon, 14 Aug 2023 20:39:43 +0300
  102. Subject: [PATCH 3/4] arm: qemu: Enable usb keyboard as an input device
  103. Commit 02be57caf730 ("riscv: qemu: Enable usb keyboard as an input
  104. device") adds PCI xHCI support to QEMU RISC-V virtual machines and
  105. enables using a USB keyboard as one of the input devices. Similarly,
  106. enable those for ARM virtual machines as well.
  107. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
  108. Reviewed-by: Simon Glass <sjg@chromium.org>
  109. Reviewed-by: Bin Meng <bmeng@tinylab.org>
  110. Link: https://lore.kernel.org/u-boot/20230814173944.288356-4-alpernebiyasak@gmail.com/
  111. ---
  112. arch/arm/Kconfig | 5 +++++
  113. board/emulation/qemu-arm/qemu-arm.c | 5 +++++
  114. board/emulation/qemu-arm/qemu-arm.env | 2 +-
  115. configs/qemu_arm64_defconfig | 2 --
  116. configs/qemu_arm_defconfig | 2 --
  117. doc/board/emulation/qemu-arm.rst | 4 ++++
  118. 6 files changed, 15 insertions(+), 5 deletions(-)
  119. diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
  120. index 1cc2be55140a..4c739bd9bc82 100644
  121. --- a/arch/arm/Kconfig
  122. +++ b/arch/arm/Kconfig
  123. @@ -1041,6 +1041,11 @@ config ARCH_QEMU
  124. imply SYS_WHITE_ON_BLACK
  125. imply SYS_CONSOLE_IS_IN_ENV
  126. imply PRE_CONSOLE_BUFFER
  127. + imply USB
  128. + imply USB_XHCI_HCD
  129. + imply USB_XHCI_PCI
  130. + imply USB_KEYBOARD
  131. + imply CMD_USB
  132. config ARCH_RMOBILE
  133. bool "Renesas ARM SoCs"
  134. diff --git a/board/emulation/qemu-arm/qemu-arm.c b/board/emulation/qemu-arm/qemu-arm.c
  135. index dfea0d92a3c8..942f1fff5717 100644
  136. --- a/board/emulation/qemu-arm/qemu-arm.c
  137. +++ b/board/emulation/qemu-arm/qemu-arm.c
  138. @@ -11,6 +11,7 @@
  139. #include <fdtdec.h>
  140. #include <init.h>
  141. #include <log.h>
  142. +#include <usb.h>
  143. #include <virtio_types.h>
  144. #include <virtio.h>
  145. @@ -114,6 +115,10 @@ int board_late_init(void)
  146. */
  147. virtio_init();
  148. + /* start usb so that usb keyboard can be used as input device */
  149. + if (CONFIG_IS_ENABLED(USB_KEYBOARD))
  150. + usb_init();
  151. +
  152. return 0;
  153. }
  154. diff --git a/board/emulation/qemu-arm/qemu-arm.env b/board/emulation/qemu-arm/qemu-arm.env
  155. index 86a99a2e8713..fb4adef281ed 100644
  156. --- a/board/emulation/qemu-arm/qemu-arm.env
  157. +++ b/board/emulation/qemu-arm/qemu-arm.env
  158. @@ -2,7 +2,7 @@
  159. /* environment for qemu-arm and qemu-arm64 */
  160. -stdin=serial
  161. +stdin=serial,usbkbd
  162. stdout=serial,vidconsole
  163. stderr=serial,vidconsole
  164. fdt_high=0xffffffff
  165. diff --git a/configs/qemu_arm64_defconfig b/configs/qemu_arm64_defconfig
  166. index 94bd96678443..f6b8ae530a4a 100644
  167. --- a/configs/qemu_arm64_defconfig
  168. +++ b/configs/qemu_arm64_defconfig
  169. @@ -35,7 +35,6 @@ CONFIG_CMD_NVEDIT_EFI=y
  170. CONFIG_CMD_DFU=y
  171. CONFIG_CMD_MTD=y
  172. CONFIG_CMD_PCI=y
  173. -CONFIG_CMD_USB=y
  174. CONFIG_CMD_TPM=y
  175. CONFIG_CMD_MTDPARTS=y
  176. CONFIG_ENV_IS_IN_FLASH=y
  177. @@ -68,7 +67,6 @@ CONFIG_SYSRESET=y
  178. CONFIG_SYSRESET_CMD_POWEROFF=y
  179. CONFIG_SYSRESET_PSCI=y
  180. CONFIG_TPM2_MMIO=y
  181. -CONFIG_USB=y
  182. CONFIG_USB_EHCI_HCD=y
  183. CONFIG_USB_EHCI_PCI=y
  184. CONFIG_TPM=y
  185. diff --git a/configs/qemu_arm_defconfig b/configs/qemu_arm_defconfig
  186. index 7cb1e9f037ff..1347b86f34b1 100644
  187. --- a/configs/qemu_arm_defconfig
  188. +++ b/configs/qemu_arm_defconfig
  189. @@ -36,7 +36,6 @@ CONFIG_CMD_NVEDIT_EFI=y
  190. CONFIG_CMD_DFU=y
  191. CONFIG_CMD_MTD=y
  192. CONFIG_CMD_PCI=y
  193. -CONFIG_CMD_USB=y
  194. CONFIG_CMD_TPM=y
  195. CONFIG_CMD_MTDPARTS=y
  196. CONFIG_ENV_IS_IN_FLASH=y
  197. @@ -69,7 +68,6 @@ CONFIG_SYSRESET=y
  198. CONFIG_SYSRESET_CMD_POWEROFF=y
  199. CONFIG_SYSRESET_PSCI=y
  200. CONFIG_TPM2_MMIO=y
  201. -CONFIG_USB=y
  202. CONFIG_USB_EHCI_HCD=y
  203. CONFIG_USB_EHCI_PCI=y
  204. CONFIG_TPM=y
  205. diff --git a/doc/board/emulation/qemu-arm.rst b/doc/board/emulation/qemu-arm.rst
  206. index c423fce76edd..5481ef6da328 100644
  207. --- a/doc/board/emulation/qemu-arm.rst
  208. +++ b/doc/board/emulation/qemu-arm.rst
  209. @@ -84,6 +84,10 @@ can be enabled with the following command line parameters:
  210. -device usb-ehci,id=ehci
  211. +- To add a USB keyboard attached to an emulated xHCI controller, pass e.g.::
  212. +
  213. + -device qemu-xhci,id=xhci -device usb-kbd,bus=xhci.0
  214. +
  215. - To add an NVMe disk, pass e.g.::
  216. -drive if=none,file=disk.img,id=mydisk -device nvme,drive=mydisk,serial=foo
  217. --
  218. 2.42.0
  219. From fcc1b6cb56beaaf90bf80928627a606f33a42c3c Mon Sep 17 00:00:00 2001
  220. From: Alper Nebi Yasak <alpernebiyasak@gmail.com>
  221. Date: Mon, 14 Aug 2023 20:39:44 +0300
  222. Subject: [PATCH 4/4] doc: qemu: arm: Add a section on booting Linux distros
  223. Add an example qemu-system-aarch64 command that can make U-Boot on QEMU
  224. boot into the Debian Installer, along with resulting console messages
  225. from U-Boot, based on the existing documentation section for the x86
  226. version.
  227. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
  228. Link: https://lore.kernel.org/u-boot/20230814173944.288356-5-alpernebiyasak@gmail.com/
  229. ---
  230. doc/board/emulation/qemu-arm.rst | 68 ++++++++++++++++++++++++++++++++
  231. 1 file changed, 68 insertions(+)
  232. diff --git a/doc/board/emulation/qemu-arm.rst b/doc/board/emulation/qemu-arm.rst
  233. index 5481ef6da328..1c91c7f3ac67 100644
  234. --- a/doc/board/emulation/qemu-arm.rst
  235. +++ b/doc/board/emulation/qemu-arm.rst
  236. @@ -98,6 +98,74 @@ can be enabled with the following command line parameters:
  237. These have been tested in QEMU 2.9.0 but should work in at least 2.5.0 as well.
  238. +Booting distros
  239. +---------------
  240. +
  241. +It is possible to install and boot a standard Linux distribution using
  242. +qemu_arm64 by setting up a root disk::
  243. +
  244. + qemu-img create root.img 20G
  245. +
  246. +then using the installer to install. For example, with Debian 12::
  247. +
  248. + qemu-system-aarch64 \
  249. + -machine virt -cpu cortex-a53 -m 4G -smp 4 \
  250. + -bios u-boot.bin \
  251. + -serial stdio -device VGA \
  252. + -nic user,model=virtio-net-pci \
  253. + -device virtio-rng-pci \
  254. + -device qemu-xhci,id=xhci \
  255. + -device usb-kbd -device usb-tablet \
  256. + -drive if=virtio,file=debian-12.0.0-arm64-netinst.iso,format=raw,readonly=on,media=cdrom \
  257. + -drive if=virtio,file=root.img,format=raw,media=disk
  258. +
  259. +The output will be something like this::
  260. +
  261. + U-Boot 2023.10-rc2-00075-gbe8fbe718e35 (Aug 11 2023 - 08:38:49 +0000)
  262. +
  263. + DRAM: 4 GiB
  264. + Core: 51 devices, 14 uclasses, devicetree: board
  265. + Flash: 64 MiB
  266. + Loading Environment from Flash... *** Warning - bad CRC, using default environment
  267. +
  268. + In: serial,usbkbd
  269. + Out: serial,vidconsole
  270. + Err: serial,vidconsole
  271. + Bus xhci_pci: Register 8001040 NbrPorts 8
  272. + Starting the controller
  273. + USB XHCI 1.00
  274. + scanning bus xhci_pci for devices... 3 USB Device(s) found
  275. + Net: eth0: virtio-net#32
  276. + Hit any key to stop autoboot: 0
  277. + Scanning for bootflows in all bootdevs
  278. + Seq Method State Uclass Part Name Filename
  279. + --- ----------- ------ -------- ---- ------------------------ ----------------
  280. + Scanning global bootmeth 'efi_mgr':
  281. + Scanning bootdev 'fw-cfg@9020000.bootdev':
  282. + fatal: no kernel available
  283. + scanning bus for devices...
  284. + Scanning bootdev 'virtio-blk#34.bootdev':
  285. + 0 efi ready virtio 2 virtio-blk#34.bootdev.par efi/boot/bootaa64.efi
  286. + ** Booting bootflow 'virtio-blk#34.bootdev.part_2' with efi
  287. + Using prior-stage device tree
  288. + Failed to load EFI variables
  289. + Error: writing contents
  290. + ** Unable to write file ubootefi.var **
  291. + Failed to persist EFI variables
  292. + Missing TPMv2 device for EFI_TCG_PROTOCOL
  293. + Booting /efi\boot\bootaa64.efi
  294. + Error: writing contents
  295. + ** Unable to write file ubootefi.var **
  296. + Failed to persist EFI variables
  297. + Welcome to GRUB!
  298. +
  299. +Standard boot looks through various available devices and finds the virtio
  300. +disks, then boots from the first one. After a second or so the grub menu appears
  301. +and you can work through the installer flow normally.
  302. +
  303. +After the installation, you can boot into the installed system by running QEMU
  304. +again without the drive argument corresponding to the installer CD image.
  305. +
  306. Enabling TPMv2 support
  307. ----------------------
  308. --
  309. 2.42.0