FAT32 Bootloader

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
trinopoty
Member
Member
Posts: 87
Joined: Wed Feb 09, 2011 2:21 am
Location: Raipur, India

Re: FAT32 Bootloader

Post by trinopoty »

First, use hex for the values, it's easier to understand.
In MBR formatted disks, only the first partition is set as bootable, this makes things a lot easier. The first partition resides at LBA 0x3F.
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: FAT32 Bootloader

Post by iansjack »

trinopoty wrote:First, use hex for the values, it's easier to understand.
In MBR formatted disks, only the first partition is set as bootable, this makes things a lot easier. The first partition resides at LBA 0x3F.
More misinformation, unfortunately. Any partition on an MBR disk can be set to be the active partition. And you can never assume that a partition will start at a particular sector; that's why you have a partition table.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: FAT32 Bootloader

Post by Brynet-Inc »

trinopoty wrote:In MBR formatted disks, only the first partition is set as bootable, this makes things a lot easier. The first partition resides at LBA 0x3F.

Code: Select all

Disk: wd0       geometry: 60801/255/63 [976773168 Sectors]
Offset: 0       Signature: 0xAA55
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
0: 00      0   0   0 -      0   0   0 [           0:           0 ] unused      
1: 00      0   0   0 -      0   0   0 [           0:           0 ] unused      
2: 00      0   0   0 -      0   0   0 [           0:           0 ] unused      
*3: A6      0   1   2 -  12269 254  63 [          64:   197117486 ] OpenBSD
Liar.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: FAT32 Bootloader

Post by Solar »

Brynet-Inc wrote:Liar.
"Never attribute to malice that which is adequately explained by stupidity."
Every good solution is obvious once you've found it.
User avatar
Firestryke31
Member
Member
Posts: 550
Joined: Sat Nov 29, 2008 1:07 pm
Location: Throw a dart at central Texas
Contact:

Re: FAT32 Bootloader

Post by Firestryke31 »

jbemmel wrote:
Firestryke31 wrote:
jbemmel wrote:Could consider to align the stack by 4 by using 0x8002 instead of 0x8000
0x8002 % 4 != 0, so 0x8002 is not 4-byte aligned. 0x8000 is, though.
If you read the code, you will see that the first thing pushed is bx, followed by a bunch of 32-bit pushes. The stack is currently misaligned for the latter cases.
Sorry, like I said it's been a long time since I've even last seen the code (and I still haven't looked at it). If I were to need a FAT32 bootsector today I'd probably end up starting over from scratch. It wouldn't surprise me if I had made plenty of stupid mistakes in that code.
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?
Post Reply