[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-discuss] UEFI, OVMF Qemu example

From: 邓尧
Subject: Re: [Qemu-discuss] UEFI, OVMF Qemu example
Date: Tue, 5 Aug 2014 18:25:41 +0800

"losetup --offset 34" is incorrect: the offset is 34 sectors (17408 bytes) instead of 34 bytes.

BTW, kpartx can be used to access partitions on a loop device:
kpartx -a /dev/loopX
After running the command above, device files like /dev/maper/loopXp1 or /dev/loopXp1 would appear, which can be format/mount directly.

On Sat, Aug 2, 2014 at 4:37 AM, Bradley, Mike <address@hidden> wrote:



I’m trying to create a qemu example to boot a UEFI program, with the goal of it calling a baremetal program.  But, I’m stuck in getting the UEFI program to run as I want.

Also, I assume this is the correct way to do this (e.g. UEFI runs, calls my UEFI program, which will then jump to baremetal).


Currently, I have tianocore installed, and have built the HelloWorld example.


I can successfully do:


% file hda/x64/HelloWorld.efi

      hda/x64/HelloWorld.efi: MS-DOS executable


% qemu-system-x86_64   -bios OVMF.fd    -enable-kvm     -hda fat:hda/x64


The UEFI boot shell comes up, and I can execute “HelloWorld”.



But, I want to boot this automatically, without having to type in the UEFI shell.  I found a recommendation to create a disk image summary:


% dd if=/dev/zero of=$dname bs=512 count=200

% gdisk disk.hdd

… options to create partition


% gdisk -l disk.hdd

GPT fdisk (gdisk) version 0.8.9


Partition table scan:

  MBR: protective

  BSD: not present

  APM: not present

  GPT: present


Found valid GPT with protective MBR; using GPT.

Disk disk.hdd: 200 sectors, 100.0 KiB

Logical sector size: 512 bytes

Disk identifier (GUID): F076CC86-0ABB-4D59-A188-4923F7415030

Partition table holds up to 128 entries

First usable sector is 34, last usable sector is 166

Partitions will be aligned on 2-sector boundaries

Total free space is 0 sectors (0 bytes)


Number  Start (sector)    End (sector)  Size       Code  Name

   1              34             166   66.5 KiB    EF00  EFI System


% losetup --offset 34 --sizelimit 159000 /dev/loop0  disk.hdd

% mkdosfs /dev/loop0

% mkdir -p efi

% mount /dev/loop0 efi

% mkdir -p efi/EFI/BOOT/

% cp  HelloWorld.efi   efi/EFI/BOOT/BOOTX64.EFI


Then run qemu:


% qemu-system-x86_64   -bios OVMF.fd    -enable-kvm     -hda disk.hdd


But now I still get the UEFI shell, but, HelloWorld is not found.  I assume I did not make the disk properly, or maybe completely off-base… Help please !




reply via email to

[Prev in Thread] Current Thread [Next in Thread]