Qemu 0.14 PowerPC & Debian.

So I got this request about running Mono on the PowerPC. As it stands right now I don’t have a PowerPC box in my home to test, so I thought I’d turn to Qemu & Debian.

Qemu 0.14.0 PowerPC Debian boot

Qemu 0.14.0 PowerPC Debian boot

And yes, it surprisingly boots!

I opted for the network install, as I didn’t even know if it would work. But not only did the 32bit version of Linux for the PPC boot up, but the 64bit did as well! The flags were a little involved to get going, but it went something like this for the 32bit version:

qemu-system-ppc.exe -m 512 -boot d -hda debian-ppc.qcow2 -L pc-bios -M mac99 -net nic,model=pcnet -net user -cdrom debian-6.0.1a-powerpc-netinst.iso -boot d

And for the 64bit version:

qemu-system-ppc64.exe -L pc-bios -m 512 -hda ppc64.qcow2 -net nic,model=pcnet -net user -cdrom debian-6.0.1a-powerpc-netinst.iso -boot d

And then it’s a matter of waiting… Maybe I should have just torrented the install DVDs or something.. 😐

Qemu 0.14.0 PowerPC Debian install 33%

Qemu 0.14.0 PowerPC Debian install 33%

But booting from the hard disk produces a:

openbios panic: Unexpected exception 704

So close. Perhaps the macintosh machine type I select means the boot type isn’t PReP like for OpenBIOS to find?

I’ve also been told you can find various pre-built images here.

10 years of OS X 10.0 !

So today is 10×10 or … ten years of OS X 10.0

I know that is confusing, but the 1.0 version of OS X was released in 1999. I should have saved the receipt, but I still have the box.

It does go without saying that OS X changed apple, as it FINALLY integrated the NeXTSTEP OS onto the consumer level machines, and propelled Apple to the #1 spot for the Unix market. Yeah take a step back with me here, and look at the market like this. Apple ships more computers in any given year then HP/SUN(Oracle)/IBM ship that come preloaded with a UNIX. Not to mention Apple also loads their UNIX is the core of the iPhone, iPad, and some of the iPods. Wow imagine that, Apple brought UNIX everywhere. And made it so buried under a UI 99% of the users don’t even know it’s there.

That’s pretty snazzy, isn’t it?

So 10 years ago today, Apple finally shipped 10.0.0 . And let me tell you it was rough around the edges. I had an iMac and at the time I LOVED it. In between the 1.0 & the 10.0 I had bought a G4 and was disappointed that 1.0 wouldn’t run on my beloved G4. I had no intention of running OS 9, but that’s all it could run. So in those fleeting months I managed to run windows 95 on SoftPC (SLOW!) and even got my hands dirty on OpenBSD for the PowerPC.

OS X really made a splash with usable applications that shipped with the OS. I know the nerds hate iTunes, but damn, it’s something a user can use. Same with Mail, and even Microsoft Internet Explorer.

So enough with the reminiscing, I’m sure you want to see it run under some kind of emulation, right?
Well the best (if not only) emulator for running PowerPC Macintosh stuff is PearPC. And version 0.4 is about as good as it gets. Mostly because of Stefan Weyergraf’s untimely death.

Which is sad, however I did find with a little playing around, 10.0.0 can boot single user mode from the CD.

PearPC 10.0 single user

PearPC 10.0 single user

PearPC 10.0 single user hostinfo

PearPC 10.0 single user hostinfo

One thing was for sure, at the time, 10.0.0 was so.. rough around the edges Apple did give everyone a free copy of 10.1 . And that version certainly better then 10.0! And it runs on PearPC!

PearPC 10.1 boot happy mac

PearPC 10.1 boot happy mac

The boot screen, notice the old style mac.

PearPC 10.1 boot thru motions

PearPC 10.1 boot thru motions

And the progress bar, just like NeXTSTEP. The more things change the more they stay the same..

PearPC 10.1 booted

PearPC 10.1 booted

And welcome to the desktop.

Well since it does run in single user mode, maybe it could be possible to manually place a 10.0 dump on the disk, but that may take a bunch of time… So for now enjoy 10.1!

Notes on fat binaries & OS X

I suppose this also applied to NeXTSTEP/OPENSTEP but I didn’t cross build that much between the m68k and i386…

So let’s start with a 3 way compile…

$ gcc -arch i386 -arch x86_64 -arch ppc7400 dhrystone.c -o dhrystone
$ file dhrystone
dhrystone: Mach-O universal binary with 3 architectures
dhrystone (for architecture i386): Mach-O executable i386
dhrystone (for architecture x86_64): Mach-O 64-bit executable x86_64
dhrystone (for architecture ppc7400): Mach-O executable ppc
$

