linuxbootloaderbochsfloppy

bochs booting from floppy FLOPPY: read() on floppy image returns 0


i study os recently, but I can not make bootloader work

bochsrc.floppy:

#configuration file generated by Bochs
plugin_ctrl: biosdev=1, speaker=1, extfpuirq=1, parallel=1, serial=1, iodebug=1 ,unmapped=0
config_interface: textconfig
display_library: x
memory: host=2048, guest=2048
romimage: file="/usr/local/share/bochs/BIOS-bochs-latest"
vgaromimage: file="/usr/local/share/bochs/VGABIOS-lgpl-latest"
boot: floppy
floppy_bootsig_check: disabled=0
floppya: type=1_44, 1_44="boot.img", status=inserted, write_protected=0
#no floppyb
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
ata0-master: type=none
ata0-slave: type=none
ata1: enabled=1, ioaddr1=0x170, ioaddr2=0x370, irq=15
ata1-master: type=none
ata1-slave: type=none
ata2: enabled=0
ata3: enabled=0
pci: enabled=1, chipset=i440fx
vga: extension=vbe, update_freq=5
cpu: count=1:1:1, ips=4000000, quantum=16, model=corei7_ivy_bridge_3770k, reset_on_triple_fault=1, cpuid_limit_winnt=0, ignore_bad_msrs=1, mwait_is_nop=0, msrs="msrs.def"
cpuid: x86_64=1,level=6, mmx=1, sep=1,  aes=1, movbe=1, xsave=1,apic=x2apic,sha=1,movbe=1,adx=1,xsaveopt=1,avx_f16c=1,avx_fma=1,bmi=bmi2,1g_pages=1,pcid=1,fsgsbase=1,smep=1,smap=1,mwait=1 
cpuid: family=6, model=0x1a, stepping=5, vendor_string="GenuineIntel", brand_string="Intel(R) Core(TM) i7-3770 CPU (Haswell)"
print_timestamps: enabled=0
debugger_log: -
magic_break: enabled=0
port_e9_hack: enabled=0
private_colormap: enabled=0
clock: sync=none, time0=local, rtc_sync=0
# no cmosimage
# no loader
log: -
logprefix: %t%e%d
debug: action=ignore
info: action=report
error: action=report
panic: action=ask
keyboard: type=mf, serial_delay=250, paste_delay=100000, user_shortcut=none
mouse: type=ps2, enabled=0, toggle=ctrl+mbutton
speaker: enabled=1, mode=system
parport1: enabled=1, file=none
parport2: enabled=0
com1: enabled=1, mode=null
com2: enabled=0
com3: enabled=0
com4: enabled=0
megs: 148

then there is tow asm files,boot.asm and loader.asm

run.sh:

nasm boot.asm -o boot.bin
nasm loader.asm -o loader.bin
dd if=boot.bin of=boot.img bs=512 count=1 conv=notrunc

if [ ! -e tmp ];then
             mkdir tmp
fi

mount -t vfat -o loop boot.img tmp/

cp loader.bin tmp/
sync
umount tmp/

rmdir tmp
if [ -e /usr/bin/bochs ];then
    /usr/bin/bochs -qf bochsrc.floppy
else
    echo "Please check your bochs environment!!!"
    exit 1
fi

when executed cp command:

cp: cannot create regular file 'tmp/loader.bin': No space left on device

finally, this error in bochs Booting from 0000:7c00 [FLOPPY] read() on floppy image returns 0

Can someone explain to me what is wrong?


Solution

  • In the original project their run.sh file contained a crucial set of lines that creates the disk image boot.img so that it is the size of a 1.44MB floppy. You will need to add them to the top of your run.sh:

    if [ -e boot.img ];then
        echo "find boot.img !"
    else
        echo "no boot.img! generating..."
        echo -e  "1\nfd\n\nboot.img\n" | bximage
    fi
    

    These lines check that a boot.img file already exists. If boot.img already exists the existing one is used otherwise a new one is created. You could also replace:

    echo -e  "1\nfd\n\nboot.img\n" | bximage
    

    with:

    dd if=/dev/zero of=boot.img bs=1024 count=1440
    

    Important Note: You will need to remove your old boot.img file that isn't the correct size so that a new properly sized one is generated by the code above.