OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 25, 2024 5:00 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 31 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Booting from USB drive (SOLVED)
PostPosted: Wed Apr 15, 2015 6:32 am 
Offline
Member
Member

Joined: Tue Oct 01, 2013 2:50 am
Posts: 118
Location: Budapest, Hungary
I have tried to boot my OS from USB pen-drive for a few days, I read the following threads:
http://f.osdev.org/viewtopic.php?f=1&t=19681
http://f.osdev.org/viewtopic.php?f=1&t=27974&start=0
viewtopic.php?f=13&t=27510
viewtopic.php?f=1&t=24360
viewtopic.php?f=1&t=26517&start=0
viewtopic.php?f=1&t=27432
http://f.osdev.org/viewtopic.php?f=1&t=19366
viewtopic.php?f=1&t=28781
http://f.osdev.org/viewtopic.php?f=1&t=403
viewtopic.php?f=1&t=26392
http://board.flatassembler.net/topic.php?t=12389

Fortunately I managed to do it some time ago on a Dell D820 laptop.
To sum up what is in the threads above:
"USB Storage Device" needs to be the first setting in the Boot-Sequence in BIOS.
If there are "Emulate USB as Floppy" and "Emulate USB as HDD" settings in your BIOS, then set "Emulate USB as HDD".
In the BIOS of the D820 there are no such settings, so I assume that "Emulate USB as HDD" is the default setting.
This must be true because I couldn't boot from USB-drive with my floppy-image (with or without the BIOS Parameter Block (BPB)).
The code below assumes that HDD-emulation is used.

I am a Linux user, so I don't know much about Windows, but they say that diskpart can be used for
partitioning an USB-drive, and bootsect.exe for copying sectors to it.

On Linux, we will use mostly the command dd.

How to do it on Linux:
Let's assume that we have a USB-drive formatted with FAT32. Plug it in.
The mount command will print the following line (this line was missing from mount before plugging the pen-drive in):
"/dev/sdb1 on /media/68D4-F9FC type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0077,codepage=cp437,iocharset=utf8,
shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks)"
So the pen-drive is /dev/sdb1. We could also get this info e.g. from dmesg.
It is important to know that sdb1 is the first partition of the pen-drive.
If there were more partitions, then there would be /dev/sdb2, /dev/sdb3, ... in the list, so we have to use /dev/sdb with dd.

1. Unmount the pen-drive
umount /dev/sdb1

2. Get the binaries (see mbr.asm and vbr.asm below)
nasm -f bin mbr.asm -o mbr.bin
nasm -f bin vbr.asm -o vbr.bin

3. Transfer the Master Boot Record (mbr.bin) to the first sector (i.e. 0th)
dd if=mbr.bin of=/dev/sdb

4. Transfer the Volume Boot Record (vbr.bin) to the second sector (i.e. 1st), seek=1 skips one sector
dd if=vbr.bin of=/dev/sdb seek=1

That's all. Just plug the pen-drive in your computer and boot. The following messages should appear:
*** USB (MBR) ***

*** Volume Boot Record (VBR) ***



There are a few things I am not certain about:
- Do we need to call GetDriveParams? It is commented out. (MBR)
- DAP buffer is not 16-byte aligned. Would it be important? Mentioned in a thread above.
Should be allocated dynamically, in order to be aligned. (it works this way too) (MBR)
- I am not sure if I correctly filled the first partition-entry (MBR)
- BPB is commented out in the vbr.asm. Would it be necessary? (VBR)

The MBR just loads the second sector (i.e. 1st, VBR) and jumps to its beginning.
It also saves the drive-index it was booted from (it is 0x80).
According to my tests 0x81 is my local winchester in the D820, and 0x82 failed, so it doesn't exist.
As it was mentioned in one of the threads above, the drive we boot from gets 0x80, and then comes the other ones in sequence.
The assembly-code is not the best, I know.

Code:
;*********************************************
;   mbr.asm
;
;*********************************************

bits 16                        ; we are in 16 bit real mode

org   0                        ; we will set regisers later

;*********************************************
;   Entry Point
;*********************************************