This builds the single file for all 3 machine types of OS X..

For anyone that cares, this is my quad core box..

$ ./dhrystone
Dhrystone(1.1) time for 500000000 passes = 83
This machine benchmarks at 6024096 dhrystones/second

Ok, now let’s pull out the PowerPC executable, and run that….

$ lipo -extract ppc7400 dhrystone -output dpc
$ file dpc
dpc: Mach-O universal binary with 1 architecture
dpc (for architecture ppc7400): Mach-O executable ppc
$
$ ./dpc
Dhrystone(1.1) time for 500000000 passes = 214
This machine benchmarks at 2336448 dhrystones/second
$

Which isn’t too bad, seeing the emulator runs at 1/3rd speed of the native exe.. It’s no wonder that IBM bought transitive, and shut them down. This kind of technology would make it far too easy for everyone to move away from expensive CPUs…!

Now let’s extract the 32bit i386 exe.

$ lipo -extract i386 dhrystone -output di3

Nothing to really see here.

And for the final part, let’s combine the extracted PPC & i386 executables.

$ lipo di3 dpc -create -output dip
$ file dip
dip: Mach-O universal binary with 2 architectures
dip (for architecture i386): Mach-O executable i386
dip (for architecture ppc7400): Mach-O executable ppc

And there we have it.. Using this I guess I can try to find versions of Qemu that will hopefully cross build on my machine that I can stitch together so that some platforms (PPC) have *SOMETHING* to run at least…..

Or maybe it’ll help someone at least make a stub ‘we are sorry, nothing to see here’ vs an exe error.

Qemu ARM, MIPS & PowerPC images…

Well I was thinking of building something like this, but someone did the work for me….

You can find various images here.

So needless to say, a special thank you goes to the dietpc guy… These are all set for MS Windows users, just download the VM you want, and you are ready to go. The only ‘issue’ I had with the PowerPC one, is that I needed to run fsck on the root and reboot it…. (remember the root password is foobar).

Other then that it seems happy as it can be.

root@dietpc3-dev-ppc:/usr/src/f2c# cat /proc/cpuinfo
processor : 0
cpu : 740/750
temperature : 62-64 C (uncalibrated)
clock : 1000.000000MHz
revision : 3.1 (pvr 0008 0301)
bogomips : 40.44
timebase : 16605783
platform : PowerMac
model : Power Macintosh
machine : Power Macintosh
motherboard : AAPL,PowerMac G3 MacRISC
detected as : 49 (PowerMac G3 (Silk))
pmac flags : 00000000
pmac-generation : OldWorld

I wouldn’t dream of really benching it, but this is better then blindly cross compiling as you can check your work…

The downloads are quite sizable about 450mb each… but it is a complete run & go linux environment.

And here is a gratuitous screenshot:

 

Sheepshaver

SheepShaver on Windows

SheepShaver on Windows

I was hoping for this to be a full featured review but alas there are a few major issues to prevent wide spread use of this emulator…

First you really need access to a Power Macintosh of some kind to use this. You’ll need a ROM and a version of the OS that isn’t for free on Apple’s site. Right now I’m using my 7.6.1 CD to run stuff, and it works great. Honestly its way better than the real deal.. Unless you are running something CPU intensive… Like SIMH on MiNT (all 68000 code) on Sheepshaver (PowerPC emulator)… it can be quirky at times.

However let me say if you do have MacOS 7.6 – 9 you’ll love Sheepshaver. If you feel left out from the PowerPC to Intel transition and feel you need this old clunker around to run some 68000 apps or even PowerPC system 7-9 applications that are not carbon compatible, sheepshaver is freaking AWESOME.

I’m still running Vista x86_64 on my laptop where I do most of my work, so for me I needed to download Sheepshaver. Now it does mention it can run MacOS 7.5.2 however the copy on apple’s site is a massive disk image… So you’ll need a Mac to extract it… Yeah I know.  I did make an ISO image to help those who need/want it.

I haven’t tried it, however I do know that 7.5.2 did *NOT* work on my 5400. The good news is that the disk images work between MiniVmac & Sheepshaver. This has saved my sanity (perhaps yours as well!) This does mean that you can also use HFVExplorer to move files in/out of Sheepshaver. A word of caution, the SLiRP networking causes my setup to crash… I really don’t know if it’s Vista 64, and I’m not in the mood to test within Virtual PC… emulating within an emulator is a recipe for disaster.

