Can an ARM qemu system emulator boot from a card image without kernel parameters?

I have seen many examples of how to run the QEMU ARM board emulator. In each case, in addition to the SD card parameter, QEMU was also always provided with the kernel parameter, 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" 

I’m swimming with bootloaders and want to create my own bootable SD card, but so far I don’t have a real board and want to learn using emulated. However, if you run as described above, QEMU skips the bootloader stage and starts the kernel.

So what should I do to emulate the complete boot sequence on QEMU so that it runs the bootloader? Should I get a ROM dump and pass it as the -bios option ?

+5
source share
2 answers

You can do this by uploading an uboot image. I have never used a ROM dump.

QEMU BOOT SQEUQNCE:

  • On real physical boards, the boot process usually includes non-volatile memory (such as Flash) containing the bootloader and the operating system. When the power is turned on, the kernel loads and starts the bootloader, which, in turn, loads and starts the operating system.

  • QEMU has the ability to emulate flash memory on many platforms, but not on VersatilePB. There are patch advertising procedures available that can add flash support, but for now I wanted to leave QEMU as it is.

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

  • QEMU then prepares the kernel arguments and jumps to 0x10000 (64KiB) to run Linux. I wanted to recreate the same situation using U-Boot, and to make the situation look like real, I wanted to create one binary image containing the entire system, just like having Flash on board. The -kernel option in QEMU will be used to load the Flash binary into the emulated memory, which means that the starting address of the binary image will be 0x10000 (64KiB).

This example is based on the ARM Universal Board.

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

Creating a flash image * Download the source tree u-boot-xxx.x and extract it * cd to the directory of the source tree and create 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 boot

To boot Linux, we can finally call:

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

You need to give it some kind of bootloader image via -bios (or the pflash option), yes. I doubt that the ROM dump will work, although, as a rule, the ROM will be much better to match the real hardware than QEMU provides. You want the bootloader to be written and tested to work with QEMU. For example, if you use the virt panel and the UEFI image that is built for QEMU.

Otherwise, QEMU will use its "built-in bootloader", which is a few instructions that can load the kernel that you pass with -kernel.

0
source

Source: https://habr.com/ru/post/1266006/


All Articles