xref: /openbmc/qemu/docs/system/ppc/ppce500.rst (revision ea413970)
137337472SBin Mengppce500 generic platform (``ppce500``)
237337472SBin Meng======================================
337337472SBin Meng
437337472SBin MengQEMU for PPC supports a special ``ppce500`` machine designed for emulation and
537337472SBin Mengvirtualization purposes.
637337472SBin Meng
737337472SBin MengSupported devices
837337472SBin Meng-----------------
937337472SBin Meng
1037337472SBin MengThe ``ppce500`` machine supports the following devices:
1137337472SBin Meng
1237337472SBin Meng* PowerPC e500 series core (e500v2/e500mc/e5500/e6500)
1337337472SBin Meng* Configuration, Control, and Status Register (CCSR)
1437337472SBin Meng* Multicore Programmable Interrupt Controller (MPIC) with MSI support
1537337472SBin Meng* 1 16550A UART device
1637337472SBin Meng* 1 Freescale MPC8xxx I2C controller
1737337472SBin Meng* 1 Pericom pt7c4338 RTC via I2C
1837337472SBin Meng* 1 Freescale MPC8xxx GPIO controller
1937337472SBin Meng* Power-off functionality via one GPIO pin
2037337472SBin Meng* 1 Freescale MPC8xxx PCI host controller
2137337472SBin Meng* VirtIO devices via PCI bus
22*ea413970SBin Meng* 1 Freescale Enhanced Triple Speed Ethernet controller (eTSEC)
2337337472SBin Meng
2437337472SBin MengHardware configuration information
2537337472SBin Meng----------------------------------
2637337472SBin Meng
2737337472SBin MengThe ``ppce500`` machine automatically generates a device tree blob ("dtb")
2837337472SBin Mengwhich it passes to the guest, if there is no ``-dtb`` option. This provides
2937337472SBin Menginformation about the addresses, interrupt lines and other configuration of
3037337472SBin Mengthe various devices in the system.
3137337472SBin Meng
3237337472SBin MengIf users want to provide their own DTB, they can use the ``-dtb`` option.
3337337472SBin MengThese DTBs should have the following requirements:
3437337472SBin Meng
3537337472SBin Meng* The number of subnodes under /cpus node should match QEMU's ``-smp`` option
3637337472SBin Meng* The /memory reg size should match QEMU’s selected ram_size via ``-m``
3737337472SBin Meng
3837337472SBin MengBoth ``qemu-system-ppc`` and ``qemu-system-ppc64`` provide emulation for the
3937337472SBin Mengfollowing 32-bit PowerPC CPUs:
4037337472SBin Meng
4137337472SBin Meng* e500v2
4237337472SBin Meng* e500mc
4337337472SBin Meng
4437337472SBin MengAdditionally ``qemu-system-ppc64`` provides support for the following 64-bit
4537337472SBin MengPowerPC CPUs:
4637337472SBin Meng
4737337472SBin Meng* e5500
4837337472SBin Meng* e6500
4937337472SBin Meng
5037337472SBin MengThe CPU type can be specified via the ``-cpu`` command line. If not specified,
5137337472SBin Mengit creates a machine with e500v2 core. The following example shows an e6500
5237337472SBin Mengbased machine creation:
5337337472SBin Meng
5437337472SBin Meng.. code-block:: bash
5537337472SBin Meng
5637337472SBin Meng  $ qemu-system-ppc64 -nographic -M ppce500 -cpu e6500
5737337472SBin Meng
5837337472SBin MengBoot options
5937337472SBin Meng------------
6037337472SBin Meng
6137337472SBin MengThe ``ppce500`` machine can start using the standard -kernel functionality
6237337472SBin Mengfor loading a payload like an OS kernel (e.g.: Linux), or U-Boot firmware.
6337337472SBin Meng
6437337472SBin MengWhen -bios is omitted, the default pc-bios/u-boot.e500 firmware image is used
6537337472SBin Mengas the BIOS. QEMU follows below truth table to select which payload to execute:
6637337472SBin Meng
6737337472SBin Meng===== ========== =======
6837337472SBin Meng-bios    -kernel payload
6937337472SBin Meng===== ========== =======
7037337472SBin Meng    N          N  u-boot
7137337472SBin Meng    N          Y  kernel
7237337472SBin Meng    Y don't care  u-boot
7337337472SBin Meng===== ========== =======
7437337472SBin Meng
7537337472SBin MengWhen both -bios and -kernel are present, QEMU loads U-Boot and U-Boot in turns
7637337472SBin Mengautomatically loads the kernel image specified by the -kernel parameter via
7737337472SBin MengU-Boot's built-in "bootm" command, hence a legacy uImage format is required in
7837337472SBin Mengsuch senario.
7937337472SBin Meng
8037337472SBin MengRunning Linux kernel
8137337472SBin Meng--------------------
8237337472SBin Meng
8337337472SBin MengLinux mainline v5.11 release is tested at the time of writing. To build a
8437337472SBin MengLinux mainline kernel that can be booted by the ``ppce500`` machine in
8537337472SBin Meng64-bit mode, simply configure the kernel using the defconfig configuration:
8637337472SBin Meng
8737337472SBin Meng.. code-block:: bash
8837337472SBin Meng
8937337472SBin Meng  $ export ARCH=powerpc
9037337472SBin Meng  $ export CROSS_COMPILE=powerpc-linux-
9137337472SBin Meng  $ make corenet64_smp_defconfig
9237337472SBin Meng  $ make menuconfig
9337337472SBin Meng
9437337472SBin Mengthen manually select the following configuration:
9537337472SBin Meng
9637337472SBin Meng  Platform support > Freescale Book-E Machine Type > QEMU generic e500 platform
9737337472SBin Meng
9837337472SBin MengTo boot the newly built Linux kernel in QEMU with the ``ppce500`` machine:
9937337472SBin Meng
10037337472SBin Meng.. code-block:: bash
10137337472SBin Meng
10237337472SBin Meng  $ qemu-system-ppc64 -M ppce500 -cpu e5500 -smp 4 -m 2G \
10337337472SBin Meng      -display none -serial stdio \
10437337472SBin Meng      -kernel vmlinux \
10537337472SBin Meng      -initrd /path/to/rootfs.cpio \
10637337472SBin Meng      -append "root=/dev/ram"
10737337472SBin Meng
10837337472SBin MengTo build a Linux mainline kernel that can be booted by the ``ppce500`` machine
10937337472SBin Mengin 32-bit mode, use the same 64-bit configuration steps except the defconfig
11037337472SBin Mengfile should use corenet32_smp_defconfig.
11137337472SBin Meng
11237337472SBin MengTo boot the 32-bit Linux kernel:
11337337472SBin Meng
11437337472SBin Meng.. code-block:: bash
11537337472SBin Meng
11637337472SBin Meng  $ qemu-system-ppc{64|32} -M ppce500 -cpu e500mc -smp 4 -m 2G \
11737337472SBin Meng      -display none -serial stdio \
11837337472SBin Meng      -kernel vmlinux \
11937337472SBin Meng      -initrd /path/to/rootfs.cpio \
12037337472SBin Meng      -append "root=/dev/ram"
12137337472SBin Meng
12237337472SBin MengRunning U-Boot
12337337472SBin Meng--------------
12437337472SBin Meng
125*ea413970SBin MengU-Boot mainline v2021.07 release is tested at the time of writing. To build a
12637337472SBin MengU-Boot mainline bootloader that can be booted by the ``ppce500`` machine, use
12737337472SBin Mengthe qemu-ppce500_defconfig with similar commands as described above for Linux:
12837337472SBin Meng
12937337472SBin Meng.. code-block:: bash
13037337472SBin Meng
13137337472SBin Meng  $ export CROSS_COMPILE=powerpc-linux-
13237337472SBin Meng  $ make qemu-ppce500_defconfig
13337337472SBin Meng
13437337472SBin MengYou will get u-boot file in the build tree.
13537337472SBin Meng
13637337472SBin MengWhen U-Boot boots, you will notice the following if using with ``-cpu e6500``:
13737337472SBin Meng
13837337472SBin Meng.. code-block:: none
13937337472SBin Meng
14037337472SBin Meng  CPU:   Unknown, Version: 0.0, (0x00000000)
14137337472SBin Meng  Core:  e6500, Version: 2.0, (0x80400020)
14237337472SBin Meng
14337337472SBin MengThis is because we only specified a core name to QEMU and it does not have a
14437337472SBin Mengmeaningful SVR value which represents an actual SoC that integrates such core.
14537337472SBin MengYou can specify a real world SoC device that QEMU has built-in support but all
14637337472SBin Mengthese SoCs are e500v2 based MPC85xx series, hence you cannot test anything
14737337472SBin Mengbuilt for P4080 (e500mc), P5020 (e5500) and T2080 (e6500).
14837337472SBin Meng
14937337472SBin MengBy default a VirtIO standard PCI networking device is connected as an ethernet
15037337472SBin Menginterface at PCI address 0.1.0, but we can switch that to an e1000 NIC by:
15137337472SBin Meng
15237337472SBin Meng.. code-block:: bash
15337337472SBin Meng
15437337472SBin Meng  $ qemu-system-ppc -M ppce500 -smp 4 -m 2G \
15537337472SBin Meng                    -display none -serial stdio \
15637337472SBin Meng                    -bios u-boot \
15737337472SBin Meng                    -nic tap,ifname=tap0,script=no,downscript=no,model=e1000
158*ea413970SBin Meng
159*ea413970SBin MengThe QEMU ``ppce500`` machine can also dynamically instantiate an eTSEC device
160*ea413970SBin Mengif “-device eTSEC” is given to QEMU:
161*ea413970SBin Meng
162*ea413970SBin Meng.. code-block:: bash
163*ea413970SBin Meng
164*ea413970SBin Meng  -netdev tap,ifname=tap0,script=no,downscript=no,id=net0 -device eTSEC,netdev=net0
165