OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 1:19 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 98 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7  Next
Author Message
 Post subject: Re: Making a bootable image
PostPosted: Tue Nov 03, 2020 11:35 am 
Offline
Member
Member
User avatar

Joined: Wed Feb 19, 2020 1:08 pm
Posts: 270
Location: Italy
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

_________________
Regards, Bonfra.


Top
 Profile  
 
 Post subject: Re: Making a bootable image
PostPosted: Tue Nov 03, 2020 11:44 am 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 671
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:
Code:
dd if=disk.img od=x:
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.


Top
 Profile  
 
 Post subject: Re: Making a bootable image
PostPosted: Tue Nov 03, 2020 12:11 pm 
Offline
Member
Member
User avatar

Joined: Wed Feb 19, 2020 1:08 pm
Posts: 270
Location: Italy
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:
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:
Image
Yes the prompt is in administrator

_________________
Regards, Bonfra.


Top
 Profile  
 
 Post subject: Re: Making a bootable image
PostPosted: Tue Nov 03, 2020 12:51 pm 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 671
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.


Last edited by MichaelPetch on Tue Nov 03, 2020 1:14 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Making a bootable image
PostPosted: Tue Nov 03, 2020 1:02 pm 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 1584
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


Top
 Profile  
 
 Post subject: Re: Making a bootable image
PostPosted: Tue Nov 03, 2020 1:16 pm 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 671
Chrysocome DD specifically added the `od=` (and `id=`) options and why I recommended the latest beta release that has that option.


Last edited by MichaelPetch on Tue Nov 03, 2020 1:44 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Making a bootable image
PostPosted: Tue Nov 03, 2020 1:20 pm 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 1584
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


Top
 Profile  
 
 Post subject: Re: Making a bootable image
PostPosted: Tue Nov 03, 2020 2:19 pm 
Offline
Member
Member
User avatar

Joined: Wed Feb 19, 2020 1:08 pm
Posts: 270
Location: Italy
bzt wrote:
give a try to USBImager

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

_________________
Regards, Bonfra.


Top
 Profile  
 
 Post subject: Re: Making a bootable image
PostPosted: Tue Nov 03, 2020 2:26 pm 
Offline
Member
Member
User avatar

Joined: Wed Feb 19, 2020 1:08 pm
Posts: 270
Location: Italy
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.

_________________
Regards, Bonfra.


Top
 Profile  
 
 Post subject: Re: Making a bootable image
PostPosted: Tue Nov 03, 2020 2:33 pm 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 671
Can you humour me and do this.In your MBR you have
Code:
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:
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.


Top
 Profile  
 
 Post subject: Re: Making a bootable image
PostPosted: Tue Nov 03, 2020 2:39 pm 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 671
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.


Top
 Profile  
 
 Post subject: Re: Making a bootable image
PostPosted: Tue Nov 03, 2020 2:44 pm 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 671
One other thing. Do you actually see the message 'VBR loaded!` displayed before it apparently hangs?


Top
 Profile  
 
 Post subject: Re: Making a bootable image
PostPosted: Tue Nov 03, 2020 2:46 pm 
Offline
Member
Member
User avatar

Joined: Wed Feb 19, 2020 1:08 pm
Posts: 270
Location: Italy
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...

_________________
Regards, Bonfra.


Top
 Profile  
 
 Post subject: Re: Making a bootable image
PostPosted: Tue Nov 03, 2020 3:05 pm 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 671
As an experiment what do you get if you make this code your VBR:
Code:
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.


Top
 Profile  
 
 Post subject: Re: Making a bootable image
PostPosted: Tue Nov 03, 2020 3:19 pm 
Offline
Member
Member
User avatar

Joined: Wed Feb 19, 2020 1:08 pm
Posts: 270
Location: Italy
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.

_________________
Regards, Bonfra.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 98 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 62 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group