From nobody@FreeBSD.org  Mon Mar  1 20:15:46 2004
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 413BD16A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  1 Mar 2004 20:15:46 -0800 (PST)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 3B30B43D2D
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  1 Mar 2004 20:15:46 -0800 (PST)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.10/8.12.10) with ESMTP id i224Fk72046553
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 1 Mar 2004 20:15:46 -0800 (PST)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.10/8.12.10/Submit) id i224FkCW046552;
	Mon, 1 Mar 2004 20:15:46 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200403020415.i224FkCW046552@www.freebsd.org>
Date: Mon, 1 Mar 2004 20:15:46 -0800 (PST)
From: Alan Robson <kimandalan@covad.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: patch to i.386 master boot record to allow boot from USB Flash drive
X-Send-Pr-Version: www-2.3

>Number:         63628
>Category:       i386
>Synopsis:       [loader] [patch] i386 master boot record to allow boot from USB Flash drive
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gavin
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 01 20:20:12 PST 2004
>Closed-Date:    Mon Feb 04 18:26:04 UTC 2008
>Last-Modified:  Mon Feb 04 18:26:04 UTC 2008
>Originator:     Alan Robson
>Release:        5.2 Release
>Organization:
>Environment:
FreeBSD planb.local 5.2-RELEASE FreeBSD 5.2-RELEASE #0: Sun Jan 11 04:21:45 GMT 2004     root@wv1u.btc.adaptec.com:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
For some reason, the BIOS will not load a partition boot record from a flash USB "thumb" drive using the Cylinder, Head & Sector values in the MBR in an int13/02 BIOS call. Instead and LBA call should be used
  
>How-To-Repeat:
install the minimal FreeBSD installation to a USB Memory stick from the distribution CD and try to boot from it. The boot always fails, even when the bios supports booting from a USB device.
   
>Fix:
Modify the mbr.s file to try LBA as the first resort, then fall back to CHS if that fails. My system works with the following diff -u patch to mbr.s, I have no way to test it on other equipment.
 
--- mbr.s.origional     Sun Feb 29 20:58:05 2004
+++ mbr.s       Sun Feb 29 21:20:40 2004
@@ -89,9 +89,7 @@
                movw 0x2(%si),%cx               # Load cylinder:sector
                movw $LOAD,%bx                  # Transfer buffer
                cmpb $0xff,%dh                  # Might we need to use LBA?
-               jnz main.7                      # No.
                cmpw $0xffff,%cx                # Do we need to use LBA?
-               jnz main.7                      # No.
                pushw %cx                       # Save %cx
                pushw %bx                       # Save %bx
                movw $0x55aa,%bx                # Magic
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-i386->bms 
Responsible-Changed-By: bms 
Responsible-Changed-When: Wed Jun 23 07:15:54 GMT 2004 
Responsible-Changed-Why:  
I'll try to look at this. 
My hunch is that we are best reorganising mbr.s in the same way 
as has been done for boot0.s, and using cpp macros to conditionalize 
the LBA vs CHS by default code paths. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=63628 
State-Changed-From-To: open->feedback 
State-Changed-By: bms 
State-Changed-When: Wed Aug 2 12:46:44 UTC 2006 
State-Changed-Why:  
There have been changes to FreeBSD since this PR was filed. 

Can you confirm that the problem still exists? 
It seems ceri@ was able to boot from USB sticks; the change was 
made after this PR was filed, to mbr.s, to enable packet mode 
by default which may fix your problem., 

See r1.7 of src/sys/boot/i386/mbr/mbr.s 


http://www.freebsd.org/cgi/query-pr.cgi?pr=63628 
Responsible-Changed-From-To: bms->freebsd-bugs 
Responsible-Changed-By: bms 
Responsible-Changed-When: Wed Aug 2 12:48:12 UTC 2006 
Responsible-Changed-Why:  
back to the pool... 

http://www.freebsd.org/cgi/query-pr.cgi?pr=63628 
State-Changed-From-To: feedback->closed 
State-Changed-By: gavin 
State-Changed-When: Mon Feb 4 18:24:35 UTC 2008 
State-Changed-Why:  
Feedback timeout (18 months) 


Responsible-Changed-From-To: freebsd-bugs->gavin 
Responsible-Changed-By: gavin 
Responsible-Changed-When: Mon Feb 4 18:24:35 UTC 2008 
Responsible-Changed-Why:  
Feedback timeout (18 months) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=63628 
>Unformatted:
