Having trouble booting from CD?
Posted: Thu Jun 11, 2015 7:55 am
So I've been developing a sort of mini OS (Go figure xD) and wanted to try booting from a CD. I used VirtualBox of course, and I've decided to use VirtualBox to develop it for the most part. But the end goal IS to create something bootable from a CD, even if it only works on my machine.
So I decided to try a simple bootloader and burning it to a CD as an iso, and running it. You know, as a simple 'Hello World'.
Boot for some reason, when I go into BIOS, and click on boot from CD, it goes directly to FreeDOS. I'm not entirely sure if this is an intermediate step to actually booting from CD, or if somehow the CD burner isn't working right, but I am just completely lost as to what I do next.
If you know why it's doing this, you can skip the next section.
Here's the installation method I went through:
Compiled with nasm flags: nasm C:/CustomOs/Bootloader.asm -f bin -o C:/CustomOs/Image/cdcontents/Bootloader.img
Then, using mkisofs, I turn it into a burnable iso image as so:
mkisofs/ -no-emul-boor -boot-load-size 4 -o Test_OS.iso -V Test_OS -b "Bootloader.img" C:/CustomOs/Image/cdcontents"
Don't know if it's worth mentioning but the iso size comes out to be 354 kb. Saw somewhere that it should be 1.44 Megabytes or something, don't know if my iso size being less could have anything to do with it.
Afterwards, I burn the iso to the disc and it burns successfully (As in, the windows disc burner recognizes my iso as a burnable image.)
I go back to boot through the BIOS, and I have to set Secure Boot off on my machine. Only way for it to detect the CD. I click on running the CD and-----
It goes to FreeDOS.
Again, it is entirely possible that this is intentional, and that FreeDos is just a median step to actually booting from a cd. If it is, then I would like to know how to go from FreeDos and run my test system.
If it is not supposed to go to FreeDos, then I am unsure as to what I am doing wrong. If you guys have any more questions about my system specs or anything, I'll respond promptly.
Finally, I am new to OS development, but I read theory and consider myself competent at assembly and c. I'm not trying to make the next Windows, just a for fun thing to show my friends. Also, I already use VirtualBox to debug. I would just like the capability to boot from a cd for stable 'releases' to test on actual hardware.
Thanks!
So I decided to try a simple bootloader and burning it to a CD as an iso, and running it. You know, as a simple 'Hello World'.
Boot for some reason, when I go into BIOS, and click on boot from CD, it goes directly to FreeDOS. I'm not entirely sure if this is an intermediate step to actually booting from CD, or if somehow the CD burner isn't working right, but I am just completely lost as to what I do next.
If you know why it's doing this, you can skip the next section.
Here's the installation method I went through:
Code: Select all
BITS 16
start:
mov sp, 4096
mov ax, 0x07C0 ; Set data segment to where we're loaded
mov ds, ax
keyb_in:
mov ah, 00h ; keyboard input subprogram
int 16h ; character input
; character is stored in al
mov [keyboard_in], al ; copy character from al to keyboard in.
mov al, [keyboard_in] ;I know this step is redundant, but i did it for practice sake.
mov ah, 0Eh
int 10h
cmp al, 0
je keyb_in
cmp al, '.' ;Will shutdown pc if user presses '.' on the keyboard.
je shutdown
jmp keyb_in
keyboard_in: db 0
shutdown:
;Connect to APM API ;WILL ATTEMPT TO TURN COMPUTER OFF
;mov AX,5301h
;xor BX,BX
;int 0x15
;Try to set APM version (to 1.2)
;MOV ax,530Eh
;XOR bx,bx
;MOV cx,0x0102
;INT 0x15
;Turn off the system
; MOV ax,5307h
;MOV bx,0001h
;MOV cx,0003h
;int 0x15
mov ah, 0Eh
mov al, '1'
int 10h
;perform an installation check
mov ah,53h ;this is an APM command
mov al,00h ;installation check command
xor bx,bx ;device id (0 = APM BIOS)
int 15h ;call the BIOS function through interrupt 15h
jc APM_error ;if the carry flag is set there was an error
;the function was successful
;AX = APM version number
;AH = Major revision number (in BCD format)
;AL = Minor revision number (also BCD format)
;BX = ASCII characters "P" (in BH) and "M" (in BL)
;CX = APM flags (see the official documentation for more details)
mov ah, 0Eh
mov al, '2'
int 10h
;connect to an APM interface
mov ah,53h ;this is an APM command
mov al,01;see above description
xor bx,bx ;device id (0 = APM BIOS)
int 15h ;call the BIOS function through interrupt 15h
jc APM_error ;if the carry flag is set there was an error
;otherwise, the function was successful
;The return values are different for each interface.
;The Real Mode Interface returns nothing.
;16-Bit Protected Mode Interface
;AX = Code Segment
;BX = Entry Point (Offset)
;CX = Data Segment
;SI = Code Segment Length
;DI = Data Segment Length
;32-Bit Protected Mode Interface
;AX = 32-Bit Code Segment
;EBX = 32-Bit Entry Point (Offset)
;CX = 16-Bit Code Segment
;DX = Data Segment
;ESI 0:15 = 32-Bit Code Segment Length
;ESI 16:31 = 16-Bit Code Segment Length
;DI = Data Segment Length
mov ah, 0Eh
mov al, '3'
int 10h
;disconnect from any APM interface
mov ah,53h ;this is an APM command
mov al,04h ;interface disconnect command
xor bx,bx ;device id (0 = APM BIOS)
int 15h ;call the BIOS function through interrupt 15h
jc .disconnect_error ;if the carry flag is set see what the fuss is about.
jmp .no_error
.disconnect_error: ;the error code is in ah.
cmp ah,03h ;if the error code is anything but 03h there was an error.
jne APM_error ;the error code 03h means that no interface was connected in the first place.
jmp shutdown
.no_error:
mov ah, 0Eh
mov al, '4'
int 10h
;Enable power management for all devices
mov ah,53h ;this is an APM command
mov al,08h ;Change the state of power management...
mov bx,0001h ;...on all devices to...
mov cx,0003h ;...power management on.
int 15h ;call the BIOS function through interrupt 15h
jc APM_error ;if the carry flag is set there was an error
mov ah, 0Eh
mov al, '5'
int 10h
;Set the power state for all devices
mov ah,53h ;this is an APM command
mov al,07h ;Set the power state...
mov bx,0001h ;...on all devices to...
mov cx,03h ;off
int 15h ;call the BIOS function through interrupt 15h
jc APM_error ;if the carry flag is set there was an error
APM_error:
mov ah, 0Eh
mov al, 'L' ;If system prints L, we can assume shutdown did not work and force shutdown is neccessary.
int 10h
;Exit (for good measure and in case of failure)
ret
times 510-($-$$) db 0 ; Pad remainder of boot sector with 0s
dw 0xAA55 ; The standard PC boot signature
Then, using mkisofs, I turn it into a burnable iso image as so:
mkisofs/ -no-emul-boor -boot-load-size 4 -o Test_OS.iso -V Test_OS -b "Bootloader.img" C:/CustomOs/Image/cdcontents"
Don't know if it's worth mentioning but the iso size comes out to be 354 kb. Saw somewhere that it should be 1.44 Megabytes or something, don't know if my iso size being less could have anything to do with it.
Afterwards, I burn the iso to the disc and it burns successfully (As in, the windows disc burner recognizes my iso as a burnable image.)
I go back to boot through the BIOS, and I have to set Secure Boot off on my machine. Only way for it to detect the CD. I click on running the CD and-----
It goes to FreeDOS.
Again, it is entirely possible that this is intentional, and that FreeDos is just a median step to actually booting from a cd. If it is, then I would like to know how to go from FreeDos and run my test system.
If it is not supposed to go to FreeDos, then I am unsure as to what I am doing wrong. If you guys have any more questions about my system specs or anything, I'll respond promptly.
Finally, I am new to OS development, but I read theory and consider myself competent at assembly and c. I'm not trying to make the next Windows, just a for fun thing to show my friends. Also, I already use VirtualBox to debug. I would just like the capability to boot from a cd for stable 'releases' to test on actual hardware.
Thanks!