Missing operating system!

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.
Romiro27
Posts: 10
Joined: Sat Aug 08, 2020 1:16 pm
Location: Russia, Volgograd

Missing operating system!

Post by Romiro27 »

Hello everyone, I'm new to OS development so I hope you can understand me.

After doing everything according to the Bare Bones tutorial (I just copied and pasted, whether it works or not :) ), I compiled the kernel (the compilation went without errors).

But then the trouble came - when starting the OS using QEMU, except for GRUB, nothing worked.

After that, I decided to write the OS image to a USB flash drive and boot from it. The only thing I got was "missing operating system"

to be honest, I have no idea what the problem is, because all stages of compilation go through without errors.
Attachments
linker.ld
(1.05 KiB) Downloaded 107 times
kernel.c
(2.58 KiB) Downloaded 118 times
boot.asm
(4.48 KiB) Downloaded 97 times
Octocontrabass
Member
Member
Posts: 5759
Joined: Mon Mar 25, 2013 7:01 pm

Re: Missing operating system!

Post by Octocontrabass »

Romiro27 wrote:But then the trouble came - when starting the OS using QEMU, except for GRUB, nothing worked.
Did GRUB give you an error, or did it successfully boot your kernel and your kernel just didn't do anything?
Romiro27 wrote:After that, I decided to write the OS image to a USB flash drive and boot from it. The only thing I got was "missing operating system"
How did you write it to the flash drive?
Romiro27
Posts: 10
Joined: Sat Aug 08, 2020 1:16 pm
Location: Russia, Volgograd

Re: Missing operating system!

Post by Romiro27 »

Octocontrabass wrote:Did GRUB give you an error, or did it successfully boot your kernel and your kernel just didn't do anything?
No, GRUB starts successfully
Octocontrabass wrote:How did you write it to the flash drive?
I wrote it down on a flash drive using the method from the Bare Bones tutorial (like the entire system as a whole).
Octocontrabass
Member
Member
Posts: 5759
Joined: Mon Mar 25, 2013 7:01 pm

Re: Missing operating system!

Post by Octocontrabass »

Romiro27 wrote:No, GRUB starts successfully
What happens after GRUB starts?
Romiro27 wrote:I wrote it down on a flash drive using the method from the Bare Bones tutorial (like the entire system as a whole).
What was the device name you used?
Romiro27
Posts: 10
Joined: Sat Aug 08, 2020 1:16 pm
Location: Russia, Volgograd

Re: Missing operating system!

Post by Romiro27 »

Octocontrabass wrote:What happens after GRUB starts?
After GRUB boots, nothing happens.
Octocontrabass wrote:What was the device name you used?
I do not quite understand, but if you are talking about a USB flash drive, then some kind of Kingston.

(Forgive me in advance for possible mistakes, I am not a native speaker of English)
Octocontrabass
Member
Member
Posts: 5759
Joined: Mon Mar 25, 2013 7:01 pm

Re: Missing operating system!

Post by Octocontrabass »

Romiro27 wrote:After GRUB boots, nothing happens.
What does GRUB display?
Octocontrabass wrote:I do not quite understand, but if you are talking about a USB flash drive, then some kind of Kingston.
No, I mean the letters after "/dev/" in the command.
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: Missing operating system!

Post by bzt »

Romiro27 wrote:After GRUB boots, nothing happens.
This can't be. If you have GRUB booted, then something must happen (a menu, a prompt, an error message displayed, anything). Octorontrabass is right, I believe he's on the right track with his questions.

Just in case, if the problem is caused by the incorrect imaging of the device, I'd suggest to try out USBImager. This is a very minimal GUI app for Win, MacOS, Linux. If you experience the same issue using two different imaging method, then you can be sure the problem is with your image (namely with your GRUB setup within that image) and not with the process how you write the image to the device.

Cheers,
bzt
Romiro27
Posts: 10
Joined: Sat Aug 08, 2020 1:16 pm
Location: Russia, Volgograd

Re: Missing operating system!

Post by Romiro27 »

Octocontrabass wrote:What does GRUB display?
bzt wrote:This can't be. If you have GRUB booted, then something must happen (a menu, a prompt, an error message displayed, anything).
When launched in QEMU, the GRUB menu is shown with a choice of OS to start, after which nothing happens (again, all the sources were copied from the Bare Bones tutorial).

When starting from a USB stick, the error "missing operating system" is displayed.
Octocontrabass wrote:No, I mean the letters after "/dev/" in the command.
/dev/sdb1
Octocontrabass
Member
Member
Posts: 5759
Joined: Mon Mar 25, 2013 7:01 pm

Re: Missing operating system!

Post by Octocontrabass »