main:

   ;----------------------------------------------------
   ; code located at 0000:7C00, adjust segment registers
   ;----------------------------------------------------
     
         cli                  ; disable interrupts
         mov ax, 0x07C0         ; setup registers to point to our segment
         mov ds, ax
         mov es, ax            ; es: segment to put loaded data into (bx: offset)
         mov fs, ax
         mov gs, ax

   ;----------------------------------------------------
   ; create stack
   ;----------------------------------------------------
     
         mov ax, 0x0000         ; set the stack
         mov ss, ax
         mov sp, 0xFFFF
         sti                  ; restore interrupts

   ;----------------------------------------------------
   ; save drive-idx we booted from
   ;----------------------------------------------------

         mov [drive_idx], dl

   ;----------------------------------------------------
   ; Display loading message
   ;----------------------------------------------------
     
         mov si, msgTxt
         call Print

   ;----------------------------------------------------
   ; Get Drive Parameters from BIOS
   ;----------------------------------------------------

;         call GetDriveParams

   ;----------------------------------------------------
   ; Load Volume Boot Record (VBR) from sector 1 (2nd sector), to 0x0050:0000 (i.e. 0x500)
   ;----------------------------------------------------
         mov eax, 1         ; read (from) 2nd sector
         mov cx, 1         ; read 1 sector
         mov bx, 0x0050      ; to 0x0050:0000
         mov di, 0
         call ReadSectors

         mov dl, [drive_idx]

         ; jump to 0x500
         push WORD 0x0050
         push WORD 0x0000
         retf

     
;************************************************
; Prints a string
; IN:
;      DS:SI (0 terminated string)
;************************************************
Print:      lodsb            ; load next byte from string from SI to AL
         or   al, al         ; Does AL=0?
         jz .Back         ; Yep, null terminator found-bail out
         mov   ah, 0x0E      ; Nope-Print the character
         int   0x10
         jmp   Print         ; Repeat until null terminator found
.Back      ret               ; we are done, so return


;GetDriveParams:   ; (DS:SI ptr to buffer)
;         mov ah, 0x48
;         mov dl, [drive_idx]
;         push ds
;         mov bx, 0x50
;         mov ds, bx
;         mov si, 0
;         int 0x13
;         ; save result
;         mov ax, 0x50
;         mov ds, ax
;         mov si, 0
;         mov eax, [ds:si+4]
;         mov [phys_cylinders], eax
;         mov eax, [ds:si+8]
;         mov [phys_heads], eax
;         mov eax, [ds:si+12]
;         mov [phys_sectors], eax
;         mov ax, [ds:si+24]
;         mov [bytes_per_sector], ax
;         pop ds
;         ret


;************************************************
; Reads a series of sectors
; IN:    EAX (Starting sector)
;      CX (Number of sectors to read)
;      BX:DI (Buffer to read to)
;************************************************
ReadSectors:
         pusha
         mov bp, 0x0005            ; max. 5 retries
.Again      mov dl, [drive_idx]
         mov BYTE [buff], 0x10      ; size of this structure (1 byte)
         mov BYTE [buff+1], 0      ; always zero (1 byte)
         mov WORD [buff+2], cx      ; number of sectors to read (2 bytes)
         mov WORD [buff+4], di      ; segment:offset ptr to memory to read to (4 bytes)
         mov WORD [buff+6], bx
         mov DWORD [buff+8], eax      ; read from sector (8 bytes)
         mov DWORD [buff+12], 0
         mov ah, 0x42
         mov si, buff
         int 0x13
         jnc   .Ok
         dec bp
         jnz   .Again
         mov si, msgErrTxt
         call Print
      jmp $
         int 0x18
.Ok         popa
         ret


buff            times 16 db 0      ; Note: DAP-buff is not 16-byte aligned. Problem!?

msgTxt            db 0x0D, 0x0A, "*** USB (MBR) ***", 0x0D, 0x0A, 0x00
msgErrTxt         db "VBR error", 0x0D, 0x0A, 0x00
drive_idx         db 0
;phys_cylinders      dd 0
;phys_heads         dd 0
;phys_sectors      dd 0
;bytes_per_sector   dw 0

     

; Partition1 0x01BE  (i.e. first partition-entry begins from 0x01BE)
; Partition2 0x01CE
; Partition3 0x01DE
; Partition4 0x01EE
; We only fill/use Partition1
TIMES 0x1BE-($-$$) DB 0
db 0x80         ; Boot indicator flag (0x80 means bootable)
db 0         ; Starting head
db 3      ; Starting sector (6 bits, bits 6-7 are upper 2 bits of cylinder)
db 0         ; Starting cylinder (10 bits)
db 0x8B         ; System ID   (0x8B means FAT32)
db 0         ; Ending head
db 100         ; Ending sector (6 bits, bits 6-7 are upper 2 bits of cylinder)
db 0         ; Ending cylinder (10 bits)
dd 2      ; Relative sector (32 bits, start of partition)
dd 97   ; Total sectors in partition (32 bits)
; it's a dummy partition-entry (sectornumbers can't be zeros,
starting CHS and LBA values should be the same if converted to each other).

