Wednesday, December 31, 2008

Curing Ubuntu's Black Screen of Death on a Mac Pro

My wife recently gave me her very recent Mac Pro, and I wanted to set it up for triple-boot Leopard, Snow Leopard, and Ubuntu 8.10 (Intrepid Ibex). The Mac OS X installs were, of course, trivial - but much to my surprise, Ubuntu wasn't.

I'd recently used the general approach from the Ubuntu wiki to set up an old Intel iMac with dual-boot Leopard/Intrepid, and everything went like clockwork:
  1. Boot from the Leopard install DVD
  2. Early in the OS X install process, use Disk Utility to create a small HFS Plus partition and a big partition I would later snuff for use by Ubuntu, then install Leopard.
  3. Install rEFIt.
  4. Use a GParted LiveCD to turn the partition from step 2 into free space.
  5. Install Ubuntu Intrepid from a LiveCD.
Then I went to do the same thing for the Mac Pro, but when the LiveCD went into graphics mode, the screen went black.

That was odd, since lots of people have reported successfully installing various Ubuntu versions on Mac Pros.

Now, black screens for Ubuntu are not unusual; they generally indicate some kind of driver or X configuration mismatch. I routinely run into them when doing kernel updates on one of my boxen, and the usual search engines offer lots of hits for solutions. But none of the usual techniques worked on this particular Mac Pro.

