master
rst 97 lines 2.79 KB
Raw
1 :orphan:
2
3 ==========================================
4 loongson3 virt generic platform (``virt``)
5 ==========================================
6
7 The ``virt`` machine use gpex host bridge, and there are some
8 emulated devices on virt board, such as loongson7a RTC device,
9 IOAPIC device, ACPI device and so on.
10
11 Supported devices
12 -----------------
13
14 The ``virt`` machine supports:
15
16 * Gpex host bridge
17 * Ls7a RTC device
18 * Ls7a IOAPIC device
19 * ACPI GED device
20 * Fw_cfg device
21 * PCI/PCIe devices
22 * Memory device
23 * CPU device. Type: la464.
24
25 CPU and machine Type
26 --------------------
27
28 The ``qemu-system-loongarch64`` provides emulation for virt
29 machine. You can specify the machine type ``virt`` and
30 cpu type ``la464``.
31
32 Boot options
33 ------------
34
35 We can boot the LoongArch virt machine by specifying the uefi bios,
36 initrd, and linux kernel. And those source codes and binary files
37 can be accessed by following steps.
38
39 (1) Build qemu-system-loongarch64:
40
41 .. code-block:: bash
42
43 ./configure --target-list="loongarch64-softmmu"
44 make -j8
45
46 (2) Set cross tools:
47
48 .. code-block:: bash
49
50 wget https://github.com/loongson/build-tools/releases/download/2022.09.06/loongarch64-clfs-6.3-cross-tools-gcc-glibc.tar.xz
51 tar -vxf loongarch64-clfs-6.3-cross-tools-gcc-glibc.tar.xz -C /opt
52 export PATH=/opt/cross-tools/bin:$PATH
53 export LD_LIBRARY_PATH=/opt/cross-tools/lib:$LD_LIBRARY_PATH
54 export LD_LIBRARY_PATH=/opt/cross-tools/loongarch64-unknown-linux-gnu/lib/:$LD_LIBRARY_PATH
55
56 Note: You need get the latest cross-tools at https://github.com/loongson/build-tools
57
58 (3) Build BIOS:
59
60 See: https://github.com/tianocore/edk2/tree/master/OvmfPkg/LoongArchVirt#readme
61
62 Note: To build the release version of the bios, set --buildtarget=RELEASE,
63 the bios file path: Build/LoongArchQemu/RELEASE_GCC5/FV/QEMU_EFI.fd
64
65 (4) Build kernel:
66
67 .. code-block:: bash
68
69 git clone https://github.com/loongson/linux.git
70 cd linux
71 git checkout loongarch-next
72 make ARCH=loongarch CROSS_COMPILE=loongarch64-unknown-linux-gnu- loongson3_defconfig
73 make ARCH=loongarch CROSS_COMPILE=loongarch64-unknown-linux-gnu- -j32
74
75 Note: The branch of linux source code is loongarch-next.
76 the kernel file: arch/loongarch/boot/vmlinuz.efi
77
78 (5) Get initrd:
79
80 You can use busybox tool and the linux modules to make a initrd file. Or you can access the
81 binary files: https://github.com/yangxiaojuan-loongson/qemu-binary
82
83 .. code-block:: bash
84
85 git clone https://github.com/yangxiaojuan-loongson/qemu-binary
86
87 Note: the initrd file is ramdisk
88
89 (6) Booting LoongArch:
90
91 .. code-block:: bash
92
93 $ ./build/qemu-system-loongarch64 -machine virt -m 4G -cpu la464 \
94 -smp 1 -bios QEMU_EFI.fd -kernel vmlinuz.efi -initrd ramdisk \
95 -serial stdio -monitor telnet:localhost:4495,server,nowait \
96 -append "root=/dev/ram rdinit=/sbin/init console=ttyS0,115200" \
97 --nographic