[openfirmware] Problem compiling OpenFirmware for ppc

Mitch Bradley wmb at laptop.org
Thu Nov 19 18:35:23 CET 2009

Christian Johansson wrote:
> Hi!
> Thank you for your answer.
> Let me start by saying that this project is just for my own amusement.
> Well, what I'm trying to do is to use openfirmware as firmware for 
> qemu-system-ppc(64).
> The far-far end of this project is trying to get AIX to boot somehow ...
> (Really doubt it myself, but anyway ...)

My memory is that, of all the operating systems we worked with in the 
heyday of PREP and multiple-OSs on PPC, AIX was perhaps the easiest to 
get booting.

> After doing extreme amounts of violence on wrapper.c,
> (there is some sort of mixup with AIX - macros)
> i got forth to compile cleanly on AIX 32-bits.

When you're ready, send me your modified version and I'll see about 
upstreaming the changes.  I'm not surprised the that macros are messed 
up, since it has been ages since I had an AIX system to use.

> Unfortunately, now the build process bails out with:

Okay, so this is good.  The problem below is understood and easy to 
fix.  The good news is that a whole lot of stuff is working in order to 
get to that point.

The tag-file problem results from a change I made in svn 1294.  I folded 
the source changes into the PPC code, but forgot to recompile the builder.

I recompiled the builder and checked in a new version - svn 1493 is your 

To break the chicken-and-egg problem of recompiling, I temporarily 
commented-out lines 62 and 64 of meta1.fth, recompiled the kernel (to 
get the variable "tag-file" included in the base Forth dictionary), 
recompiled tools.dic, and builder.dic.  That gave me a builder that 
includes the "tag-file" variable.  Then I put meta1.fth back to its 
uncommented-out state and recompiled everything just to check.

In the process I found and fixed a bug in ppc/kerncode.fth that svn 1294 
had introduced.

It should all work now.

By the way, you can do builds for PPC on an x86 system without needing 
qemu.  If, on an x86 Linux system, you go into cpu/x86/Linux and do

   $ make -f Makefile.ppcforth

You will get an executable "ppcforth" that is a wrapper plus PPC 
instruction set emulator.  You can use it instead of "forth" (perhaps 
symlinking it to "forth" and "ppcforth") to run ppc .dic files.  I wrote 
that simulator one weekend in a frenzy of hacking, after several weeks 
of unsuccessful negotiations with Motorola to get access to their 
existing simulator.  This was before we had any powerpc hardware at 
all.  Eventually IBM agreed to let us actually touch a 601-based 
"Sandalwood" machine in a customer's lab.  A few months later we had 
more powerpc hardware than we knew what to deal with, but in the early 
days, getting hardware to test was tough.

If you use the "ppcforth.trace" variant, you can do instruction-level 
debugging.  See the "trace()" subroutine in cpu/ppc/ppcsim/ppcsim.c.

I had nearly forgotten that all that stuff existed...

