IBM®
Skip to main content
    Country/region [select]      Terms of use
 
 
    
     Home      Products      Services & solutions      Support & downloads      My account     
Multifunction multimedia machine, Part 1: Load Linux on the Mac mini
skip to main content

developerWorks  >  Power Architecture technology  >

Multifunction multimedia machine, Part 1: Load Linux on the Mac mini

Initial installation and setup

developerWorks
Document options

Document options requiring JavaScript are not displayed


Rate this page

Help us improve this content


Level: Introductory

Lewin Edwards (sysadm@zws.com), Author, Freelance

10 May 2005

The Mac mini is an ideal low-cost, high-performance PowerPC development platform for numerous applications. Learn how to install and configure Linux on the mini. Future articles will add the software required to make it into a stand-alone multimedia appliance.

This short series of articles shows you how to take a conveniently inexpensive, high-end PowerPC® platform (specifically, an Apple Mac mini) and build it into a home multimedia appliance using Linux™. At the end of the series, you'll have a stand-alone device that can play slide shows of images, audio, and movies, and that is controlled and administered from another machine using a standard Web browser.

The PowerPC platform is very well-suited to this type of multimedia application, and the G4 with AltiVec used in the Mac mini is an exceptionally powerful and flexible choice. This first article introduces you to the hardware's capabilities and walks you through installing and configuring Yellow Dog Linux so you can delve into some application code in the next article.

Licenses, patents, and law

Before getting into the actual project details, however, I need to say a few words about an important intellectual property issue. You need to be aware that data compression, encryption, and other technologies related to digital multimedia are a minefield of patents, unfriendly copyright laws, and intellectual property squabbles. This series of articles, and its accompanying source code, are educational and research materials, so I can ignore many of the legal issues. If you're following along and experimenting, for your own edification, with the materials I provide, you can largely skip over the legal worries, too. However, if you plan to distribute a product based on this or similar code, you have significant homework to do. The source code accompanying these articles is licensed to you under the GNU GPL; you can sell derivative works or give them away as you please (as long as you comply with the terms of the GPL), and I don't want a dime from you. However, I don't own, and hence can't license to you, any patented algorithms this code happens to implement. You need to do an audit of which patents might need to be licensed, and which authority governs their licensing.

This warning is mostly applicable to movie playback. For example, there are numerous open source MPEG-2 video playback programs. Standard DVD discs use MPEG-2 encoding. However, if you start selling a device that uses one of these open source player programs to play DVDs (even if you ignore the thorny issues surrounding DVD encryption and only support unprotected disks), you'll soon be receiving letters demanding license fees for each unit sold. An interesting data point I read recently is that the US$39.95 DVD players you commonly see at chain stores contain almost US$20 of patent license fees. (This is one reason why China is trying to promote the homegrown EVD standard in preference to DVD for domestic video content; EVD was specifically designed to avoid Western patent portfolios). Hidden legal bear traps like this are waiting almost everywhere for the unwary. For example, Fraunhofer IIS requires a (small) per-unit payment for every device sold containing an MP3 decoder. There is even a patent claim on an aspect of the common JPEG still-image compression algorithm; it's widely regarded as meritless, to date it has not been successfully litigated by the holder, and it does expire fairly soon, but it's still something you might need to think about.

One safe route, by the way: Build your application around a media player that has already negotiated licenses for the appropriate patents. As far as I know, the only company actively working on a patent-licensed media player for Linux at the moment is Linspire (see Resources). They have a licensed version of xine for sale; it's intended for use with their particular flavor of Linux, but when I've inquired about this in the past they have indicated a willingness to issue serial numbers for use with any Linux variant, for a fairly reasonable per-unit fee. The only problem in this series is that their product is x86-only, though they might be persuaded to build it for PowerPC if asked nicely.



Back to top


Why the Mac mini?

