Page 6 of 8

Re: Problem on real hardware

Posted: Wed Dec 07, 2011 1:57 pm
by Muneer
If your BIOS supports HDD booting, Boot your system. Goto BIOS. Change the settings that says USB EMULATION TYPE/MODE. Of course it depends on BIOS. And also beware of the USB stick (LBA).

Re: Problem on real hardware

Posted: Wed Dec 07, 2011 2:11 pm
by DavidCooper
guyfawkes wrote:
DavidCooper wrote:
guyfawkes wrote:One thing to NOTE do not try and read a number of sectors at a time, its buggy, read one sector at a time, but do it in a loop.
There's no need to go that far, and at the moment it only needs to load one for the kernel to respond when jumped to. It isn't doing that, so it looks as if none of it's being loaded.
But he's trying to read more than one sector at a time
What are the odds against the first of the 50 sectors failing to load every time he tries it on real hardware if the only problem is that he's trying to load 50 sectors in one go? If it fails at the second sector or later, the first one will already be in memory, but it seems that that isn't happening. I've never had any trouble getting BIOSes to load 18 sectors at a time from floppy disks, so I can't see why you'd need to drop down to one-at-a-time for a hard drive (which is likely to be more reliable).

Re: Problem on real hardware

Posted: Wed Dec 07, 2011 2:16 pm
by DavidCooper
HardCoder wrote:If your BIOS supports HDD booting, Boot your system. Goto BIOS. Change the settings that says USB EMULATION TYPE/MODE. Of course it depends on BIOS. And also beware of the USB stick (LBA).
Surely you shouldn't need to do anything so radical? If it's booting the boot sector, it should already be set up to do the rest. If it is a USB device that Romfox is trying to boot from, this may be relevant:-

http://board.flatassembler.net/topic.php?t=12389

Is the bootsector the first sector of a partition, or has it been written over the MBR? If the latter, it will act like a floppy disk. If the former, it will act like a hard disk. Either way, it should have a BPB.

Edit: switched round "latter" and "former".

Re: Problem on real hardware

