1

So I'm currently working on my own OS (just for fun), and it's currently being compiled into an IMG file. I know it's not needed but I would like to try and compile it into an ISO, but so far I've had no luck with it. I'm not quite sure which files are needed, so just ask for them and I will edit the post :)

When I run the img I get this: IMG result

But when I run the ISO I get this: ISO result

Here's my compile script I wrote in batch:

@echo off

echo Building KronkOS floppy image!
echo.
echo Assembling bootloader...
echo ======================================================
wsl nasm -f bin bootloader/boot.asm -o bootloader/boot.bin
echo Done!

echo.
echo Assembling KronkOS kernel...
echo ======================================================
wsl nasm -f bin kernel.asm -o KERNEL.BIN -l kernel_list.lst
echo Done!

::echo.
::echo Creating elf kernel file...
::echo ======================================================
::wsl nasm -f elf32 -o kernel.o kernel.asm
::wsl ld -m elf_i386 -o kernel.elf kernel.o
::del kernel.o
::echo Done!

::echo.
::echo Assembling programs...
::echo ======================================================
::cd programs
::    for %%i in (*.BKF) do del %%i
::    for %%i in (*.ASM) do wsl nasm -O0 -f BIN %%i
::    for %%i in (*.) do ren %%i %%i.BKF
::cd ..
::echo Done!

echo.
echo Adding bootsector to disk image...
echo ======================================================
wsl mformat -f 1440 -B bootloader/boot.bin -C -i images/KronkOS.img
echo.
echo Done!

echo.
echo Copying kernel and applications to disk image...
echo ======================================================
wsl mcopy -D o -i images/KronkOS.img KERNEL.BIN ::/
wsl mcopy -D o -i images/KronkOS.img programs/*.BKF ::/
wsl mcopy -D o -i images/KronkOS.img programs/*.BAS ::/
echo.
echo Done!

echo.
echo Do you want to build and ISO?
echo ======================================================
choice /c YN
if errorlevel 1 set x=1
if errorlevel 2 set x=2

if "%x%" == "1" (
    cd images
    wsl genisoimage -input-charset utf-8 -o KronkISO.iso -V KRONKOS -b KronkOS.img ./
    cd..
    echo.
    echo Done!
)

echo.
echo ======================================================
echo Build done!
choice /c YN /m "Run KronkOS build in QEMU?"
if errorlevel 1 set y=1
if errorlevel 2 set y=2

if "%y%" == "1" (
    if "%1" == "-d" (
        wsl sh -c "export DISPLAY=0:0 && qemu-system-x86_64 -s -S -fda images/KronkOS.img"
    ) else (
        if "%x%" == "1" (
            wsl sh -c "export DISPLAY=0:0 && qemu-system-x86_64 images/KronkISO.iso"
        ) else (
            wsl sh -c "export DISPLAY=0:0 && qemu-system-x86_64 -fda images/KronkOS.img"
        )
    )
)'
cls
  • Regarding `export DISPLAY=0:0 && qemu-system-x86_64 images/KronkISO.iso`- If you want to boot ISO try `export DISPLAY=0:0 && qemu-system-x86_64 -cdrom images/KronkISO.iso` . I've specified `cdrom` as the boot device. – Michael Petch Nov 13 '20 at 21:11
  • 2
    I'm voting to reopen since there is more than enough in this to identify a problem and I believe there is a solution. Technically the solution isn't to a programming problem but it is part of kernel development and Stackoverflow fields similar questions already. – Michael Petch Nov 13 '20 at 21:14
  • 1
    Adding the -cdrom working, also I change the tool I used to convert it into an ISO form fat_imgen to mtools since it was creating some problems... now everything seems to work like a charm, thanks again Michael. Also I agree, if you ask me... how to compile an OS into an ISO seems pretty fitting for stackoverflow. – Insert joke here Nov 14 '20 at 00:38
  • After some testing, I've discovered that it appears that it's having some trouble when it runs my read/write code... but I guessing that this is more of a problem with my kernel code than a problem in the way that I create my ISO. Although I'm not sure, since it works when I'm running the IMG but halts when I'm running the ISO. – Insert joke here Nov 14 '20 at 00:43
  • Probably because your ATA code doesn't work with CDROM ATAPI devices. – Michael Petch Nov 14 '20 at 02:04
  • Ah yeah, that makes sense – Insert joke here Nov 14 '20 at 11:57

1 Answers1

1

So I changed the tool I used to convert it into an ISO from fat_imgen to mtools.
I also followed what Michael Petch suggested in a comment which was to use the -cdrom option in qemu, and now everything seems to work as it should.