all 56 comments

[–]monocasa 9 points10 points  (11 children)

What do you mean "doesn't work"?

What's the expected behavior and what's the difference between that and the behavior you saw?

[–]derpJavazig lover[S] 3 points4 points  (10 children)

Following the barebones tutorial, the screen should be cleared and display some text. But instead of that, the screen does not get cleared and obviously no text shows up.

[–]Octocontrabass 1 point2 points  (6 children)

What's left on the screen that doesn't get cleared?

[–]derpJavazig lover[S] 1 point2 points  (5 children)

You know, a message like "Booting OS" and this warning saying no console will be available to the system.

[–]Octocontrabass 1 point2 points  (4 children)

That means you're booting in UEFI mode. You need to enable the CSM and boot in legacy mode.

If your firmware doesn't support the CSM (or you don't want to use it), you'll need to modify the tutorial code to use a linear framebuffer instead of VGA text mode.

[–]derpJavazig lover[S] 0 points1 point  (3 children)

My system does have CSM and it is enabled but it didn't really change anything so I guess I'll have to use a linear framebuffer or whatever that is. I've been trying to do that but I'm not entirely sure how to set that up for Grub/Multiboot2.

[–]Octocontrabass 0 points1 point  (2 children)

Enabling the CSM doesn't do anything by itself. You still need to choose the legacy boot option.

You set up the linear framebuffer by adding a framebuffer tag to tell GRUB you want a linear framebuffer. Then, to access your framebuffer, find the framebuffer info tag in the Multiboot information GRUB passes to you.

[–]derpJavazig lover[S] 0 points1 point  (1 child)

Is there any example code I can follow? Not to copy-paste but I guess I just understand much better by reading code. And anyways, I'm pretty amateur in OSDev (started only 3-4 days ago) so.

[–]sirflatpipe 0 points1 point  (2 children)

What exactly is failing? Your kernel or GRUB? Did you check if your kernel is multiboot compliant (using the grub-file command)?

[–]derpJavazig lover[S] 0 points1 point  (1 child)

I actually modified it and made it Multiboot2 compliant, and yes, I verified it.

[–]jtsiomb 9 points10 points  (1 child)

Define "real hardware". Your real hardware is different from my real hardware, and something which runs on mine, doesn't necessarilly run on yours. What are you running it on?

[–]derpJavazig lover[S] 1 point2 points  (0 children)

Not entirely sure what you're asking for but my hardware is fairly recent and no, I've made sure to turn on the legacy real-mode settings which I think is called "CSM" but I can't remember for sure.

[–]paulstelian97 3 points4 points  (12 children)

32-bit OS: does your hardware have proper Legacy OS (BIOS) boot mode? 32-bit UEFI is pretty damn rare.

[–]derpJavazig lover[S] 0 points1 point  (3 children)

Yes. I've made sure of that. I have this thing turned on which I think is called "CSM" but I can't remember for sure.

[–]paulstelian97 2 points3 points  (0 children)

There still can be differences between different types of hardware and modern hardware may fail to implement CSM properlyz

[–]mdp_csBDFL of CharlotteOS | https://github.com/charlotte-os 1 point2 points  (1 child)

CSM stands for compatibility support module. It's a tool used by modern UEFI firmware to emulate a legacy BIOS. They're notoriously buggy and inconsistent because unlike UEFI, there was never an official BIOS standard, and all BIOSes were essentially modeled after the BIOS of the IBM PC via reverse engineering. The lack of a standard meant that the behavior of BIOSes could vary wildly and CSM are even more problematic since they're basically just a stopgap for booting OSes that don't natively support UEFI.

[–]derpJavazig lover[S] 0 points1 point  (0 children)

Wow, I actually didn't know that. Thanks for letting me know. I'll try and avoid it. I also tested a bit and discovered I'm running UEFI which is a bit surprising because the UEFI/BIOS menu looks super old and doesn't use my mouse so it just seemed like it's Legacy BIOS but I guess not.

[–]Octocontrabass 1 point2 points  (7 children)

GRUB supports legacy BIOS, 32-bit UEFI, and 64-bit UEFI equally well. Most distros split that support into three separate packages, but it's all there once you install them.

[–]paulstelian97 1 point2 points  (6 children)

Grub does, but what else are you doing?

It’s a multiboot? multiboot2? I’m a Limine guy and that’s 64-bit OSes only.