TIMES 510-($-$$) DB 0
DW 0xAA55



Code:
;*********************************************
;   vbr.asm
;
;*********************************************

bits 16                        ; we are in 16 bit real mode

org   0                        ; we will set regisers later

;start:   jmp   main               ; jump to start of bootloader

;*********************************************
;   BIOS Parameter Block
;*********************************************

; BPB Begins 3 bytes from start. We do a far jump, which is 3 bytes in size.
; If you use a short jump, add a "nop" after it to offset the 3rd byte.

;bpbOEM               db "My OS   "      ; OEM identifier (Cannot exceed 8 bytes!)
;bpbBytesPerSector:     DW 512
;bpbSectorsPerCluster:   DB 1            ; we want 1 sector/cluster
;bpbReservedSectors:    DW 1            ; the Bootsector (it won't have a FAT)
;bpbNumberOfFATs:      DB 2            ; FAT12 has 2 FATs
;bpbRootEntries:      DW 224            ; Floppy has max. 224 dirs in its root dir
;bpbTotalSectors:      DW 2880
;bpbMedia:            DB 0xF0            ; 0xf8  ;; 0xF1   ; Info about the disk; it's a bit pattern
;bpbSectorsPerFAT:      DW 9
;bpbSectorsPerTrack:   DW 18
;bpbHeadsPerCylinder:   DW 2
;bpbHiddenSectors:      DD 0
;bpbTotalSectorsBig:   DD 0
;bsDriveNumber:         DB 0             ; not 1 !?
;bsUnused:            DB 0
;bsExtBootSignature:   DB 0x29
;bsSerialNumber:      DD 0xa0a1a2a3
;bsVolumeLabel:         DB "MOS FLOPPY "   ; exactly 11 bytes
;bsFileSystem:         DB "FAT12   "      ; exactly 8 bytes



;*********************************************
;   Bootloader Entry Point
;*********************************************

main:

   ;----------------------------------------------------
   ; code located at 0000:0500, adjust segment registers
   ;----------------------------------------------------
     
         cli                  ; disable interrupts
         mov ax, 0x0050         ; setup registers to point to our segment
         mov ds, ax
         mov es, ax
         mov fs, ax
         mov gs, ax

   ;----------------------------------------------------
   ; create stack
   ;----------------------------------------------------
     
         mov ax, 0x0000         ; set the stack
         mov ss, ax
         mov sp, 0xFFFF
         sti                  ; restore interrupts

   ;----------------------------------------------------
   ; Ensure 80*25
   ;----------------------------------------------------

;         mov ax, 3            ; mode 80*25, clearscreen
;         int 10h

   ;----------------------------------------------------
   ; Display loading message
   ;----------------------------------------------------
     
         mov si, msgTxt
         call Print

         hlt

     
;************************************************
; Prints a string
; IN:
;      DS:SI (0 terminated string)
;************************************************
Print:      lodsb            ; load next byte from string from SI to AL
         or   al, al         ; Does AL=0?
         jz .Back         ; Yep, null terminator found-bail out
         mov   ah, 0x0E      ; Nope-Print the character
         int   0x10
         jmp   Print         ; Repeat until null terminator found
.Back      ret               ; we are done, so return


msgTxt            db 0x0D, 0x0A, "*** Volume Boot Record ***", 0x0D, 0x0A, 0x00

     

TIMES 510-($-$$) DB 0
DW 0xAA55



Last edited by bigbob on Wed Apr 15, 2015 11:26 am, edited 3 times in total.

Top
 Profile  
 
 Post subject: Re: Booting from USB drive (Info)
PostPosted: Wed Apr 15, 2015 6:52 am 
Offline
Member
Member

Joined: Tue Jan 20, 2015 9:01 am
Posts: 119
Hello,

bigbob wrote:
- Do we need to call GetDriveParams? It is commented out. (MBR)
At least me, I don't do it, as long as I use BIOS LBA Extensions, maybe I am wrong.

bigbob wrote:
- DAP buffer is not 16-byte aligned. Would it be important? Mentioned in a thread above.
Should be allocated dynamically, in order to be aligned. (it works this way too) (MBR)
If you are unsure just align it, though you could also reserve some space outside the MBR to have more space for executable code.

As for the other questions I am unsure me too. :(

PS: As for the "org 0" and ds=es=fs=gs=0x7C0 I think it would be better to change it to "org 0x7C00" and ds=es=fs=gs=0, so you can easier access memory below the bootloader. It will be certainly needed for any future structures built while the bootloader executes.

Regards,
glauxosdev


Top
 Profile  
 
 Post subject: Re: Booting from USB drive (Info)
PostPosted: Wed Apr 15, 2015 7:00 am 
Offline
Member
Member
User avatar

Joined: Thu Mar 27, 2014 3:57 am
Posts: 568
Location: Moscow, Russia
GetDriveParams is not necessary, but can be useful.

_________________
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay


Top
 Profile  
 
 Post subject: Re: Booting from USB drive (Info)
PostPosted: Wed Apr 15, 2015 7:59 am 
Offline
Member
Member

Joined: Tue Oct 01, 2013 2:50 am
Posts: 118
Location: Budapest, Hungary
Thanks for the answers guys!

I have an "ASUS Eee PC 1001PX" Netbook and in its BIOS I set "Removeable Dev." as the first one in the Boot Sequence.
There are no other USB-related settings.
The problem is that it doesn't see my USB-pendrive as a bootable one. As if it wasn't there.
Immediately GRUB loads Debian Linux.
I plugged the pendrive directly in the Netbook and not via a HUB.

So, my Dell D820 boots from it, but my ASUS Netbook doesn't.
Can it be that the BIOS of the Netbook finds the first partition-entry unsuitable in the MBR? Maybe something is missing from it.
I am sure that booting from USB can't be this unreliable.

There is GRUB+Debian Linux also on the D820.
My Netbook is newer than the D820.


Top
 Profile  
 
 Post subject: Re: Booting from USB drive (Info)
PostPosted: Wed Apr 15, 2015 8:41 am 
Offline
Member
Member

Joined: Tue Jan 20, 2015 9:01 am
Posts: 119
Once I came across an Altec laptop which was unable to boot my OS, but more than able to boot Windows Installer from USB. Maybe there are manufacturers that use Microsoft patents to prevent any OS other than Windows? I'm not talking about Secure Boot right now, but about biased BIOSes.


Top
 Profile  
 
 Post subject: Re: Booting from USB drive (Info)
PostPosted: Wed Apr 15, 2015 9:20 am 
Offline
Member
Member

Joined: Tue Oct 01, 2013 2:50 am
Posts: 118
Location: Budapest, Hungary
glauxosdev wrote:
Once I came across an Altec laptop which was unable to boot my OS, but more than able to boot Windows Installer from USB. Maybe there are manufacturers that use Microsoft patents to prevent any OS other than Windows? I'm not talking about Secure Boot right now, but about biased BIOSes.


I bought it with Win7.
I have no idea, but I hope it's not the case.
In those threads in my first post, I remember at least one person mentioning successful boots from USB-drive on Netbooks too (he managed to boot on several computers). I can't be this unlucky (one of my computers having a biased BIOS) :)


Top
 Profile  
 
 Post subject: Re: Booting from USB drive (Info)
PostPosted: Wed Apr 15, 2015 10:01 am 
Offline
Member
Member

Joined: Tue Oct 01, 2013 2:50 am
Posts: 118
Location: Budapest, Hungary
I managed to test it on a Packard Bell laptop a few minutes ago.
The boot-sequence of the Packard-BIOS has three USB-related setting:
- USB CD/DVD
- USB HDD
- USB FDD

I set "USB HDD" to be the first in the boot-sequence, but the result is the same as with the Netbook, as if the pen-drive wasn't there, Linux gets booted immediately.
So out of three computers, only the Dell D820 boots from the pen-drive with the MBR.

EDIT: I changed the starting-sector (3rd byte) in the first partition-entry to 1, and the ending-sector (6th byte) to 100, since the sector-number can't be zero, it didn't help.
I also added "mov dl, [drive_idx]" to mbr.asm (right before jumping to VBR).


Top
 Profile  
 
 Post subject: Re: Booting from USB drive (SOLVED)
PostPosted: Wed Apr 15, 2015 11:22 am 
Offline
Member
Member

Joined: Tue Oct 01, 2013 2:50 am
Posts: 118
Location: Budapest, Hungary
It turned out that the partition-entry was wrong:
- sectornumbers can't be zeros
- starting CHS and LBA have to be the same (converting one to the other)

I changed the code of the MBR above (added dummy values to the partition-entry).

Now it also boots on the Packard Bell laptop :)


Last edited by bigbob on Wed Apr 15, 2015 11:57 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Booting from USB drive (SOLVED)
PostPosted: Wed Apr 15, 2015 11:56 am 
Offline
Member
Member

Joined: Tue Oct 01, 2013 2:50 am
Posts: 118
Location: Budapest, Hungary
EDIT:
Just one more thing.
In order to restore the original USB-pendrive just use "GParted" or "Disks" (in Ubuntu).
http://askubuntu.com/questions/185815/h ... thumbdrive

Maybe the best would have been to save the original MBR with dd, and then get the values of its partition-entry with e.g.
hexdump -C mbrorig.bin
and put them to our partition-entry in mbr.asm.
And of course, it would be possible to restore the original MBR now.


Last edited by bigbob on Thu Apr 16, 2015 1:37 am, edited 5 times in total.

Top
 Profile  
 
 Post subject: Re: Booting from USB drive (SOLVED)
PostPosted: Wed Apr 15, 2015 10:34 pm 
Offline
Member
Member
User avatar

Joined: Mon Jun 16, 2014 5:33 pm
Posts: 213
Location: Costa Rica
That's good, and pretty much real OSDeving! Now, let's do the "hard" work, upload this to the wiki :wink: . I'm sure we're all grateful for your contributions.

_________________
Happy New Code!
Hello World in Brainfuck :D:
Code:
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.


Top
 Profile  
 
 Post subject: Re: Booting from USB drive (SOLVED)
PostPosted: Wed Apr 15, 2015 11:50 pm 
Offline
Member
Member

Joined: Tue Oct 01, 2013 2:50 am
Posts: 118
Location: Budapest, Hungary
KemyLand wrote:
That's good, and pretty much real OSDeving! Now, let's do the "hard" work, upload this to the wiki :wink: . I'm sure we're all grateful for your contributions.


Thanks! I have thought about that too.
The original code is from the BrokenThorn tutorials, but I am still not sure about the code I added to it (INT13H with AH=42H and the partition-entry).
My netbook still ignores the USB-pendrive.
It seems that some BIOSs do more strict checking than others :)

