Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Jul 2002 17:57:09 +1000
From:      Peter Grehan <peterg@ptree32.com.au>
To:        andy@wantpackets.com
Cc:        freebsd-ppc@freebsd.org
Subject:   Re: FreeBSD-powerpc compiled init -> "ppcdisk"
Message-ID:  <3D3674D5.864C543E@ptree32.com.au>
References:  <1026963034.3d36365a28b28@www.wantpackets.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi Andrew,

>   "ppcdisk" from Oct 18 does not contain anything in reguards to any binaries (or
>  it would seem so as it compresses to about nothing.)  I compiled and linked init
>  as a FreeBSD powerpc binary, and would like to try it out.

 I'm amazed that you managed to get init to compile, since there are
some major pieces missing in libc. I'll put a pointer to the patches
further down.

 Actually, there are a whole lot more things that will get in your way,
but
if you're willing, keep reading :-)

>  I cannot do this be
>  cause I can't(do not know how?) to mount the big endian ppcdisk image to put the
>  file init in /sbin.  I ask for somebody to tell me how to mess with big endian
>  stuff with my i386 or to do the above themselves on a NetBSD-PPC (or any ffs-rea
>  ding os on the powerpc).  The binary is available at
>  https://wantpackets.com/~andy/init .
>   (using the 4.6-RELEASE write_mfs_in_kernel.c works :)

 I currently use mkisofs to build an ISO image, build ofwd, cd9660 and 
GEOM into the ppc kernel, and use psim's disk capability to mount root.
The idea also being that I can use this ISO image on a real system when 
I'm happy with it. So, the steps are:

 1. Apply the relevant kernel/libc patches from

       http://www.ptree32.com.au/freebsd/ppc-0718.tgz 

 2. Take out the BOOTP, BOOTP_NFSROOT, and NFS_ROOT lines from your
kernel 
    conf file. Add GEOM and CD9660 (I'm using GEOM since an Apple
partition 
    module will be added to it at some point). Also, GEOM requires the
    following lines to be added to files.powerpc. I guess they might
make it
    into the MI files file at some point.

      crypto/rijndael/rijndael-alg-fst.c optional geom
      crypto/rijndael/rijndael-api-fst.c optional geom

 3. Populate a directory tree with /sbin/init, /dev, and various files &
utilities.
    (e.g. /bin/sh, /bin/ls, /etc/rc) and create an ISO image of this.

 5. In the kernel compile directory, create a psim device tree file,
with the
    following lines. Yes, there's a lot of crap here, but unfortunately
it's
    required by psim.

/#address-cells 1

#
# CPU definition.
#
/cpus/cpu@0

#
# disk file, done via phb junk. wish there was a better way.
#
/phb@0x70000000
        ./device_type "pci
        ./name "pci
        ./#address-cells 3
        ./#size-cells 2
        ./ranges ni0,0,0,0 0xc0000000 0x10000

/phb@0x70000000/ide@1
        ./device_type "ide
        ./name "ide
        ./assigned-addresses \
                ni0,0,10,1f0 8 \
                ni0,0,14,3f8 8 \
                ni0,0,18,170 8 \
                ni0,0,1c,378 8 \
                ni0,0,20,200 8
        ./reg \
                1 0 \
                i0,0,10,0 8 \
                i0,0,18,0 8 \
                i0,0,14,6 1 \
                i0,0,1c,6 1 \
                i0,0,20,0 8
        ./ready-delay 1000

# Put ISO image file here
/phb@0x70000000/ide@1/disk@0/file "PPC.IMG
  

 6. Create a .gdbinit file with the option to tell psim to read in the
device
    tree. You probably don't need to use 128M for the '-r' param.

      target sim -e chirp -r 134217728 -f psim-tree
      load

 7. Now boot the kernel with psim, and it should eventually get to the
root
    mount prompt. When it does, enter 'cd9660:ofwd0', and that should
kick off
    the boot process:

(gdb) r
Starting program:
/mnt/home/freebsd/work/sys/powerpc/compile/PETERG/kernel.debug 
powerpc_init: no loader metadata.
Copyright (c) 1992-2002 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights
reserved.
FreeBSD 5.0-CURRENT #198: Thu Jul 18 06:14:18 GMT 2002
   
grehan@fb1.ptree32.com.au:/mnt/home/freebsd/work/sys/powerpc/compile/PETERG
CPU: PowerPC Simulator (psim) (Revision 0)
real memory  = 133132288 (130012K bytes)
avail memory = 125636608 (122692K bytes)
nexus_probe: can't get interrupt-controllernexus0: <OpenFirmware Nexus
device>
ofwd0: <OpenFirmware disk> on nexus0
ofwd0: located at /phb@0x70000000/ide@1/disk@0
Initializing GEOMetry subsystem
Timecounter "powerpc"  frequency 16666666 Hz
Timecounters tick every 10.000 msec

Manual root filesystem specification:
  <fstype>:<device>  Mount <device> using filesystem <fstype>
                       eg. ufs:da0a
  ?                  List valid disk boot devices
  <empty line>       Abort manual input

mountroot> cd9660:ofwd0
cd9660:ofwd0
Mounting root from cd9660:ofwd0
cd9660: RockRidge Extension
Jan  1 00:00:01 init: login_getclass: unknown class 'daemon'

 8. Now the fun begins, since things appear to hang about here. The
problem is
   that init has opened /dev/console, which kicks off the OpenFirmware
console
   polling process. But, the psim stdin implementation is blocking, so
the
   ofw_cons_checkc() routine in ofw_timeout() doesn't return. A
workaround is
   to hit ^C in gdb: if you see something like:

   ^C
   Program received signal SIGINT, Interrupt.
   0x80004004 in ?? ()
   (gdb) 

   you know that you're stuck in OpenFirmware. BUT, if you continue from
here,
   the stdin routine *will* return an error status, and things will
continue.

   I'm sure this psim problem can be fixed, but I've worked around it
either with
   ^C, or by putting in a variable that prevented ofw_cons_checkc() from
being
   called until I set it in the debugger.

 9. If you're lucky, you may get to a shell prompt, but this is where my
    debugging is currently at.

later,

Peter.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ppc" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3D3674D5.864C543E>