xref: /openbmc/qemu/docs/system/ppc/ppce500.rst (revision 3f288c4b)
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*3f288c4bSPhilippe Mathieu-Daudé* 1 Freescale Enhanced Secure Digital Host controller (eSDHC)
23ea413970SBin Meng* 1 Freescale Enhanced Triple Speed Ethernet controller (eTSEC)
2437337472SBin Meng
2537337472SBin MengHardware configuration information
2637337472SBin Meng----------------------------------
2737337472SBin Meng
2837337472SBin MengThe ``ppce500`` machine automatically generates a device tree blob ("dtb")
2937337472SBin Mengwhich it passes to the guest, if there is no ``-dtb`` option. This provides
3037337472SBin Menginformation about the addresses, interrupt lines and other configuration of
3137337472SBin Mengthe various devices in the system.
3237337472SBin Meng
3337337472SBin MengIf users want to provide their own DTB, they can use the ``-dtb`` option.
3437337472SBin MengThese DTBs should have the following requirements:
3537337472SBin Meng
3637337472SBin Meng* The number of subnodes under /cpus node should match QEMU's ``-smp`` option
3737337472SBin Meng* The /memory reg size should match QEMU’s selected ram_size via ``-m``
3837337472SBin Meng
3937337472SBin MengBoth ``qemu-system-ppc`` and ``qemu-system-ppc64`` provide emulation for the
4037337472SBin Mengfollowing 32-bit PowerPC CPUs:
4137337472SBin Meng
4237337472SBin Meng* e500v2
4337337472SBin Meng* e500mc
4437337472SBin Meng
4537337472SBin MengAdditionally ``qemu-system-ppc64`` provides support for the following 64-bit
4637337472SBin MengPowerPC CPUs:
4737337472SBin Meng
4837337472SBin Meng* e5500
4937337472SBin Meng* e6500
5037337472SBin Meng
5137337472SBin MengThe CPU type can be specified via the ``-cpu`` command line. If not specified,
5237337472SBin Mengit creates a machine with e500v2 core. The following example shows an e6500
5337337472SBin Mengbased machine creation:
5437337472SBin Meng
5537337472SBin Meng.. code-block:: bash
5637337472SBin Meng
5737337472SBin Meng  $ qemu-system-ppc64 -nographic -M ppce500 -cpu e6500
5837337472SBin Meng
5937337472SBin MengBoot options
6037337472SBin Meng------------
6137337472SBin Meng
6237337472SBin MengThe ``ppce500`` machine can start using the standard -kernel functionality
6337337472SBin Mengfor loading a payload like an OS kernel (e.g.: Linux), or U-Boot firmware.
6437337472SBin Meng
6537337472SBin MengWhen -bios is omitted, the default pc-bios/u-boot.e500 firmware image is used
6637337472SBin Mengas the BIOS. QEMU follows below truth table to select which payload to execute:
6737337472SBin Meng
6837337472SBin Meng===== ========== =======
6937337472SBin Meng-bios    -kernel payload
7037337472SBin Meng===== ========== =======
7137337472SBin Meng    N          N  u-boot
7237337472SBin Meng    N          Y  kernel
7337337472SBin Meng    Y don't care  u-boot
7437337472SBin Meng===== ========== =======
7537337472SBin Meng
7637337472SBin MengWhen both -bios and -kernel are present, QEMU loads U-Boot and U-Boot in turns
7737337472SBin Mengautomatically loads the kernel image specified by the -kernel parameter via
7837337472SBin MengU-Boot's built-in "bootm" command, hence a legacy uImage format is required in
79b980c1aeSStefan Weilsuch scenario.
8037337472SBin Meng
8137337472SBin MengRunning Linux kernel
8237337472SBin Meng--------------------
8337337472SBin Meng
8437337472SBin MengLinux mainline v5.11 release is tested at the time of writing. To build a
8537337472SBin MengLinux mainline kernel that can be booted by the ``ppce500`` machine in
8637337472SBin Meng64-bit mode, simply configure the kernel using the defconfig configuration:
8737337472SBin Meng
8837337472SBin Meng.. code-block:: bash
8937337472SBin Meng
9037337472SBin Meng  $ export ARCH=powerpc
9137337472SBin Meng  $ export CROSS_COMPILE=powerpc-linux-
9237337472SBin Meng  $ make corenet64_smp_defconfig
9337337472SBin Meng  $ make menuconfig
9437337472SBin Meng
9537337472SBin Mengthen manually select the following configuration:
9637337472SBin Meng
9737337472SBin Meng  Platform support > Freescale Book-E Machine Type > QEMU generic e500 platform
9837337472SBin Meng
9937337472SBin MengTo boot the newly built Linux kernel in QEMU with the ``ppce500`` machine:
10037337472SBin Meng
10137337472SBin Meng.. code-block:: bash
10237337472SBin Meng
10337337472SBin Meng  $ qemu-system-ppc64 -M ppce500 -cpu e5500 -smp 4 -m 2G \
10437337472SBin Meng      -display none -serial stdio \
10537337472SBin Meng      -kernel vmlinux \
10637337472SBin Meng      -initrd /path/to/rootfs.cpio \
10737337472SBin Meng      -append "root=/dev/ram"
10837337472SBin Meng
10937337472SBin MengTo build a Linux mainline kernel that can be booted by the ``ppce500`` machine
11037337472SBin Mengin 32-bit mode, use the same 64-bit configuration steps except the defconfig
11137337472SBin Mengfile should use corenet32_smp_defconfig.
11237337472SBin Meng
11337337472SBin MengTo boot the 32-bit Linux kernel:
11437337472SBin Meng
11537337472SBin Meng.. code-block:: bash
11637337472SBin Meng
117c593d1ccSBernhard Beschow  $ qemu-system-ppc64 -M ppce500 -cpu e500mc -smp 4 -m 2G \
11837337472SBin Meng      -display none -serial stdio \
11937337472SBin Meng      -kernel vmlinux \
12037337472SBin Meng      -initrd /path/to/rootfs.cpio \
12137337472SBin Meng      -append "root=/dev/ram"
12237337472SBin Meng
12337337472SBin MengRunning U-Boot
12437337472SBin Meng--------------
12537337472SBin Meng
126ea413970SBin MengU-Boot mainline v2021.07 release is tested at the time of writing. To build a
12737337472SBin MengU-Boot mainline bootloader that can be booted by the ``ppce500`` machine, use
12837337472SBin Mengthe qemu-ppce500_defconfig with similar commands as described above for Linux:
12937337472SBin Meng
13037337472SBin Meng.. code-block:: bash
13137337472SBin Meng
13237337472SBin Meng  $ export CROSS_COMPILE=powerpc-linux-
13337337472SBin Meng  $ make qemu-ppce500_defconfig
13437337472SBin Meng
13537337472SBin MengYou will get u-boot file in the build tree.
13637337472SBin Meng
13737337472SBin MengWhen U-Boot boots, you will notice the following if using with ``-cpu e6500``:
13837337472SBin Meng
13937337472SBin Meng.. code-block:: none
14037337472SBin Meng
14137337472SBin Meng  CPU:   Unknown, Version: 0.0, (0x00000000)
14237337472SBin Meng  Core:  e6500, Version: 2.0, (0x80400020)
14337337472SBin Meng
14437337472SBin MengThis is because we only specified a core name to QEMU and it does not have a
14537337472SBin Mengmeaningful SVR value which represents an actual SoC that integrates such core.
14637337472SBin MengYou can specify a real world SoC device that QEMU has built-in support but all
14737337472SBin Mengthese SoCs are e500v2 based MPC85xx series, hence you cannot test anything
14837337472SBin Mengbuilt for P4080 (e500mc), P5020 (e5500) and T2080 (e6500).
14937337472SBin Meng
150e018489dSBernhard BeschowNetworking
151e018489dSBernhard Beschow----------
152e018489dSBernhard Beschow
15337337472SBin MengBy default a VirtIO standard PCI networking device is connected as an ethernet
15437337472SBin Menginterface at PCI address 0.1.0, but we can switch that to an e1000 NIC by:
15537337472SBin Meng
15637337472SBin Meng.. code-block:: bash
15737337472SBin Meng
158c593d1ccSBernhard Beschow  $ qemu-system-ppc64 -M ppce500 -smp 4 -m 2G \
15937337472SBin Meng                      -display none -serial stdio \
16037337472SBin Meng                      -bios u-boot \
16137337472SBin Meng                      -nic tap,ifname=tap0,script=no,downscript=no,model=e1000
162ea413970SBin Meng
163ea413970SBin MengThe QEMU ``ppce500`` machine can also dynamically instantiate an eTSEC device
164ea413970SBin Mengif “-device eTSEC” is given to QEMU:
165ea413970SBin Meng
166ea413970SBin Meng.. code-block:: bash
167ea413970SBin Meng
168ea413970SBin Meng  -netdev tap,ifname=tap0,script=no,downscript=no,id=net0 -device eTSEC,netdev=net0
16963e4bf8eSBernhard Beschow
17063e4bf8eSBernhard BeschowRoot file system on flash drive
17163e4bf8eSBernhard Beschow-------------------------------
17263e4bf8eSBernhard Beschow
17363e4bf8eSBernhard BeschowRather than using a root file system on ram disk, it is possible to have it on
17463e4bf8eSBernhard BeschowCFI flash. Given an ext2 image whose size must be a power of two, it can be used
17563e4bf8eSBernhard Beschowas follows:
17663e4bf8eSBernhard Beschow
17763e4bf8eSBernhard Beschow.. code-block:: bash
17863e4bf8eSBernhard Beschow
17963e4bf8eSBernhard Beschow  $ qemu-system-ppc64 -M ppce500 -cpu e500mc -smp 4 -m 2G \
18063e4bf8eSBernhard Beschow      -display none -serial stdio \
18163e4bf8eSBernhard Beschow      -kernel vmlinux \
18263e4bf8eSBernhard Beschow      -drive if=pflash,file=/path/to/rootfs.ext2,format=raw \
18363e4bf8eSBernhard Beschow      -append "rootwait root=/dev/mtdblock0"
184*3f288c4bSPhilippe Mathieu-Daudé
185*3f288c4bSPhilippe Mathieu-DaudéAlternatively, the root file system can also reside on an emulated SD card
186*3f288c4bSPhilippe Mathieu-Daudéwhose size must again be a power of two:
187*3f288c4bSPhilippe Mathieu-Daudé
188*3f288c4bSPhilippe Mathieu-Daudé.. code-block:: bash
189*3f288c4bSPhilippe Mathieu-Daudé
190*3f288c4bSPhilippe Mathieu-Daudé  $ qemu-system-ppc64 -M ppce500 -cpu e500mc -smp 4 -m 2G \
191*3f288c4bSPhilippe Mathieu-Daudé      -display none -serial stdio \
192*3f288c4bSPhilippe Mathieu-Daudé      -kernel vmlinux \
193*3f288c4bSPhilippe Mathieu-Daudé      -device sd-card,drive=mydrive \
194*3f288c4bSPhilippe Mathieu-Daudé      -drive id=mydrive,if=none,file=/path/to/rootfs.ext2,format=raw \
195*3f288c4bSPhilippe Mathieu-Daudé      -append "rootwait root=/dev/mmcblk0"
196