Subject: Re: 1.4.2 install notes
To: Havard Eidnes <he@netbsd.org>
From: Miles Nordin <carton@Ivy.NET>
List: port-macppc
Date: 02/12/2000 14:02:33
I agree that the macppc port is in much, much better shape than its
documentation and the box of tools you get for installing it.  I think we
can probably come up with some very useful documentation just by tossing
around what we've learned here, and thus avoid taking time away from the
Real developers working on stuff like UniNorth support.

I'll answer your well-put questions, and maybe this will get us started.
I know we have some docs already, but I'm not sure they would serve as a
better starting point than your questions.  If people out there see errors 
in what I've written or have something to add, please speak up, privately
or publicly.

On Sat, 12 Feb 2000, Havard Eidnes wrote:

>     - how to get into OpenFirmware

If you 
 o Have a newer Macintosh
 o Want to netboot
 o Don't want to pass any options to the kernel

you may be able to simply reset your computer and hold down 'N'.
Otherwise,

Reset, and Hold down Command - Opt - O - F.  If the screen stays black or
grey for many seconds after the Bong, then you have a serial-console
OpenFirmware, and you must interact with it over the modem port at
38400bps.  Newer machines will give you a prompt on the screen.  In any
case, it looks something like

ok
0 >

If you want to always boot to OpenFirmware, enter the following at an
OpenFirmware prompt

setenv auto-boot? false

Don't worry about screwing up MacOS--you can always type 'set-defaults' if
you change a variable and get in over your head.

MacOS X may complicate this a bit, but for now set-defaults is a safe way
out of most messes.

>     - how to boot from the floppy

?
What floppy? :)

Seriously, there is a way to do this, but I don't think we should offer it
to users as a favoured booting method any more.  The current instructions
suggest booting from a suntar or dd-made floppy, but new machines don't
even have floppies--it might be good to avoid confusion by not focusing on
floppies at all.  There is a way to boot off an HFS volume, isn't there?

One thing I'd like to see is a list of Macintosh models and what their
OpenFirmware is/isn't capable of doing.  Some have framebuffer support,
some are serial only.  Some can boot off [XXX media, XXX partition table,
XXX filesystem], others can't. Some can boot ELF, some require COFF.

Maybe if we make a unified list of OpenFirmware Boot Commands for
{SCSI,IDE}{ZIP's,hard disks,CD-ROM's}, floppys, HFS volumes, people can
try them out and slowly report in what works.  I have a feeling after we
do this, we'll be able to offer almost all Mac users a better option than
the floppy, but I may be wrong.

>     - how to boot from the network

boot enet:0

To get a boot prompt from the second-stage loader,

boot enet:0 -a

>     - how to get the firmrware input/output from the screen

Not all firmware can use the screen.

Type printenv to get a list of all variables.  The variables
'input-device' and 'output-device' control this, IIRC.

On Sun's, you say 'set output-device screen' and 'set input-device
keyboard', but on OF I tihnk 'screen' and 'keyboard' is not specific
enough on a Macintosh.  Or maybe 'keyboard' is but 'screen' isn't. You
need to look at the FAQ to get the device path for your screen (and
keyboard?), or maybe you can type 'printenv' and look at the defaults to
see what the screen is called on your Mac.

The Modem port, on older Mac's that have one, is called ttya (is it?).

>     - a pointer to other relevant information regarding these
>       and related issues

Apple has an OpenFirmware primer linked on one of the web pages, but in my
opinion it is atrocious.  Maybe it only seems bad because Apple's
implementation of OpenFirmware is so buggy and piss-poor compared to what
Sun users are used to.  In any case, I think we should write our own docs
for OF.

Anyone know what the commands are to get a list of the devices installed
on your system?  There are commands to enumerate PCI cards, obio devices,
disks, partitions, yes?  I see others doing it and wish I knew how.

