How to build OpenBIOS on Mac OS X: Difference between revisions

From OpenBIOS
Jump to navigation Jump to search
(Created page with "<!--This file created by AppleWorks HTML Filter 6.0--> <HTML> <HEAD> <META NAME=GENERATOR CONTENT="AppleWorks HTML Filter 6.0"> <META HTTP-EQUIV="Content-Type" CONTENT="text/h...")
 
No edit summary
 
(28 intermediate revisions by the same user not shown)
Line 1: Line 1:
<!--This file created by AppleWorks HTML Filter 6.0-->
<HTML>
<HEAD>
<META NAME=GENERATOR CONTENT="AppleWorks HTML Filter 6.0">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=macintosh">
<TITLE>Building OpenBIOS on OS X.cwk</TITLE>
</HEAD>
<BODY  >
<P ALIGN=CENTER><FONT SIZE=5><B>How to build OpenBIOS on Mac OS X<BR>
</B></FONT><BR>
</P>
<P><BR>
<P><BR>
Apple&#146;s supplied GCC on Mac OS X does not support the elf binary format. So compiling OpenBIOS on Mac OS X is not easy. Thankfully someone has already made a PowerPC cross compiler for Mac OS X that can compile OpenBIOS. Note: this tutorial was made with Mac OS 10.6. I suggest you use Mac OS 10.5 or higher when trying to build OpenBIOS. <BR>
Apple's GCC on Mac OS X does not support the elf binary format. So compiling OpenBIOS on Mac OS X is not easy. Thankfully someone has already made a PowerPC cross compiler for Mac OS X that can compile OpenBIOS. Note: this tutorial was made with Mac OS 10.6. I suggest you use Mac OS 10.5 or higher when trying to build OpenBIOS. <BR>
<BR>
Disclaimer: You assume all risk involved when following this tutorial. <BR>
<BR>
<BR>
<BR>
<BR>
<FONT COLOR="#AA0000"><B><U>Part 1: Installing the cross compiler on Mac OS X</U><BR>
<FONT COLOR="#AA0000"><B><U>Part 1: Installing the cross compiler on Mac OS X</U><BR>
</B></FONT><BR>
</B></FONT><BR>
1). Download the AWOS cross compiler: <A HREF="http://awos.wilcox-tech.com/downloads/AWOS-CC.bz2"><FONT COLOR="#0000DD"><U>http://awos.wilcox-tech.com/downloads/AWOS-CC.bz2</A></U></FONT><BR>
1). Download the AWOS cross compiler: http://awos.wilcox-tech.com/downloads/AWOS-CC.bz2<BR>
<BR>
<BR>
2) Expand this bz2 file by double clicking on it.<BR>
2) Expand this bz2 file by double clicking on it.<BR>
Line 28: Line 13:
4) Open the image file. <BR>
4) Open the image file. <BR>
<BR>
<BR>
5) Open the &#147;AWOS Cross-Compiler for OS X&#148; file on the newly mounted disk.<BR>
5) Open the "AWOS Cross-Compiler for OS X" file on the newly mounted disk.<BR>
<BR>
<BR>
6) Select the &#147;PowerPC Support&#148; check box only when given the option.<BR>
6) Select the "PowerPC Support" and the "i386 Support" check boxes when given the option.<br>
<IMG SRC="Building OpenBIOS on OS X.1.jpg"><BR>
[[File:Installer.png]]
<BR>
<BR>
<BR>
<BR>
7) Continue with the installation until it is finished. <BR>
7) Continue with the installation until it is finished. <BR>
<BR>
<BR>
8) Add the new compiler&#146;s folder to the PATH variable. This is the command you use if you are in the Bash shell: export PATH=:/usr/local/ppcelfgcc/bin. <BR>
8) Add the new compiler's folder to the PATH variable. This is the command you use if you are in the Bash shell:<br>
<BR>
export PATH=$PATH:/usr/local/ppcelfgcc/bin<br>
Note: the above step will probably need to be repeated with each new session of the shell you start. It can be made permanent by altering the .bashrc file for the Bash shell. Check your shell&#146;s documentation for more information. <BR>
export PATH=$PATH:/usr/local/i386elf/i386elf/bin<br>
<BR>
 
