In the process of slowly developing my OS I've been poking around with the brokenthorn.com tutorials about OS development. In particular, I've been trying to convert the "BUILD.bat" batch files in the tutorial to Makefiles.
This is what I have so far -
Code: Select all
This is the code for the first batch file.
nasm -f bin Boot1.asm -o Boot1.bin
PARTCOPY Boot1.bin 0 3 -f0 0
PARTCOPY Boot1.bin 3E 1C2 -f0 3E
pause
Code: Select all
# Demo1 - Makefile - Stage 1
# Author - mooseman
all:
nasm -f bin boot1.asm -o boot1.bin
dd bs=512 count=2880 if=/dev/zero of=floppy.img
mkfs.msdos floppy.img
sudo mount -o loop floppy.img /media/floppy/
cp boot1.bin floppy.img
sudo umount /media/floppy/
Code: Select all
nasm -f bin Stage2.asm -o KRNLDR.SYS
copy KRNLDR.SYS A:\KRNLDR.SYS
pause
.... which I've converted to this - the Stage 2 binary is copied onto the existing floppy image from Stage 1 -
Code: Select all
# Demo1 - Makefile - Stage 2
# Author - mooseman
all:
nasm -f bin stage2.asm -o krnldr.sys
cp ~/plan_42/Demo1/Stage1/floppy.img .
sudo mount -o loop floppy.img /media/floppy/
cp krnldr.sys floppy.img
sudo umount /media/floppy/
Ok. Now, the good news is that the makefiles *work* - they do exactly as expected. The bad news is that the floppy image resulting from stage 2 doesn't boot ( I use Qemu for testing ).
This is the Qemu command I use - $ is the prompt -
$ qemu-system-i386 -boot once=a -fda floppy.img
This is the Qemu error that I get -
Booting from Floppy....
This is not a bootable disk. Please insert a bootable floppy and press any key to try again....
I am *so close* to a bootable image with having the makefiles working now!
I am *sure* that the problem lies in Stage1 with the two PARTCOPY commands (PARTCOPY is apparently an obscure copying utility made by John Fine. )
http://www.brokenthorn.com/Resources/Pr ... RTCOPY.TXT
What I believe I need to be able to do is to reproduce these two commands from the first batch file *exactly*, using dd -
PARTCOPY Boot1.bin 0 3 -f0 0
PARTCOPY Boot1.bin 3E 1C2 -f0 3E
From the PARTCOPY manual shown above -
"USAGE:
PARTCOPY source source_offset length destination {destination_offset}
Only destination_offset is optional. The other parameters are always required. The offsets and length are always in HEX. "
So - does anyone know how to reproduce those two commands using dd (or something else)?
Many thanks in advance -
- mooseman