1ppce500 generic platform (``ppce500``) 2====================================== 3 4QEMU for PPC supports a special ``ppce500`` machine designed for emulation and 5virtualization purposes. 6 7Supported devices 8----------------- 9 10The ``ppce500`` machine supports the following devices: 11 12* PowerPC e500 series core (e500v2/e500mc/e5500/e6500) 13* Configuration, Control, and Status Register (CCSR) 14* Multicore Programmable Interrupt Controller (MPIC) with MSI support 15* 1 16550A UART device 16* 1 Freescale MPC8xxx I2C controller 17* 1 Pericom pt7c4338 RTC via I2C 18* 1 Freescale MPC8xxx GPIO controller 19* Power-off functionality via one GPIO pin 20* 1 Freescale MPC8xxx PCI host controller 21* VirtIO devices via PCI bus 22* 1 Freescale Enhanced Secure Digital Host controller (eSDHC) 23* 1 Freescale Enhanced Triple Speed Ethernet controller (eTSEC) 24 25Hardware configuration information 26---------------------------------- 27 28The ``ppce500`` machine automatically generates a device tree blob ("dtb") 29which it passes to the guest, if there is no ``-dtb`` option. This provides 30information about the addresses, interrupt lines and other configuration of 31the various devices in the system. 32 33If users want to provide their own DTB, they can use the ``-dtb`` option. 34These DTBs should have the following requirements: 35 36* The number of subnodes under /cpus node should match QEMU's ``-smp`` option 37* The /memory reg size should match QEMU’s selected ram_size via ``-m`` 38 39Both ``qemu-system-ppc`` and ``qemu-system-ppc64`` provide emulation for the 40following 32-bit PowerPC CPUs: 41 42* e500v2 43* e500mc 44 45Additionally ``qemu-system-ppc64`` provides support for the following 64-bit 46PowerPC CPUs: 47 48* e5500 49* e6500 50 51The CPU type can be specified via the ``-cpu`` command line. If not specified, 52it creates a machine with e500v2 core. The following example shows an e6500 53based machine creation: 54 55.. code-block:: bash 56 57 $ qemu-system-ppc64 -nographic -M ppce500 -cpu e6500 58 59Boot options 60------------ 61 62The ``ppce500`` machine can start using the standard -kernel functionality 63for loading a payload like an OS kernel (e.g.: Linux), or U-Boot firmware. 64 65When -bios is omitted, the default pc-bios/u-boot.e500 firmware image is used 66as the BIOS. QEMU follows below truth table to select which payload to execute: 67 68===== ========== ======= 69-bios -kernel payload 70===== ========== ======= 71 N N u-boot 72 N Y kernel 73 Y don't care u-boot 74===== ========== ======= 75 76When both -bios and -kernel are present, QEMU loads U-Boot and U-Boot in turns 77automatically loads the kernel image specified by the -kernel parameter via 78U-Boot's built-in "bootm" command, hence a legacy uImage format is required in 79such scenario. 80 81Running Linux kernel 82-------------------- 83 84Linux mainline v5.11 release is tested at the time of writing. To build a 85Linux mainline kernel that can be booted by the ``ppce500`` machine in 8664-bit mode, simply configure the kernel using the defconfig configuration: 87 88.. code-block:: bash 89 90 $ export ARCH=powerpc 91 $ export CROSS_COMPILE=powerpc-linux- 92 $ make corenet64_smp_defconfig 93 $ make menuconfig 94 95then manually select the following configuration: 96 97 Platform support > Freescale Book-E Machine Type > QEMU generic e500 platform 98 99To boot the newly built Linux kernel in QEMU with the ``ppce500`` machine: 100 101.. code-block:: bash 102 103 $ qemu-system-ppc64 -M ppce500 -cpu e5500 -smp 4 -m 2G \ 104 -display none -serial stdio \ 105 -kernel vmlinux \ 106 -initrd /path/to/rootfs.cpio \ 107 -append "root=/dev/ram" 108 109To build a Linux mainline kernel that can be booted by the ``ppce500`` machine 110in 32-bit mode, use the same 64-bit configuration steps except the defconfig 111file should use corenet32_smp_defconfig. 112 113To boot the 32-bit Linux kernel: 114 115.. code-block:: bash 116 117 $ qemu-system-ppc64 -M ppce500 -cpu e500mc -smp 4 -m 2G \ 118 -display none -serial stdio \ 119 -kernel vmlinux \ 120 -initrd /path/to/rootfs.cpio \ 121 -append "root=/dev/ram" 122 123Running U-Boot 124-------------- 125 126U-Boot mainline v2021.07 release is tested at the time of writing. To build a 127U-Boot mainline bootloader that can be booted by the ``ppce500`` machine, use 128the qemu-ppce500_defconfig with similar commands as described above for Linux: 129 130.. code-block:: bash 131 132 $ export CROSS_COMPILE=powerpc-linux- 133 $ make qemu-ppce500_defconfig 134 135You will get u-boot file in the build tree. 136 137When U-Boot boots, you will notice the following if using with ``-cpu e6500``: 138 139.. code-block:: none 140 141 CPU: Unknown, Version: 0.0, (0x00000000) 142 Core: e6500, Version: 2.0, (0x80400020) 143 144This is because we only specified a core name to QEMU and it does not have a 145meaningful SVR value which represents an actual SoC that integrates such core. 146You can specify a real world SoC device that QEMU has built-in support but all 147these SoCs are e500v2 based MPC85xx series, hence you cannot test anything 148built for P4080 (e500mc), P5020 (e5500) and T2080 (e6500). 149 150Networking 151---------- 152 153By default a VirtIO standard PCI networking device is connected as an ethernet 154interface at PCI address 0.1.0, but we can switch that to an e1000 NIC by: 155 156.. code-block:: bash 157 158 $ qemu-system-ppc64 -M ppce500 -smp 4 -m 2G \ 159 -display none -serial stdio \ 160 -bios u-boot \ 161 -nic tap,ifname=tap0,script=no,downscript=no,model=e1000 162 163The QEMU ``ppce500`` machine can also dynamically instantiate an eTSEC device 164if “-device eTSEC” is given to QEMU: 165 166.. code-block:: bash 167 168 -netdev tap,ifname=tap0,script=no,downscript=no,id=net0 -device eTSEC,netdev=net0 169 170Root file system on flash drive 171------------------------------- 172 173Rather than using a root file system on ram disk, it is possible to have it on 174CFI flash. Given an ext2 image whose size must be a power of two, it can be used 175as follows: 176 177.. code-block:: bash 178 179 $ qemu-system-ppc64 -M ppce500 -cpu e500mc -smp 4 -m 2G \ 180 -display none -serial stdio \ 181 -kernel vmlinux \ 182 -drive if=pflash,file=/path/to/rootfs.ext2,format=raw \ 183 -append "rootwait root=/dev/mtdblock0" 184 185Alternatively, the root file system can also reside on an emulated SD card 186whose size must again be a power of two: 187 188.. code-block:: bash 189 190 $ qemu-system-ppc64 -M ppce500 -cpu e500mc -smp 4 -m 2G \ 191 -display none -serial stdio \ 192 -kernel vmlinux \ 193 -device sd-card,drive=mydrive \ 194 -drive id=mydrive,if=none,file=/path/to/rootfs.ext2,format=raw \ 195 -append "rootwait root=/dev/mmcblk0" 196