master
rst 195 lines 6.32 KB
Raw
1 ppce500 generic platform (``ppce500``)
2 ======================================
3
4 QEMU for PPC supports a special ``ppce500`` machine designed for emulation and
5 virtualization purposes.
6
7 Supported devices
8 -----------------
9
10 The ``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
25 Hardware configuration information
26 ----------------------------------
27
28 The ``ppce500`` machine automatically generates a device tree blob ("dtb")
29 which it passes to the guest, if there is no ``-dtb`` option. This provides
30 information about the addresses, interrupt lines and other configuration of
31 the various devices in the system.
32
33 If users want to provide their own DTB, they can use the ``-dtb`` option.
34 These 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
39 Both ``qemu-system-ppc`` and ``qemu-system-ppc64`` provide emulation for the
40 following 32-bit PowerPC CPUs:
41
42 * e500v2
43 * e500mc
44
45 Additionally ``qemu-system-ppc64`` provides support for the following 64-bit
46 PowerPC CPUs:
47
48 * e5500
49 * e6500
50
51 The CPU type can be specified via the ``-cpu`` command line. If not specified,
52 it creates a machine with e500v2 core. The following example shows an e6500
53 based machine creation:
54
55 .. code-block:: bash
56
57 $ qemu-system-ppc64 -nographic -M ppce500 -cpu e6500
58
59 Boot options
60 ------------
61
62 The ``ppce500`` machine can start using the standard -kernel functionality
63 for loading a payload like an OS kernel (e.g.: Linux), or U-Boot firmware.
64
65 When -bios is omitted, the default pc-bios/u-boot.e500 firmware image is used
66 as 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
76 When both -bios and -kernel are present, QEMU loads U-Boot and U-Boot in turns
77 automatically loads the kernel image specified by the -kernel parameter via
78 U-Boot's built-in "bootm" command, hence a legacy uImage format is required in
79 such scenario.
80
81 Running Linux kernel
82 --------------------
83
84 Linux mainline v5.11 release is tested at the time of writing. To build a
85 Linux mainline kernel that can be booted by the ``ppce500`` machine in
86 64-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
95 then manually select the following configuration:
96
97 Platform support > Freescale Book-E Machine Type > QEMU generic e500 platform
98
99 To 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
109 To build a Linux mainline kernel that can be booted by the ``ppce500`` machine
110 in 32-bit mode, use the same 64-bit configuration steps except the defconfig
111 file should use corenet32_smp_defconfig.
112
113 To 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
123 Running U-Boot
124 --------------
125
126 U-Boot mainline v2021.07 release is tested at the time of writing. To build a
127 U-Boot mainline bootloader that can be booted by the ``ppce500`` machine, use
128 the 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
135 You will get u-boot file in the build tree.
136
137 When 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
144 This is because we only specified a core name to QEMU and it does not have a
145 meaningful SVR value which represents an actual SoC that integrates such core.
146 You can specify a real world SoC device that QEMU has built-in support but all
147 these SoCs are e500v2 based MPC85xx series, hence you cannot test anything
148 built for P4080 (e500mc), P5020 (e5500) and T2080 (e6500).
149
150 Networking
151 ----------
152
153 By default a VirtIO standard PCI networking device is connected as an ethernet
154 interface 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
163 The QEMU ``ppce500`` machine can also dynamically instantiate an eTSEC device
164 if “-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
170 Root file system on flash drive
171 -------------------------------
172
173 Rather than using a root file system on ram disk, it is possible to have it on
174 CFI flash. Given an ext2 image whose size must be a power of two, it can be used
175 as 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
185 Alternatively, the root file system can also reside on an emulated SD card
186 whose 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"