Another thing you’ll need is the GTK+ runtime for the gui configuration… I found mine by googling the term “gtk-2.12.9-win32-2.exe” … For some reason sourceforge seems to have issues at the moment with its projects unless you know exactly what you are looking for.

That being said I love sheepshaver. I run it full screen at my laptops native resolution (1280×800) and with the sound on, and it FEELS like a Macintosh Laptop. Even my 1.8Ghz laptop feels snappier than the 120Mhz PowerPC.. But from the Sheepshaver site, they do say to expect to run at 1/8th the speed.. So my laptop “feels” like it’s 225Mhz. A SCREAMER! Of course this would be horrible for people expecting to run photoshop & friends.

There is no doubt about it, Sheepshaver is great for running old games and applications.

A few tips though. Turn off Virtual memory in Sheepshaver. There is no need for it, as it’s far better to allow Sheepshaver to just have more memory.. In this day & age odds are you can easily allow it to have 64 – 256 megabytes. While you are unable to turn off the disk cache, you should tune it down to 64kb. Although the CPU isn’t much faster than many of the Power Mac’s, the disk IO of a modern computer far exceeds it. Most computers are actually IO bound, so running older systems with faster IO gives the appearance of them running substantially faster. It’s only nested emulation that brings it out how slow it is.

I’ve also found that older version of the OS support more software, and run better.  That is 7.5.3, 7.6, 8.0 and 8.1.  8.5, 8.6 and 9.0 have more PowerPC hooks in them, and SheepShaver hooks the 68000 code to do it’s paravirtualization (it doesn’t emulate any hardware), and the more older tied to the 68000 code tend to be more stable.

That being said, running Mathematica, SoftPC, and Photoshop would not be a “good idea” if you are expecting faster performance. But at the same time, it’s great being able to run old software that you’ve purchased throughout the years.

Some 5400/12 – Performa 200 restoration notes

(Image from Wikipedia) I never took a picture of mine.

(Image from Wikipedia) I never took a picture of mine.

I’ll throw out a little tidbit about the Power Macintosh 5400/120, otherwise known as the Performa 200. If you do not have any Mac OS CD’s this will be *VERY* hard to get going with nothing. The good news is that there are boot floppies available out there.

The bad news is that they are encoded in a method in which you’ll have to get access to a working Mac. If there was somewhere I could post these files forever I would.

Anyways the boot disk is this one:

5400-6400_Disk_Tools.img.bin

Which I currently see online here:

http://www2.cddc.vt.edu/apple/Apple_Software_Updates/English-North_American/Macintosh/System/CPU_Specific_Updates/6360-64xx-54xx/5400-6400_Disk_Tools.img.bin

Now it’s a diskcopy 6.4 image. Which you’ll need a Mac. I was able to finagle one from a Mac, however I’m wondering now if it’s possible to do this via emulation. During this whole resurrect my $12 Mac I’ve come across vMac, Basilisk II & SheepShaver.

I plan on doing some serious review, however it is worth noting that while both do run fine, they are actually buggy on weird stuff vs the real iron.

From what I gather with the boot disk, you can boot your Mac up, partition & format it, and install this super small bootable System 7.6 onto the hard disk. It will complain about you doing it this way, but it will work, allowing you to get the box up & running somewhat, to let you try some methods of getting the install disk for 7.6 onto your Mac.

It is worth noting that the 7.5.3 on Apple’s download site that is provided for FREE does *NOT* work on the 5400! I did at one point try it, and I got some wonderful message :

The System Software 7.5.3 Installer script does not recognize this Macintosh. Please use the original disks that came with your computer.

Sadly all information I see is that this thing shipped with 7.5.3 Oh well. I eventually found a boot floppy!

The site I gleaned this boot disk from was this:

http://home.earthlink.net/~gamba2/bootdisks.html

If anyone does anything MacOS for a living or is going to play with a Mac you ought to save the whole thing! It’s VERY useful, more so than Apple’s documentation.

Anyways I’ve tweaked up a copy of the SIMH PDP-11 to compile and do a small test under MiNT/MacOS. Tomorrow we shall see if it’s usable.

psim, the PowerPC simulator

Psim is one of those great peices of software that has been long sice forgotten. In every copy of GDB since 4.14 it has been sitting there dormant. What is it? Well it’ll emulate various PowerPC systems to some degree (GXemul & Qemu are better now) but what is cool is the ‘run’ program. Simply put, any system that can run GDB can run powerpc NetBSD statically linked EXE’s! Now isn’t that exciting!