I will experiment some more with it and will think about adding it to the Wiki when it boots on all three of my computers.
My OS booted from CD with floppy-emulation for a long time, so booting from USB is pretty new to me.

Graphical Forth OS
https://sites.google.com/site/forthoperatingsystem/


Top
 Profile  
 
 Post subject: Re: Booting from USB drive (SOLVED)
PostPosted: Fri Apr 17, 2015 8:40 am 
Offline
Member
Member

Joined: Tue Oct 01, 2013 2:50 am
Posts: 118
Location: Budapest, Hungary
The code of an MBR is not that simple (e.g. relocation from 0x7C00 is necessary in order to load the VBR to 0x7C00).
It seems, it's enough if I change the boot-flag of the partition-entry in the MBR (if it is not already 0x80), get the DWORD from the 8th byte in the partition-entry ("Relative Sector (to start of partition -- also equals the partition's starting LBA value)"). This "Relative Sector" is the address of the VBR.
For example, if it is 0x00000020, then:
dd if=vbr.bin of=/dev/sdb seek=32
writes vbr.bin to the 0x00000020th sector.
"*** Volume Boot Record ***"-message gets displayed on the screen (don't forget to change vbr.asm to 0x7C00).
The problem with this solution is that I have to add this value of the "Relative Sector" (i.e 0x00000020) to the code of the VBR, since I can't make MBR to pass it to VBR.
At least, I see no other way now. The start of the partition is not in the BPB, and of course, it is necessary to read/write the partition.

Unfortunately it still doesn't boot on my netbook (but it boots on two latops).
EDIT: I also added the BPB to the code of the VBR from the original VBR (e.g. by "hexdump -C OrigVBR.bin").


Top
 Profile  
 
 Post subject: Re: Booting from USB drive (SOLVED)
PostPosted: Fri Apr 17, 2015 10:55 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 27, 2010 4:53 pm
Posts: 1150
Location: Scotland
bigbob wrote:
The problem with this solution is that I have to add this value of the "Relative Sector" (i.e 0x00000020) to the code of the VBR, since I can't make MBR to pass it to VBR.

Your MBR is supposed to put the address of the bootable partition entry in DS:SI so that your VBR can then look there to find out where its partition began. http://wiki.osdev.org/MBR. If you're writing a multiboot MBR it can offer a choice of partition to boot and then it will line DS:SI up on the one the user chooses to boot from.

Quote:
Unfortunately it still doesn't boot on my netbook (but it boots on two latops).

Have you tried someone else's MBR code or tried any other way to see if it can boot anything at all from USB? I wouldn't advise you to use my MBR because the main path through its code hasn't been tested extensively (but feel free to try it) - I normally use it with just one bootable partition (although it allows the user to choose from up to four) and because it normally finds my own special type of partition it then jumps to special code that lets the user select and boot a subpartition from within that partition (which can contain hundreds of bootable floppy disk images, though it only allows direct booting of two of them [the first subpartition and the most recently modified one down the line from there until the dates jump backwards] - the rest can be selected and booted from within my OS).

Here's my MBR code if you want to risk it, but be warned that it accesses the 8042 port directly to get keyboard input instead of using the BIOS, so it won't work on any machines that don't have a PS/2 port. (I keep meaning to fix that but never have the time.) You can get it onto a flash drive using a hex editor like HxD (use copy and paste) - just make sure you select sector 0 of a physical drive and not a logical drive. This code has been tested and works fine on two netbooks (both Advent) and a laptop (Sony), all machines from the Windows XP era.

Edit: warning withdrawn - I had changed the code to use the BIOS for key input but never got round to updating my notes on it.

Code:
33 C0 8E D0 BC 00 7C 8E D8 8E C0 8B F4 BF 00 06 B9 00 01 FC F3 A5 EA 1B 06 00 00 BF 28 07 B8 00 B8 B9 31 00 8E C0 BE AE 07 B8 10 00 03 F0 8A 04 3C 80 75 3E 8A D9 66 8B 44 08 66 A3 B0 07 60 06 1E B4 42 BE A8 07 CD 13 FC 1F 07 61 A1 AC 07 56 96 AD 46 B4 09 8A C1 AB B0 20 AB 51 B1 08 AC AB E2 FC 59 B8 8C 00 03 F8 5E A1 AC 07 05 00 02 A3 AC 07 41 91 3C 35 91 75 B0 8B C7 3D 28 07 75 02 EB FE 3D C8 07 8A E3 BB 08 00 74 0F E8 59 00 3C 02 72 F9 3C 06 73 F5 04 2F 8A E0 BE 28 07 26 8A 04 3A C4 74 0D B9 A0 00 03 F1 43 43 3B F7 74 DC EB EC FB BE AE 07 2C 30 8A C8 B8 10 00 03 F0 E2 FC 33 C0 8E C0 8A 44 04 C1 C3 08 3C 82 74 25 56 93 96 BF 00 7C B9 00 01 F3 A5 5E 66 8B 4C 08 4C 66 33 DB EA 00 7C 00 00 06 1E B4 00 CD 16 1F 07 8A C4 FC C3 BF F7 AD 8E C7 56 BE 9B 07 4F B4 0C AC AB 3C 6E 75 FA 33 C0 8E C0 5E E8 DA FF 3C 1C 74 BD 3C 39 75 F5 B8 00 02 03 C3 A3 AC 07 53 8B D8 05 00 02 97 66 8B 44 08 66 05 00 0C 00 00 66 A3 B0 07 BE A8 07 B4 42 60 06 1E CD 13 1F 07 61 FC 66 8B 45 F2 66 3D 00 56 62 72 75 3C 66 8B 45 FA 66 91 66 8B 47 FA 66 3B C8 72 2D 75 17 66 8B 45 F6 66 91 66 8B 47 F6 66 C1 E0 08 66 C1 E1 08 66 3B C8 72 14 60 8B F3 B8 00 04 2B F8 B9 00 01 F3 A5 61 66 A1 B0 07 EB A0 5B 66 8B 44 08 66 2D 00 0C 00 00 66 89 44 08 E9 34 FF 53 70 61 63 65 2F 52 65 74 75 72 6E 00 10 00 01 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 21 00 0C FE FF FF 20 00 00 00 E0 FF BF 01 80 FE FF FF 82 FE FF FF 00 00 C0 01 2E 17 1D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA

_________________
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c

MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming


Last edited by DavidCooper on Sat Apr 18, 2015 9:53 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Booting from USB drive (SOLVED)
PostPosted: Fri Apr 17, 2015 1:18 pm 
Offline
Member
Member

Joined: Tue Oct 01, 2013 2:50 am
Posts: 118
Location: Budapest, Hungary
Thanks, David.
I read the wiki on MBR, but I just tested changing only the boot-flag in the MBR of the pen-drive and writing only my vbr.bin to the beginning of the partition (LBAbegin). It worked.
Of course, I can pass the LBAbegin to my VBR, If I use my custom-MBR.

It's a good idea to test it with someone else's MBR.
I am a Linux user and I didn't manage to find a hex editor that could import data from a text file (I tried several ones).
So, I had to write a python-script that does it.
Your MBR boots on my Dell D820 laptop (I saw e.g. "Space/Return" text in color), but on the netbook it doesn't.
I checked again the Boot-Sequence of the BIOS of the netbook and it was correct.

Anyway, it is not a bad result, to be able to boot from USB on two computers out of three :-)
Maybe I will never be able to figure out what the problem is.
EDIT: as you said, it's also possible that the netbook can't boot from USB. I haven't tried it yet.


