x86上运行LoongArch的环境

很多朋友只有x86的系统,因为我们上学时代和工作机大部分都x86系统。loongson推出LoongArch指令集后,也想尝尝鲜或者作为一个开发者又不想买新的机器,此时就可以用到我下边为大家介绍的方法。

此处也给大家提供一个debian社区发布的官方的文档:

debian社区发布:LoongArch/sbuildQEMU - Debian Wiki

也可以参考我为大家已经整理好的资料 GitHub - loongson-zn/qemu-debian

如果你翻墙困难,我将整理的readme粘贴到此处:

  • 宿主机环境

 架      构:x86_64

系统环境:debian bookworm 

具体操作步骤:

  • 安装qemu-user
root@debian:~# apt install binfmt-support
root@debian:~# apt build-dep qemu-user-static
root@debian:~# git clone https://github.com/qemu/qemu.git
root@debian:~# cd qemu
root@debian:~/qemu# ./configure --static --disable-system --target-list=loongarch64-linux-user
root@debian:~/qemu# make
root@debian:~/qemu# cp build/loongarch64-linux-user/qemu-loongarch64 /usr/bin/qemu-loongarch64-static
root@debian:~/qemu# cat >/tmp/qemu-loongarch64 <<EOF
package qemu-user-static
type magic
offset 0
magic \x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02\x01                    
mask \xff\xff\xff\xff\xff\xff\xff\xfc\x00\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff
interpreter /usr/bin/qemu-loongarch64-static
EOF

root@debian:~/qemu# update-binfmts --import /tmp/qemu-loongarch64 
  • 制作LA最小镜像
root@debian:~# apt install debootstrap sbuild debian-ports-archive-keyring
root@debian:~# debootstrap --foreign --arch=loong64 --variant=buildd --include=debian-ports-archive-keyring --verbose --components=main --keyring=/etc/apt/trusted.gpg.d/debian-ports-archive-2023.gpg --resolve-deps --extra-suites=unreleased unstable /srv/chroots/sid-loong64-sbuild/ http://ftp.ports.debian.org/debian-ports
root@debian:~# cd /srv/chroots/sid-loong64-sbuild/
root@debian:/srv/chroots/sid-loong64-sbuild# cp /usr/bin/qemu-loongarch64-static usr/bin/
root@debian:/srv/chroots/sid-loong64-sbuild# chroot .
I have no name!@loongson01:/# /debootstrap/debootstrap --second-stage
  • 准备gcc编译器(我提供的gcc及qemu是支持lasx及lsx向量的,如果不需要,用debian仓库安装即可)
git clone https://github.com/loongson-zn/qemu-debian.git
cd qemu-debian/gcc_13.2.0-7.1_nodbg
apt install ./*
apt install gcc gfortran
mount -t proc proc proc
mount -t sysfs sys sys
mount -t devtmpfs dev dev 
mount -t devpts devpts dev/pts 
mount -t tmpfs shmfs dev/shm

写这篇博客是在2023.12.15,LA还处于正在推进debian社区 的阶段,此时的地址为:

#root@loongson01:~# cat /srv/chroots/sid-loong64-sbuild/etc/apt/sources.list     
# binary default
deb http://ftp.ports.debian.org/debian-ports unstable main 
deb http://ftp.ports.debian.org/debian-ports unreleased main

相关推荐

  1. x86运行LoongArch环境

    2023-12-16 06:24:04       46 阅读
  2. x86开机过程()

    2023-12-16 06:24:04       9 阅读
  3. 使用qemu在arm模拟x86运行docker

    2023-12-16 06:24:04       57 阅读

最近更新

  1. TCP协议是安全的吗?

    2023-12-16 06:24:04       19 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-16 06:24:04       20 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-16 06:24:04       20 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-16 06:24:04       20 阅读

热门阅读

  1. TCP标志位

    2023-12-16 06:24:04       39 阅读
  2. 5G基础设施:2024-2028年市场趋势与预测

    2023-12-16 06:24:04       37 阅读
  3. 华为云CodeArts Pipeline常见问答汇总

    2023-12-16 06:24:04       39 阅读
  4. 华为云CodeArts Check常见问答汇总

    2023-12-16 06:24:04       44 阅读
  5. 新时代商业市场:AR技术的挑战与机遇并存

    2023-12-16 06:24:04       42 阅读
  6. 云架构的思考5--云上组织架构

    2023-12-16 06:24:04       37 阅读
  7. 在Node.js中停止使用dotenv

    2023-12-16 06:24:04       46 阅读