Now I know you’ll want to build your own copy of the ‘run’ program, and then setup a cross compile enviroment so that you, to can produce NetBSD PowerPC executables. I’m assuming that you are not on a PowerPC running NetBSD, since this whole excersize would be… redundant.

For this example I’m using OpenBSD 4.0 on the i386. You will need a real unixy envioment for this. MinGW isn’t good enough, cygwin however is. BSD/Linux will work too.

Ok first let’s start with building the run program. I’m going to download my GDB from ftp://ftp.gnu.org/ .

Gdb 5.3

Unpack it somewhere, and then run the following commadn to configure GDB.

./configure --enable-sim-powerpc --target=powerpc-unknown-eabi --prefix=/usr/local/psim

 

You will need to replace or update the sim/ppc/emul_netbsd.c program to include system calls up to 300, and make sure that 279 is setup to do_fstat. Otherwise you will be unable to run any programs. This is also a good excersize to see how libraries interact with the simulator so you can add your own native interfaces, for things like OpenGL, SDL….

 

Now we are ready to build it.. You could use -O0 in your CFLAGS to build it quicker, but it will result in a slower run times.. If you have issues with this you will want to use those flags so it doesnt take forever to be building this thing. Otherwise a simple ‘make;make install’ will suffice.

Next up is binutils. I’m using version 2.17

Binutils 2.17

Again download and unpack this somewhere (/usr/src?) Then run the following to configure your binutils


./configure --target=powerpc-unknown-netbsd --prefix=/usr/local/psim

Since execution time here isn’t as critical as the emulator, and I want to hurry it along I’m going to use the following command to build & install:


make CFLAGS=’-O0 -pipe’ ;make install

On OpenBSD 4.1 the install fails, and I had to manually copy the binutils applications into /usr/local/psim/powerpc-unknown-netbsd-bin

Before you build gcc you will want to populate your directory with headers & libraries from NetBSD 1.4 get the compiler package and copy the usr/lib files to /usr/local/psim/powerpc-unknown-netbsd/lib and the usr/include files to /usr/local/psim/include . I get my includes & lib files from here ( ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-archive/NetBSD-1.4/macppc/binary/sets/comp.tgz )

Gcc 3.3

You may need to do some special tweaking to this source to get it to run correctly
Optionally running make with CFLAGS=-O0 may speed your compliation.

You know the drill by now. Download, unpack and configure as follows:


./configure --target=powerpc-unknown-netbsd --prefix=/usr/local/psim --disable-shared --enable-languages="c" --disable-threads --disable-intl

Now make the compiler as follows. Note that I’m only interested in the C compiler. I haven’t even looked at C++/ObjectiveC…

You will need to add /usr/local/psim/bin into your path, as Gcc 3.3 will expext to be able to call powerpc-unknown-netbsd-ld/ar/ranlib etc while building itself.

export PATH=$PATH:/usr/local/psim/bin

Next I would comment out the following line from gcc/builtins.c

builtins.c:2864:// error (“__builtin_saveregs not supported by this target”);

Now we can build the compiler

make CFLAGS=’-O0 –pipe’

Now before we get all giddy, lets test this thing out!

cd into the gcc directory, and lets make a simple c program… hello world is a good starting place.

use xgcc to compile it, and this will test your c compiler.

#include <stdio.h>
void main(void)
{
printf("hello from PowerPC\n");
}

bash-2.05a$ xgcc hello.c -o hello

hello.c: In function main':hello.c:2: warning: return type ofmain’ is not `int’

bash-2.05a$ file hello

hello: ELF 32-bit MSB executable Version 1

bash-2.05a$ ./hello

bash: ./hello: cannot execute binary file

Ok the executable that we have just created is NOT for our native platform, but for the PowerPC.. So lets kick in the emulator! If you didn’t patch your emul_netbsd.c you’ll get this:


% /usr/local/psim/bin/powerpc-unknown-eabi-psim hello

do_call() os_emul call 279 out-of-range

 

However if you did, this is what you’ll get!
% /usr/local/psim/bin/powerpc-unknown-eabi-psim hello
hello from PowerPC

On my computer the installation of gcc gets retarded so I manually copy the files to the right places.


cp xgcc to /usr/local/psim/bin/powerpc-unknown-netbsd-gcc

mkdir -p /usr/local/psim/lib/gcc-lib/powerpc-unknown-netbsd/3.3/

cp cc1 /usr/local/psim/lib/gcc-lib/powerpc-unknown-netbsd/3.3/

cp crtsaveres.o /usr/local/psim/lib/gcc-lib/powerpc-unknown-netbsd/3.3/

Building cross compilers is always involved, but hopefully this will help someone.