xref: /qemu/docs/system/ppc/ppce500.rst (revision d0fb9657)
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
23Hardware configuration information
24----------------------------------
25
26The ``ppce500`` machine automatically generates a device tree blob ("dtb")
27which it passes to the guest, if there is no ``-dtb`` option. This provides
28information about the addresses, interrupt lines and other configuration of
29the various devices in the system.
30
31If users want to provide their own DTB, they can use the ``-dtb`` option.
32These DTBs should have the following requirements:
33
34* The number of subnodes under /cpus node should match QEMU's ``-smp`` option
35* The /memory reg size should match QEMU’s selected ram_size via ``-m``
36
37Both ``qemu-system-ppc`` and ``qemu-system-ppc64`` provide emulation for the
38following 32-bit PowerPC CPUs:
39
40* e500v2
41* e500mc
42
43Additionally ``qemu-system-ppc64`` provides support for the following 64-bit
44PowerPC CPUs:
45
46* e5500
47* e6500
48
49The CPU type can be specified via the ``-cpu`` command line. If not specified,
50it creates a machine with e500v2 core. The following example shows an e6500
51based machine creation:
52
53.. code-block:: bash
54
55  $ qemu-system-ppc64 -nographic -M ppce500 -cpu e6500
56
57Boot options
58------------
59
60The ``ppce500`` machine can start using the standard -kernel functionality
61for loading a payload like an OS kernel (e.g.: Linux), or U-Boot firmware.
62
63When -bios is omitted, the default pc-bios/u-boot.e500 firmware image is used
64as the BIOS. QEMU follows below truth table to select which payload to execute:
65
66===== ========== =======
67-bios    -kernel payload
68===== ========== =======
69    N          N  u-boot
70    N          Y  kernel
71    Y don't care  u-boot
72===== ========== =======
73
74When both -bios and -kernel are present, QEMU loads U-Boot and U-Boot in turns
75automatically loads the kernel image specified by the -kernel parameter via
76U-Boot's built-in "bootm" command, hence a legacy uImage format is required in
77such senario.
78
79Running Linux kernel
80--------------------
81
82Linux mainline v5.11 release is tested at the time of writing. To build a
83Linux mainline kernel that can be booted by the ``ppce500`` machine in
8464-bit mode, simply configure the kernel using the defconfig configuration:
85
86.. code-block:: bash
87
88  $ export ARCH=powerpc
89  $ export CROSS_COMPILE=powerpc-linux-
90  $ make corenet64_smp_defconfig
91  $ make menuconfig
92
93then manually select the following configuration:
94
95  Platform support > Freescale Book-E Machine Type > QEMU generic e500 platform
96
97To boot the newly built Linux kernel in QEMU with the ``ppce500`` machine:
98
99.. code-block:: bash
100
101  $ qemu-system-ppc64 -M ppce500 -cpu e5500 -smp 4 -m 2G \
102      -display none -serial stdio \
103      -kernel vmlinux \
104      -initrd /path/to/rootfs.cpio \
105      -append "root=/dev/ram"
106
107To build a Linux mainline kernel that can be booted by the ``ppce500`` machine
108in 32-bit mode, use the same 64-bit configuration steps except the defconfig
109file should use corenet32_smp_defconfig.
110
111To boot the 32-bit Linux kernel:
112
113.. code-block:: bash
114
115  $ qemu-system-ppc{64|32} -M ppce500 -cpu e500mc -smp 4 -m 2G \
116      -display none -serial stdio \
117      -kernel vmlinux \
118      -initrd /path/to/rootfs.cpio \
119      -append "root=/dev/ram"
120
121Running U-Boot
122--------------
123
124U-Boot mainline v2021.04 release is tested at the time of writing. To build a
125U-Boot mainline bootloader that can be booted by the ``ppce500`` machine, use
126the qemu-ppce500_defconfig with similar commands as described above for Linux:
127
128.. code-block:: bash
129
130  $ export CROSS_COMPILE=powerpc-linux-
131  $ make qemu-ppce500_defconfig
132
133You will get u-boot file in the build tree.
134
135When U-Boot boots, you will notice the following if using with ``-cpu e6500``:
136
137.. code-block:: none
138
139  CPU:   Unknown, Version: 0.0, (0x00000000)
140  Core:  e6500, Version: 2.0, (0x80400020)
141
142This is because we only specified a core name to QEMU and it does not have a
143meaningful SVR value which represents an actual SoC that integrates such core.
144You can specify a real world SoC device that QEMU has built-in support but all
145these SoCs are e500v2 based MPC85xx series, hence you cannot test anything
146built for P4080 (e500mc), P5020 (e5500) and T2080 (e6500).
147
148By default a VirtIO standard PCI networking device is connected as an ethernet
149interface at PCI address 0.1.0, but we can switch that to an e1000 NIC by:
150
151.. code-block:: bash
152
153  $ qemu-system-ppc -M ppce500 -smp 4 -m 2G \
154                    -display none -serial stdio \
155                    -bios u-boot \
156                    -nic tap,ifname=tap0,script=no,downscript=no,model=e1000
157