xref: /openbmc/qemu/docs/system/ppc/ppce500.rst (revision 37337472)
1*37337472SBin Mengppce500 generic platform (``ppce500``)
2*37337472SBin Meng======================================
3*37337472SBin Meng
4*37337472SBin MengQEMU for PPC supports a special ``ppce500`` machine designed for emulation and
5*37337472SBin Mengvirtualization purposes.
6*37337472SBin Meng
7*37337472SBin MengSupported devices
8*37337472SBin Meng-----------------
9*37337472SBin Meng
10*37337472SBin MengThe ``ppce500`` machine supports the following devices:
11*37337472SBin Meng
12*37337472SBin Meng* PowerPC e500 series core (e500v2/e500mc/e5500/e6500)
13*37337472SBin Meng* Configuration, Control, and Status Register (CCSR)
14*37337472SBin Meng* Multicore Programmable Interrupt Controller (MPIC) with MSI support
15*37337472SBin Meng* 1 16550A UART device
16*37337472SBin Meng* 1 Freescale MPC8xxx I2C controller
17*37337472SBin Meng* 1 Pericom pt7c4338 RTC via I2C
18*37337472SBin Meng* 1 Freescale MPC8xxx GPIO controller
19*37337472SBin Meng* Power-off functionality via one GPIO pin
20*37337472SBin Meng* 1 Freescale MPC8xxx PCI host controller
21*37337472SBin Meng* VirtIO devices via PCI bus
22*37337472SBin Meng
23*37337472SBin MengHardware configuration information
24*37337472SBin Meng----------------------------------
25*37337472SBin Meng
26*37337472SBin MengThe ``ppce500`` machine automatically generates a device tree blob ("dtb")
27*37337472SBin Mengwhich it passes to the guest, if there is no ``-dtb`` option. This provides
28*37337472SBin Menginformation about the addresses, interrupt lines and other configuration of
29*37337472SBin Mengthe various devices in the system.
30*37337472SBin Meng
31*37337472SBin MengIf users want to provide their own DTB, they can use the ``-dtb`` option.
32*37337472SBin MengThese DTBs should have the following requirements:
33*37337472SBin Meng
34*37337472SBin Meng* The number of subnodes under /cpus node should match QEMU's ``-smp`` option
35*37337472SBin Meng* The /memory reg size should match QEMU’s selected ram_size via ``-m``
36*37337472SBin Meng
37*37337472SBin MengBoth ``qemu-system-ppc`` and ``qemu-system-ppc64`` provide emulation for the
38*37337472SBin Mengfollowing 32-bit PowerPC CPUs:
39*37337472SBin Meng
40*37337472SBin Meng* e500v2
41*37337472SBin Meng* e500mc
42*37337472SBin Meng
43*37337472SBin MengAdditionally ``qemu-system-ppc64`` provides support for the following 64-bit
44*37337472SBin MengPowerPC CPUs:
45*37337472SBin Meng
46*37337472SBin Meng* e5500
47*37337472SBin Meng* e6500
48*37337472SBin Meng
49*37337472SBin MengThe CPU type can be specified via the ``-cpu`` command line. If not specified,
50*37337472SBin Mengit creates a machine with e500v2 core. The following example shows an e6500
51*37337472SBin Mengbased machine creation:
52*37337472SBin Meng
53*37337472SBin Meng.. code-block:: bash
54*37337472SBin Meng
55*37337472SBin Meng  $ qemu-system-ppc64 -nographic -M ppce500 -cpu e6500
56*37337472SBin Meng
57*37337472SBin MengBoot options
58*37337472SBin Meng------------
59*37337472SBin Meng
60*37337472SBin MengThe ``ppce500`` machine can start using the standard -kernel functionality
61*37337472SBin Mengfor loading a payload like an OS kernel (e.g.: Linux), or U-Boot firmware.
62*37337472SBin Meng
63*37337472SBin MengWhen -bios is omitted, the default pc-bios/u-boot.e500 firmware image is used
64*37337472SBin Mengas the BIOS. QEMU follows below truth table to select which payload to execute:
65*37337472SBin Meng
66*37337472SBin Meng===== ========== =======
67*37337472SBin Meng-bios    -kernel payload
68*37337472SBin Meng===== ========== =======
69*37337472SBin Meng    N          N  u-boot
70*37337472SBin Meng    N          Y  kernel
71*37337472SBin Meng    Y don't care  u-boot
72*37337472SBin Meng===== ========== =======
73*37337472SBin Meng
74*37337472SBin MengWhen both -bios and -kernel are present, QEMU loads U-Boot and U-Boot in turns
75*37337472SBin Mengautomatically loads the kernel image specified by the -kernel parameter via
76*37337472SBin MengU-Boot's built-in "bootm" command, hence a legacy uImage format is required in
77*37337472SBin Mengsuch senario.
78*37337472SBin Meng
79*37337472SBin MengRunning Linux kernel
80*37337472SBin Meng--------------------
81*37337472SBin Meng
82*37337472SBin MengLinux mainline v5.11 release is tested at the time of writing. To build a
83*37337472SBin MengLinux mainline kernel that can be booted by the ``ppce500`` machine in
84*37337472SBin Meng64-bit mode, simply configure the kernel using the defconfig configuration:
85*37337472SBin Meng
86*37337472SBin Meng.. code-block:: bash
87*37337472SBin Meng
88*37337472SBin Meng  $ export ARCH=powerpc
89*37337472SBin Meng  $ export CROSS_COMPILE=powerpc-linux-
90*37337472SBin Meng  $ make corenet64_smp_defconfig
91*37337472SBin Meng  $ make menuconfig
92*37337472SBin Meng
93*37337472SBin Mengthen manually select the following configuration:
94*37337472SBin Meng
95*37337472SBin Meng  Platform support > Freescale Book-E Machine Type > QEMU generic e500 platform
96*37337472SBin Meng
97*37337472SBin MengTo boot the newly built Linux kernel in QEMU with the ``ppce500`` machine:
98*37337472SBin Meng
99*37337472SBin Meng.. code-block:: bash
100*37337472SBin Meng
101*37337472SBin Meng  $ qemu-system-ppc64 -M ppce500 -cpu e5500 -smp 4 -m 2G \
102*37337472SBin Meng      -display none -serial stdio \
103*37337472SBin Meng      -kernel vmlinux \
104*37337472SBin Meng      -initrd /path/to/rootfs.cpio \
105*37337472SBin Meng      -append "root=/dev/ram"
106*37337472SBin Meng
107*37337472SBin MengTo build a Linux mainline kernel that can be booted by the ``ppce500`` machine
108*37337472SBin Mengin 32-bit mode, use the same 64-bit configuration steps except the defconfig
109*37337472SBin Mengfile should use corenet32_smp_defconfig.
110*37337472SBin Meng
111*37337472SBin MengTo boot the 32-bit Linux kernel:
112*37337472SBin Meng
113*37337472SBin Meng.. code-block:: bash
114*37337472SBin Meng
115*37337472SBin Meng  $ qemu-system-ppc{64|32} -M ppce500 -cpu e500mc -smp 4 -m 2G \
116*37337472SBin Meng      -display none -serial stdio \
117*37337472SBin Meng      -kernel vmlinux \
118*37337472SBin Meng      -initrd /path/to/rootfs.cpio \
119*37337472SBin Meng      -append "root=/dev/ram"
120*37337472SBin Meng
121*37337472SBin MengRunning U-Boot
122*37337472SBin Meng--------------
123*37337472SBin Meng
124*37337472SBin MengU-Boot mainline v2021.04 release is tested at the time of writing. To build a
125*37337472SBin MengU-Boot mainline bootloader that can be booted by the ``ppce500`` machine, use
126*37337472SBin Mengthe qemu-ppce500_defconfig with similar commands as described above for Linux:
127*37337472SBin Meng
128*37337472SBin Meng.. code-block:: bash
129*37337472SBin Meng
130*37337472SBin Meng  $ export CROSS_COMPILE=powerpc-linux-
131*37337472SBin Meng  $ make qemu-ppce500_defconfig
132*37337472SBin Meng
133*37337472SBin MengYou will get u-boot file in the build tree.
134*37337472SBin Meng
135*37337472SBin MengWhen U-Boot boots, you will notice the following if using with ``-cpu e6500``:
136*37337472SBin Meng
137*37337472SBin Meng.. code-block:: none
138*37337472SBin Meng
139*37337472SBin Meng  CPU:   Unknown, Version: 0.0, (0x00000000)
140*37337472SBin Meng  Core:  e6500, Version: 2.0, (0x80400020)
141*37337472SBin Meng
142*37337472SBin MengThis is because we only specified a core name to QEMU and it does not have a
143*37337472SBin Mengmeaningful SVR value which represents an actual SoC that integrates such core.
144*37337472SBin MengYou can specify a real world SoC device that QEMU has built-in support but all
145*37337472SBin Mengthese SoCs are e500v2 based MPC85xx series, hence you cannot test anything
146*37337472SBin Mengbuilt for P4080 (e500mc), P5020 (e5500) and T2080 (e6500).
147*37337472SBin Meng
148*37337472SBin MengBy default a VirtIO standard PCI networking device is connected as an ethernet
149*37337472SBin Menginterface at PCI address 0.1.0, but we can switch that to an e1000 NIC by:
150*37337472SBin Meng
151*37337472SBin Meng.. code-block:: bash
152*37337472SBin Meng
153*37337472SBin Meng  $ qemu-system-ppc -M ppce500 -smp 4 -m 2G \
154*37337472SBin Meng                    -display none -serial stdio \
155*37337472SBin Meng                    -bios u-boot \
156*37337472SBin Meng                    -nic tap,ifname=tap0,script=no,downscript=no,model=e1000
157