Page 5 of 7
Re: Making a bootable image
Posted: Tue Nov 03, 2020 11:35 am
by Bonfra
MichaelPetch wrote:You don't actually print out an error message if you load a sector successfully
Ok I fixed it, the updated code is on github. But still in the real hardware hangs forever.
MichaelPetch wrote:How do you write your image to the USB stick?
I use
Rufus
Re: Making a bootable image
Posted: Tue Nov 03, 2020 11:44 am
by MichaelPetch
Did you add an error message when the 0xaa55 signature wasn't found? Did it actually find the disk signature of the VBR? Hanging doesn't tell me anything but it is important to know that the sector read actually contains the VBR before jumping to the VBR. If you read garbage into memory (all zeroes or whatever) and jump to it then who knows what it will do.
I don't know anything about RUFUS. Is it writing things as an ISO image? I really don't know. On Windows if I have to write directly to a USB stick I use Chrysocome DD that can be found here
http://www.chrysocome.net/dd and in particular this version
http://www.chrysocome.net/downloads/dd-0.6beta3.zip which supports an `od=` parameter.
Something like:
where disk.img is the name of your disk image and x: is the actual drive letter you want to write to (make sure you write to the correct drive!). You will have to have admin privileges in Windows for this to work correctly.
Re: Making a bootable image
Posted: Tue Nov 03, 2020 12:11 pm
by Bonfra
MichaelPetch wrote:Did you add an error message when the 0xaa55 signature wasn't found?
Yes, where was just a jump to error now is a jump to a specific error with a print:
Code: Select all
cmp WORD [0x7DFE], 0xAA55 ; Check Boot Signature
jne error.noBootSignature ; Error if not Boot Signature
...
.noBootSignature:
mov si, Message.Error.NoBootSignature
call BiosPrint
jmp hang
MichaelPetch wrote:Did it actually find the disk signature of the VBR?
Yes it does not print the error so I think it jumps.
MichaelPetch wrote:I don't know anything about RUFUS. Is it writing things as an ISO image?
I used it only for burning ISOs and Floppy images so it could be.
I tryied dd for windows and this is the result:
Yes the prompt is in administrator
Re: Making a bootable image
Posted: Tue Nov 03, 2020 12:51 pm
by MichaelPetch
Regarding the USB writing problem, I have seen that before as well. You may have to wipe out what is on the USB stick when it comes to existing partitioning info. Follow this guide:
https://www.howtogeek.com/235824/how-to ... -problems/ and when finished the `clean` command in the diskpart tool you are finished and you can type `exit` to return back to the command prompt. Try DD after that.
As for it finding the signature but not doing anything after jumping I really don't know. That makes very little sense. If that was the case then I almost wonder if you have the right code in the VBR. The only other thing I can think of is that the original bootloader at 0x7c00 was still present and never replaced by the disk read.
Re: Making a bootable image
Posted: Tue Nov 03, 2020 1:02 pm
by bzt
Bonfra wrote:MichaelPetch wrote:How do you write your image to the USB stick?
I use
Rufus
If "dd" doesn't work for you (it should), give a try to
USBImager. Portable executable, no installation required, about 300K only. But it's a GUI app, so unlike "dd" you can't use it from a Makefile.
About the "dd", instead of "od=i:" does "of=\\.\PhysicalDrive1" work? Just a guess, I'm not a Win expert. Use 0 for the first disk, 1 for the second etc. So if you have three fixed disks, then the USB stick going to be "\\.\PhysicalDrive3".
Cheers,
bzt
Re: Making a bootable image
Posted: Tue Nov 03, 2020 1:16 pm
by MichaelPetch
Chrysocome DD specifically added the `od=` (and `id=`) options and why I recommended the latest beta release that has that option.
Re: Making a bootable image
Posted: Tue Nov 03, 2020 1:20 pm
by bzt
MichaelPetch wrote:of=\\.\PhysicalDrive1 won't work. It will attempt to access things relative to the volume and not the beginning of the drive.
I seriously doubt that. "PhysicalDrive" has nothing to do with volumes, it reflects the raw drive.
MichaelPetch wrote:This was a common problem for people wanting to overwrite the MBR.
That works with USBImager perfectly. Tested by many users.
MichaelPetch wrote:That was the reason Chrysocome DD specifically added the `od=` (and `id=`) options.
I get that (and it is a pretty cool addition to dd on Win). How about "seek" and "skip"? Specially in combination with "PhysicalDrive" (Just a guess)?
Cheers,
bzt
Re: Making a bootable image
Posted: Tue Nov 03, 2020 2:19 pm
by Bonfra
Same problem as rufus, the image is written but the bootloader does not work.
MichaelPetch wrote:You may have to wipe out what is on the USB stick when it comes to existing partitioning info
Following the guide and cleaning the USB stick, change a bit the result, before it failed instantly, (In the previous screenshot 1M) now it advance to a higher number but still stops at some point.
MichaelPetch wrote:I almost wonder if you have the right code in the VBR
The code is in ./boot/boot.asm in the github repo. But if works in QEMU and is just a print it should work.
MichaelPetch wrote:
The only other thing I can think of is that the original bootloader at 0x7c00 was still present and never replaced by the disk read.
If this was the case (and has been due to some bugs that I've fixed) it should loop the successful read message since it jumps to itself.
I'm asking a friend to test in his own hardware I'll let you know if it works
Re: Making a bootable image
Posted: Tue Nov 03, 2020 2:26 pm
by Bonfra
Bonfra wrote:I'm asking a friend to test in his own hardware I'll let you know if it works
He used his own sandisk USB stick and an old compaq but the problem persist, no "Hello, World!" printed. He used rufus.
Re: Making a bootable image
Posted: Tue Nov 03, 2020 2:33 pm
by MichaelPetch
Can you humour me and do this.In your MBR you have
Code: Select all
LBA_Packet:
.packet_size db 0x10 ; use_transfer_64 ? 10h : 18h
.reserved db 0x00 ; always zero
.block_cout dw 0x01 ; number of sectors to read
.transfer_buffer dd 0x7C00 ; address to load in ram
.lba_value dq 0x0 ; LBA addres value
Change it so it is:
Code: Select all
align 4
LBA_Packet:
.packet_size db 0x10 ; use_transfer_64 ? 10h : 18h
.reserved db 0x00 ; always zero
.block_cout dw 0x01 ; number of sectors to read
.transfer_buffer dd 0x7C00 ; address to load in ram
.lba_value dq 0x0 ; LBA addres value
I have added `align 4` before the structure.
Re: Making a bootable image
Posted: Tue Nov 03, 2020 2:39 pm
by MichaelPetch
Can you do me a favor. Take your disk image that you burned and add it to your Github project (zip it if you like to save space). I'd like to take a look at the actual disk image that isn't working for you.
Re: Making a bootable image
Posted: Tue Nov 03, 2020 2:44 pm
by MichaelPetch
One other thing. Do you actually see the message 'VBR loaded!` displayed before it apparently hangs?
Re: Making a bootable image
Posted: Tue Nov 03, 2020 2:46 pm
by Bonfra
MichaelPetch wrote:Take your disk image that you burned and add it to your Github project .
Sure, just pushed. I've also added the align 4 but nothing changed...
Re: Making a bootable image
Posted: Tue Nov 03, 2020 3:05 pm
by MichaelPetch
As an experiment what do you get if you make this code your VBR:
Code: Select all
bits 16
org 0x7c00
jmp short boot
nop
biosParameterBlock:
times 0x52-($-$$) db 0 ; BPB 7.1 FAT32 ends at 0x52.
boot:
mov ax, 0xb800
mov es, ax
mov word [es:0], (0x57 << 8) | 'T'
mov word [es:2], (0x57 << 8) | 'E'
mov word [es:4], (0x57 << 8) | 'S'
mov word [es:6], (0x57 << 8) | 'T'
cli
.hltloop:
hlt
jmp .hltloop
TIMES 510-($-$$) db 0x00
dw 0xaa55
This should print TEST in the upper left of the display with white on magenta.
Re: Making a bootable image
Posted: Tue Nov 03, 2020 3:19 pm
by Bonfra
Just the code that you posted does not work, moving the cli to the first line of boot, in QEMU it works as you sayed but in the real hardware doesn't work.