Page 1 of 1

About copy-boot and bootable images

Posted: Tue Sep 30, 2014 11:53 am
by nextvolume
About copy-boot and bootable images

It is unfortunately not normally possible to build bootable Visopsys images
on non-Linux platforms. The problem lies in the following piece of code in the
setOsLoaderParams() function in src/programs/copy-boot.c (the source code for the copy-boot program, which copies the boot sector on a device or image):

Code: Select all

#ifdef VISOPSYS
		// For some reason the Linux driver gives us the second unused cluster
		firstUnusedCluster += 1;
#endif
While this piece of code seems to be needed due to a quirk of Linux's FAT filesystem driver, this makes loading vloader (the second-stage bootloader) fail when the FAT filesystem is written using other filesystem drivers (such as NetBSD's).

A provisional solution when building 0.74 is simply to comment the piece of code out. The definitive solution is obviously changing the #ifdef to something like #ifdef linux (check this, I don't remember exactly what is set by the Linux system headers)

Also, the shipped scripts to build floppy and CD images only work for Linux systems, as they use Linux specific utilities and features and they require
being run as root.

It is however possible to make a working floppy image in the following way:
- make a 1440K blank image, and format it using your platform's own tool
Let's call this image testflp.img
- run copy-boot on the image ( ./copy-boot ../build/system/boot/bootsect.fat testflp.img)
- use the tools provided by the MTools suite in order to copy the files on the floppy
image, remembering to first copy vloader (the second-stage bootloader), then visopsys (the kernel) and then everything else

This results is a working floppy image, and it does not even require root priviliges to make.

A CD image is made likewise, just remember to make a root cd filesystem, copy the files for the live CD environment on it, copy the bootable floppy image in it,
and run a tool like mkisofs specifying that you want to make ISO image bootable using floppy emulation.

Notice, also, that GCC versions <= 4.5 miscompile the Visopsys kernel, and you'll run in all kinds of problems. Use a GCC version >= 4.6 and they will go away. Old Visopsys kernel versions compiled fine with GCC <= 4.5, and maybe this has something to do with how fpu registers are backed-up and restored? I don't exactly know, just a guess.

Re: About copy-boot and bootable images

Posted: Wed Oct 01, 2014 11:14 am
by andymc
nextvolume wrote:A provisional solution when building 0.74 is simply to comment the piece of code out. The definitive solution is obviously changing the #ifdef to something like #ifdef linux (check this, I don't remember exactly what is set by the Linux system headers)

Also, the shipped scripts to build floppy and CD images only work for Linux systems, as they use Linux specific utilities and features
This is true, yes. I've not tried to develop Visopsys on other systems, nor do I have any BSDs or similar to try it with. I guess I could install one in a VM, but even better if one of our contributors can help out with this! :shifty:
nextvolume wrote:This results is a working floppy image, and it does not even require root priviliges to make.
Good stuff, thanks mate!
nextvolume wrote:Notice, also, that GCC versions <= 4.5 miscompile the Visopsys kernel, and you'll run in all kinds of problems. Use a GCC version >= 4.6 and they will go away. Old Visopsys kernel versions compiled fine with GCC <= 4.5, and maybe this has something to do with how fpu registers are backed-up and restored? I don't exactly know, just a guess.
Grr, yeah, the GCC guys are always messing about and breaking things between versions. Usually I have to keep up with the more recent versions, because if those are broken I'm more likely to get bug reports from people trying to build it. The FPU stuff uses inline assembler macros.