To cut to the chase, here's the solution. Starting after Step 3 above...
  1. From the Mac System Profiler, determine the manufacturer and details of your video card. (Mine was an ATI Radeon HD 2600 with 256 MB RAM.)
  2. Start the installation from the Ubuntu Alternate CD, which uses an old DOS-style text mode for its user interface. (If you use the LiveCD or LiveDVD, it will try to go into graphics mode and you're toast.)
  3. Zap that big partition you made as part of the installation process. You may also have to manually specify the size of your swap space. You can look up details on how to do this using the usual search engines.
  4. When you reboot at the end of your Ubuntu install, you'll get the black screen. Press command-control-F1 to switch to a command prompt. (The meta-keys may be different if you picked a non-Macintosh keyboard during install.)
  5. Use sudo apt-get to update everything, and reboot.
  6. When the screen goes black, use the key combo again to get a command prompt. Use sudo apt-get to install envyng-gtk. Then do sudo envyng -t.
  7. Pick the manufacturer of your video card from the envyng list, then reboot.
At that point, I was successfully booting into the Ubuntu GUI.

Wednesday, December 3, 2008

Triple-Boot Sony Vaio VGN-AR Notebook - Part II: How I Did It

I finally got my Sony Vaio VGN-AR290G laptop to triple-boot XP, Vista, and Ubuntu. Here's the general gist of how I did it.


This is not a detailed how-to - it's pretty general, and only includes the major steps but not the details. So if you decide to do this, you should read it fully first, and then look up any specific steps you're not sure about. You also need to be sure to read this article first.

  1. Make sure the hard drivers are not coupled as RAID. The instructions for this are in my previous post.
  2. Put a recent GParted boot CD in the CD-ROM drive and reboot. (I used version 0.3.9-4.) Use GParted to delete all partitions from both drives. Don't create any new ones. Exit GParted.
  3. On an existing XP installation, go to the AR290G support page and download the one file under the RAID heading - the file description is "Original - Intel® RAID Driver". You don't need anything else from there right now.
  4. Make an empty directory somewhere on the XP installation machine. Run the program you downloaded in step 4. It will want to install files onto a floppy, but change it to install the files into the directory you made. Those files are the driver files you'll slipstream.
  5. On the same existing XP installation, go to the nLite home page and download the nLite slipstreaming utility.Get an original Windows XP SP2 installation disk (I made mine from the MSDN Professional DVD). Use nLite per the instructions from the site I told you to read above to create a slipstreamed XP installer ISO image.
  6. Burn the ISO image onto a blank CD-ROM. This is your slipstreamed XP installer CD. I used a MacBook to do this; the Mac OS Disk Utility works great for this and comes for free with Mac OS. There are other utilities to do this on Windows (e.g. Nero) and Linux (e.g. Brasero) that will work fine as long as you have a compatible CD burner.
  7. Put the slipstreamed XP installer CD into the Vaio and reboot. It will eventually tell you there are no installable disk partitions, and give you the choice of formatting one. Format a partition on the first drive that only uses part of the drive, and install there. (My two drives are each about 93 GB, so I made this partition 40 GB). Finish the XP install, and reboot. Verify you can boot from your XP installation.
  8. Put a Vista installer CD or DVD into the Vaio and reboot it. (I used a Vista Ultimate DVD that came with an MSDN Professional subscription.) Tell it to install into the unformatted space on the first drive. (This is the leftover space on the first drive from the last step.) Finish the installation, and verify the Vista bootloader appears and lets you boot either from Vista or an "earlier" version of Windows (your XP installation). Verify you can boot into each Windows version.
  9. Put a Ubuntu 8.10 Alternate Install CD into the Vaio and reboot it. Tell it to install into the largest unformatted space, which will be the entire second drive. Finish the installation. In one of the last screens, confirm that grub should let you boot into either Ubuntu or the Vista bootloader.
  10. After removing the Ubuntu CD, verify you can boot into Ubuntu, Windows XP via the Vista bootloader, and Windows Vista via the Vista bootloader.
  11. Now you're triple-booting, but there's one more important step. On a computer other than the Vaio (the XP system from step 3 will work fine), go back to the AR290G support page and download installers for video and networking drivers, and any other drivers or programs you think you'll need. Copy them onto a USB flash drive, then boot into XP on your Vaio, attach the USB flash drive, and install the drivers and programs you downloaded.

You're done!



Questions and Answers


Q: Why did you decouple the RAID?

A: I had tried this with RAID enabled, and was able to get either XP or Ubuntu working, but not both at the same time. Also, my main interest in this machine is doing compiles. I ran some benchmarks, and saw absolutely zero benefit to using RAID.


Q: What? Using RAID provided no benefit?

A: Yes. I set the system up as RAID 0, installed Ubuntu, and compiled gcc 4.3.2. Then I decoupled the drives, re-installed Ubuntu, and compiled gcc 4.3.2. And I got the following results:

  • Extract (tar xf) the gcc tarball: RAID0 2.5s, No RAID 10s
  • ./configure: RAID0 5s, No RAID 6s
  • make (sequential compile): RAID0 1h 26m, No RAID 1h 26m
  • make -j 8 (parallel compile): RAID0 13m 22s, No RAID 12m 50s


Q: That's weird. Why do you think RAID doesn't accelerate compiles?

A: Because gcc is not disk-bound, it's CPU-bound. On top of that, I believe the RAID in the Vaio is "fake RAID", which uses the CPU to implement some of the RAID capabilities. So when you do parallel compiles and really beat up the CPU, the extra CPU overhead to implement the RAID actually slows down the compile. (It's possible other compilers, such as Visual Studio, might benefit from a RAID 0 configuration, but that's just a guess.)


Q: Why did you use GParted and Ubuntu Alternate Install?

A: I had them handy. I suspect that I could have used the Ubuntu LiveCD. Then in step 3 I would have booted from the LiveCD and used the Partition Editor, and in step 12 I would have installed from the LiveCD. But I don't know for sure this will work.


Q: Why did you install all those drivers into XP at step 13? Why not slipstream them in step 8?

A: I couldn't figure out an easy way to slipstream them, and this way works fine.


Tuesday, November 18, 2008

Triple-Boot Sony Vaio VGN-AR Notebook - Part I: RAID Uncoupling

I needed a portable development machine that would let me triple-boot XP, Vista, and Ubuntu.

So far, not a problem - but here's the kicker: it also needs a PCMCIA Type II (CardBus) slot. I occasionally code for a dated interface which, for laptops, is only available in PCMCIA. Unfortunately, PCMCIA has almost entirely been replaced by ExpressCard. As far as I can tell, in late 2008 you can get it on a few expensive Dells, a few of Acer's low-end Extensas - and Sony's Vaio VGN-AR series.

These Vaios had a lot of other things I liked, including a nice big 17" screen, and dual SATA drives. Woohoo - different drives for different OS's!

So I got a lightly used VGN-AR290G from eBay, and then found something out...

Those dual hard drives? They're hooked up to an Intel hardware RAID controller, and by default are configured as RAID 1. The upshot?
  • You can install Vista.
  • You can also install the custom, pre-slipstreamed version of XP Media Center Edition that comes with it - but that's not what I need for development
  • You can't install plain old XP Pro, because it doesn't see any disk drives.
  • Ubuntu sees both disk drives, and appears to install, but doesn't boot. That's because Ubuntu attempts to install as non-RAID, and then when you boot, the GRUB bootloader is all confused.
There are instructions online for getting Ubuntu installed onto RAID, and somebody claims to have gotten it to work with the 290G with dual boot, but I didn't have much luck. It would rock to have the speed of RAID0 on this thing, but I decided it would be simpler to uncouple the RAID.

And that, as usual, is easier said than done. But to save you the time I spent figuring it out, here's the recipe:
  1. Reboot the laptop.
  2. When the Sony logo comes on the screen, hold down the F2 key. You can let up when the laptop starts beeping at you. After a few seconds, this will bring you into the BIOS utility.
  3. Go to BIOS utility's Advanced tab and switch RAID Configuration to Show (if it's not set to that already). Then save the BIOS configuration and exit. The laptop should now reboot.
  4. You should now see more boot messages, and eventually get to a screen that shows you the disk configuration. During the few seconds this is up, hold down the Ctrl and I keys at the same time. This should switch the computer into the RAID editor utility.
  5. In the RAID utility, from main menu, choose the option to Reset Disks to Non-RAID. Save the configuration and exit.