Top
 Profile  
 
 Post subject: Re: Booting from USB drive (SOLVED)
PostPosted: Sat Apr 18, 2015 11:07 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 27, 2010 4:53 pm
Posts: 1150
Location: Scotland
bigbob wrote:
I am a Linux user and I didn't manage to find a hex editor that could import data from a text file (I tried several ones).
So, I had to write a python-script that does it.

Sorry about that - I should have provided a binary file as well. Thanks for daring to test it. By the way, it does actually use the BIOS to get key input rather than reading the PS/2 port directly - I changed it a couple of years ago but failed to update my notes to say so.

Quote:
Your MBR boots on my Dell D820 laptop (I saw e.g. "Space/Return" text in color), but on the netbook it doesn't.

You should only see the "Space/Return" message if it's booting my special multi-floppy partition, so I'm guessing you retained my partition data, or at least the value that gives the partition type (I use the value for CP/M since it's unlikely that anyone would ever use a CP/M partition on a drive alongside my OS). ["Space" loads the newest version; "Return" loads from the first subpartition. If there are four bootable partitions, you press 1, 2, 3 or 4 to choose which to boot from, and then if you choose a multi-floppy partition you get the Space/Return option.]

Quote:
I checked again the Boot-Sequence of the BIOS of the netbook and it was correct.

You may just have an unusually awkward machine. Mine won't boot from USB if they're being booted up after hibernating so I have to shut Windows right down first. That won't be the issue on your machine, but it does show that there is at least one hidden setting somewhere that can make the BIOS ignore a USB device if Windows decides to be unhelpful.

Quote:
Anyway, it is not a bad result, to be able to boot from USB on two computers out of three :-)
Maybe I will never be able to figure out what the problem is.
EDIT: as you said, it's also possible that the netbook can't boot from USB. I haven't tried it yet.

It's disappointing when a machine can't be used this way - you really need to test them straight away after buying them and send them back if they won't boot via USB, letting the seller know your reason why - the information might find its way back to the manufacturer and that would maybe give them a kick up the backside. Also, find somewhere to review the machine online and complain there about it.

It would be worth trying booting from a USB floppy drive and a USB CD drive too though, just to see if it's a complete lock out. If it can, it might be worth going on trying to find a way round the barrier, but otherwise it's probably a dead loss, although one possible fix if you're determined to use your OS on an unhelpful machine would be to hack the MBR on the internal drive and hope Windows doesn't keep undoing your modifications. You could then load your own multiboot code from a spare sector or two to offer to boot from any drive that the BIOS has numbered, though I suppose it's possible that the MBR on the internal drive might be ignored too.

What we really really need at OSDEV is a list of machines that are OSDEV friendly and a list of machines that aren't - that would help people select new machines, and it would be particularly helpful if they're thinking of buying some of the newer types that might not have a BIOS in them at all.

_________________
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c

MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 31 posts ]  Go to page 1, 2, 3  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: Amazonbot [bot], Bing [Bot], Google [Bot], Majestic-12 [Bot] and 230 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