Page 2 of 5

Re: Keyboard driver resets system when key is pressed.

Posted: Sat Aug 31, 2024 2:45 pm
by Tomrs123
So I'm deciding to not build a cross-compiler because it.. it takes too long.

Because of that, I'm using these as my GCC args:

Code: Select all

-ffreestanding -mgeneral-regs-only -Wall -Wextra -Werror
But, when I compile, I get this error:

Code: Select all

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
I've tried adding

Code: Select all

-nostartfiles
but that doesn't work, I get another error:

Code: Select all

/usr/bin/ld: warning: cannot find entry symbol _start; defaulting to 0000000000001000
ld: attempted static link of dynamic object `build/main.o'
Added

Code: Select all

-static
, still didn't work, got this error:

Code: Select all

ld: cannot use executable file 'build/main.o' as input to a link
So yeah. I'm out of ideas :(
UPDATE: I added -m32... that made it WAY worse.

Code: Select all

/usr/bin/ld: cannot find Scrt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/12/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc: No such file or directory
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libgcc_s.so.1 when searching for libgcc_s.so.1
/usr/bin/ld: cannot find libgcc_s.so.1: No such file or directory
/usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libgcc_s.so.1 when searching for libgcc_s.so.1
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/12/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc: No such file or directory

Re: Keyboard driver resets system when key is pressed.

Posted: Sat Aug 31, 2024 6:29 pm
by MichaelPetch
When you compile source files to object files (.o) files are you passing the -c option to compile to object? Almost seems as if your object files are actually executables.

Re: Keyboard driver resets system when key is pressed.

Posted: Sat Aug 31, 2024 7:31 pm
by Octocontrabass
Tomrs123 wrote: Sat Aug 31, 2024 2:45 pmSo I'm deciding to not build a cross-compiler because it.. it takes too long.
Did you forget to use the -j option when you ran make? Plus, why does it matter how long it takes when you only need to build the cross-compiler once?

Re: Keyboard driver resets system when key is pressed.

Posted: Sun Sep 01, 2024 8:33 am
by Tomrs123
MichaelPetch wrote: Sat Aug 31, 2024 6:29 pm When you compile source files to object files (.o) files are you passing the -c option to compile to object? Almost seems as if your object files are actually executables.
Oh...
Octocontrabass wrote: Sat Aug 31, 2024 7:31 pm
Tomrs123 wrote: Sat Aug 31, 2024 2:45 pmSo I'm deciding to not build a cross-compiler because it.. it takes too long.
Did you forget to use the -j option when you ran make? Plus, why does it matter how long it takes when you only need to build the cross-compiler once?
Well... I should probably build one. I am going to upload it to a private GitHub repo so I can just download it when I need it.

EDIT: I'm giving up on compiling a cross-compiler... Here's the reason.
The laptop I'm doing all of this on has about 250GB of storage. Most of that is games. So I only have about 10GB~. So, whenever I build, my storage gets full, so I have to completely unregister WSL as a quick solution. :cry:

Re: Keyboard driver resets system when key is pressed.

Posted: Mon Sep 02, 2024 3:01 am
by sh42
Tomrs123 wrote: Wed Aug 28, 2024 1:58 pm i am now going to start from scratch.
All the best :D - This post is my life haha. 10 years of starting from scratch ^^ its a good learning adventure.

Re: Keyboard driver resets system when key is pressed.

Posted: Mon Sep 02, 2024 12:44 pm
by iansjack
Just buy an external SSD for your laptop. They’re really cheap nowadays.

Re: Keyboard driver resets system when key is pressed.

Posted: Tue Sep 10, 2024 12:09 pm
by Tomrs123
Okay, so I'm working on the GDT on the start-from-scratch version, but I dont know what to fill in for the code and data segments. I've updated the GitHub Repo, so you guys can help.

:D

Re: Keyboard driver resets system when key is pressed.

Posted: Tue Sep 10, 2024 12:14 pm
by Octocontrabass
Tomrs123 wrote: Tue Sep 10, 2024 12:09 pmI've updated the GitHub Repo
No you didn't. Part of your code is missing.

Re: Keyboard driver resets system when key is pressed.

Posted: Tue Sep 10, 2024 12:19 pm
by Tomrs123
What part? Everything seems to be there...

Re: Keyboard driver resets system when key is pressed.

Posted: Tue Sep 10, 2024 12:25 pm
by Octocontrabass

Re: Keyboard driver resets system when key is pressed.

Posted: Tue Sep 10, 2024 12:27 pm
by Tomrs123
Huh, seems like the gdt c file didn't get commited.... gotta fiix that :shock:

Fixed it.

Re: Keyboard driver resets system when key is pressed.

Posted: Tue Sep 10, 2024 12:40 pm
by Octocontrabass
Unless you're doing something unusual, you want to set the base to 0 and the limit to 0xFFFFF in both segment descriptors.

You're storing your GDT in a local variable. Do you know why that's a problem?

Your GDTR limit is off by one. It'll still work, but details are important when you're writing an OS.

You never actually tell the CPU to use your GDT.

Re: Keyboard driver resets system when key is pressed.

Posted: Tue Sep 10, 2024 12:49 pm
by Tomrs123
So I did all what you said, but I now get this error when I build:

Code: Select all

ld: build/boot.o: in function `start':
src/boot.asm:(.text+0x0): multiple definition of `start'; build/boot.o:src/boot.asm:(.text+0x0): first defined here
How do I fix this?

Re: Keyboard driver resets system when key is pressed.

Posted: Tue Sep 10, 2024 1:21 pm
by Octocontrabass

Re: Keyboard driver resets system when key is pressed.

Posted: Tue Sep 10, 2024 1:26 pm
by Tomrs123
Oh .. I read the linker page, and I thought I could add it. Fixing it now