Portal:LoongArch

Jump to: navigation, search
Welcome to the LoongArch Portal Edit
LoongArch is a new 64-bit architecture developed by the Chinese company Loongson Technology. It is based on the MIPS architecture with some modifications and extensions reminiscent to the RISC-V architecture.

The CPU are used in both desktop and laptops and server machines as well as embedded applications.

The architecture is supported by the Linux kernel since version 5.19 and in QEMU since version 7.1. The architecture is supported by all relevant upstream projects such as LLVM, Rust, OpenJDK, GCC, Go, GRUB, NodeJS and many more.

The mature upstream support as well as existing, but unsuppported distribution support in both Debian as well as Fedora and Gentoo.

The platform is therefore a potential candidate for a new openSUSE port.
Topics Edit
=== Setting up a LoongArch QEMU instance running Debian unstable on openSUSE Tumbleweed ===

1. Install QEMU for LoongArch

# zypper in qemu qemu-extra qemu-img

2. Download and install LoongArch EFI firmware

# wget https://kojipkgs.fedoraproject.org/packages/edk2/20241117/5.fc42/noarch/edk2-loongarch64-20241117-5.fc42.noarch.rpm
# zypper in ./edk2-loongarch64-20240813-2.fc42.noarch.rpm
$ mkdir ~/qemu
$ cp /usr/share/edk2/loongarch64/QEMU_VARS.fd ~/qemu/qemu-loongarch_efivars.fd

3. Download Debian unstable ISO image for LoongArch (loong64)

$ cd ~/qemu
$ wget https://cdimage.debian.org/cdimage/ports/snapshots/2024-11-11/debian-12.0.0-loong64-NETINST-1.iso

4. Create QEMU disk image

$ cd ~/qemu
$ qemu-img create -f qcow2 debian_loong64.qcow2 20G

5. Create new bash script for running QEMU

#!/bin/bash

qemu-system-loongarch64 \
         -m 4G  -machine virt,pflash0=rom,pflash1=efivars \
         -blockdev node-name=rom,driver=file,read-only=true,filename=/usr/share/edk2/loongarch64/QEMU_EFI.fd \
         -blockdev node-name=efivars,driver=file,filename=${HOME}/qemu/qemu-loongarch_efivars.fd \
         -smp cpus=4 \
         -netdev user,id=eth0,hostfwd=tcp::5900-:5900 \
         -net nic,netdev=eth0 \
         -device nec-usb-xhci,id=xhci,addr=0x1b \
         -device usb-tablet,id=tablet,bus=xhci.0,port=1 \
         -device usb-kbd,id=keyboard,bus=xhci.0,port=2 \
         -device virtio-gpu-gl,xres=1280,yres=800 -display gtk,gl=on \
         -drive file=${HOME}/qemu/debian_loong64.qcow2,format=qcow2,media=disk \
         -cdrom ${HOME}/qemu/debian-12.0.0-loong64-NETINST-1.iso

Save the script as qemu-loongarch.sh.

Note: In order to redirect the console output to a virtual terminal, replace

-device virtio-gpu-gl,xres=1280,yres=800 -display gtk,gl=on \

with

-nographic \

Additionally, it's mandatory to pass "console=ttyS0" to the kernel command line. This can be achieved by pressing <e> while in GRUB, move the cursor to the line starting with "linux", pressing <Ctrl>+<e> (to move the cursor at the end of the line and appending "console=ttyS0" after "quiet", then boot the kernel with <Ctrl>+<x>.

6. Make script executable and run it

$ chmod 755 qemu-loongarch.sh
$ ./qemu-loongarch.sh

7. Installing Debian

Once GRUB has started, press <Enter> to run "Install" from the GRUB menu and follow the instructions on the screen.

Afer the installation as has finished, exit QEMU and edit the script above to remove the last line starting with "-cdrom". Please also remove the trailing backslash from the previous line.

Then run the script again to boot the installed system. If GRUB doesn't boot automatically, exit the EFI Shell by typing "exit", navigate to the "Boot Maintenance Manager" and find the grubloongarch64.efi EFI binary to boot

into GRUB.