0

I'm working on a simple application that will be running on a Intel Galileo's board as UEFI app. I've started with a "Hello, World" app and tested it under qemu-system-i386 and it works well. Then, I've run it under Galileo EFI Shell and it stuck (nothing happend and never returned anything - like a never-ending loop). I know that Intel Galileo's Quark processor is a i586 architecture. It shouldn't be a problem to run application compiled for i386 under i586, due to the backward compatibility, am I right? Or am I missing something?

I'm using Ubuntu 14.04 (32-bit) for development with GCC 5.4.0 (default). Also, I'm using gnu-efi in version 3.0.4.

Should I build a cross-compiler? Will it resolve all of my problems? Is it necessary?

Here is a sample code:

#include <efi.h>
#include <efilib.h>

EFI_STATUS EFIAPI efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) {
    InitializeLib(ImageHandle, SystemTable);
    Print(L"Hello, World!\n");

    return EFI_SUCCESS;
}

Here is my Makefile:

ARCH            = ia32

OBJS            = src/main.o
HEADERS         = 
TARGET          = build/main.efi

EFIINC          = lib/gnu-efi/inc
EFIINCS         = -I$(EFIINC) -I$(EFIINC)/$(ARCH) -I$(EFIINC)/protocol
LIB             = lib/gnu-efi/$(ARCH)/lib
EFILIB          = lib/gnu-efi/gnuefi
EFI_CRT_OBJS    = $(EFILIB)/crt0-efi-$(ARCH).o
EFI_LDS         = $(EFILIB)/elf_$(ARCH)_efi.lds

CFLAGS          = $(EFIINCS) -ffreestanding -fno-stack-protector -fpic -fshort-wchar -mno-red-zone -Wall -masm=intel

LDFLAGS         = -nostdlib -znocombreloc -T $(EFI_LDS) -shared -Bsymbolic -L $(EFILIB) -L $(LIB) $(EFI_CRT_OBJS)

all: $(TARGET)

build: $(TARGET)

src/%.so: $(OBJS) $(HEADERS)
    ld $(LDFLAGS) $(OBJS) -o $@ -l:libefi.a -l:libgnuefi.a

build/%.efi: src/%.so
    objcopy -j .text -j .sdata -j .data -j .dynamic \
        -j .dynsym  -j .rel -j .rela -j .reloc \
        --target=efi-app-$(ARCH) $^ $@

run:
    qemu-system-i386 bin/OVMF.fd -hda fat:build

.PHONY: all build run
Jakub Powierza
  • 111
  • 2
  • 11
  • 1
    Do you need to add -m32 to CFLAGS to ensure the compiler is not generatng 64-bit code? – unixsmurf Nov 20 '16 at 11:23
  • Thanks for your answer! But it didn't help at all :( Galileo still doesn't work while QEMU works properly. – Jakub Powierza Nov 20 '16 at 22:39
  • I've found something on Intel forum: https://communities.intel.com/thread/52645 . Is there any reason why gnu-efi is not working on Intel Galileo? It should be **Unified** EFI. I will try to use EDKII and let you all know about my progress. – Jakub Powierza Nov 23 '16 at 22:53
  • Sounds to me like a "we can't support it because we don't know it" type answer. The only reason why gnu-efi wouldn't work with Galileo would be bugs ... and I can imagine it is not a platform that sees as frequent use as other gnu-efi targets, so that's certainly a possibility. – unixsmurf Nov 24 '16 at 10:19

0 Answers0