The most common sequence for setting up an XP/Vista/Linux triple-boot is to partition the drive(s) with gparted, then install XP, Vista, and Linux in that order. But alas, after all this, XP Pro still didn't recognize the hard drives. So I just installed Ubuntu 8.10, since that was my most pressing need, and it now works fine.

My guess is that I'll have to slipstream the RAID driver onto the XP Pro install CD, but that's a job (and a post) for another day.

Monday, October 27, 2008

Coding Eye-Candy for Portable Linux Devices

At ACCESS, I've had the opportunity to do interesting things with Linux on cell phones. Some modern ARM chips, such as the Marvell XScale and TI OMAP series, have unusual frame buffer architectures that let you do "eye candy" on the cheap, without requiring a GPU.

In July 2008, I presented a paper about this work at the Ottawa Linux Symposium. I was also supposed to give it at GUADEC in Istanbul, but wasn't able to attend, so David "Lefty" Schlesinger gave it for me there.

If you are interested, here are links to:
  • The paper itself, which is somewhat academic in tone
  • The PowerPoint presentation based on the paper, which is more informal
  • A movie showing this in action on an XScale-based Zylonite prototype system, with narration by yours truly
As of the date of this post, I'm in the middle of porting this system to an OMAP 3430-based system.

Monday, October 20, 2008

Open Source Builds For Newbies

Introduction

If you build open source software, you'll run into a lot of variants of the following list of commands:
cd (some directory)
./configure
make
sudo make install


Some common variants replace the ./configure with ./autogen.sh, or add some extra stuff on the end of that line or the make line. This article explains what's going on with this kind of command sequence.

Makefiles

If you look at most programs and other software components whose purpose is not trivial, they're made from more than one source file. There are several ways to tell a computer how to put all those source files together to create a component, and the most common is called a makefile. (There are also various kinds of project files that are used with development systems like Microsoft's Visual Studio, or Metrowerks' CodeWarrior.)

The Bad Old Days

The problem with makefiles is that they can need different contents to account for different computers and operating systems and compiler systems. For example, you might need one makefile for Linux on an x86 computer with version 3.4 of the gcc compiler, another for the same system using gcc 4.2, yet another for a Sun workstation running Solaris, and yet another for Mac OS X.

Up through the mid 1990s, the normal way to cope with this was to supply a different makefile for each combination of hardware, operating system, and compiler. That often meant a dozen or more makefiles. And if you had an unsupported combination, you had to write your own makefile.

Also, many software components rely on other software components, mostly known as libraries. But people work on libraries, so they change over time, and it's possible to get mismatches. For instance, if you write a program that works with PNG images, you'll probably want to use the "libpng" library. But there are different versions of libpng, and in the old days, if you wrote your program to work with one version, and somebody got your source code and tried to build it with a different version of libpng, the build might have failed, or the program might not have worked right. And makefiles have no reasonable way to check to see if you have the right version of a library.

The Good New Days

Several tools solve this whole problem - these are called the GNU Autotools, and pkg-config.
  • The GNU Autotools create the configure file, which is a set of commands that builds a makefile for your particular computer, operating system, and compiler collection.
  • Then the configure file typically uses pkg-config to make sure you have the right versions of any libraries you need, and complains if you don't.
What Each Step Does
  1. cd (some directory) makes that directory the current one.
  2. ./configure runs the configure script in that directory. That checks your operating system, compiler, CPU, and what libraries you have installed. If everything is okay, it creates a makefile in that same directory.
  3. make gets information from the makefile to build your software component
  4. sudo make install takes the component you built at the make step, and installs it where it needs to go on your computer to be useful.
For more information
Here are links about: