Keyboard driver resets system when key is pressed.

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Tomrs123
Member
Member
Posts: 36
Joined: Mon Aug 19, 2024 11:12 am

Re: Keyboard driver resets system when key is pressed.

Post 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
MichaelPetch
Member
Member
Posts: 734
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: Keyboard driver resets system when key is pressed.

Post 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.
Octocontrabass
Member
Member
Posts: 5440
Joined: Mon Mar 25, 2013 7:01 pm

Re: Keyboard driver resets system when key is pressed.

Post 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?
Tomrs123
Member
Member
Posts: 36
Joined: Mon Aug 19, 2024 11:12 am

Re: Keyboard driver resets system when key is pressed.

Post 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:
Last edited by Tomrs123 on Mon Sep 02, 2024 10:35 am, edited 2 times in total.
sh42
Posts: 13
Joined: Sat Aug 17, 2024 4:45 pm

Re: Keyboard driver resets system when key is pressed.

Post 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.
User avatar
iansjack
Member
Member
Posts: 4668
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Keyboard driver resets system when key is pressed.

Post by iansjack »

Just buy an external SSD for your laptop. They’re really cheap nowadays.
Tomrs123
Member
Member
Posts: 36
Joined: Mon Aug 19, 2024 11:12 am

Re: Keyboard driver resets system when key is pressed.

Post 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
Octocontrabass
Member
Member
Posts: 5440
Joined: Mon Mar 25, 2013 7:01 pm

Re: Keyboard driver resets system when key is pressed.

Post 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.
Tomrs123
Member
Member
Posts: 36
Joined: Mon Aug 19, 2024 11:12 am

Re: Keyboard driver resets system when key is pressed.

Post by Tomrs123 »

What part? Everything seems to be there...
Tomrs123
Member
Member
Posts: 36
Joined: Mon Aug 19, 2024 11:12 am

Re: Keyboard driver resets system when key is pressed.

Post by Tomrs123 »

Huh, seems like the gdt c file didn't get commited.... gotta fiix that :shock:

Fixed it.
Octocontrabass
Member
Member
Posts: 5440
Joined: Mon Mar 25, 2013 7:01 pm

Re: Keyboard driver resets system when key is pressed.

Post 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.
Tomrs123
Member
Member
Posts: 36
Joined: Mon Aug 19, 2024 11:12 am

Re: Keyboard driver resets system when key is pressed.

Post 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?
Tomrs123
Member
Member
Posts: 36
Joined: Mon Aug 19, 2024 11:12 am

Re: Keyboard driver resets system when key is pressed.

Post by Tomrs123 »

Oh .. I read the linker page, and I thought I could add it. Fixing it now
Post Reply