If you're still reading after all that legal waffle, take a look at the important attributes of the Mac mini. This system makes a good choice for this project for the following reasons:

  1. Price. At US$499, the entry-level Mac mini is unquestionably the best-value, high-end PowerPC evaluation platform money can buy. It is about one quarter the cost of an equivalent evaluation board from industrial single-board computer (SBC) vendors, AND the price of the Mac mini includes a hard disk, RAM, optical drive, and housing and power supply, all of which would be add-on costs for the industrial SBC.
  2. Physical size. Even without tearing the electronics out of the housing, the Mac mini is small and light.
  3. Orientation-neutral design. The optical drive is slot-loading and is equally usable at any angle to the horizontal. This means that you can simply glue it to the back of a monitor and presto! -- instant multimedia appliance!

The following is a brief overview of the Mac mini hardware capabilities:

  • PowerPC G4 microprocessor. The motherboard is jumper-configurable from 1.25 to 1.58GHz (the jumpers are soldered), with the standard speeds from Apple being 1.25 or 1.42GHz. Find a link in Resources to a site with all the overclocking details you might want, if that sort of thing appeals to you. Overclocking is totally unnecessary for this application and I don't recommend it. The Mac mini is already frisky enough for everything you need to do.
  • Built-in wired Ethernet
  • One Firewire port
  • Two USB 2.0 ports
  • Internal (mono) speaker and stereo audio output. At the time of writing this article, the specific audio chip used in the Mac mini is not supported by the Linux kernel, but this appears to be a very minor chip ID (revision level) issue. There is no audio input connector.
  • DVI video output. This also provides analog VGA signals through an adapter shipped with the computer. (It can even composite video and S-video signals through an optional adapter.)
  • One internal IDE bus connected to a 2.5" IDE hard disk (either 40Gb or 80Gb according to model).
  • A slot-loading laptop-style optical drive; either a combo DVD/CD-RW drive or a "Superdrive" (DVD+/-R, CD-RW).
  • A proprietary internal mezzanine card holding an optional 802.11g wireless LAN adapter (unfortunately not supportable by Linux due to lack of disclosure by Broadcom, the chipset manufacturer) and/or a Bluetooth module.
  • An internal 56Kbps modem. I don't have an analog phone line (we're a cell phone and broadband family) so I don't know anything about this peripheral.

Why Linux?

This series uses the Linux operating system for a couple of reasons. The foremost reason is that it is a design goal for this project to be entirely open source. This goal cannot be fulfilled on top of Mac OS. The other primary reasons for selecting Linux are that it is modularly configurable to a relatively fine granularity, and it offers excellent API-level compatibility amongst different platforms that are popular for high-end (32-bit and larger) embedded cores: PPC, ARM, x86, and MIPS.

I experimented with a few distributions of Linux for PowerPC platforms. Debian (available in Resources) weighs in at a svelte nine gigabyte download, or fourteen CD images, although you don't actually need all of those disks. I eventually chose Yellow Dog Linux 4.0.1 because the standard disk set is a smaller download (four CD images), and, more importantly, this distribution resembles Fedora very closely. I happen to have spent most of my Linux life working with Red Hat-based products, so this was a comfort choice for me. I had no compelling technical reason to choose Yellow Dog, and if you're more comfortable with another distribution, feel free to use it as you follow along with this series. The application you'll build in this series will run happily on practically any distribution.



Back to top


Installing Yellow Dog Linux

To install Yellow Dog, first download and burn the four ISO CD images. Power up the Mac mini, insert CD #1 in the drive (quickly) and hold C to force CD startup. You'll be taken to the yaboot startup screen, at which you should simply type install to run the default graphical installer. You can use this disk for emergency startup as well as installation, and it has some alternative images on it also, such as a G5-optimized version. You can get a list of available images by pressing Tab at the boot: prompt, but for now let's move on with the installation.