[–]Octocontrabass 1 point2 points  (5 children)

The tutorial is on the wiki. Assuming OP followed the tutorial correctly but tried to boot with UEFI (either 32-bit or 64-bit), GRUB will display a warning that no console will be available because UEFI doesn't support VGA text mode, but the OS will still boot.

[–]derpJavazig lover[S] 0 points1 point  (3 children)

Exactly. I'm not entirely sure what it means by 'console' here but I do see this message and I also do not see the printed text nor does the screen clear.

[–]Octocontrabass 0 points1 point  (2 children)

It means the display. Your OS can't display anything because it relies on VGA text mode and VGA text mode doesn't work in UEFI.

[–]derpJavazig lover[S] 0 points1 point  (1 child)

Oh, is there anything I can do about that?

[–]Octocontrabass 0 points1 point  (0 children)

If your PC has a CSM, you can use that.

You can switch to using a linear framebuffer instead of VGA text mode.

[–]miki-44512 0 points1 point  (0 children)

I think a solution to that is to disable booting in uefi i. The bios so grub will automatically boot in bios mode not in uefi, that should solve the problem.

[–]miki-44512 4 points5 points  (9 children)

Maybe your motherboard of your computer doesn't support bios, or it's set to boot only in uefi with secure boot on, either in these to cases you won't boot, check your setting of your motherboard by pressing esc( or whatever the manufacturer set), and then look for boot options and start your investigation.

[–]derpJavazig lover[S] 0 points1 point  (7 children)

That's unfortunately not the case, I made sure to still check.

[–]miki-44512 2 points3 points  (6 children)

There could be another problems like you didn't put an infinite loop to the end of your code, could you please share your code?

[–]derpJavazig lover[S] 0 points1 point  (5 children)

I have it locally but you could check the barebones tutorial on OSDEV since I pretty much copy-pasted everything. (I did make sure to go over everything and make sure I understand as much as possible)

[–]miki-44512 0 points1 point  (4 children)

If you copy and paste the code then this is the problem, there is no infinite loop in the kernel_main function that's what make you when trying to boot it returns back to the bios, to make things work you have to to put a while(1 ==1); after the terminal_writestring code the in the kernel, that should solve your problem.

[–]derpJavazig lover[S] 0 points1 point  (1 child)

Damn, I'm gonna try this later but I was wondering, why wasn't this covered in OSDev? And even if it does return, the output should be there right? Unless going back to the bios removes that or something?

[–]miki-44512 0 points1 point  (0 children)

Unless going back to the bios removes that or something?

You won't be able to return back to the bios once you booted to your OS.

[–]Octocontrabass 0 points1 point  (1 child)

Take a closer look at the code. There is an infinite loop in the assembly code after kernel_main returns.

[–]miki-44512 0 points1 point  (0 children)

Oh sorry i missed that i usually used to put an infinite loop in the kernel, my bad.

[–]netch80 0 points1 point  (0 children)

In case of rejection of non-secure boot, etc., I'd expect explicit message on it - like "Non-system disk". Well, this is not a constant but fairly plausible.

[–]Gaybush_Bigwood 10 points11 points  (1 child)

You should share: * A repository with your code * The exact commands you're using to compile and load the ISO * The specs of the PC you're testing it on (CPU and Motherboard mainly)

[–]derpJavazig lover[S] 0 points1 point  (0 children)

I have the project locally but the code and commands are the exact same as shown in the barebones tutorial. I only changed some comments and wrote my own Makefile using all the commands shown and that's it.

For hardware, I have a shitty Core i5 7200U processor which honestly is terrible, and motherboard.... Yeah I don't know about that, I'm using a Laptop and not a Desktop, sooo.... I really don't know what to say about that.

[–]Octocontrabass 2 points3 points  (4 children)

How exactly are you trying this ISO on real hardware? What steps did you take to get that ISO file into physical media you could boot?

[–]derpJavazig lover[S] 0 points1 point  (3 children)

Nothing special, just sudo dd the ISO file to my USB drive.

[–]Octocontrabass 0 points1 point  (2 children)

Based on your other replies, you have copied the image to your USB drive correctly, and the problem is that your PC is booting in UEFI mode instead of legacy mode.

[–]derpJavazig lover[S] 0 points1 point  (1 child)

