ajxs / uefi-elf-bootloader

UEFI ELF Bootloader example
GNU General Public License v3.0
91 stars 14 forks source link

bootloader f*cks up without active serial port #1

Closed austanss closed 3 years ago

austanss commented 3 years ago

i'm using a moderately modified version of your bootloader: https://github.com/microNET-OS/microCORE/tree/stable/src/bootloader

and I don't know if it's a me problem or a you problem but the GOP works and shit i got that working i passed framebuffer info to my kernel so I've accomplished graphics. yay. anyway the bootloader doesn't work when i use a computer that doesn't have an active serial port for some reason. i tested it on my pc which has a serial port but it isn't active and it failed to init serial io. i disabled that conditional and made it just spit a warning and then it got like fucked up bad. the memory map failed (buffer too small) and the text was all over the place. any idea why?

austanss commented 3 years ago

ok so i fixed the issue with the text all over but mem map still fails fuck.

austanss commented 3 years ago

ok i fixed mem map yay.

ajxs commented 3 years ago

Thanks so much for your interest in my work! I really appreciate it. It looks like that link is broken with some recent changes. Can you point me to the code where you fix these issues? I'll have a look at adapting your fixes back into the codebase. Alternatively, you can raise a PR and I'll merge your fixes in to my master.

From memory, one common reason the allocation of the memory map can fail is doing any operation requiring memory allocation after getting the mmap size. This can be as simple as printing a string, since (from memory) the UEFI serial printing buffer is dynamically allocated. Looking at my own code, I can see that I print a string after getting the mmap size. I should fix this.

What was the issue with the text?

austanss commented 3 years ago

The link is dead, it's in a new repo: https://github.com/microNET-OS/microBOOT

The text was encoded improperly.

Also, I don't think I can PR from a non-fork repo... if so, enlighten me.

austanss commented 3 years ago

Well, since I like knowing I can make a difference in the world, I will make a fork and apply my bugfixes thereforth. I'll open a PR in a few hours.

ajxs commented 3 years ago

Sure. I look forward to it! I think you're right, you'll need to fork the repo before you can make a pull request.

austanss commented 3 years ago

I'm having a hard time with your Makefiles. I am attempting to build the x86_64-elf cross-compiler but I'm having a hard time...

ajxs commented 3 years ago

Is this a problem with the Makefiles in the project? If you're using a Linux host you can use this prebuilt toolchain: http://newos.org/toolchains/x86_64-elf-4.9.1-Linux-x86_64.tar.xz

austanss commented 3 years ago

No, it's compiling properly... my wording was bad. The header files are throwing an error because the compiler can't find stdint.h:

x86_64-elf-gcc  -I/usr/include/efi  -I/usr/include/efi/x86_64  -I/usr/include/efi/protocol  -Isrc/include    -fno-stack-protector       -fpic                      -fshort-wchar              -mno-red-zone              -Wall                      -Wextra                    -Wmissing-prototypes       -Wstrict-prototypes     -DEFI_FUNCTION_WRAPPER -o src/elf.o -c src/elf.c
In file included from /usr/include/efi/efi.h:41,
                 from src/elf.c:10:
/usr/include/efi/x86_64/efibind.h:88:14: fatal error: stdint.h: No such file or directory
   88 |     #include <stdint.h>
      |              ^~~~~~~~~~
compilation terminated.
make[1]: *** [makefile:87: src/elf.o] Error 1
ajxs commented 3 years ago

What compiler version are you using? stdint.h should be a standard component of your compiler. Can you run x86_64-elf-gcc --version?

austanss commented 3 years ago
COLLECT_GCC=x86_64-elf-gcc
Target: x86_64-elf
Configured with: ../gcc-4.9.1/configure --target=x86_64-elf --prefix=/home/geist/svn/toolchains/x86_64-elf-4.9.1-Linux-x86_64 --enable-languages=c,c++ --disable-werror
Thread model: single
gcc version 4.9.1 (GCC) 
austanss commented 3 years ago

thats not source compiled, thats a downloaded binary

austanss commented 3 years ago

i had two conflicting gcc versions, removing the conflicting one seemed to help. still can't compile; says cc1 not found:

x86_64-elf-gcc  -I/usr/include/efi  -I/usr/include/efi/x86_64  -I/usr/include/efi/protocol  -Isrc/include    -fno-stack-protector       -fpic                      -fshort-wchar              -mno-red-zone              -Wall                      -Wextra                    -Wmissing-prototypes       -Wstrict-prototypes     -DEFI_FUNCTION_WRAPPER -o src/elf.o -c src/elf.c
x86_64-elf-gcc: error trying to exec 'cc1': execvp: No such file or directory
make[1]: *** [makefile:87: src/elf.o] Error 1
ajxs commented 3 years ago

This looks like an issue with your GCC installation. cc1 is an internal component of GCC. Maybe clean out your $PATH to remove any references to any other x86_64 compiler instances, and/or reinstall the cross-compiler.

austanss commented 3 years ago

yah it was an installation issue. still my GCC is too old, and can't handle the u"" string constants. gotta compile gcc one more time...

austanss commented 3 years ago

When attempting to compile GCC 9.3, I corrupted my install. Sorry for the delay. Reinstalling right now.

austanss commented 3 years ago

the issue is with your cflags. you need -ffreestanding or else the compiler will attempt to include the libc version of stdint.h.

austanss commented 3 years ago

I apologize, but I cannot contribute my bugfixes due to critical build-system bugs that I do not have the ability to resolve.