>     - Which protocols does the network boot process use (this
>       translates into "what do I need to configure on the server
>       end to make it go")

The Macintosh uses BOOTP or DHCP.  Newer Mac's use DHCP, older ones use
BOOTP.  The BOOTP macs have the additional issue of whether or not they
use Vendor Extensions.  Some of them may need always-reply-rfc1048 like
older SRM console code.

Again, we may need to provide some worst-case documentation and get people
to report what works and what doesn't for various models.

No Macs use RPC bootparams.  I believe our generic diskless(?)
instructions are very bootparams-focused.  DHCP is more flexible than
bootparams because (in theory) only the DHCP server needs to be on the
local wire--the TFTP and NFS servers can be behind a router.  With
bootparams, the rarp, bootparams, and TFTP server must all be on the local
wire, and only the NFS server can be behind a router.  bootparams is more
flexible because it allows the TFTP server and NFS server to be on
different machines, and DHCP doesn't allow that.  DHCP has the
frustratingly silly problem that if your cable modem or DSL box isn't
behind a router under your control, your ISP can pounce all over your DHCP
responses and not give the box enough information to netboot.  You might
have to disconnect your cable modem/DSL connection just long enough to get
the root filesystem mounted.

After the Mac gets its IP address, it loads a file via TFTP.  The filename
is controlled by the BOOTP/DHCP reply, not fixed like it is on Suns.
Typically, the name of this file is 'ofwboot.elf'.

ofwboot.elf sends out another DHCP query (always DHCP, never BOOTP), and
finds the 'root-path'.  It mounts this path from the NFS server and looks
for NetBSD kernels with the usual names (ex. /netbsd).  If you pass
ofwboot.elf the -a option, it will prompt you fo the name of the kernel
you want to boot and the boot options you want to use.  ex.

boot enet:0 -a

will pass ofwboot.elf the -a option.

ofwboot.elf does _not_ load kernels over TFTP, as is fallaciously stated
on the ``how to boot your iMac'' FAQ.  It loads them over NFS, from the
same IP address as the TFTP server is at, from the 'root-path' you provide
in the DHCP reply.

It is possible to boot kernels directly over TFTP without using
ofwboot.elf, but this is foolish because:
 o ofwboot gives you another opportunity to type things at a boot prompt
 o ofwboot can boot gzip'ed kernels if you want to
 o all the other ``real'' computers use a second-stage loader, and you
   want to use your Mac like a ``real'' computer, don't you? :)
 o you should boot /netbsd off your real root filesystem, because it's
   important that the kernel you just finished booting be available to
   userland kvm-grovelers.
 o Upgrading /netbsd on the running box is intuitive, while upgrading
   /usr/export/tftpboot/netbsd-MAC46472-A on the NFS server is not
   intuitive.

ofwboot.elf is an ELF object, and ofwboot.xcf is COFF.  ofwboot.xcf is not
part of the distribution set, but it is buildable by hand in
src/sys/arch/macppc/stand and will hopefully be included in the
distribution soon.  

If you have an older Mac that can only boot COFF files, use ofwboot.xcf.  
You wi ll know your Mac is old because when you try to boot ofwboot.elf it
will give you a cryptic error in all-caps something like:

OBJECT FILE FORMAT NOT RECOGNIZED

only, it will be a lot mroe cryptic and nonsensical than that.  Once
ofwboot.xcf loads, it will read your ELF kernel over NFS just fine.  [XXX
-- can anyone confirm or deny this paragraph?  I'm totally just making
this stuff up and haven't tested at all.]

>     - Does the boot process use a two-stage loader, or can I boot
>       the kernel directly (which translates into "which files do
>       I minimally need on the file server to make it go")?

If your Mac can boot ELF objects directly, you can minimally boot a
netbsd-GENERIC_MD kernel over TFTP, and not set up an NFS server at all.
If your Mac requires COFF objects, you will have to use ofwboot.xcf as
described above [XXX -- lies, damn lies?].

>     - How do I tell it which file to boot?

Here is a shortened version of the /etc/dhcpd.conf that Works For Me.

-------8<-----
# Notes:
# To set up dhcpd, install this file and ensure that /var/db/dhcpd.leases 
# exists.  
#
get-lease-hostnames true;		# DNS lookup for dynamic IP's
use-host-decl-names true;		# take fixed-ip hostname from the 
					# host <x> declaration

	subnet 209.181.65.120 netmask 255.255.255.248 {
	# no dynamically assigned addrs in this subnet
		option routers 209.181.65.121;
		option subnet-mask 255.255.255.248;
		option broadcast-address 209.181.65.127;
	}

host majic {
	hardware ethernet 00:05:02:f7:22:d3;
	filename "netbsd-macppc-boot.net";
	next-server 209.181.65.123;
	option root-path "/usr/export/majic";
	fixed-address majic;
#	always-reply-rfc1048 true;
}
-------8<-----

Note that I have renamed ofwboot.elf to netbsd-macppc-boot.net to
distinguish it from second-stage loaders for other platforms.  You can put
any filename in the 'filename' option.  Also notice the
always-reply-rfc1048 is _disabled_ because I found that I didn't need it.
I'm not sure that _any_ Macintosh needs it, but you might try it if your
syslog file says replies of the 'BOOTP' sort are going out but the Mac
isn't liking them. DHCP Mac's don't care about this option.

Also note that the root-path has a maximum length which is pretty short.
If ofwboot.elf has problems loading your kernel, try arranging for it to
work with a shorter root-path.  The root-path above was short enough for
me, but if you add 'netbsd-nfsroot/' to it, it becomes too long.

>     - The notes speak about 30M on the file server.  Surely you
>       don't need that much if you are only going to boot the
>       install kernel

My feeling is this:
 1) if you are netbooting for the purpose of installing on a disk,
    _don't_ install base.tgz and etc.tgz in your root filesystem.  install
    netbsd-GENERIC_MD, or whatever the miniroot-laden install kernel is
    called in the future, and use sysinst.  Your root filesystem will
    contain _one_ file.  If you have an ELF-aware Mac, you might even be
    able to get away with pointing 'filename' in dhcpd.conf straight to a
    TFTP-able gunzip'ed install kernel and skipping ofwboot altogether.
    This is more like 3MB, not 30MB.
 2) If you are going to netboot forever, don't use netbsd-GENERIC_MD at
    all.  Use the kernel out of the kern.tgz set.  Don't use sysinst--just
    untar all the sets, 'cd ..../../dev; ./MAKEDEV all', edit rc.conf and
    fstab, and you're done.  BTW be sure to set up some NFS swapspace if
    you install this way.  
 3) Also note that until 'options BUFPAGES=800' gets added to the GENERIC
    config file, or UBC gets integrated, the kernel in kern.tgz is broken
    on Macs with lots of memory.  You need to rebuild one yourself with
    'options BUFPAGES=xxx' by temporarily booting netbsd-GENERIC_MD with
    the -a option and pointing it at your NFSroot.  This will effect 
    both sysinst and manual installs on Macs with lots of memory.

ok
0 > boot enet:0 -a
>>> NetBSD ofwboot [...]
boot> netbsd-GENERIC_MD -a
[...]
[...boot dmesgs...]
root device: ?
Choose one of ......
root device(md0a): bm0
dump device:
filesystem (generic): nfs

I'm interested in working on documentation, but unfortunately i'm lazy and
it's difficult to motivate to continue testing things once I've got _my_
Macintosh working and would rather move on to getting X working or
obtaining and building LiViD so I can watch those annoying Chris Rock
DVD's that apparently the DVDCCA has not market-licensed to work with the
Apple DVD Player.

OpenFirmware revisions differ in subtle and annoying ways between models,
so it would probably help the documentation tremendously to get a lot of
user input, problems people have encountered, solutions that we eventually
work out.

-- 
Miles Nordin / v:+1 720 841-8308 fax:+1 530 579-8680
555 Bryant Street PMB 182 / Palo Alto, CA 94301-1700 / US