booting from USB flash memory
booting from USB flash memory
hi
say i want my os to be installed and boot from usb flash memory and i dont it to support FAT or partitions also suppose i'm developing new file system,as if the usb flash memory is the only storage device attached to pc and bios support booting from usb device,now can i simply copy my boot sector to first sector then loading my kernel,according to my new file system,and let my os interface with the usb device,again according to my new file system formatting or layout,!?
now the reason for such question is,i am not trying to get my os replace windows nor linux nor even dos but to know how i am thinking,for example in james tutorial about running unix clone ,and it is so great tutorial, why developing new clone if it is already exist!
i hope i was somewhat clear,or over-clear may be?,
say i want my os to be installed and boot from usb flash memory and i dont it to support FAT or partitions also suppose i'm developing new file system,as if the usb flash memory is the only storage device attached to pc and bios support booting from usb device,now can i simply copy my boot sector to first sector then loading my kernel,according to my new file system,and let my os interface with the usb device,again according to my new file system formatting or layout,!?
now the reason for such question is,i am not trying to get my os replace windows nor linux nor even dos but to know how i am thinking,for example in james tutorial about running unix clone ,and it is so great tutorial, why developing new clone if it is already exist!
i hope i was somewhat clear,or over-clear may be?,
-
- Member
- Posts: 116
- Joined: Wed Oct 22, 2008 2:21 am
- Location: Roma,Italy
Re: booting from USB flash memory
Sureweezo wrote:hi
say i want my os to be installed and boot from usb flash memory and i dont it to support FAT or partitions also suppose i'm developing new file system,as if the usb flash memory is the only storage device attached to pc and bios support booting from usb device,now can i simply copy my boot sector to first sector then loading my kernel,according to my new file system,and let my os interface with the usb device,again according to my new file system formatting or layout,!?
But note that some Laptop with Stupid Bios (HP with Phoenix BIOS)
fail the boot from USB if it don't see FAT format
Re: booting from USB flash memory
I happen to have a HP laptop that has a Phoenix BIOS, but I don't have that problem. It's booted anything I've thrown at it. Could you provide more information about the BIOS in question? Perhaps BIOS version, date, model of machine or how old it is?djmauretto wrote:Sureweezo wrote:hi
say i want my os to be installed and boot from usb flash memory and i dont it to support FAT or partitions also suppose i'm developing new file system,as if the usb flash memory is the only storage device attached to pc and bios support booting from usb device,now can i simply copy my boot sector to first sector then loading my kernel,according to my new file system,and let my os interface with the usb device,again according to my new file system formatting or layout,!?
But note that some Laptop with Stupid Bios (HP with Phoenix BIOS)
fail the boot from USB if it don't see FAT format
- Firestryke31
- Member
- Posts: 550
- Joined: Sat Nov 29, 2008 1:07 pm
- Location: Throw a dart at central Texas
- Contact:
Re: booting from USB flash memory
I have a Compaq (for all intents and purposed an HP) laptop with (IIRC) a Phoenix BIOS and it's had no problems trying to boot anything that had a valid signature. It even tries to boot from my iPod if I forget to unplug it.
Owner of Fawkes Software.
Wierd Al wrote: You think your Commodore 64 is really neato,
What kind of chip you got in there, a Dorito?
Re: booting from USB flash memory
We as a community need to clear this up, as its been asked too many time's and these different answers.
I have two simple boot sector here:
With BPB
Without BPB
Now the one without BPB should work just the same as the one with and they should both work on both hdd and fdd emulation, if it does not mater whats on the sector as some have said.
So please test it with your USB BIOS and we can find out for sure.
NOTE: I can post a .bin files and a prog to put it on usb, if that will help.
I have two simple boot sector here:
With BPB
Code: Select all
;************************************
; By Dex
; Assemble with fasm
; c:\fasm USB1.asm USB1.bin
;
;************************************
org 0x7C00
use16
Boot: jmp start
nop
;------------------------------------------;
; Standard BIOS Parameter Block, "BPB". ;
;------------------------------------------;
bpbOEM db 'MSDOS5.0'
bpbSectSize dw 512
bpbClustSize db 1
bpbReservedSec dw 1
bpbFats db 2
bpbRootSize dw 224
bpbTotalSect dw 2880
bpbMedia db 240
bpbFatSize dw 9
bpbTrackSect dw 18
bpbHeads dw 2
bpbHiddenSect dd 0
bpbLargeSect dd 0
;---------------------------------;
; extended BPB for FAT12/FAT16 ;
;---------------------------------;
bpbDriveNo db 0
bpbReserved db 0
bpbSignature db 41
bpbID dd 1
bpbVolumeLabel db 'BOOT FLOPPY'
bpbFileSystem db 'FAT12 '
;****************************
; Realmode startup code.
;****************************
start:
xor ax,ax
mov ds,ax
mov es,ax
mov ss,ax
mov sp,0x7C00
mov si,Mesage1
call print
jmp $
;****************************
; print.
;****************************
print:
mov ah,0Eh
again1:
lodsb
or al,al
jz done1
int 10h
jmp again1
done1:
ret
Mesage1: db 'USB, with BPB works OK',0
;*************************************
; Make program 510 byte's + 0xaa55
;*************************************
times 510- ($-Boot) db 0
dw 0xaa55
Code: Select all
;************************************
; By Dex
; Assemble with fasm
; c:\fasm USB2.asm USB2.bin
;
;************************************
org 0x7C00
use16
;****************************
; Realmode startup code.
;****************************
start:
xor ax,ax
mov ds,ax
mov es,ax
mov ss,ax
mov sp,0x7C00
mov si,Mesage1
call print
jmp $
;****************************
; print.
;****************************
print:
mov ah,0Eh
again1:
lodsb
or al,al
jz done1
int 10h
jmp again1
done1:
ret
Mesage1: db 'USB, without BPB works OK',0
;*************************************
; Make program 510 byte's + 0xaa55
;*************************************
times 510- ($-start) db 0
dw 0xaa55
So please test it with your USB BIOS and we can find out for sure.
NOTE: I can post a .bin files and a prog to put it on usb, if that will help.
-
- Member
- Posts: 116
- Joined: Wed Oct 22, 2008 2:21 am
- Location: Roma,Italy
Re: booting from USB flash memory
HP Pavilion dv8000t, i just try to load my os ( note that it boot fine on every PC desktop)I happen to have a HP laptop that has a Phoenix BIOS, but I don't have that problem. It's booted anything I've thrown at it. Could you provide more information about the BIOS in question? Perhaps BIOS version, date, model of machine or how old it is?
with CDrom ,USB floppy and USB HD emulation ,but it's not work , of course
HP boot windows xp ,and also Win98 fine,and i don't understand why ,until i have
formatted my usb pen with fat format,then HP boot fine also me
-
- Member
- Posts: 116
- Joined: Wed Oct 22, 2008 2:21 am
- Location: Roma,Italy
Re: booting from USB flash memory
Of course BIOS don't search for FAT but needed only BPB for disk geometry,
but i don't have investigate because the HP it's not mine...
but i don't have investigate because the HP it's not mine...
Re: booting from USB flash memory
I (sofar) concur with dex.. I opted for my boot loaders to not have any sort of BPB/MBR at all as I don't need it.. my file-system is managed in a totally separate way. Sofar my boot code has worked on cdrom/hdd/fdd and usb (hdd emulation) on the systems ive tested with. The only machine it didn't work on with usb is a machine that doesn't boot ANY bootable usb.. so thats a machine issue not a code issue.
Re: booting from USB flash memory
So far from basic test with those boot sector, i get this;
If i use the one with BPB it boots on both pc/laptop, but without BPB it will only boot on one, but the differenc seems (on my test, anyway).
That under HDD emulation it will both both with or without the BPB, but with FDD emulation it will only boot with BPB.
As if i plug the same fob in with the BPB code,it shows up in the boot menu, as a FDD-USB, but without the BPB, it shows up as a HDD.
It maybe the case that if your BIOS only boots FDD emulation for USB, than it will need a BPB, but for HDD emulation it is not needed, but there may still be case where there is checks for "active partition" for example.
So my ? are,
1. Can anyone boot usb with FDD emulation, without the BPB being present ?.
So BPB is only needed for USB FDD emulation
This is why we are geting different results.
If i use the one with BPB it boots on both pc/laptop, but without BPB it will only boot on one, but the differenc seems (on my test, anyway).
That under HDD emulation it will both both with or without the BPB, but with FDD emulation it will only boot with BPB.
As if i plug the same fob in with the BPB code,it shows up in the boot menu, as a FDD-USB, but without the BPB, it shows up as a HDD.
It maybe the case that if your BIOS only boots FDD emulation for USB, than it will need a BPB, but for HDD emulation it is not needed, but there may still be case where there is checks for "active partition" for example.
So my ? are,
1. Can anyone boot usb with FDD emulation, without the BPB being present ?.
So BPB is only needed for USB FDD emulation
This is why we are geting different results.
Last edited by Dex on Sun Mar 15, 2009 11:24 am, edited 1 time in total.
Re: booting from USB flash memory
i posted a reply as topic by mistake lol
anyway i would like to thank u dex u always get to point ,so it is such simple as long as i know what i am doing?
something else,can u refere me to any resources or tutorials about interfacing with usb flash memory,i mean like ATA for hard disks?
thnx again
anyway i would like to thank u dex u always get to point ,so it is such simple as long as i know what i am doing?
something else,can u refere me to any resources or tutorials about interfacing with usb flash memory,i mean like ATA for hard disks?
thnx again
Re: booting from USB flash memory
Thanks weezo, as to your request, if you boot from a usb fob, you can read/write to the fob just the same as you would to the device its emulating, eg: int 13h, but once you go to pmode emulation stops.
Now in my OS i have both a pmode fdd and hdd drivers and a go back to realmode to use int 13h, as whe you go back emuation starts again.
So this mean you can read/write to usb just like any other drive.
But if you want to talk to it dirctly that is much harder, and you need to write a usb stack, for your OS.
You need to get the usb spec pdf, see here:
http://www.usb.org/developers
http://www.usbmadesimple.co.uk/index.html
And here some basic starter code
http://forum.osdev.org/viewtopic.php?f= ... ex#p139910
Now in my OS i have both a pmode fdd and hdd drivers and a go back to realmode to use int 13h, as whe you go back emuation starts again.
So this mean you can read/write to usb just like any other drive.
But if you want to talk to it dirctly that is much harder, and you need to write a usb stack, for your OS.
You need to get the usb spec pdf, see here:
http://www.usb.org/developers
http://www.usbmadesimple.co.uk/index.html
And here some basic starter code
http://forum.osdev.org/viewtopic.php?f= ... ex#p139910