> ./build basefw.dic
> --- Rebuilding kernel.dic
> --- Cmd: ${HOSTDIR}/forth ${HOSTDIR}/../build/builder.dic ../kernel.bth
> ${BP}/forth/kernel/meta1.fth:62: tag-file ?
> ${BP}/forth/kernel/meta1.fth:62: tag-file ?
> ${BP}/forth/kernel/meta1.fth:64: tag-file ?
> ${BP}/cpu/ppc/metainit.fth:27: Undefined word encountered 
> make: *** [basefw.dic] Error 1
> HOSTDIR is ~/openfirmware/cpu/ppc/AIX, which contains the forth-binary.
> Any ideas what can cause this?
> //Br
> //Br
> 2009/11/16 Mitch Bradley <wmb at laptop.org <mailto:wmb at laptop.org>>
>     The last time I got anywhere near a 64-bit PPC machine was
>     something like 13 years ago, so I'm afraid I know almost nothing
>     at all about how things work on powerpc64-*-linux.
>     You might try gdb to see where it's dying.
>     I'm not surprised that it doesn't work.  I'm not sure the OFW
>     build system for PPC has ever been adapted to 64-bit Linux.  When
>     FirmWorks was last working with 64 bit PPC machines, the customer
>     was using AIX.  PPC Linux only came out towards the end of that
>     project, and probably didn't run on 64-bit systems, as few were
>     available then.
>     If I recall correctly, on 64-bit systems like the 620 processor,
>     we ran OFW with 32-bit stacks, with the ability to access data in
>     the 64-bit address space.  If powerpc64-suse-linux is a full
>     64-bit execution environment, that's probably not going to play
>     well with a 32-bit Forth kernel.  The ppc kernel code appears to
>     be parameterized so it could be extended to 64-bit stacks with
>     some effort (as was the SPARC kernel), but I don't see any
>     evidence in my archived source trees that a 64-bit PPC Forth
>     kernel was ever built.
>     Apple and IBM made it pretty difficult for FirmWorks to make any
>     money in the PowerPC market, by either giving away or
>     bundle-licensing their own internally-developed OFW
>     implementations.  As a result, FirmWorks had to abandon the PPC
>     market and focus on other processors.  FirmWorks' core OFW
>     implementation on PowerPC had reached a high level of stability by
>     that point, but since then there has been very little further
>     development, especially in the area of support for more current
>     build environments.  We did port the builder to mklinux, for use
>     in an embedded project that targeted MPC823, but development sort
>     of stalled after that.
>     What is your intended application?  If this is a project with
>     commercial implications, I am available for consulting help.  If
>     it's just for curiosity, I can perhaps give you some pointers, but
>     can't spend a lot of time on it.
>     Mitch Bradley
>     Christian Johansson wrote:
>         Hi!
>         I'm trying to compile of, rev. 1484 on Linux-ppc64, but after
>         'forth' has been built,
>         it segfaults when running "./build basefw.dic"
>         First try, i got:
>         Can't find environment variable HOSTDIR in
>         ${HOSTDIR}/../build/builder.dic
>         forth: Can't open dictionary file ${HOSTDIR}/../build/builder.dic
>         make: *** [basefw.dic] Error 1
>         So I'd set HOSTDIR=$HOME/of2/openfirmware/cpu/ppc/Linux
>         After this, I'm just getting:
>         ./build basefw.dic
>         forth: Segmentation fault
>         make: *** [basefw.dic] Quit
>         When running make in $HOME/of2/openfirmware/cpu/ppc/build
>         I'm using:
>          chjo at op5p1:~/of/of2/openfirmware/cpu/ppc/build> gcc --v
>         Using built-in specs.
>         Target: powerpc64-suse-linux
>         Configured with: ../configure --enable-threads=posix
>         --prefix=/usr --with-local-prefix=/usr/local
>         --infodir=/usr/share/info --mandir=/usr/share/man
>         --libdir=/usr/lib --libexecdir=/usr/lib
>         --enable-languages=c,c++,objc,fortran,obj-c++,java,ada
>         --enable-checking=release
>         --with-gxx-include-dir=/usr/include/c++/4.2.1 --enable-ssp
>         --disable-libssp --disable-libgcj --with-slibdir=/lib
>         --with-system-zlib --enable-shared --enable-__cxa_atexit
>         --enable-libstdcxx-allocator=new --disable-libstdcxx-pch
>         --program-suffix=-4.2 --enable-version-specific-runtime-libs
>         --without-system-libunwind --with-cpu=default32
>         --enable-secureplt --with-long-double-128
>         --host=powerpc64-suse-linux
>         Thread model: posix
>         gcc version 4.2.1 (SUSE Linux)
>         Any advice how to proceed?
>         //Br
>         ------------------------------------------------------------------------
>         _______________________________________________
>         openfirmware mailing list
>         openfirmware at openfirmware.info
>         <mailto:openfirmware at openfirmware.info>
>         https://openfirmware.info/mailman/listinfo/openfirmware
> ------------------------------------------------------------------------
> _______________________________________________
> openfirmware mailing list
> openfirmware at openfirmware.info
> https://openfirmware.info/mailman/listinfo/openfirmware

More information about the openfirmware mailing list