loongson3.rst (3753B)
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 - Gpex host bridge 16 - Ls7a RTC device 17 - Ls7a IOAPIC device 18 - ACPI GED device 19 - Fw_cfg device 20 - PCI/PCIe devices 21 - Memory device 22 - CPU device. Type: la464-loongarch-cpu. 23 24 CPU and machine Type 25 -------------------- 26 27 The ``qemu-system-loongarch64`` provides emulation for virt 28 machine. You can specify the machine type ``virt`` and 29 cpu type ``la464-loongarch-cpu``. 30 31 Boot options 32 ------------ 33 34 We can boot the LoongArch virt machine by specifying the uefi bios, 35 initrd, and linux kernel. And those source codes and binary files 36 can be accessed by following steps. 37 38 (1) booting command: 39 40 .. code-block:: bash 41 42 $ qemu-system-loongarch64 -machine virt -m 4G -cpu la464-loongarch-cpu \ 43 -smp 1 -bios QEMU_EFI.fd -kernel vmlinuz.efi -initrd initrd.img \ 44 -append "root=/dev/ram rdinit=/sbin/init console=ttyS0,115200" \ 45 --nographic 46 47 Note: The running speed may be a little slow, as the performance of our 48 qemu and uefi bios is not perfect, and it is being fixed. 49 50 (2) cross compiler tools: 51 52 .. code-block:: bash 53 54 wget https://github.com/loongson/build-tools/releases/download/ \ 55 2022.05.29/loongarch64-clfs-5.0-cross-tools-gcc-full.tar.xz 56 57 tar -vxf loongarch64-clfs-5.0-cross-tools-gcc-full.tar.xz 58 59 (3) qemu compile configure option: 60 61 .. code-block:: bash 62 63 ./configure --disable-rdma --disable-pvrdma --prefix=usr \ 64 --target-list="loongarch64-softmmu" \ 65 --disable-libiscsi --disable-libnfs --disable-libpmem \ 66 --disable-glusterfs --enable-libusb --enable-usb-redir \ 67 --disable-opengl --disable-xen --enable-spice \ 68 --enable-debug --disable-capstone --disable-kvm \ 69 --enable-profiler 70 make 71 72 (4) uefi bios source code and compile method: 73 74 .. code-block:: bash 75 76 git clone https://github.com/loongson/edk2-LoongarchVirt.git 77 78 cd edk2-LoongarchVirt 79 80 git submodule update --init 81 82 export PATH=$YOUR_COMPILER_PATH/bin:$PATH 83 84 export WORKSPACE=`pwd` 85 86 export PACKAGES_PATH=$WORKSPACE/edk2-LoongarchVirt 87 88 export GCC5_LOONGARCH64_PREFIX=loongarch64-unknown-linux-gnu- 89 90 edk2-LoongarchVirt/edksetup.sh 91 92 make -C edk2-LoongarchVirt/BaseTools 93 94 build --buildtarget=DEBUG --tagname=GCC5 --arch=LOONGARCH64 --platform=OvmfPkg/LoongArchQemu/Loongson.dsc 95 96 build --buildtarget=RELEASE --tagname=GCC5 --arch=LOONGARCH64 --platform=OvmfPkg/LoongArchQemu/Loongson.dsc 97 98 The efi binary file path: 99 100 Build/LoongArchQemu/DEBUG_GCC5/FV/QEMU_EFI.fd 101 102 Build/LoongArchQemu/RELEASE_GCC5/FV/QEMU_EFI.fd 103 104 (5) linux kernel source code and compile method: 105 106 .. code-block:: bash 107 108 git clone https://github.com/loongson/linux.git 109 110 export PATH=$YOUR_COMPILER_PATH/bin:$PATH 111 112 export LD_LIBRARY_PATH=$YOUR_COMPILER_PATH/lib:$LD_LIBRARY_PATH 113 114 export LD_LIBRARY_PATH=$YOUR_COMPILER_PATH/loongarch64-unknown-linux-gnu/lib/:$LD_LIBRARY_PATH 115 116 make ARCH=loongarch CROSS_COMPILE=loongarch64-unknown-linux-gnu- loongson3_defconfig 117 118 make ARCH=loongarch CROSS_COMPILE=loongarch64-unknown-linux-gnu- 119 120 make ARCH=loongarch CROSS_COMPILE=loongarch64-unknown-linux-gnu- install 121 122 make ARCH=loongarch CROSS_COMPILE=loongarch64-unknown-linux-gnu- modules_install 123 124 Note: The branch of linux source code is loongarch-next. 125 126 (6) initrd file: 127 128 You can use busybox tool and the linux modules to make a initrd file. Or you can access the 129 binary files: https://github.com/yangxiaojuan-loongson/qemu-binary