Romiro27 wrote:When launched in QEMU, the GRUB menu is shown with a choice of OS to start, after which nothing happens (again, all the sources were copied from the Bare Bones tutorial).
What happens if you select one of those choices using the arrow keys, and then start it with the enter key?
Romiro27 wrote:/dev/sdb1
That is a partition. You must write it to the whole device using "/dev/sdb" instead of "/dev/sdb1".
Romiro27
Posts: 10
Joined: Sat Aug 08, 2020 1:16 pm
Location: Russia, Volgograd

Re: Missing operating system!

Post by Romiro27 »

Octocontrabass wrote:What happens if you select one of those choices using the arrow keys, and then start it with the enter key?
As I wrote, nothing
Octocontrabass wrote:That is a partition. You must write it to the whole device using "/dev/sdb" instead of "/dev/sdb1".
Sorry, I was wrong, of course the recording was on /dev/sdb, otherwise there would have been an error
Octocontrabass
Member
Member
Posts: 5759
Joined: Mon Mar 25, 2013 7:01 pm

Re: Missing operating system!

Post by Octocontrabass »

Romiro27 wrote:As I wrote, nothing
Are you sure it's not triple-faulting and rebooting?
Romiro27
Posts: 10
Joined: Sat Aug 08, 2020 1:16 pm
Location: Russia, Volgograd

Re: Missing operating system!

Post by Romiro27 »

Octocontrabass wrote:Are you sure it's not triple-faulting and rebooting?
I'm not sure, but as I understand it, the triple fault causes the PC to restart, which is not happening for me.
PeterX
Member
Member
Posts: 590
Joined: Fri Nov 22, 2019 5:46 am

Re: Missing operating system!

Post by PeterX »

It's hard to find a bug here!

Could you tell here the (complete!) commands you use for
- compiling and linking (not the linker script but the shell commands)
- running Qemu
- creating the OS image
- writing the kernel (or OS image) to disk

EDIT: This might not be the issue, but I couldn't find a "bits 32" instruction at the beginning of boot.asm.
Thanks
Peter
Romiro27
Posts: 10
Joined: Sat Aug 08, 2020 1:16 pm
Location: Russia, Volgograd

Re: Missing operating system!

Post by Romiro27 »

PeterX wrote:- compiling and linking (not the linker script but the shell commands)
I have a Makefile, sorry if it's awkward and not formatted correctly

Code: Select all

CC=gcc-10
ASM=nasm
LD=gcc-10

CCSRC=src/c/
ASMSRC=src/asm/
LDSRC=src/ld/

CCTARGET=build/kernel.o
ASMTARGET=build/boot.o
LDTARGET=build/os.bin

CCFLAGS=-c $(CCSRC)kernel.c -o $(CCTARGET) -std=gnu99 -ffreestanding -O2 -Wall -Wextra
ASMFLAGS=-felf32 $(ASMSRC)boot.asm -o $(ASMTARGET)
LDFLAGS=-T $(LDSRC)linker.ld -o $(LDTARGET) -ffreestanding -O2 -nostdlib $(ASMTARGET) $(CCTARGET) -lgcc

all: clean c asm ld isodir

c:
	@echo 'CC $(CCSRC)kernel.c	-> $(CCTARGET)'
	@$(CC) $(CCFLAGS)

asm:
	@echo 'ASM $(ASMSRC)boot.asm	-> $(ASMTARGET)'
	@$(ASM) $(ASMFLAGS)

ld:
	@echo 'LD $(LDSRC)linker.ld	-> $(LDTARGET)'
	@$(LD) $(LDFLAGS)

isodir:
	@mkdir -p isodir/boot/grub
	@cp $(LDTARGET) isodir/boot/os.bin
	@cp grub.cfg isodir/boot/grub/grub.cfg
	@grub-mkrescue -o os.iso isodir

clean:
	@echo 'CLEAN $(CCTARGET)' 
	@rm -f build/$(CCTARGET)
	@echo 'CLEAN $(ASMTARGET)'
	@rm -f build/$(ASMTARGET)
	@echo 'CLEAN $(LDTARGET)'
	@rm -f build/$(LDTARGET)
	@echo 'CLEAN ISO AND ISODIR'
	@rm -r isodir
	@rm os.iso
PeterX wrote:- running Qemu
qemu-system-i386 -nographic -cdrom os.iso
PeterX wrote:- creating the OS image
In the Makefile above
PeterX wrote:- writing the kernel (or OS image) to disk
dd if=myos.iso of=/dev/sdb && sync

EDIT: bits 32 at the beginning of boot.asm didn't help
PeterX
Member
Member
Posts: 590
Joined: Fri Nov 22, 2019 5:46 am

Re: Missing operating system!

Post by PeterX »

I would suggest that you do some debug output in boot.asm and as the first instruction in main(). If that works, your terminal code is wrong. If that doesn't work, your boot code is wrong.

In boot.asm: Write byte 'A' to [0xB8000].
In main(): Write byte 'B' to a pointer with address 0xB8002.

Greetings
Peter
Post Reply