本文介绍了ARM qemu系统仿真器可以从没有内核参数的卡映像启动吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了很多示例,这些示例如何运行QEMU ARM板仿真器.在每种情况下,除了SD卡映像参数外,QEMU还始终提供内核参数,即:

I've seen a lot of examples how to run a QEMU ARM board emulator. In every case, besides SD card image param, QEMU was also always supplied with kernel param, i.e.:

qemu-system-arm -M versatilepb \
                -kernel vmlinuz-2.6.18-6-versatile \ #KERNEL PARAM HERE
                -initrd initrd.gz \
                -hda hda.img -append "root=/dev/ram"

我正在使用引导加载程序,并希望创建自己的可引导SD卡,但是还没有一块真正的板,并且想学习一个模拟的SD卡.但是,如果如上所述运行,则QEMU会跳过引导加载程序阶段并运行内核.

I am palying with bootloaders and want to create my own bootable SD card, but don't have a real board yet and want to learn with an emulated one. However, if run as described above, QEMU skips bootloader stage and runs kernel.

那么我应该怎么做才能在QEMU上模拟完整的启动顺序,以便它执行引导加载程序?我是否应该获取ROM转储并将其作为 -bios 参数传递?

So what should I do to emulate a full boot sequence on QEMU so that it executes bootloader? Should I get a ROM dump and pass it as a -bios param?

推荐答案

您可以通过提供uboot映像来做到这一点.我从未使用过ROM转储.

You can do that by feeding the uboot image. I never used ROM dump.

  • 在实际的物理板上,引导过程通常涉及包含引导加载程序和操作系统的非易失性存储器(例如Flash).上电时,内核加载并运行引导加载程序,而引导加载程序又加载并运行操作系统.

  • On real, physical boards the boot process usually involves a non-volatile memory (e.g. a Flash) containing a boot-loader and the operating system. On power on, the core loads and runs the boot-loader, that in turn loads and runs the operating system.

QEMU可以在许多平台上仿真闪存,但不能在VersatilePB上仿真.有一些补丁广告程序可以添加Flash支持,但现在我想保持QEMU不变.

QEMU has the possibility to emulate Flash memory on many platforms, but not on the VersatilePB. There are patches ad procedures available that can add flash support, but for now I wanted to leave QEMU as it is.

QEMU可以使用-kernel和-initrd选项加载Linux内核.在较低的级别上,这些选项具有将两个二进制文件加载到模拟内存中的效果:位于地址0x10000(64KiB)的内核二进制文件和位于地址0x800000(8MiB)的ramdisk二进制文件.

QEMU can load a Linux kernel using the -kernel and -initrd options; at a low level, these options have the effect of loading two binary files into the emulated memory: the kernel binary at address 0x10000 (64KiB) and the ramdisk binary at address 0x800000 (8MiB).

然后,QEMU准备内核参数,并跳转到0x10000(64KiB)以执行Linux.我想使用U-Boot重新创建相同的情况,并保持与真实情况相似的状态,我想创建一个包含整个系统的单个二进制映像,就像板上装有Flash一样. QEMU中的-kernel选项将用于将Flash二进制文件加载到仿真内存中,这意味着二进制文件映像的起始地址将为0x10000(64KiB).

Then QEMU prepares the kernel arguments and jumps at 0x10000 (64KiB) to execute Linux. I wanted to recreate this same situation using U-Boot, and to keep the situation similar to a real one I wanted to create a single binary image containing the whole system, just like having a Flash on board. The -kernel option in QEMU will be used to load the Flash binary into the emulated memory, and this means the starting address of the binary image will be 0x10000 (64KiB).

此示例基于ARM多用途pb板

make CROSS_COMPILE=arm-none-eabi- versatilepb_config
make CROSS_COMPILE=arm-none-eabi- all

创建Flash图像 *下载u-boot-xxx.x源代码树并将其解压缩 *进入源代码树目录并进行构建

Creating the Flash image * download u-boot-xxx.x source tree and extract it * cd into the source tree directory and build it

mkimage -A arm -C none -O linux -T kernel -d zImage -a 0x00010000 -e 0x00010000 zImage.uimg
mkimage -A arm -C none -O linux -T ramdisk -d rootfs.img.gz -a 0x00800000 -e 0x00800000 rootfs.uimg
dd if=/dev/zero of=flash.bin bs=1 count=6M
dd if=u-boot.bin of=flash.bin conv=notrunc bs=1
dd if=zImage.uimg of=flash.bin conv=notrunc bs=1 seek=2M
dd if=rootfs.uimg of=flash.bin conv=notrunc bs=1 seek=4M

启动Linux

要启动Linux,我们最终可以调用:

To boot Linux we can finally call:

qemu-system-arm -M versatilepb -m 128M -kernel flash.bin -serial stdio

这篇关于ARM qemu系统仿真器可以从没有内核参数的卡映像启动吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 08:59