diff --git a/bsp/README.md b/bsp/README.md index feb1e45c193..87a9b13a62e 100644 --- a/bsp/README.md +++ b/bsp/README.md @@ -247,9 +247,9 @@ This document is based on the RT-Thread mainline repository and categorizes the #### 🟢 QEMU Virt64 AArch64 (RT-Smart) (SMP) -| BSP Name | GPIO | UART | RTC | VirtIO-BLK | VirtIO-NET | VirtIO-Console | VirtIO-GPU | VirtIO-Input | -|----------|------|------|-----|-----------|-----------|---------------|-----------|--------------| -| [qemu-virt64-aarch64](qemu-virt64-aarch64) | ✅ | ✅ | ✅ | ✅ | - | ✅ | ✅ | ✅ | +| BSP Name | GPIO | UART | RTC | WDT | PCI | Storage | Flash | LCD | Input | Camera | Sound | Crypto | RNG | Net | Console | RPMSG | +|----------|------|------|-----|-----|-----|---------|-------|-----|-------|--------|-------|--------|-----|-----|---------|-------| +| [qemu-virt64-aarch64](qemu-virt64-aarch64) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | #### 🟡 Phytium (RT-Smart) (SMP) diff --git a/bsp/qemu-virt64-aarch64/README.md b/bsp/qemu-virt64-aarch64/README.md index 6811bf30623..8ac4012c1ca 100644 --- a/bsp/qemu-virt64-aarch64/README.md +++ b/bsp/qemu-virt64-aarch64/README.md @@ -110,13 +110,13 @@ msh /> | Option | Default | Description | | ------ | ------- | ----------- | -| `-gic` | `2` | GIC version (`2` / `3` / `max`); auto-switches to GICv3 when `-smp` > 8 | -| `-smp` | `RT_CPUS_NR` (4) | Number of CPU cores | +| `-gic` | `2` | GIC version (`2` or `3`); auto-switches to GICv3 when `-smp` > 8; with `-el 2` and GICv3, internally uses `gic-version=max` (not passable via `-gic max`) | +| `-smp` | `RT_CPUS_NR` (4) | Number of CPU cores; `-dtbo` adds 1 automatically when `amp_soc` is present | | `-mem` | `128` | Memory size (MB) | | `-el` | `1` | Exception level: `1` default; `2` virtualization on; `3` secure on | | `-bootargs` | see below | Kernel boot arguments | | `-initrd` | — | Path to initrd image | -| `-graphic` | — | Graphics mode (ramfb + VirtIO keyboard/tablet), replaces `-nographic` | +| `-graphic` | — | Graphics mode (ramfb + `virtio-gpu-device` + VirtIO keyboard/tablet), replaces `-nographic` | | `-gl` | — | In graphics mode, attach `virtio-gpu-gl-pci` and enable QEMU display OpenGL (e.g. `-gl gtk`); requires QEMU built with `--enable-opengl` and `--enable-virglrenderer`; must be used with `-graphic` | | `-debug` | — | Enable GDB debugging (`-S -s`) | | `-dumpdtb` | — | Export runtime DTB and convert to DTS | @@ -133,8 +133,8 @@ msh /> | `-tap` | — | Use TAP networking (replaces user mode) | | `-ssh` | `12055` | SSH port forwarding in user mode (`hostfwd=tcp::PORT-:22`) | | `-9p` | — | VirtIO 9P shared directory path (enable VirtIO 9P in menuconfig) | -| `-camera` | — | Enable vfio-user camera (Linux only, with `qemu-device-camera`) | -| `-dtbo` | — | AMP mode: DTBO overlay file (e.g. `amp.dtsi`); **requires Smart kernel** (see below) | +| `-camera` | — | Host V4L2 device path (e.g. `/dev/video0`); Linux only; read access to the device is required (usually add your user to the `video` group); compiles and runs `qemu-device-camera.c` in the background, then attaches a vfio-user PCI camera (requires **libvfio-user**) | +| `-dtbo` | — | AMP mode: DTBO overlay file (e.g. `amp.dtsi`); auto-increments `-smp` by 1; **requires Smart kernel** and sufficient `-mem` (see below) | Default `-bootargs`: @@ -156,7 +156,7 @@ QEMU OpenGL display (`-gl`): ./qemu.py -graphic -gl gtk ``` -> **Note**: `-gl` enables OpenGL only on the QEMU / host display path (`virtio-gpu-gl-pci` + VirGL). This BSP includes only the VirtIO GPU 2D framebuffer driver by default — **no OpenGL / VirGL user-space or kernel implementation**. `-gl` does not provide OpenGL acceleration inside RT-Thread. For graphics demos, use `-graphic` (`virtio-gpu-device`) with framebuffer / HMI tests. +> **Note**: `-gl` enables OpenGL only on the QEMU / host display path (`virtio-gpu-gl-pci` + VirGL). This BSP includes only the VirtIO GPU 2D framebuffer driver by default — **no OpenGL / VirGL user-space or kernel implementation**. `-gl` does not provide OpenGL acceleration inside RT-Thread. For graphics demos, use `-graphic` (`virtio-gpu-device`) with the framebuffer stack. GDB debugging: @@ -194,14 +194,16 @@ AMP heterogeneous multi-core (RPMSG slave, **requires Smart version**): ./qemu.py -dtbo amp.dtsi -mem 258 ``` -> **Note**: The AMP demo requires the **Smart version** (`RT_USING_SMART`). The standard kernel must run in a region where virtual addresses equal physical addresses. The slave image is loaded by QEMU `loader` to fixed physical addresses specified in `amp.dtsi` (e.g. `kernel-entry = 0x48480000`), which differs from the primary MMU layout; the standard kernel cannot boot correctly in that address space. Enable Smart in menuconfig and rebuild. +> **Note**: The AMP demo requires the **Smart version** (`RT_USING_SMART`) and **`-mem 258`** (memory layout in `amp.dtsi` needs ~258 MB; the default 128 MB is insufficient). `qemu.py` also increments `-smp` by 1 when `amp_soc` is detected (e.g. `RT_CPUS_NR=4` runs as `-smp 5`). QEMU `loader` pre-loads `amp.dtb` and `rtthread.bin` to fixed physical addresses in `amp.dtsi` (e.g. `kernel-entry = 0x48480000`); the primary core then starts the slave via PSCI. The standard kernel must run in a region where virtual addresses equal physical addresses and cannot be used for the slave address space. Enable Smart in menuconfig and rebuild. -Camera demo: +Camera demo (requires `-graphic` for framebuffer overlay in `camera.c`): ``` -./qemu.py -graphic -camera +./qemu.py -graphic -camera /dev/video0 ``` +> **Note**: `-camera` requires a host V4L2 device path. On Linux, install [libvfio-user](https://github.com/nutanix/libvfio-user) first (see comments in `qemu-device-camera.c`), and ensure your user can read the device node (e.g. `sudo usermod -aG video $USER` then log in again, or check with `ls -l /dev/video0`). Open will also fail if another program is using the camera. The script compiles `qemu-device-camera.c`, waits for `/tmp/qemu-device-camera.sock`, starts QEMU, and stops the helper process when QEMU exits. + ### 3.6 Console and Telnet | Port | Device | Description | @@ -231,7 +233,7 @@ TAP requires bridge setup on Linux; support on Windows / WSL is limited. SSH por ## 4. Default QEMU Devices -`qemu.py` attaches the following devices by default (matching the default driver configuration): +`qemu.py` attaches the following devices by default (matching the default driver configuration). UFS is included only when QEMU ≥ 8.2.0; optional devices are listed with their triggering option. | QEMU device | Image file | RT-Thread side | | ----------- | ---------- | -------------- | @@ -242,7 +244,7 @@ TAP requires bridge setup on Linux; support on Windows / WSL is limited. SSH por | `sdhci-pci` + `sd-card` | `emmc.qcow2` | SDHCI eMMC (enable SDIO) | | `nvme` + `nvme-ns` | `nvme.qcow2` | NVMe | | `ahci` + `ide-hd` | `ahci.qcow2` | AHCI SATA | -| `ufs` + `ufs-lu` | `ufs.qcow2` | UFS (QEMU ≥ 8.2.0) | +| `ufs` + `ufs-lu` (QEMU ≥ 8.2.0 only) | `ufs.qcow2` | UFS | | `virtio-net-device` | — | VirtIO Net (enable network stack) | | `virtio-rng-device` | — | VirtIO RNG | | `virtio-crypto-device` | — | VirtIO Crypto | @@ -256,7 +258,7 @@ TAP requires bridge setup on Linux; support on Windows / WSL is limited. SSH por | `virtio-keyboard-device` / `virtio-tablet-device` | — | VirtIO Input | | `virtio-9p-device` (`-9p`) | — | VirtIO 9P (enable driver) | | `virtio-sound-pci` (`-sound virtio`) | — | VirtIO Sound | -| vfio-user camera (`-camera`) | — | PCI camera (BSP `drv_camera`) | +| vfio-user camera (`-camera `) | host V4L2 device | PCI camera (BSP `drv_camera`) | ## 5. Driver Support @@ -268,7 +270,6 @@ TAP requires bridge setup on Linux; support on Windows / WSL is limited. SSH por | Serial | 8250 PCI | PCI serial, Telnet port 4322 | | RTC | PL031 | Real-time clock | | GPIO | PL061 | GPIO controller | -| Clock | ARM Architected Timer | System tick | | Watchdog | I6300ESB | PCI watchdog | | Storage | VirtIO Block | Block device, `vda` | | Storage | VirtIO SCSI | SD / CD-ROM | @@ -278,31 +279,19 @@ TAP requires bridge setup on Linux; support on Windows / WSL is limited. SSH por | Storage | MTD NOR CFI | pflash flash | | Storage | BLK partition | DFS / EFI partition table | | Graphics | VirtIO GPU | 2D framebuffer (`-graphic`); no OpenGL / VirGL | -| Graphics | Framebuffer | ROMFB 800×600, HMI / graphics tests | +| Graphics | Framebuffer | RAMFB 800×600 (`RT_GRAPHIC_ROMFB_WIDTH` / `HEIGHT`, `drv_romfb.c`) | | Graphics | LCD | LCD device framework | | Input | VirtIO Input | Keyboard, mouse, tablet (`-graphic`) | -| Input | Touchscreen | Touchscreen framework | -| Input | Keyboard GPIO | GPIO keyboard | -| Input | Power | Power key | | Audio | Intel HDA | Default `-sound hda` | | Audio | VirtIO Sound | `-sound virtio` | -| Crypto | HwCrypto | AES / DES / 3DES / RC4 / RNG | | Crypto | VirtIO Crypto | VirtIO crypto backend | | Random | VirtIO RNG | Hardware random number | | Comm | VirtIO Console | Telnet 4321 | -| Comm | VirtIO RPROC Serial | Remoteproc serial link | | Comm | RPMSG | VirtIO RPMSG character device | | Comm | Mailbox PIC | Mailbox interrupt controller | | Firmware | QEMU FW_CFG | Firmware configuration interface | | Bus | PCI | ECAM + Generic Host, MSI / MSI-X | -| Bus | VirtIO | MMIO + PCI transport | -| IRQ | GICv2 / GICv3 / ITS | Including GICv2m MSI | -| Devicetree | OFW / FDT | Dynamic devicetree parsing | -| Other | DMA | DMA framework | -| Other | MFD EDU / SYSCON | Multi-function devices | -| Other | Regulator / Reset | Power and reset framework | -| Filesystem | DFS v2 | FatFs, devfs, romfs | -| POSIX | Partial APIs | poll / select / termios / pipe, etc. | +| Other | MFD EDU | Multi-function device | ### 5.2 Not Enabled by Default but Available via menuconfig @@ -313,16 +302,6 @@ This BSP enables the PCI bus and VirtIO PCI transport; QEMU also attaches the co | VirtIO Net | `RT_USING_SAL` + `RT_USING_LWIP` + `RT_USING_ETHERNET` | `virtio-net-device` | Network stack not enabled by default | | VirtIO 9P | `RT_VIRTIO_9P` | `virtio-9p-device` | Use with `-9p` shared directory | | SDHCI eMMC | `RT_USING_SDIO` + `RT_SDIO_SDHCI_PCI` | `sdhci-pci` | eMMC storage | -| SDIO DW MMC PCI | `RT_USING_SDIO` + `RT_SDIO_DW_MMC_PCI` | — | DesignWare MMC | -| USB | `RT_USING_USB_HOST` / `RT_USING_USB_DEVICE` | Add USB controller manually | Not a default QEMU device | -| CherryUSB | `RT_USING_CHERRYUSB` | Add USB controller manually | — | -| I2C / SPI | `RT_USING_I2C` / `RT_USING_SPI` | Depends on PCI device | Requires matching PCI controller driver | -| CAN | `RT_USING_CAN` | Depends on PCI device | — | -| Sensor | `RT_USING_SENSOR` | — | — | -| WiFi | `RT_USING_WIFI` | — | — | -| PM | `RT_USING_PM` | — | — | -| Pinctrl | `RT_USING_PINCTRL` | — | — | -| SCMI firmware | `RT_FIRMWARE_ARM_SCMI` + `RT_VIRTIO_SCMI` | — | — | > **Note**: Any PCI driver marked `depends on RT_USING_PCI` can be enabled on this BSP via menuconfig. If QEMU does not attach the device by default, add the corresponding `-device` argument in `qemu.py`. @@ -330,9 +309,8 @@ This BSP enables the PCI bus and VirtIO PCI transport; QEMU also attaches the co | Feature | Config | Startup | | ------- | ------ | ------- | -| HMI graphics test | `RT_GRAPHIC_HMI_TEST` | `-graphic` (embedded in `drv_romfb.c`) | -| Graphics draw test | `RT_GRAPHIC_GRAPHIC_TEST` | `-graphic` (embedded in `drv_romfb.c`) | -| Camera driver | `RT_SOC_CAMERA` | `-graphic -camera` | +| RAMFB resolution | `RT_GRAPHIC_ROMFB_WIDTH` / `RT_GRAPHIC_ROMFB_HEIGHT` | `-graphic` (`drv_romfb.c` supplies size to RAMFB) | +| Camera driver | `RT_SOC_CAMERA` | `-camera `; use `-graphic` for `camera.c` preview | ### 5.4 Sample Applications (`applications/`) @@ -348,9 +326,9 @@ Default application. Prints `hello rt-thread` after boot, then enters msh. **`amp.c` (AMP + RPMSG)** -The primary core boots an additional CPU running RT-Thread as slave via the `amp_soc` devicetree node and PSCI. Primary and slave communicate through VirtIO RPMSG and Mailbox. The primary writes VirtIO Block `vdb` resource info into the slave DTB before starting the slave. +QEMU `loader` pre-loads `amp.dtb` and `rtthread.bin` to addresses in `amp.dtsi`; the primary core then boots the slave CPU via the `amp_soc` devicetree node and PSCI. Primary and slave communicate through VirtIO RPMSG and Mailbox. The primary writes VirtIO Block `vdb` resource info into the slave DTB before starting the slave. `qemu.py` increments `-smp` by 1 for the extra CPU. -**Version requirement**: **Smart version** required (`RT_USING_SMART` in menuconfig). The standard kernel must run with virtual addresses equal to physical addresses. The AMP slave is loaded by QEMU into a separate physical memory region (see `amp_memory`, `kernel-entry` in `amp.dtsi`), which violates that constraint — the standard kernel cannot be used for AMP demos. +**Version requirement**: **Smart version** required (`RT_USING_SMART` in menuconfig), plus **`-mem 258`**. The standard kernel must run with virtual addresses equal to physical addresses. The AMP slave is loaded into a separate physical memory region (see `amp_memory`, `kernel-entry` in `amp.dtsi`), which violates that constraint — the standard kernel cannot be used for AMP demos. Startup: @@ -374,10 +352,10 @@ An RPMSG endpoint is created automatically at boot (`rpmsg_char0`, endpoint name Centers and overlays the vfio-user PCI camera feed onto the framebuffer. Default devices `camera0` → `fb0`, runs for about 10 seconds (300 frames). -Startup: +Startup (Linux host with libvfio-user and a V4L2 camera): ``` -./qemu.py -graphic -camera +./qemu.py -graphic -camera /dev/video0 ``` msh command: @@ -414,9 +392,10 @@ Optional VirtIO device arguments (add in `qemu.py` as needed): ## 8. Notes After Configuration Changes -- After changing CPU count, adjust `qemu.py -smp` or rebuild so `RT_CPUS_NR` matches. -- GIC auto-switches to v3 when exceeding 8 cores; or specify `-gic 3` manually. +- After changing CPU count, rebuild so `RT_CPUS_NR` matches (or override with `qemu.py -smp`). In `-dtbo` mode, `qemu.py` adds 1 to the CPU count automatically. +- GIC auto-switches to v3 when exceeding 8 cores; or specify `-gic 3` manually. `gic-version=max` is set only internally when using `-el 2` with GICv3. - 9P directory sharing requires QEMU built with virtfs (`--enable-virtfs`). - `-gl` requires QEMU built with OpenGL / VirGL (`--enable-opengl`, `--enable-virglrenderer`); this is independent of RT-Thread OpenGL support — the default software stack is 2D graphics only. -- AMP (`-dtbo`) requires Smart kernel (`RT_USING_SMART`); the standard kernel requires VA=PA and cannot be used with slave images loaded at fixed physical addresses. +- AMP (`-dtbo`) requires Smart kernel (`RT_USING_SMART`), `-mem 258`, and auto-increments CPU count; the standard kernel requires VA=PA and cannot be used with slave images loaded at fixed physical addresses. +- `-camera` requires a host V4L2 device path, Linux, and libvfio-user; your user must have read access to the device (typically via the `video` group); `-graphic` is needed only for the `camera.c` framebuffer preview demo. - Override root device or boot parameters via `-bootargs`. diff --git a/bsp/qemu-virt64-aarch64/README_zh.md b/bsp/qemu-virt64-aarch64/README_zh.md index 7cdcaaf73ca..0b623627d83 100644 --- a/bsp/qemu-virt64-aarch64/README_zh.md +++ b/bsp/qemu-virt64-aarch64/README_zh.md @@ -106,13 +106,13 @@ msh /> | 参数 | 默认值 | 说明 | | ---- | ------ | ---- | -| `-gic` | `2` | GIC 版本(`2` / `3` / `max`);`-smp` 大于 8 时自动切换为 GICv3 | -| `-smp` | `RT_CPUS_NR`(4) | CPU 核心数 | +| `-gic` | `2` | GIC 版本(`2` 或 `3`);`-smp` 大于 8 时自动切换为 GICv3;`-el 2` 且 GICv3 时内部使用 `gic-version=max`(不可通过 `-gic max` 手动指定) | +| `-smp` | `RT_CPUS_NR`(4) | CPU 核心数;`-dtbo` 检测到 `amp_soc` 时自动加 1 | | `-mem` | `128` | 内存大小(MB) | | `-el` | `1` | 异常级别:`1` 默认;`2` 开启虚拟化;`3` 开启 secure | | `-bootargs` | 见下文 | 内核启动参数 | | `-initrd` | — | 指定 initrd 镜像路径 | -| `-graphic` | — | 图形模式(ramfb + VirtIO 键盘/平板),替代 `-nographic` | +| `-graphic` | — | 图形模式(ramfb + `virtio-gpu-device` + VirtIO 键盘/平板),替代 `-nographic` | | `-gl` | — | 图形模式下挂载 `virtio-gpu-gl-pci` 并开启 QEMU 显示端 OpenGL(如 `-gl gtk`);需 QEMU 带 `--enable-opengl`、`--enable-virglrenderer`,且须与 `-graphic` 合用 | | `-debug` | — | 启用 GDB 调试(`-S -s`) | | `-dumpdtb` | — | 导出运行时 DTB 并转为 DTS | @@ -129,8 +129,8 @@ msh /> | `-tap` | — | 使用 TAP 网卡(替代 user 模式) | | `-ssh` | `12055` | user 模式下 SSH 端口转发(`hostfwd=tcp::PORT-:22`) | | `-9p` | — | VirtIO 9P 共享目录路径(需在 menuconfig 中启用 VirtIO 9P) | -| `-camera` | — | 启用 vfio-user 摄像头(仅 Linux,配合 `qemu-device-camera`) | -| `-dtbo` | — | AMP 模式:指定 DTBO overlay 文件(如 `amp.dtsi`);**须 Smart 版本内核**(见下文说明) | +| `-camera` | — | 宿主机 V4L2 设备路径(如 `/dev/video0`);仅 Linux;需对设备有读权限(通常加入 `video` 组);后台编译运行 `qemu-device-camera.c` 并通过 vfio-user 挂载 PCI 摄像头(需安装 **libvfio-user**) | +| `-dtbo` | — | AMP 模式:指定 DTBO overlay 文件(如 `amp.dtsi`);自动将 `-smp` 加 1;**须 Smart 版本内核**且配置足够 `-mem`(见下文) | 默认 `-bootargs`: @@ -152,7 +152,7 @@ QEMU OpenGL 显示(`-gl`): ./qemu.py -graphic -gl gtk ``` -> **说明**:`-gl` 仅在 QEMU / 宿主机显示链路侧启用 OpenGL(`virtio-gpu-gl-pci` + VirGL)。本 BSP 默认仅包含 VirtIO GPU 2D 帧缓冲驱动,**没有 OpenGL / VirGL 用户态与内核侧实现**,因此 `-gl` 不会带来 RT-Thread 内的 OpenGL 加速;图形演示请使用 `-graphic`(`virtio-gpu-device`)配合 framebuffer / HMI 测试。 +> **说明**:`-gl` 仅在 QEMU / 宿主机显示链路侧启用 OpenGL(`virtio-gpu-gl-pci` + VirGL)。本 BSP 默认仅包含 VirtIO GPU 2D 帧缓冲驱动,**没有 OpenGL / VirGL 用户态与内核侧实现**,因此 `-gl` 不会带来 RT-Thread 内的 OpenGL 加速;图形演示请使用 `-graphic`(`virtio-gpu-device`)配合 framebuffer 栈。 GDB 调试: @@ -190,14 +190,16 @@ AMP 异构多核(RPMSG 从核,**须 Smart 版本**): ./qemu.py -dtbo amp.dtsi -mem 258 ``` -> **说明**:AMP 示例要求启用 **Smart 版本**(`RT_USING_SMART`)。标准版内核要求在虚拟地址与物理地址相等的区域运行;从核镜像由 QEMU `loader` 加载到 `amp.dtsi` 指定的固定物理地址(如 `kernel-entry = 0x48480000`),与主核 MMU 映射布局不同,标准版无法在该地址空间正常启动。请在 menuconfig 中开启 Smart 后重新编译。 +> **说明**:AMP 示例要求启用 **Smart 版本**(`RT_USING_SMART`),且必须使用 **`-mem 258`**(`amp.dtsi` 内存布局约需 258 MB,默认 128 MB 不足)。`qemu.py` 检测到 `amp_soc` 时会将 `-smp` 自动加 1(例如 `RT_CPUS_NR=4` 时实际以 `-smp 5` 启动)。QEMU `loader` 会预先将 `amp.dtb` 与 `rtthread.bin` 加载到 `amp.dtsi` 指定的固定物理地址(如 `kernel-entry = 0x48480000`),主核再通过 PSCI 拉起从核。标准版内核要求在虚拟地址与物理地址相等的区域运行,无法用于从核地址空间。请在 menuconfig 中开启 Smart 后重新编译。 -摄像头演示: +摄像头演示(`camera.c` 叠加画面到 framebuffer,需配合 `-graphic`): ``` -./qemu.py -graphic -camera +./qemu.py -graphic -camera /dev/video0 ``` +> **说明**:`-camera` 必须传入宿主机 V4L2 设备路径。Linux 下需先安装 [libvfio-user](https://github.com/nutanix/libvfio-user)(详见 `qemu-device-camera.c` 注释),并确保当前用户对设备节点有读权限(例如 `sudo usermod -aG video $USER` 后重新登录,或用 `ls -l /dev/video0` 确认权限)。若设备正被其他程序占用,也会打开失败。脚本会编译 `qemu-device-camera.c`、等待 `/tmp/qemu-device-camera.sock` 就绪后启动 QEMU,并在 QEMU 退出后结束辅助进程。 + ### 3.6 控制台与 Telnet | 端口 | 设备 | 说明 | @@ -227,7 +229,7 @@ Linux 下需预先配置 TAP 网桥,Windows / WSL 下 TAP 支持有限。TAP ## 4. QEMU 默认挂载设备 -`qemu.py` 默认向虚拟机挂载以下设备(与驱动默认配置对应): +`qemu.py` 默认向虚拟机挂载以下设备(与驱动默认配置对应)。UFS 仅在 QEMU ≥ 8.2.0 时挂载;带触发条件的可选设备在表中标注。 | QEMU 设备 | 镜像文件 | RT-Thread 侧 | | --------- | -------- | ------------ | @@ -238,7 +240,7 @@ Linux 下需预先配置 TAP 网桥,Windows / WSL 下 TAP 支持有限。TAP | `sdhci-pci` + `sd-card` | `emmc.qcow2` | SDHCI eMMC(需启用 SDIO) | | `nvme` + `nvme-ns` | `nvme.qcow2` | NVMe | | `ahci` + `ide-hd` | `ahci.qcow2` | AHCI SATA | -| `ufs` + `ufs-lu` | `ufs.qcow2` | UFS(QEMU ≥ 8.2.0) | +| `ufs` + `ufs-lu`(仅 QEMU ≥ 8.2.0) | `ufs.qcow2` | UFS | | `virtio-net-device` | — | VirtIO Net(需启用网络协议栈) | | `virtio-rng-device` | — | VirtIO RNG | | `virtio-crypto-device` | — | VirtIO Crypto | @@ -252,7 +254,7 @@ Linux 下需预先配置 TAP 网桥,Windows / WSL 下 TAP 支持有限。TAP | `virtio-keyboard-device` / `virtio-tablet-device` | — | VirtIO Input | | `virtio-9p-device`(`-9p`) | — | VirtIO 9P(需启用驱动) | | `virtio-sound-pci`(`-sound virtio`) | — | VirtIO Sound | -| vfio-user 摄像头(`-camera`) | — | PCI 摄像头(BSP `drv_camera`) | +| vfio-user 摄像头(`-camera <路径>`) | 宿主机 V4L2 设备 | PCI 摄像头(BSP `drv_camera`) | ## 5. 驱动支持情况 @@ -264,7 +266,6 @@ Linux 下需预先配置 TAP 网桥,Windows / WSL 下 TAP 支持有限。TAP | 串口 | 8250 PCI | PCI 串口,Telnet 端口 4322 | | RTC | PL031 | 实时时钟 | | GPIO | PL061 | GPIO 控制器 | -| 时钟 | ARM Architected Timer | 系统 tick | | 看门狗 | I6300ESB | PCI 看门狗 | | 存储 | VirtIO Block | 块设备,`vda` | | 存储 | VirtIO SCSI | SD / CD-ROM | @@ -274,31 +275,19 @@ Linux 下需预先配置 TAP 网桥,Windows / WSL 下 TAP 支持有限。TAP | 存储 | MTD NOR CFI | pflash 闪存 | | 存储 | BLK 分区 | DFS / EFI 分区表 | | 图形 | VirtIO GPU | 2D 帧缓冲(`-graphic`);不含 OpenGL / VirGL | -| 图形 | Framebuffer | ROMFB 800×600,含 HMI / 图形测试 | +| 图形 | Framebuffer | RAMFB 800×600(`RT_GRAPHIC_ROMFB_WIDTH` / `HEIGHT`,`drv_romfb.c`) | | 图形 | LCD | LCD 设备框架 | | 输入 | VirtIO Input | 键盘、鼠标、平板(`-graphic`) | -| 输入 | Touchscreen | 触摸屏框架 | -| 输入 | Keyboard GPIO | GPIO 键盘 | -| 输入 | Power | 电源键 | | 音频 | Intel HDA | 默认 `-sound hda` | | 音频 | VirtIO Sound | `-sound virtio` | -| 加密 | HwCrypto | AES / DES / 3DES / RC4 / RNG | | 加密 | VirtIO Crypto | VirtIO 加密后端 | | 随机数 | VirtIO RNG | 硬件随机数 | | 通信 | VirtIO Console | Telnet 4321 | -| 通信 | VirtIO RPROC Serial | Remoteproc 串口链路 | | 通信 | RPMSG | VirtIO RPMSG 字符设备 | | 通信 | Mailbox PIC | 邮箱中断控制器 | | 固件 | QEMU FW_CFG | 固件配置接口 | | 总线 | PCI | ECAM + Generic Host,MSI / MSI-X | -| 总线 | VirtIO | MMIO + PCI 传输 | -| 中断 | GICv2 / GICv3 / ITS | 含 GICv2m MSI | -| 设备树 | OFW / FDT | 动态设备树解析 | -| 其他 | DMA | DMA 框架 | -| 其他 | MFD EDU / SYSCON | 多功能设备 | -| 其他 | Regulator / Reset | 电源与复位框架 | -| 文件系统 | DFS v2 | FatFs、devfs、romfs | -| POSIX | 部分接口 | poll / select / termios / pipe 等 | +| 其他 | MFD EDU | 多功能设备 | ### 5.2 默认未启用但可通过 menuconfig 开启 @@ -309,16 +298,6 @@ Linux 下需预先配置 TAP 网桥,Windows / WSL 下 TAP 支持有限。TAP | VirtIO Net | `RT_USING_SAL` + `RT_USING_LWIP` + `RT_USING_ETHERNET` | `virtio-net-device` | 网络协议栈未默认启用 | | VirtIO 9P | `RT_VIRTIO_9P` | `virtio-9p-device` | 配合 `-9p` 共享目录 | | SDHCI eMMC | `RT_USING_SDIO` + `RT_SDIO_SDHCI_PCI` | `sdhci-pci` | eMMC 存储 | -| SDIO DW MMC PCI | `RT_USING_SDIO` + `RT_SDIO_DW_MMC_PCI` | — | DesignWare MMC | -| USB | `RT_USING_USB_HOST` / `RT_USING_USB_DEVICE` | 需自行添加 USB 控制器 | 非 QEMU 默认设备 | -| CherryUSB | `RT_USING_CHERRYUSB` | 需自行添加 USB 控制器 | — | -| I2C / SPI | `RT_USING_I2C` / `RT_USING_SPI` | 视具体 PCI 设备 | 需对应 PCI 控制器驱动 | -| CAN | `RT_USING_CAN` | 视具体 PCI 设备 | — | -| Sensor | `RT_USING_SENSOR` | — | — | -| WiFi | `RT_USING_WIFI` | — | — | -| PM 电源管理 | `RT_USING_PM` | — | — | -| Pinctrl | `RT_USING_PINCTRL` | — | — | -| SCMI 固件 | `RT_FIRMWARE_ARM_SCMI` + `RT_VIRTIO_SCMI` | — | — | > **说明**:凡标注 `depends on RT_USING_PCI` 的 PCI 类驱动,均可在此 BSP 上通过 menuconfig 启用;QEMU 侧若未挂载对应设备,需自行在 `qemu.py` 中添加 `-device` 参数。 @@ -326,9 +305,8 @@ Linux 下需预先配置 TAP 网桥,Windows / WSL 下 TAP 支持有限。TAP | 功能 | 配置项 | 启动方式 | | ---- | ------ | -------- | -| HMI 图形测试 | `RT_GRAPHIC_HMI_TEST` | `-graphic`(`drv_romfb.c` 内嵌) | -| 图形绘制测试 | `RT_GRAPHIC_GRAPHIC_TEST` | `-graphic`(`drv_romfb.c` 内嵌) | -| 摄像头驱动 | `RT_SOC_CAMERA` | `-graphic -camera` | +| RAMFB 分辨率 | `RT_GRAPHIC_ROMFB_WIDTH` / `RT_GRAPHIC_ROMFB_HEIGHT` | `-graphic`(`drv_romfb.c` 向 RAMFB 提供尺寸) | +| 摄像头驱动 | `RT_SOC_CAMERA` | `-camera `;`camera.c` 预览需加 `-graphic` | ### 5.4 示例应用(`applications/`) @@ -344,9 +322,9 @@ Linux 下需预先配置 TAP 网桥,Windows / WSL 下 TAP 支持有限。TAP **`amp.c`(AMP + RPMSG)** -主核通过设备树 `amp_soc` 节点,以 PSCI 拉起额外一颗 CPU 运行从核 RT-Thread,主从之间通过 VirtIO RPMSG + Mailbox 通信。主核将 VirtIO Block `vdb` 的资源信息写入从核 DTB 后启动从核。 +QEMU `loader` 预先将 `amp.dtb` 与 `rtthread.bin` 加载到 `amp.dtsi` 指定地址,主核再通过 `amp_soc` 设备树节点与 PSCI 拉起从核 CPU。主从之间通过 VirtIO RPMSG + Mailbox 通信。主核将 VirtIO Block `vdb` 的资源信息写入从核 DTB 后启动从核。`qemu.py` 会为这颗额外 CPU 将 `-smp` 加 1。 -**版本要求**:须 **Smart 版本**(menuconfig 中 `RT_USING_SMART`)。标准版内核必须在虚拟地址与物理地址一致的映射下运行;AMP 从核由 QEMU 加载到独立物理内存区域(见 `amp.dtsi` 中 `amp_memory`、`kernel-entry` 等),不满足该约束,因此标准版无法用于 AMP 演示。 +**版本要求**:须 **Smart 版本**(menuconfig 中 `RT_USING_SMART`),且须使用 **`-mem 258`**。标准版内核必须在虚拟地址与物理地址一致的映射下运行;AMP 从核加载到独立物理内存区域(见 `amp.dtsi` 中 `amp_memory`、`kernel-entry` 等),不满足该约束,因此标准版无法用于 AMP 演示。 启动方式: @@ -370,10 +348,10 @@ msh 命令: 将 vfio-user PCI 摄像头画面居中叠加到 framebuffer,默认设备 `camera0` → `fb0`,约 10 秒(300 帧)。 -启动方式: +启动方式(Linux 宿主机,已安装 libvfio-user 且存在 V4L2 摄像头): ``` -./qemu.py -graphic -camera +./qemu.py -graphic -camera /dev/video0 ``` msh 命令: @@ -410,9 +388,10 @@ VirtIO 设备可选参数(在 `qemu.py` 中按需添加): ## 8. 修改配置后的注意事项 -- 修改 CPU 数量后,同步调整 `qemu.py -smp` 或重新编译使 `RT_CPUS_NR` 与之一致。 -- 超过 8 核时 GIC 自动切换为 v3,也可手动指定 `-gic 3`。 +- 修改 CPU 数量后,重新编译使 `RT_CPUS_NR` 与之一致(或用 `qemu.py -smp` 覆盖)。`-dtbo` 模式下 `qemu.py` 会自动将 CPU 数加 1。 +- 超过 8 核时 GIC 自动切换为 v3,也可手动指定 `-gic 3`。`gic-version=max` 仅在 `-el 2` 且 GICv3 时由脚本内部设置。 - 启用 9P 目录共享需 QEMU 编译时包含 virtfs(`--enable-virtfs`)。 - 使用 `-gl` 需 QEMU 编译时包含 OpenGL / VirGL(`--enable-opengl`、`--enable-virglrenderer`);这与 RT-Thread 是否支持 OpenGL 无关,当前软件栈默认仅 2D 图形。 -- AMP(`-dtbo`)须 Smart 版本内核(`RT_USING_SMART`);标准版要求 VA=PA 运行,无法用于从核固定物理地址加载场景。 +- AMP(`-dtbo`)须 Smart 版本内核(`RT_USING_SMART`)、`-mem 258`,且自动增加 CPU 数;标准版要求 VA=PA 运行,无法用于从核固定物理地址加载场景。 +- `-camera` 须传入宿主机 V4L2 设备路径,仅支持 Linux,且需 libvfio-user;当前用户须能访问该设备(通常加入 `video` 组);`-graphic` 仅 `camera.c` framebuffer 预览演示需要。 - 修改根设备或启动参数时,通过 `-bootargs` 覆盖默认参数。