When you press Return after typing install, there will be a brief pause while the kernel and initial RAM disk are loaded off the CD. You then see the familiar Linux kernel startup messages (observe that it's running in framebuffer mode, by the way), and finally you reach the X-based graphical installer. If you've ever installed Red Hat or Fedora Core, the graphical installer will be completely familiar to you; if not, it'll be unfamiliar but still very easy. I'll briefly walk you through the screens so that you wind up with a configuration that contains everything you need and not too much additional fluff:

  • Welcome to Yellow Dog Linux -- Click Next.
  • Language -- Choose English and click Next.
  • Keyboard Configuration -- Choose US English and click Next.
  • Installation Type -- Select Custom and click Next.
  • Disk Partitioning Setup -- Select Manually partition with Disk Druid and click Next.
  • Disk Setup -- You'll be installing the simple case: a Linux-only system (as opposed to a dual-boot Mac OS + Linux environment). In Disk Druid, first delete any partitions you see. Next, create a 1Mb partition of type Apple Bootstrap. Next, create a swap partition at least as large as the amount of physical RAM in your Mac mini. Finally, create a root partition of type ext3, and select Fill to maximum allowable size so it covers the remainder of the disk. This is not necessarily the best file system arrangement, particularly for an embedded appliance, but I'm configuring things this way for simplicity's sake. By the way, you'll notice that this version of Disk Druid, unlike the version used on x86 distributions, does not sort partitions; it puts them on the disk in the order you request them.
  • Firewall Configuration -- For this simple application, choose No firewall, and set Enable SELinux to Disabled.
  • Additional Language Support -- Leave this at its default settings; just click Next.
  • Time Zone Selection -- Choose your physical location as appropriate.
  • Set Root Password -- select a password that's easy for you to remember.

The last thing you have to set up is the Package Group Selection dialog. First, go down the list of package groups unchecking everything. Then, check the following package groups ONLY, go into the details for these groups, and verify that only the items listed below are checked:

  • In the X Window System group, check Xautoconfig, xorg-x11-twm and xterm.
  • In the Editors group, check whichever editor(s) you prefer to use; I use emacs; you might like something else.
  • In the Text-based Internet group, select elinks -- it's very useful to have a simple Web browser available in case you need it.
  • In Development Tools, the default package options are pretty good. I personally prefer to deselect gcc-g77, gcc-gnat, and gcc-java, since I know I never use these languages, but feel free to leave them checked if you want to keep your options open.
  • In Kernel Development, for some reason, GTK+ and Qt library materials are listed. Deselect all the optional packages in this group; you only need the kernel source.
  • In X Software Development, keep the default package set.

All the hard work is now done. After you confirm your desire to install the operating system, the installer informs you which CDs you're going to need -- if you followed my installation choices exactly, you'll need CDs 1, 2, and 3. You then merely need to change disks as prompted.

When the installation is complete, the last disk will eject and you'll be prompted to reboot. The startup process, if left unmolested, will run through all the familiar Red Hat-style screens and scripts, and you'll wind up at a text-mode login prompt. If Kudzu (RedHat's hardware probing code; see Resources) runs the first time you start the machine up, let it install or remove hardware configurations however it wants. Log in as root, with the password you specified earlier in the installation process.



Back to top


Configuring the system

You now need to do a little tweaking and polishing to get the system into a useful state. The first thing you need to know is that you won't have audio facilities -- at least not right away. The reason for this is that currently the audio chip in the Mac mini is not supported by the Linux kernel. However, it will almost certainly be supported soon (in fact, a patch might well be available by the time you read this). Alternatively, you could pick up a supported USB audio interface, such as the Griffin Technologies iMic (see Resources).

Enabling sound

To test the audio features I'll mention in a later article, and to verify that my code really works, I secretly built myself a second development system (a first-generation Bondi blue iMac, if you're interested) with the exact same software configuration that I discuss here. Audio wasn't detected or enabled by default after installing on the iMac, so I had to set it up manually. At the end of /etc/rc.d/rc.sysinit (immediately before the comment that reads "# Let rhgb know that we're leaving rc.sysinit"), I added the lines:


Listing 1. Configuring sound

modprobe snd-powermac
modprobe snd-pcm-oss
aumix-minimal -v85 -l85 -c85 -w85 -W85

I also added the line alias sound-slot-0 snd-powermac to /etc/modprobe.conf, although this isn't strictly necessary.

You can set your own audio volume levels, of course; those defaults just happen to work for my environment. You can use the playwave command with any convenient .wav file, or the cdp program with an audio CD, to test your current volume settings; use the aumix user interface to adjust the various mixer settings. After you set the audio to a comfortable level, run aumix again and press s (note the lowercase). This will save the current mixer settings to a file called ~/.aumixrc -- simply examine this file to determine the exact numbers to put in the script. Note that you cannot use the aumix -L (load settings) option from within startup scripts; it almost always segfaults. That's why you use aumix-minimal with command-line options.

You should make all the audio-related configuration changes described above to your Mac mini, in preparation for the availability of compatible drivers. Think of it as a vaccination against having to come back and reread this article later!

Enabling the network

The next thing to do is get the network connectivity operational. Although Linux supports the Ethernet MAC in the Mac mini, unfortunately it doesn't appear to be auto-detected. Make sure that the line alias eth0 sungem appears in /etc/modprobe.conf. You then need to create a configuration file for the Ethernet adapter. This file must be saved as /etc/sysconfig/network-scripts/ifcfg-eth0, and it should contain the following lines:


Listing 2. Configuring the network

DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
TYPE=Ethernet

Note that some people report that Kudzu automatically set all of this up for them on first boot. This didn't happen for me; it could have something to do with the rather austere set of install options I selected, or it could simply be the unreality field that surrounds me.

An FYI note: If you're really getting into the swing of this article, and you're setting up an ancient iMac like mine as your secondary system, note that the Ethernet driver is called bmac on this old machine -- so change the modprobe.conf line to alias eth0 bmac. The other setup details are all the same.

At this point you should be able to bring up the Ethernet interface with ifup eth0. Assuming you're connected to a network and a functional DHCP server is within reach, you should be able to run some basic network tests like pinging your default router. Use ifconfig to find out your machine's IP address, and write it down -- you'll need it to do some testing in a moment.

Installing a Web server

Next, install the thttpd Web server, which will provide a user interface to control your appliance-to-be. You can download the source code for thttpd from the link in Resources. Extract the tarball, cd to the directory thus created, and run ./configure to create the makefile. Now execute make all ; make install to build and install the daemon. During the install process, you'll see an error message about a nonexistent www group. You can safely ignore this error, since it relates to a feature of thttpd that you won't use.

Now that you've built and installed the server, create a minimal configuration file, using the following lines:


Listing 3. Configuring thtppd

dir=/web
cgipat=/cgi-bin/*
logfile=/dev/null
pidfile=/var/run/thttpd.pid

Save the above lines as /etc/thttpd.conf, and edit /etc/rc.d/rc.local to add the line /usr/local/sbin/thttpd -C /etc/thttpd.conf. It doesn't matter where you put this line. By the way, while you're debugging your system, it might be useful to direct the log output to a real file rather than /dev/null. For a production system, however, you should disable logging unless you have some methodology in process to rotate or truncate the log file. Otherwise, you're setting the stage for an out-of-disk-space condition at some unpredictable time in the future.

Security unconscious

Those of you who are downright razor-sharp, or who simply like to notice these sorts of things, will observe that most consumer electronics manufacturers practically ignore the concept of security for network- accessible appliances. (The only regular exception to that rule is the exceedingly limited case of digital rights management (DRM) - and that's not security for you, that's (illusory) security for the manufacturer, who can often also be a provider of paid-for media).

You'll notice that I've specifically excluded the topic of security from this article. This is not intended to encourage the above-mentioned cavalier dismissal of security as a design goal.

The main reason I've left it out is that this article is about the fun and games of multimedia playback. The network infrastructure built here is strictly for demonstration purposes, and is not intended to be production grade. In other words, I didn't want to spend all my word budget on scaffolding - I wanted to focus on the application of interest.

A compelling secondary reason to leave it out is, as mentioned in the body text of this article, that network security, and particularly Web server security, is a specialized field. In other words, I didn't want to give a five-minute dime tour of a field that takes years of experience to understand adequately.

However, I'm happy to accommodate my loyal readers - if you're interested in seeing one or two additional articles at the end of this series, which talk about some aspects of how to design the network interface to be more secure, just put a comment in the discussion forum or drop me an email.

Before continuing, make certain that the /web directory exists on your system, and create it if it doesn't. Also ensure that it is world writable with chmod 777 /web. When you have done this, run thttpd -C /etc/thttpd.conf to start the thttpd daemon manually. On another machine on the same network, open a Web browser and navigate to http://a.b.c.d/, where a.b.c.d is the IP address of your Macintosh. If everything is working properly, and assuming you didn't put anything in the /web directory, you'll see a directory listing, on a lime-green background, headed "Index of /".

Installing an FTP server

Next, you need an easy way for people to get pictures and other multimedia files onto the unit's hard disk. I use ProFTPD for this, because it's one of the best-known open source FTP servers around. It's flexible, reasonably secure, and available at an unbeatable price. The current version at the time of writing is 1.2.10, and you can find it from the link in Resources. Again, to build and install it, simply extract the tarball, change to the directory thus created, run ./configure then make all ; make install.

Configuring ProFTPD is substantially more complicated than configuring thttpd, because the FTP server tries to interact with the operating system a lot for authentication purposes. The default configuration file, which gets installed to /usr/local/etc/proftpd.conf, contains a bunch of assumptions that aren't valid for what you want to do. Here's an abbreviated configuration file that should meet your needs:


Listing 4. Configuring ProFTPD

ServerName "developerWorks Multimedia Appliance"
ServerType standalone
DefaultServer on
Port 21
Umask 022
MaxInstances 30
User root
Group root
AllowOverwrite on
<Anonymous /web>
User ftp
Group ftp
UserAlias anonymous ftp
MaxClients 10
</Anonymous>

You also need to edit /etc/rc.d/rc.local again and add the line /usr/local/sbin/in.proftpd; again, it doesn't matter where you put this line. At this point you should be able to run /usr/local/sbin/in.proftpd to start the server manually, and then test connecting from another machine (log in as "anonymous" with any password).

The above discussion assumes that your network is inherently secure against people that are going to want to do Bad Things to your photos. If you want to develop a more secure system, please refer to the ProFTPD documentation (see Resources). The complication here is that you want to provide remote access to the same directory that thttpd uses for the Web serving root; you need to be extremely careful that you don't inadvertently make it impossible for thttpd (and the CGI programs it's going to call) to read files that were uploaded over the Web interface.

One more useful network daemon runs by default in the Yellow Dog setup you installed, and that's sshd. Leave this process running, because it's handy to be able to connect to the box over the command line. (You might also want to do your development remotely). Because you haven't set up any secondary users on the Mac mini, to connect through ssh on your remote computer, use the command ssh -l root a.b.c.d, where a.b.c.d is the IP address of the Mac mini. The first time you do this, you will need to confirm the identity of the remote system. Remember to type yes and not just y.



Back to top


Summary

This article showed you how to install Linux, configure the networking and audio subsystems, and install and configure a simple Web server. You also set up an FTP server that will let you get multimedia content onto the hard disk remotely. At this point you can start doing your development pretty much entirely from a remote PC, too.



Resources



About the author

Lewin A.R.W. Edwards works for a Fortune 50 company as a wireless security/fire safety device design engineer. Prior to that, he spent five years developing x86, ARM and PA-RISC-based networked multimedia appliances at Digi-Frame Inc. He has extensive experience in encryption and security software and is the author of two books on embedded systems development. He can be reached at sysadm@zws.com.




Rate this page


Please take a moment to complete this form to help us better serve you.



YesNoDon't know
 


 


12345
Not
useful
Extremely
useful
 


Back to top



    About IBMPrivacyContact