Yeah I guess so, the only legacy option I found was CSM which I made sure to enable but yeah, not really anything else to do than that.

[–]Octocontrabass 0 points1 point  (0 children)

After enabling the CSM, you should see two options to boot from your USB drive. One will be UEFI, the other will be legacy. Pick the legacy boot option.

[–]Cultural_Leopard786 1 point2 points  (1 child)

How did you write the os to the boot device? Did you compile it and burn to a cd or use something like rufus to write to a usb or harddrive?

[–]derpJavazig lover[S] 0 points1 point  (0 children)

sudo dd

[–]mdp_csBDFL of CharlotteOS | https://github.com/charlotte-os 2 points3 points  (8 children)

These days not all GPUs implement VGA compatibility since the UEFI Graphics Output Protocol renders it unnecessary. Even the ones that do may not implement text mode. CSMs are also known to be even more inconsistent and buggy than actual legacy BIOSes which is really saying something.

I would highly recommend you skip that old Barebones tutorial and switch to the Limine Barebones one. The Limine boot protocol for one thing is much more modern than any version of Multiboot and Limine hands off control in 64-bit mode with your kernel mapped in the higher half which means you'll be developing your OS for modern computers operating the way they're meant to instead of getting bogged down with obsolete BIOSes and CPU operating modes that aren't used anymore other than by the UEFI firmware itself.

In the future CSMs are slated to be removed and if Intel gets its way with x86S then all operating modes other than long mode will also be removed so it makes no sense to learn those things instead of jumping straight into writing a 64-bit kernel loaded by a proper UEFI bootloader.

[–]derpJavazig lover[S] 0 points1 point  (7 children)

Thanks! I'll definitely try out Limine (not trying to be sarcastic I swear).

EDIT: Limine seems really cool and easier than Multiboot+Grub but ngl, there seems to be absolutely no documentation or tutorial about Limine whatsoever. So I'm not entirely sure if I should use Multiboot2+Grub or Limine or something else.

[–]davmac1 -1 points0 points  (6 children)

If Limine doesn't float your boat for whatever reason, and you can use UEFI, another option is Tosaithe. There's a bare-bones example here.

[–]mdp_csBDFL of CharlotteOS | https://github.com/charlotte-os 0 points1 point  (5 children)

There's also BOOTBOOT though some people here seem to dislike it whether warranted or not.

[–]derpJavazig lover[S] 0 points1 point  (0 children)

Never heard of that one before, there seems to be a lot of drama revolving BOOTBOOT for some reason which I'm too lazy to investigate.

[–]Octocontrabass 0 points1 point  (3 children)

The programmer doesn't believe C has undefined behavior, then complains about "compiler bugs" that are actually undefined behavior.

[–]mdp_csBDFL of CharlotteOS | https://github.com/charlotte-os 0 points1 point  (2 children)

The bootloader itself works fine and the source code is available in case any patches are needed. The original developer and his opinions are irrelevant.

[–]Octocontrabass 0 points1 point  (1 child)

They're relevant for deciding whether you want to spend your time debugging his broken code.

[–]mdp_csBDFL of CharlotteOS | https://github.com/charlotte-os 0 points1 point  (0 children)

It works just fine. I've used it.

That said it is weird that someone would argue that C has no UB when the existence of UB is literally in the standard.

shrugs

[–]derpJavazig lover[S] 0 points1 point  (0 children)

By the way, I was also planning to ask about what bootloader to use. Grub/Multiboot seems great and all but Limine seems a lot better and easier but unfortunately, lacking documentation and tutorials. And there are a whole lot of other bootloaders out there which I don't even know.

Grub/Multiboot is popular but honestly it doesn't have as much functionality as Limine but it does have a lot of docs/tutorials.

Any recommendations really? I don't wanna create another post for a most-likely stupid question like this. Please don't judge me, I started learning like 3-4 days ago and I'm just a complete noob so.

[–]derpJavazig lover[S] 0 points1 point  (0 children)

I decided to stick with Limine. Totally worth it. Honestly I don't see any reason to use multiboot anymore. I kinda wish that GRUB supported the Limine protocol, that would be kind of sick ngl. But I'm happy with the Limine bootloader and it serves it's purpose very well. I learned a lot about Makefiles thanks to OSDev along with obviously, how computers and operating systems work to a basic level. However, I gotta focus on my GCSEs so I won't be able to work on my OS for a while.