Note: the above step will probably need to be repeated with each new session of the shell you start. It can be made permanent by altering the .bash_profile file for the Bash shell. It is located in your home folder. <br>
To open this file use these commands:<br>
cd ~<br>
open .bash_profile<br>
Then simply paste the export commands in this file. Save changes when you are done.
<BR><br>
To test to see if the cross compilers work issue these commands:<br>
i386-elf-gcc --version
<br>
ppc-elf-gcc --version
<br><br>
You should see a message like this print:<br>
ppc-elf-gcc (GCC) 4.2.3
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.<br>
This should conclude installing the compiler. <BR>
This should conclude installing the compiler. <BR>
<BR>
<BR>
<BR>
<BR>
Next the switch-arch configuration script needs to be altered so it can work on Mac OS X. <FONT COLOR="#BB0000"><B><U><BR>
<FONT COLOR="#AA0000"><B><U>Part 2: Building OpenBIOS from source code</U><BR>
<BR>
Part 2: Required changes to OpenBIOS source code</U><BR>
</B></FONT><BR>
</B></FONT><BR>
1) Open the Terminal application.<BR>
1) Open the Terminal application.<BR>
Line 51: Line 50:
2) Change the current directory to the inside of the openbios-devel folder. <BR>
2) Change the current directory to the inside of the openbios-devel folder. <BR>
<BR>
<BR>
3) Copy this patch and place it into a file. Call the file mac.patch.<BR>
3) Open the file makefile.target and add a # in front of this text "CFLAGS+= -Werror". Save the changes when done.<br>
<BR>
[[File:example.png]]
<FONT COLOR="#008800"># start of patch</FONT><BR>
<br>
<BR>
<br>
Index: config/scripts/switch-arch<BR>
4) Type this command in the terminal and watch the show: <BR>
===================================================================<BR>
--- config/scripts/switch-arch (revision 1080)<BR>
+++ config/scripts/switch-arch (working copy)<BR>
@@ -89,16 +89,27 @@<BR>
<BR>
archname()<BR>
{<BR>
-    HOSTARCH=`uname -m | sed -e s/i.86/x86/ -e s/i86pc/x86/ \<BR>
- -e s/sun4u/sparc64/ -e s/sparc$/sparc32/ \<BR>
- -e s/arm.*/arm/ -e s/sa110/arm/ -e s/x86_64/amd64/ \<BR>
- -e &quot;s/Power Macintosh/ppc/&quot;`<BR>
+ OS_NAME=`uname`<BR>
+ if test &quot;$OS_NAME&quot; = &quot;Darwin&quot;; then    # Can't depend on uname -m on Mac OS X<BR>
+  IS_64BIT=`sysctl hw.cpu64bit_capable`<BR>
+  if test &quot;$IS_64BIT&quot; = &quot;hw.cpu64bit_capable: 1&quot;; then<BR>
+  HOSTARCH=&quot;amd64&quot;<BR>
+  else<BR>
+  HOSTARCH=&quot;x86&quot;<BR>
+  fi<BR>
+ else<BR>
+  HOSTARCH=`uname -m | sed -e s/i.86/x86/ -e s/i86pc/x86/ \<BR>
+  -e s/sun4u/sparc64/ -e s/sparc$/sparc32/ \<BR>
+  -e s/arm.*/arm/ -e s/sa110/arm/ -e s/x86_64/amd64/ \<BR>
+  -e &quot;s/Power Macintosh/ppc/&quot;`<BR>
+ fi<BR>
}<BR>
<BR>
select_prefix()<BR>
{<BR>
-    for TARGET in ${1}-linux-gnu- ${1}-linux- ${1}-elf- ${1}-eabi-<BR>
+    for TARGET in ${1}-linux-gnu- ${1}-linux- ${1}-elf- ${1}-eabi- ppc-elf-<BR>
    do<BR>
+        echo &quot;Trying ${TARGET}gcc&quot;<BR>
        if type ${TARGET}gcc &gt; /dev/null 2&gt;&amp;1<BR>
        then<BR>
            return<BR>
<BR>
<BR>
<FONT COLOR="#770000"># end of patch</FONT><BR>
<BR>
<BR>
4) Apply the patch to your OpenBIOS source code using the patch command. <BR>
Example: patch -p0 &lt; ~/Desktop/mac.patch<BR>
<BR>
If everything went to plan, you would see something like this: patching file config/scripts/switch-arch.<BR>
<BR>
If an error message was displayed instead, try changing the p0 argument to p1 or p2. If this doesn&#146;t help, verify you are in the openbios-devel directory. If you are still stuck, applying this patch by hand is an option.<BR>
<BR>
<BR>
CROSS_COMPILE=ppc-elf- ./config/scripts/switch-arch ppc &amp;&amp; make build-verbose<BR>
<BR>
<BR>
That is all the changes that are needed. By this point, you should be able to configure and build OpenBIOS. Just type this command in the terminal and watch the show: <BR>
There is a known build issue when building on Mac OS 10.6. The switch-arch script will report your computer as 32 bit (x86) when it is really 64 bit (amd64). If you see the message "panic: segmentation violation at …" while building, you probably have this problem.
<BR>
<br><br>
./config/scripts/switch-arch cross-pcc &amp;&amp; make build-verbose.<BR>
If this happens to you, try setting the HOSTARCH variable before using the switch-arch script.
<BR>
<br><br>
Example:
<br><br>
HOSTARCH=amd64 CROSS_COMPILE=ppc-elf- ./config/scripts/switch-arch ppc &amp;&amp; make build-verbose
<br><br>
To test out your newly created binary in qemu, use the -bios option:<BR>
To test out your newly created binary in qemu, use the -bios option:<BR>
qemu-system-ppc -bios &lt;path to binary&gt;/openbios-qemu.elf.nostrip<BR>
qemu-system-ppc -bios &lt;path to binary&gt;/openbios-qemu.elf.nostrip<BR>
<BR>
<BR>
<BR>
This tutorial was made using information available on 12/21/2017. If you encounter any problems, please report it to the openbios developer list: openbios@openbios.org. </P>
<BR>
This tutorial was made using information available on 12/17/12. It is possible things have changed since that time. If you encounter any problems, please report it to the openbios developer list: openbios@openbios.org. </P>
</BODY>
</HTML>