Posted: Wed Dec 07, 2011 2:18 pm
by romfox
I switched to HDD (it was auto) and it didnt work. After I tried in floppy mode and got an invalid partition error. =(

Edit : gonna try with a BPB.

Re: Problem on real hardware

Posted: Wed Dec 07, 2011 2:29 pm
by Muneer
I also had auto in there. Did you check whether your USB stick shows LBA(0x0C) while fat32 formated in Ubuntu Disk utility. If it is then I really cant help you. Maybe my Bios implementation is different.

Re: Problem on real hardware

Posted: Wed Dec 07, 2011 2:53 pm
by romfox
I have windows 7 and I format in auto (ntfs) cause I overwrite the 1st sector no ?
Where can I see LBA ?

Re: Problem on real hardware

Posted: Wed Dec 07, 2011 2:56 pm
by DavidCooper
romfox wrote:gonna try with a BPB.
Make sure your assembler uses a single-byte jump instruction at the start so that the table's correctly aligned. In the hex it should show up as EB.

Edit:-
romfox wrote:I have windows 7 and I format in auto (ntfs) cause I overwrite the 1st sector no ?
Where can I see LBA ?
I've only ever booted from floppy drive, so I can't make any further suggestions. It would however be a good idea if you explain what tools you're using to write to the device you're booting from and spell out where abouts you're putting your code on it. Also, if you're formatting it in ntfs, that's going to make things difficult for you later.

Re: Problem on real hardware

Posted: Wed Dec 07, 2011 3:11 pm
by romfox
Done (using the BOS's BPB). But still the same problem.

Edit : I use copy /b boot.bin+kernel.bin OS32.img
And dd if=OS32.img of=\\.\g: (cause Windows)
I've tried protecting the ds and es value but Still the same, blocking at the jump kernel time.

Re: Problem on real hardware

Posted: Wed Dec 07, 2011 3:14 pm
by guyfawkes
DavidCooper wrote: What are the odds against the first of the 50 sectors failing to load every time he tries it on real hardware if the only problem is that he's trying to load 50 sectors in one go? If it fails at the second sector or later, the first one will already be in memory, but it seems that that isn't happening. I've never had any trouble getting BIOSes to load 18 sectors at a time from floppy disks, so I can't see why you'd need to drop down to one-at-a-time for a hard drive (which is likely to be more reliable).
Well if you only have part of your code loaded and you jump to it, do you not think it will crash ?

And you may be luck with your 18 sector, but then you have not been coding a OS for long.
romfox wrote: Edit : gonna try with a BPB.
You need a BPB for fdd emulation, not needed for hdd emulation.

Re: Problem on real hardware

Posted: Wed Dec 07, 2011 3:21 pm
by DavidCooper
Have you got the right values in your BPB?

Provide more information: are you putting your bootsector into the first sector on the disk? If so, it will most likely pretend to be a floppy disk, and that will mean you need to put floppy disk values in the BPB and make sure you load sectors as if from a floppy disk (17 sectors the first time, then 18 for the next lot, and so on).

If you're not overwriting the MBR (first sector) on the disk but are putting your bootsector into the first sector of a partition, it will behave as a hard disk, in which case you need someone other than me to help you.

Re: Problem on real hardware

Posted: Wed Dec 07, 2011 3:25 pm
by Muneer
I dont know how to check it in windows 7 directly.

In the dirty way you could format the usb stick with fat32 and just get the mbr of the usb stick into a file. There are some apps for that though I dont remember. Then with a hex editor check if the 450th byte contains 0x0C.
or
If you have an ubuntu live CD, then you might have a quick look in the Disk Utility. It basically tells the addressing mode used in the USB stick. If it is 0x0B then it means it contains CHS addressing. 0x0C means LBA addressing.


EDIT: you could use cygwins dd for it.

Re: Problem on real hardware

Posted: Wed Dec 07, 2011 3:34 pm
by DavidCooper
guyfawkes wrote:Well if you only have part of your code loaded and you jump to it, do you not think it will crash ?
There's test code at the start of the kernel which should run if the first sector of it loads. I assume that Romfox has put enough of a delay after that to ensure that this would show up if the sector was loaded successfully, so it wouldn't matter if it crashed further on due to later sectors not loading.
And you may be luck with your 18 sector, but then you have not been coding a OS for long.
Quite long enough: I've got half a disk's-worth of data all loading and saving without errors on multiple machines - I have an indication on the screen which shows whenever a track has to be read twice, and it's only ever signalled errors with one new set of disks (though they have also worked without any errors after I cleaned them with lens cleaning tissues - there were patches on them in places where something had deposited disk-material-coloured smudges on the disk surface).

I did have a machine in which a failing fdc chip lost the ability to handle multiple sector loads/saves and I had to rewrite my OS to load/save one sector at a time to get round that. Later on (on a different machine) I had to change back to loading multiple sectors because I was no longer using interleaved sectors - loading one sector at a time with an interleaved disk meant it took four rotations to load a whole track (both sides), but with disks using non-interleaved sectors it was having to rotate 36 times to load a track because the BIOS wasn't quick enough to get ready in time for the next sector coming up. That was on a 486, so the problem might not happen on newer machines. There may also have been a rotation speed issue as some drives go faster than others, with slower ones giving bigger gaps between sectors (unless they were formated on that same drive).

Re: Problem on real hardware

Posted: Wed Dec 07, 2011 3:51 pm
by romfox
My BPB seems to work cause I can use my disk whenever overwritting its FAT. But I can only format it to NTFS or exFAT using Windows =/.
And emulating HDD or FDD do the same result : Reboot =(.

Edit : Formatting to FAT32, I will try using its BPB.

Re: Problem on real hardware

Posted: Wed Dec 07, 2011 3:56 pm
by DavidCooper
HardCoder recommended:-
HardCoder wrote:you could use cygwins dd for it.
I think that's the usual tool (many people only-half-jokingly say "dd" stands for "disk destroyer", and that's why I've never dared to use it and am still using floppies).

You still haven't made it clear where you're putting your bootsector on the disk.

Re: Problem on real hardware

Posted: Wed Dec 07, 2011 4:05 pm
by guyfawkes
@romfox, is your bootsector 512bytes ?
When assembled
As this does not look right

Code: Select all

times 510-($-$$) db 144
dw 0xAA55
Should that not be

Code: Select all

  TIMES 510-($-$$) DB 0

	  DW 0xAA55
But than again, i use fasm.