【问题标题】:How to build the Linux kernel for powerpc and boot it on qemu?如何为powerpc构建Linux内核并在qemu上启动?
【发布时间】:2018-06-09 19:22:36
【问题描述】:

我已经编译了一个 linux 内核并使用 buildroot 为 64 位 powerpc 生成了根文件系统。目标 CPU POWER7。

buildroot 的输出:

1] rootfs.cpio 2] rootfs.ext2 3] rootfs.tar.gz 4] vmlinux

启动qemu模拟

qemu-system-ppc64 -m 1024 -kernel output/images/vmlinux -initrd output/images/rootfs.cpio -serial stdio

--> 输出: Output Of 1st command

qemu-system-ppc64 -M pseries -cpu POWER7 -m 1024 -kernel output/images/vmlinux -append 'console=hvc0 root=/dev/sda' -drive file=output/images/rootfs.ext2,if=scsi,index=0,format=raw -serial stdio

--> 输出: Output of 2nd command

我做错了什么,我能做些什么来解决它?

【问题讨论】:

  • 欢迎来到 Stack Overflow!在这里,我们倾向于将与问题相关的所有信息在问题帖子本身(作为文本)中,而不是链接。当您使用 QEMU 运行内核时,准备一个带有输出的文本文件并将其内容插入问题帖子中应该不难。通过edit提出问题来做到这一点。

标签: linux linux-kernel qemu powerpc buildroot


【解决方案1】:

你等了多久?我假设一段时间。在这种情况下,看起来内核在启动的早期就已经在某个地方崩溃了,还没有检测到控制台。如果您的内存太少,可能会发生这种情况,但 1G 应该足够了。如果您为错误的机器/CPU 类型构建内核,也会发生这种情况,但您似乎做对了。

您可以尝试一些说明 here,这些说明已知有效。

【讨论】:

  • 感谢您的关注。问题已解决 使用 pseries_defconfig 的 pSeries 的树内 defconfig 文件而不是使用体系结构默认配置。
【解决方案2】:

Buildroot

https://buildroot.org/

我还没有专门为 powerpc 测试过它,但我敢打赌,它可以开箱即用,就像我迄今为止尝试过的每个拱门(x86、ARM 和 MIPS)一样 :-)

只需按照以下说明的步骤操作:How to download the Torvalds Linux Kernel master, (re)compile it, and boot it with QEMU? 并将 arm 替换为 ppc。

然后要使用你自己的 Linux 内核源,你基本上只需要使用 LINUX_OVERRIDE_SRCDIR 就可以了,解释如下:How to modify the source of Buildroot packages for package development?

编辑:我知道这只是一种形式,但在写完这个问题后,我实际上测试了下面的命令,并且启动按预期开箱即用:

unset LD_LIBRARY_PATH
make qemu_ppc64_pseries_defconfig
printf '
BR2_CCACHE=y
BR2_PACKAGE_HOST_QEMU=y
BR2_PACKAGE_HOST_QEMU_LINUX_USER_MODE=n
BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y
BR2_PACKAGE_HOST_QEMU_VDE2=y
' >>.config
make olddefconfig
time make BR2_JLEVEL="$(nproc)" HOST_QEMU_OPTS='--enable-sdl --with-sdlabi=2.0'
./output/host/usr/bin/qemu-system-ppc64 -M pseries -cpu POWER7 -m 256 -kernel output/images/vmlinux -append 'console=hvc0 root=/dev/sda' -drive file=output/images/rootfs.ext2,if=scsi,index=0,format=raw -serial stdio -display curses

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-04-08
    • 1970-01-01
    • 2018-08-03
    • 2012-07-10
    • 1970-01-01
    • 1970-01-01
    • 2013-06-21
    • 1970-01-01
    相关资源
    最近更新 更多