{"id":37,"date":"2024-02-08T16:17:15","date_gmt":"2024-02-08T08:17:15","guid":{"rendered":"https:\/\/www.wenlinji.com\/?p=37"},"modified":"2024-07-26T18:58:12","modified_gmt":"2024-07-26T10:58:12","slug":"00001","status":"publish","type":"post","link":"https:\/\/www.wenlinji.com\/index.php\/2024\/02\/08\/00001\/","title":{"rendered":"CentOS7\u4f7f\u7528Qemu\u6a21\u62dfARM64"},"content":{"rendered":"<div class=\"markdown\">\n<h2><a href=\"https:\/\/www.cnblogs.com\/xidongyu\/p\/11638627.html\" title=\"CentOS7\u4f7f\u7528Qemu\u6a21\u62dfARM64\">CentOS7\u4f7f\u7528Qemu\u6a21\u62dfARM64<\/a><\/h2>\n<h2>\u51c6\u5907<\/h2>\n<h3>RPM\u5305\u5b89\u88c5<\/h3>\n<h4>yum\u5b89\u88c5\u4ea4\u53c9\u7f16\u8bd1\u5de5\u5177<\/h4>\n<pre><code class=\"language-shell\">yum install -y binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu bison flex glib2 glib2-devel pixman-devel bc<\/code><\/pre>\n<h4>\u624b\u52a8\u5b89\u88c5glibc<\/h4>\n<p>yum\u5e93\u4e2d\u6ca1\u6709glibc-aarch64\uff0c\u6240\u4ee5\u9700\u8981\u624b\u52a8\u5b89\u88c5\u76f8\u5e94\u7684\u5305\u3002\u5728<a href=\"https:\/\/centos.pkgs.org\/7\/puias-computational-x86_64\/glibc-aarch64-linux-gnu-2.24-2.sdl7.2.noarch.rpm.html\" title=\"\u8be5\u7f51\u7ad9\">\u8be5\u7f51\u7ad9<\/a>\u4e0b\u8f7d\u4ee5\u4e0b\u8fde\u4e2arpm\u5305\u8fdb\u884c\u5b89\u88c5<\/p>\n<ul>\n<li>glibc-aarch64-linux-gnu<\/li>\n<li>glibc-aarch64-linux-gnu-devel<\/li>\n<\/ul>\n<h3>\u4e0b\u8f7d\u6e90\u7801\u5305<\/h3>\n<h4>Linux\u6e90\u7801<\/h4>\n<p>\u4f7f\u7528wget\u4e0b\u8f7dLinux\u6e90\u7801&quot;<a href=\"https:\/\/cdn.kernel.org\/pub\/linux\/kernel\/v4.x\/linux-4.19.77.tar.xz\"\u6216\u8005\u5728CSDN\u4e0a\">https:\/\/cdn.kernel.org\/pub\/linux\/kernel\/v4.x\/linux-4.19.77.tar.xz\"\u6216\u8005\u5728CSDN\u4e0a<\/a><\/p>\n<h4>busybox<\/h4>\n<p><a href=\"https:\/\/busybox.net\/downloads\/busybox-1.24.2.tar.bz2\">https:\/\/busybox.net\/downloads\/busybox-1.24.2.tar.bz2<\/a><\/p>\n<h4>qemu<\/h4>\n<p>qemu\u652f\u6301ARM64\u76ee\u524d\u53ea\u80fd\u901a\u8fc7\u6e90\u7801\u5305\u5f62\u5f0f\u5b89\u88c5&quot;<a href=\"https:\/\/download.qemu.org\/qemu-4.1.0.tar.xz\">https:\/\/download.qemu.org\/qemu-4.1.0.tar.xz<\/a>&quot;<\/p>\n<h4>\u62f7\u8d1d\u5934\u6587\u4ef6<\/h4>\n<p>\u5728\u7f16\u8bd1\u65f6\u7f3a\u5c11\u4e00\u4e9b\u5934\u6587\u4ef6\uff0c\u53ef\u4ee5\u5c06x86\u4e0b\u7684copy\u5230aarch64\u4e0b<\/p>\n<pre><code class=\"language-shell\">cp -r \/usr\/include\/rpc\/* \/usr\/aarch64-linux-gnu\/include\/rpc\/<\/code><\/pre>\n<h1>\u5b89\u88c5<\/h1>\n<h2>qemu<\/h2>\n<h3>\u5b89\u88c5\u547d\u4ee4<\/h3>\n<pre><code class=\"language-shell\"># \u89e3\u538bqemu\u5b89\u88c5\u5305\u8fdb\u5165\u5176\u76ee\u5f55\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\n.\/configure --target-list=aarch64-softmmu,aarch64-linux-user --enable-virtfs --enable-debug &amp;&amp; make -j4 &amp;&amp; make install<\/code><\/pre>\n<h2>Linux<\/h2>\n<h3>\u7f16\u8bd1<\/h3>\n<pre><code class=\"language-shell\"># \u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\nexport ARCH=arm64\nexport CROSS_COMPILE=aarch64-linux-gnu-\n# \u914d\u7f6e\u7f16\u8bd1\u9009\u9879\nmake defconfig \nmake menuconfig \n# \u7f16\u8bd1\nmake -j4<\/code><\/pre>\n<h2>busybox<\/h2>\n<h3>\u914d\u7f6e<\/h3>\n<p>\u6267\u884c<strong>make menuconfig<\/strong>\u547d\u4ee4\u8fdb\u884c\u914d\u7f6e\uff0c\u4ee5\u4e0b\u4e24\u4e2a\u9009\u9879\u9700\u8981\u8bbe\u7f6e<\/p>\n<\/p>\n<ul>\n<li><strong>Busybox Setting -&gt; Build Options -&gt; static binary(enable)<\/strong><\/li>\n<li><strong>Networking Utilities -&gt; inetd(disable)<\/strong><\/li>\n<li><strong>Busybox Setting -&gt; BusyBox installation prefix(..\/rootfs)<\/strong><\/li>\n<\/ul>\n<h3>\u7f16\u8bd1<\/h3>\n<pre><code>make -j4 &amp;&amp; make install<\/code><\/pre>\n<p>\u7f16\u8bd1\u5b8c\u6210\u540e\u5728busybox\u7684\u540c\u7ea7\u76ee\u5f55\u4f1a\u751f\u6210\u4e00\u4e2arootfs\u76ee\u5f55<\/p>\n<h3>\u5236\u4f5c\u6587\u4ef6\u7cfb\u7edf<\/h3>\n<p>\u8fdb\u5165rootfs\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4<\/p>\n<pre><code class=\"language-shell\">mkdir dev etc mnt \nmkdir -p etc\/init.d<\/code><\/pre>\n<p>\u8fdb\u5165etc\/init.d\u4e2d\u521b\u5efa\u6587\u4ef6rcS\uff0c\u5728\u6587\u4ef6\u4e2d\u52a0\u5165\u4ee5\u4e0b\u5185\u5bb9\uff0c\u5e76\u4fee\u6539rcS\u4e3a\u53ef\u6267\u884c<\/p>\n<pre><code class=\"language-shell\">mkdir -p \/proc\nmkdir -p \/tmp\nmkdir -p \/sys\nmkdir -p \/mnt\n\/bin\/mount -a\nmkdir -p \/dev\/pts\nmount -t devpts devpts \/dev\/pts\necho \/sbin\/mdev &gt; \/proc\/sys\/kernel\/hotplug\nmdev -s<\/code><\/pre>\n<p>\u5728etc\/ \u76ee\u5f55\u4e0b\u65b0\u5efa\u4e00\u4e2ainittab\u6587\u4ef6\uff0c\u52a0\u5165\u4ee5\u4e0b\u5185\u5bb9<\/p>\n<pre><code class=\"language-shell\">::sysinit:\/etc\/init.d\/rcS \n::respawn:-\/bin\/sh \n::askfirst:-\/bin\/sh \n::ctrlaltdel:\/bin\/umount -a -r <\/code><\/pre>\n<p>\u5728dev\u76ee\u5f55\u4e0b\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4<\/p>\n<pre><code class=\"language-shell\">mknod console c 5 1 \nmknod null c 1 3<\/code><\/pre>\n<p>\u5728rootfs\u76ee\u5f55\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4<\/p>\n<pre><code class=\"language-shell\">find . | cpio -o -H newc &gt; rootfs.cpio \ngzip -c rootfs.cpio &gt; rootfs.cpio.gz<\/code><\/pre>\n<p>\u81f3\u6b64\uff0crootfs\u4e2d\u7684rootfs.cpio.gz\u5c31\u662f\u5236\u4f5c\u597d\u7684\u6587\u4ef6\u7cfb\u7edf<\/p>\n<h1>\u865a\u62df\u673a\u7ba1\u7406<\/h1>\n<h2>\u865a\u62df\u673a\u542f\u52a8<\/h2>\n<pre><code>qemu-system-aarch64 -cpu cortex-a57 -machine type=virt -nographic -smp 1 -m 512 -kernel Image -append \"rdinit=\/linuxrc console=ttyAMA0\" -initrd rootfs.cpio.gz -device virtio-scsi-device<\/code><\/pre>\n<table>\n<thead>\n<tr>\n<th>qemu-system-aarch64<\/th>\n<th>\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u63d0\u4f9b\u6a21\u62dfaarch64\u67b6\u6784\u7684\u865a\u62df\u673a\u8fdb\u7a0b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>-m 2048<\/td>\n<td>\u5206\u914d2048MB\u5185\u5b58<\/td>\n<\/tr>\n<tr>\n<td>-M virt<\/td>\n<td>\u6a21\u62df\u6210\u4ec0\u4e48\u670d\u52a1\u5668\uff0c\u6211\u4eec\u4e00\u822c\u9009\u62e9virt\u5c31\u53ef\u4ee5\u4e86\uff0c\u4ed6\u4f1a\u81ea\u52a8\u9009\u62e9\u6700\u9ad8\u7248\u672c\u7684virt<\/td>\n<\/tr>\n<tr>\n<td>-cpu cortex-a72<\/td>\n<td>\u6a21\u62df\u6210\u4ec0\u4e48CPU\uff0c\u5176\u4e2dcortex-a53a57a72\u90fd\u662fARMv8\u6307\u4ee4\u96c6\u7684<\/td>\n<\/tr>\n<tr>\n<td>-smp 2,cores=2,threads=1,sockets=1<\/td>\n<td>2\u4e2avCPU\uff0c\u8fd92\u4e2avCPU\u7531qemu\u6a21\u62df\u51fa\u7684\u4e00\u4e2a\u63d2\u69fd\uff08socket\uff09\u4e2d\u76842\u4e2a\u6838\u5fc3\uff0c\u6bcf\u4e2a\u6838\u5fc3\u652f\u6301\u4e00\u4e2a\u8d85\u7ebf\u7a0b\u6784\u6210\u3002<\/td>\n<\/tr>\n<tr>\n<td>-bios xxx<\/td>\n<td>\u6307\u5b9abios bin\u6240\u5728\u7684\u8def\u5f84<\/td>\n<\/tr>\n<tr>\n<td>-device xxx<\/td>\n<td>\u6dfb\u52a0\u4e00\u4e2a\u8bbe\u5907\uff0c\u53c2\u6570\u53ef\u91cd\u590d<\/td>\n<\/tr>\n<tr>\n<td>-drive<\/td>\n<td>\u6dfb\u52a0\u4e00\u4e2a\u9a71\u52a8\u5668\uff0c\u53c2\u6570\u53ef\u91cd\u590d<\/td>\n<\/tr>\n<tr>\n<td>-net<\/td>\n<td>\u6dfb\u52a0\u7f51\u7edc\u8bbe\u5907<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h1>GDB\u8c03\u5f0f<\/h1>\n<h2>\u5b89\u88c5<\/h2>\n<p>\u4e0b\u8f7dGDB\u6e90\u7801\u5305<a href=\"http:\/\/ftp.gnu.org\/gnu\/gdb\">GDB<\/a>, lasted version(suggestion)<\/p>\n<p>\u7f16\u8bd1&amp;\u5b89\u88c5<\/p>\n<pre><code class=\"language-shell\">.\/configure --target=aarch64-linux-gnu --program-prefix=aarch64-linux- --prefix=\/usr\/local\/aarch64_gdb\nmake &amp;&amp; make install<\/code><\/pre>\n<p>\u6807\u7b7e: <a href=\"https:\/\/www.cnblogs.com\/xidongyu\/tag\/arm64\/\">arm64<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<div class=\"markdown\">\n<p>CentOS7\u4f7f\u7528Qemu\u6a21\u62dfARM64 \u51c6\u5907 RPM\u5305\u5b89\u88c5 yum\u5b89\u88c5\u4ea4\u53c9\u7f16\u8bd1\u5de5\u5177 yum install  [&hellip;]<\/p>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-37","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.wenlinji.com\/index.php\/wp-json\/wp\/v2\/posts\/37","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wenlinji.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wenlinji.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wenlinji.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wenlinji.com\/index.php\/wp-json\/wp\/v2\/comments?post=37"}],"version-history":[{"count":4,"href":"https:\/\/www.wenlinji.com\/index.php\/wp-json\/wp\/v2\/posts\/37\/revisions"}],"predecessor-version":[{"id":46,"href":"https:\/\/www.wenlinji.com\/index.php\/wp-json\/wp\/v2\/posts\/37\/revisions\/46"}],"wp:attachment":[{"href":"https:\/\/www.wenlinji.com\/index.php\/wp-json\/wp\/v2\/media?parent=37"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wenlinji.com\/index.php\/wp-json\/wp\/v2\/categories?post=37"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wenlinji.com\/index.php\/wp-json\/wp\/v2\/tags?post=37"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}