Latest revision as of 00:28, 22 December 2017


Apple's GCC on Mac OS X does not support the elf binary format. So compiling OpenBIOS on Mac OS X is not easy. Thankfully someone has already made a PowerPC cross compiler for Mac OS X that can compile OpenBIOS. Note: this tutorial was made with Mac OS 10.6. I suggest you use Mac OS 10.5 or higher when trying to build OpenBIOS.


Part 1: Installing the cross compiler on Mac OS X

1). Download the AWOS cross compiler: http://awos.wilcox-tech.com/downloads/AWOS-CC.bz2

2) Expand this bz2 file by double clicking on it.

3) Rename the file AWOS-CC to AWOS-CC.img.

4) Open the image file.

5) Open the "AWOS Cross-Compiler for OS X" file on the newly mounted disk.

6) Select the "PowerPC Support" and the "i386 Support" check boxes when given the option.


7) Continue with the installation until it is finished.

8) Add the new compiler's folder to the PATH variable. This is the command you use if you are in the Bash shell:
export PATH=$PATH:/usr/local/ppcelfgcc/bin
export PATH=$PATH:/usr/local/i386elf/i386elf/bin
Note: the above step will probably need to be repeated with each new session of the shell you start. It can be made permanent by altering the .bash_profile file for the Bash shell. It is located in your home folder.
To open this file use these commands:
cd ~
open .bash_profile
Then simply paste the export commands in this file. Save changes when you are done.

To test to see if the cross compilers work issue these commands:
i386-elf-gcc --version
ppc-elf-gcc --version

You should see a message like this print:
ppc-elf-gcc (GCC) 4.2.3 Copyright (C) 2007 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
This should conclude installing the compiler.


Part 2: Building OpenBIOS from source code

1) Open the Terminal application.

2) Change the current directory to the inside of the openbios-devel folder.

3) Open the file makefile.target and add a # in front of this text "CFLAGS+= -Werror". Save the changes when done.


4) Type this command in the terminal and watch the show:

CROSS_COMPILE=ppc-elf- ./config/scripts/switch-arch ppc && make build-verbose

There is a known build issue when building on Mac OS 10.6. The switch-arch script will report your computer as 32 bit (x86) when it is really 64 bit (amd64). If you see the message "panic: segmentation violation at …" while building, you probably have this problem.

If this happens to you, try setting the HOSTARCH variable before using the switch-arch script.

Example:

HOSTARCH=amd64 CROSS_COMPILE=ppc-elf- ./config/scripts/switch-arch ppc && make build-verbose

To test out your newly created binary in qemu, use the -bios option:
qemu-system-ppc -bios <path to binary>/openbios-qemu.elf.nostrip

This tutorial was made using information available on 12/21/2017. If you encounter any problems, please report it to the openbios developer list: openbios@openbios.org.