A Django site.
June 4, 2008

Hans Fugal
no nic
The Fugue :
» JACK on the MacBook

I spent the better part of two days fine tuning my linux audio setup on my MacBook, so maybe I can save anothe MacBook user some time with this post.

The sound card in this thing is an Intel HDA Controller, driven by the kernel module snd-hda-intel. Intel HDA cards (usually onboard cards) are looked down upon and generally derided, and I can testify with good reason. Like all sorry excuses for an audio card, it has only one subdevice which means only one application can use the card at a time. (If you want to know if your audio card is cheap, this is a good indicator—just look in /proc/asound/card0/pcm0p/info for subdevices_count)

Luckily in these modern times, the default ALSA device does software mixing (dmix), so even on a cheap card you can usually hear more than one application just fine. No, no, you do not need PulseAudio for this. In fact, PulseAudio steals the audio card in its default configuration (at least on Ubuntu 8.04). So if PulseAudio is running, applications that aren't PulseAudio aware (or ESD aware) will simply not be able to make sound. There are other misbehaved kids on the block, but they're fairly rare. The difference is that a well-behaved application will grab the default ALSA device, instead of the first audio card in the system explicitly, hw:0. PulseAudio in fact advises the use of this trick, to set PulseAudio as the default ALSA device, which I suppose explains why PulseAudio grabs hw:0 by default. Unfortunately Ubuntu is only halfhearted here—it enables PulseAudio but does not set up the default ALSA device to point to it. So in Ubuntu you need to either set up the default ALSA device with an ~/.asoundrc that looks like this

pcm.!default {
    type pulse
}
ctl.!default {
    type pulse
}

or you need to configure PulseAudio to use the default device instead of hw:0. If you are going to be using JACK too (and you want to hear other applications outside the JACK pipeline when JACK is running), I recommend the latter, though if you're twisted enough you might try JACK as a PulseAudio client.

JACK also by default grabs hw:0, because JACK is all about low latency and high performance and going through dmix adds a layer of overhead. If you're using JACK, you may be enough of a snob that you're ok with leaving those non-JACK applications out in the cold while JACK is running. In fact you may not want to hear Pidgin sounds (for example) at all while you're doing audio work. Semisnobs like myself, though, might want a compromise. Setting up my studio just the way I want is enough of a pain, I really don't want to quit all my JACK applications just so I can listen to Last.fm or watch sb_email.

Now at this point I would be remiss if I didn't mention the very cool JACK plugin for ALSA. It allows you to make well-behaved ALSA applications (the ones that use the default device or allow you to configure which device is used) go through JACK. I modified my .asoundrc in a manner slightly different from the example given:

pcm.jack {
        type plug
        slave {
                pcm {
                        type jack
                        playback_ports {
                                0 alsa_pcm:playback_1
                                1 alsa_pcm:playback_2
                        }
                        capture_ports {
                                0 alsa_pcm:capture_1
                                1 alsa_pcm:capture_2
                        }
                }
                rate 48000
        }
}

Then if you want to make the JACK plugin the default, you add

pcm.!default {
    type plug
    slave.pcm "jack"
}

I tried configuring PulseAudio to use the JACK plugin, but it would crash on startup. Last.fm's client also had issues—it will play fine for one song and then crash jackd when the second song starts. So unfortunately it doesn't look like the JACK plugin for ALSA is quite ready for prime time, but you can certainly use it from time to time in applications that let you choose the ALSA device.

Unfortunately, the JACK plugin isn't found in Ubuntu's libasound2-plugins package where it belongs. It's an easy remedy, however, just install libjack-dev and fakeroot, then build the package from source (you don't even have to patch it):

apt-get install libjack-dev fakeroot
apt-get build-dep libasound2-plugins
fakeroot apt-get source -b libasound2-plugins
sudo dpkg -i libasound2-plugins*.deb

Getting Ubuntu to not annoy you constantly about "upgrading" that package is another story.

Ok, so now to the meat of this post. JACK does not work well on this sound card with its default settings. It either has an insane number of xruns, or it sounds terrible. For quite some time I chased the red herring of the position_fix parameter to the snd-hda-intel module, and I can report with confidence that on this hardware you don't want to change it from the default (0, which is auto). However, if you are only concerned with JACK, you will want to change it to position_fix=3, which gives rock-solid JACK with the default settings on hw:0. However, although JACK or other direct-to-hw:0 applications sound fine, dmix sounds crackly using position_fix=3. So it's probably not a good all-around solution if you're interested in more than just JACK.

The first order of business in good JACK performance (on any system) is to enable realtime. Edit /etc/security/limits.conf and add something like this:

@audio - memlock unlimited
@audio - nice -10
@audio - rtprio 99

Now (after logging out and back in) you should be able to pass the -R option to jackd and get realtime.

If you do jackd -R -d alsa (unless you use position_fix=3) you will get lots of xruns. The best I have been able to do is jackd -R -d alsa -p 512 -n 4, as it seems that the trick is getting at least 3 periods (and to do that with hw:0 you have to reduce the period size). This works well but qjackctl reports lots of xruns still. Actually, they're mysterious messages like this

delay of 5152.000 usecs exceeds estimated spare time of 4071.000; restart ...

which don't actually cause an audio blip (but you will get an occasional real xrun). I still need to try the realtime kernel (linux-image-rt package) to see if that might help here. In my early tests (mostly playing with position_fix) the realtime kernel was actually doing worse than the generic kernel, but that was before I learned the number of periods should be at least 3, so I need to test again.

If you run jackd -R -d alsa -d default you will theoretically be able to use JACK and other applications at the same time via dmix/dsnoop. JACK will complain

You appear to be using the ALSA software "plug" layer, probably a result of using the "default" ALSA device. This is less efficient than it could be. Consider using a hardware device instead rather than using the plug layer. Usually the name of the hardware device that corresponds to the first soun

[sic] but pay it no heed, we're doing this on purpose, and actually are able to get better performance than the hw:0 route (with position_fix=0). That command will not actually work, though. It will crash within a minute even without any clients. Again the fix seems to be the number of periods, but this time we can avoid the excess delay by leaving the period size at 1024 (at the cost of some latency, of course). So, jackd -R -d alsa -d default -n 4. This is rock solid. It went all night without a single xrun. (But it wasn't doing much, though Ardour, Aeolus, and Hexter were "running". I was able to play around with them for a half hour or so with no xruns before I went to bed.) However, sometime down the road it will miss a deadline and it will crash. This crashing seems to be specific to using dmix, usually you'll just get an xrun. The workaround is to use softmode with the -s switch. Now you can run JACK 24/7 with excellent performance and without locking other applications out of the soundcard.

So in summary, if you don't care about dmix but only JACK (or any other application using hw:0, which can be all of them if you change your .asoundrc, but only one at a time), set position_fix=3 for snd-hda-intel e.g. in a file in /etc/modprobe.d/ with a line like this: options snd-hda-intel position_fix=3, and do update-initramfs -uk all. If you want a more balanced setup, where you can have JACK running and other well-behaved ALSA applications can use the sound card, leave the module parameters alone and set up realtime and use the following command to start JACK (or equivalent settings in QJackCtl):

/usr/bin/jackd -R -dalsa -ddefault -r48000 -p1024 -n4 -s

If you want to use PulseAudio in this situation, configure it to use the default ALSA device instead of hw:0.

If you like PulseAudio and JACK both, the ideal situation would be PulseAudio using JACK as a backend, JACK using hw:0 with position_fix=3, and the PulseAudio plugin as the default ALSA device. Unfortunately this is just a theoretical ideal, and doesn't work (yet) because of bugs.

And finally, if you have no or limited use for JACK, but want to use PulseAudio, just change your .asoundrc as above to make PulseAudio the default ALSA device, so that all applications, ESD aware or not, use PulseAudio.

Oh, and I almost forgot to mention the mixer. There's Master, PCM, Front, Surround, Center, LFE, Side, and various toggles. AFAICT the Front controls the internal speakers, and Surround controls the headphone volume. JACK on hw:0 has 8 system ports. The first two correspond to the front speakers and the second two to the headphone jack. When you run JACK on default, it's simply stereo output, and goes to the speakers or the headphones if they're plugged in.

Finally, I regret to report that JACK on default will crash on resume (on hw:0 it won't, at least with position_fix=3).

June 2, 2008

Hans Fugal
no nic
The Fugue :
» Linux on the MacBook

So now that I'm done with comps, it's time to start doing real research. In my case, that means playing with audio and MIDI.

Specifically, I'm going to be generating preliminary data by recording chromatic scales and musical works on Aeolus, an absolutely fantastic pipe organ synthesizer. I did get it ported to OS X (feel free to contact me about that, or just wait until the next release, he is integrating my patches), and Ardour works in OS X as well. But realizing that I wanted to record the same things with many different registrations (stop choices), I needed a MIDI sequencer, like Rosegarden. Frankly, there just doesn't seem to be anything even close available on OS X that doesn't cost an arm and a leg (at least from a student's perspective). Combined with the fact that the OS X driver for my Radium 61 seems to be buggy, I decided I need to go Linux.

OS X is supposedly the darling of multimedia types, but in my experience there is nothing like the wealth of interesting software available, for free, on the Linux Audio scene. And when it comes to audio stability and low-latency performance, there is nothing like a well-tuned Linux box. In short, I can't imagine doing serious audio work in anything but Linux.

So there are many guides out there for installing Linux on a MacBook, and I won't try to duplicate that information here. What I would like to do is detail what I had to do, and which choices I made.

The first choice is that of partitioning. In the end I decided to share the internal hard drive, giving 10G to linux. It looked like the easiest way to do that was with Boot Camp, although it appears possible without it. But Boot Camp Assistant just would not resize my OS X volume. It would either complain about files that couldn't be moved, or running out of disk space. I thought it might be running programs, so I shut them down. I thought it might be swap space so I rebooted. I thought it might work if I did it from the installation DVD. I thought maybe it needed more free space to do the shuffle. None of these fixed it. So I googled around and found that it might be possible for a file to be locked in position. So I needed to figure out what files were entrenched at the end of my HDD and see if I couldn't do something about that. I came across a not-free defragmenter, iDefrag and fired up the demo. It processed the disk and eventually showed me a map of the sectors of the drive, and mousing over them I was able to see the files using those sectors. Near the end of the drive there were a lot of red sectors that all belonged to Google Desktop. I assumed red sectors probably meant stuff that couldn't be moved, but I couldn't be bothered to look it up. Google Desktop seemed like a logical lead, though. So I uninstalled it and gave the repartitioning a try, and it worked like a charm. Incidentally I like Google Desktop, as also Quicksilver and Spotlight (I use all three, depending on what I want to do), so I'll probably reinstall it. Oh, and I didn't defragment with iDefrag since the demo only defragments drives smaller than 100M. But just try finding that information on their website or in the README.

I then installed rEFIt, which although not necessary is a nice way to bootload a dual-boot system.

I rebooted and chose to boot from CD in rEFIt. Odd, I just get a blank screen and no activity. I know this Ubuntu CD works on this very laptop because I had already tried it. So I rebooted and held down alt, which gave me the Apple boot chooser, and I chose the CD, and it worked fine.

I installed Ubuntu in the usual way. I manually partitioned, formatting the partition Boot Camp made for Windows as ext3 and not bothering with swap (I made a swapfile after installation). I told it to install the bootloader (GRUB) on the partition instead of the disk (the partition is sda3).

When I rebooted, I did the gptsync thing using the rEFIt "Partitioning Tool", which synchronized the legacy MBR with the newfangled GPT. Then I tried to boot into Linux, and again rEFIt gave me a blank screen. I booted into OS X and googled it, finally stumbling across something that said that happened once or twice and then stopped happening. So I rebooted and sure enough, it worked the second time. That's odd, and not the end of booting troubles. Sometimes when booting Linux you get a kernel panic talking about APIC. I remembered this from early experiments last year, so I didn't panic. You just try try again until it works.

I will adorn this blog with a flurry of posts on the rest of my adventures soon, but for now suffice it to say I had Linux installed, and it has come a long way. Ubuntu 8.04 had wireless, multi-finger trackpad tapping (though I prefer two fingers to be the right button not the middle button), basic sound, video acceleration, and even suspend working out of the box. It's beginning to look like I could not only do my research in Linux, but maybe even make it the primary OS on my laptop the rest of the time too.

April 28, 2008
» Extended Display on the MacBook (with xorg.conf) : Ubuntu 8.04

I’ve blogged in the past about setting up extended display on the MacBook (second gen), but I thought I’d update the post for Ubuntu 8.04.  I notice there are some small differences, which are likely caused by the updates to Xorg.  I’ll post my steps and my xorg.conf file below.

Extended Display on the MacBook

First, I tried to use the new Screen Resolution tool but it did not detect either monitor properly.  It does detect the MacBook display when it is the only display, but when my external monitor is plugged in everything gets screwed up.

I had to do things by hand using xrandr, and I had to add three lines to my xorg.conf file.  There isn’t much to it, but not as straight-forward as it could be with the graphical tools.

  1. The first step is to figure out the sum of both resolutions.  ie; 1280×800 + 1440×900 = 2720 x 1700.  Take the resolutions from your MacBook (which should be 1280×800) and add it to the resolution of your external monitor.  Make note of the result.
  2. Update your xorg.conf file to include the new, combined, resolution (example below)
  3. Restart X (logout & login or ctrl-alt-bkspace)
  4. xrandr –output VGA –auto
  5. xrandr –output VGA –above LVDS

Here is a copy of my xorg.conf file.  It is default except for the three additional lines:


# xorg.conf (X.Org X Window System server configuration file)
#
# This file was generated by dexconf, the Debian X Configuration tool, using
# values from the debconf database.
#
# Edit this file with caution, and see the xorg.conf manual page.
# (Type "man xorg.conf" at the shell prompt.)
#
# This file is automatically updated on xserver-xorg package upgrades *only*
# if it has not been modified since the last upgrade of the xserver-xorg
# package.
#
# If you have edited this file but would like it to be automatically updated
# again, run the following command:
#   sudo dpkg-reconfigure -phigh xserver-xorg

Section “InputDevice”
Identifier    “Generic Keyboard”
Driver        “kbd”
Option        “XkbRules”    “xorg”
Option        “XkbModel”    “pc105″
Option        “XkbLayout”    “us”
Option        “XkbOptions”    “lv3:ralt_switch”
EndSection

Section “InputDevice”
Identifier    “Configured Mouse”
Driver        “mouse”
Option        “CorePointer”
EndSection

Section “InputDevice”
Identifier    “Synaptics Touchpad”
Driver        “synaptics”
Option        “SendCoreEvents”    “true”
Option        “Device”        “/dev/psaux”
Option        “Protocol”        “auto-dev”
Option        “HorizEdgeScroll”    “0″
EndSection

Section “Device”
Identifier    “Configured Video Device”
EndSection

Section “Monitor”
Identifier    “Configured Monitor”
EndSection

Section “Screen”
Identifier    “Default Screen”
Monitor        “Configured Monitor”
Device        “Configured Video Device”

# added SubSection “Display” until EndSubSection
SubSection “Display”
Virtual 2720 1700
EndSubSection

EndSection

Section “ServerLayout”
Identifier    “Default Layout”
Screen        “Default Screen”
InputDevice    “Synaptics Touchpad”
EndSection

Related

December 30, 2007
» Microphone Support on the MacBook (Skype 2 Supported)

So I posted recently on how to get the camera working in Skype 2 Beta on the MacBook. One of the most common questions after that post was “But how do I get the microphone to work!?” So, I started toggling switches and trying stuff out until I could reproduce working microphone input. I did have this working in the past and I guess I must have lost the settings so I had to find them again…

Microphone on the Macbook

To get started right-click on the volume applet up near the clock and select the “Open Volume Control” option. This should open the volume control mixer application. What you’ll want to do within this application is select “Edit > Preferences”, which will present you with a long checklist of potential hardware items. The only items I have checked here are:

  • PCM
  • Input Source
  • Mux

PCM should be your main volume for audio output for best control. You can set that from the “Preferences” menu of the volume applet.

Input Source allows you to select the source of the microphone. Mic, Front Mic or Line.

Mux is the device/option I’m using for the Microphone input.

I have the “Playback” tab, on PCM, set to full and use the hardware keys to control volume. “Recording” tab, on Mux, is set to 1/3 volume. I find that I get too much static and noise set too far above that. “Options” is then set to Mic as the input.

Calls in Skype now sound great incoming and outgoing and the video works really well. I hope these similar settings work for everyone else. If you need to use alternate settings please leave a comment.

UPDATE: these instructions have been added to the Ubuntu community wiki as well. Ubuntu on the Macbook.

December 22, 2007
» Video Chat Support with Skype 2 Beta on MacBook : Ubuntu 7.10 “Gutsy”

So I’m back with Ubuntu now after a week of testing the Fedora waters. Wow its nice to be back in the living of the “Just Works”! There were far too many things that didn’t work in Fedora.. too frustrating for me.

In any event, one of the first things that I tried setting up after getting back to Ubuntu is the Video Chat support for the new Linux client, which is now supported on the MacBook. When it was first released a month or so ago the MacBook hardware was not supported. Add a bug report and a little time, and we’re in business. It’s actually pretty easy to get going, so I’ll dive right in.

iSight Firmware

The one critical part that you need to get the camera supported in both Skype and Ekiga is the Apple USB Support Firmware, available as part of a default Apple OS X installation. You’ll either need access to your OS X partition, or get the file from the DVD somehow. (I don’t really want to get into how to try and pull it off the DVD, granted you need a copy of:

AppleUSBVideoSupport

Drop this file into the directory “/lib/firmware/$(uname -r)” and restart the machine. When it comes back up you’re camera should be supported.  For more details see the community maintained Ubuntu on the MacBook wiki.

Skype 2 Beta for Linux - With Video!

Now that you’ve got the hardware supported head over to the Skype website and grab yourself a copy of the beta client for Linux. I’ve got a handy link for you right here:

Download Skype for Linux

Select the copy for Ubuntu.  (I know its listed as Ubuntu 7.04, but it works just fine on Ubuntu 7.10 as well).  Double click the saved .deb package, or open with Gdebi Installer and get it installed.  Once you’re done you should instantly be able to enjoy video chat with all of your Skype using friends.  Enjoy!

December 30, 2007
» Microphone Support on the MacBook (Skype 2 Supported)

So I posted recently on how to get the camera working in Skype 2 Beta on the MacBook. One of the most common questions after that post was “But how do I get the microphone to work!?” So, I started toggling switches and trying stuff out until I could reproduce working microphone input. I did have this working in the past and I guess I must have lost the settings so I had to find them again…

Microphone on the Macbook

To get started right-click on the volume applet up near the clock and select the “Open Volume Control” option. This should open the volume control mixer application. What you’ll want to do within this application is select “Edit > Preferences”, which will present you with a long checklist of potential hardware items. The only items I have checked here are:

  • PCM
  • Input Source
  • Mux

PCM should be your main volume for audio output for best control. You can set that from the “Preferences” menu of the volume applet.

Input Source allows you to select the source of the microphone. Mic, Front Mic or Line.

Mux is the device/option I’m using for the Microphone input.

I have the “Playback” tab, on PCM, set to full and use the hardware keys to control volume. “Recording” tab, on Mux, is set to 1/3 volume. I find that I get too much static and noise set too far above that. “Options” is then set to Mic as the input.

Also make sure that the Mux setting is unmuted just below the volume setting.

Calls in Skype now sound great incoming and outgoing and the video works really well. I hope these similar settings work for everyone else. If you need to use alternate settings please leave a comment.

UPDATE: these instructions have been added to the Ubuntu community wiki as well. Ubuntu on the Macbook.

December 22, 2007
» Video Chat Support with Skype 2 Beta on MacBook : Ubuntu 7.10 “Gutsy”

So I’m back with Ubuntu now after a week of testing the Fedora waters. Wow its nice to be back in the living of the “Just Works”! There were far too many things that didn’t work in Fedora.. too frustrating for me.

In any event, one of the first things that I tried setting up after getting back to Ubuntu is the Video Chat support for the new Linux client, which is now supported on the MacBook. When it was first released a month or so ago the MacBook hardware was not supported. Add a bug report and a little time, and we’re in business. It’s actually pretty easy to get going, so I’ll dive right in.

iSight Firmware

The one critical part that you need to get the camera supported in both Skype and Ekiga is the Apple USB Support Firmware, available as part of a default Apple OS X installation. You’ll either need access to your OS X partition, or get the file from the DVD somehow. (I don’t really want to get into how to try and pull it off the DVD, granted you need a copy of:

AppleUSBVideoSupport

Drop this file into the directory “/lib/firmware/$(uname -r)” and restart the machine. When it comes back up you’re camera should be supported.  For more details see the community maintained Ubuntu on the MacBook wiki.

Skype 2 Beta for Linux - With Video!

Now that you’ve got the hardware supported head over to the Skype website and grab yourself a copy of the beta client for Linux. I’ve got a handy link for you right here:

Download Skype for Linux

Select the copy for Ubuntu.  (I know its listed as Ubuntu 7.04, but it works just fine on Ubuntu 7.10 as well).  Double click the saved .deb package, or open with Gdebi Installer and get it installed.  Once you’re done you should instantly be able to enjoy video chat with all of your Skype using friends.  Enjoy!

November 25, 2007
» Extended Video on the Macbook : Xrandr ftw!

Update: I wrote this quite a while ago and never posted it pending more testing.  I figure it can be helpful in its current state to more users than just myself.  So, in the spirit of release early, release often here are steps that I took for configuring extended display on my MacBook. 

Based on the flood of feedback yesterday with suggestions on getting the extended display setup I’m going to attempt to blog what I have figured out. I’m still not 100% on the steps yet but hopefully this’ll help people get started and perhaps work some of the kinks out of the setup. I would like to get a better proper tutorial, but for now I want to get this written down while its fresh in my memory.

  1. I had some odd issues if both displays were connected at login prior to configuration. Login to your desktop without the external monitor connected. Connect the monitor after you’ve completely logged in.
  2. Connect the external monitor and generate a new default xorg.conf (sudo dpkg-reconfigure -phigh xserver-xorg).
  3. Figure out the highest resolution you want between the two screens (1440×900+1280×800 = 2720×1700). Calculate based on what you have. In my case my external does 1440×900. I add that to the 1280×800 of the macbook and get my total.
  4. Edit your xorg.conf file and add the line to the Section “Screen” > SubSection “Display” area. Add Virtual 2720 1700 (your resolution).
  5. Log out after saving the xorg.conf file (unplug the external monitor until after you’ve logged back in successfully)
  6. xrandr –output VGA –auto
  7. xrandr –output VGA –above LVDS

In further testing I no longer have the issue in step 1, 5 above, but I leave it there as others may have similar problems.  In regards to my hardware I am using a MacBook with an onboard intel video card.  Card information via lspci output:

00:00.0 Host bridge: Intel Corporation Mobile 945GM/PM/GMS, 943/940GML and 945GT Express Memory Controller Hub (rev 03)
00:02.0 VGA compatible controller: Intel Corporation Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller (rev 03)
00:02.1 Display controller: Intel Corporation Mobile 945GM/GMS/GME, 943/940GML Express Integrated Graphics Controller (rev 03)

I now use extended desktop quite a bit and the only “issue” is that compiz-fusion is disabled if the resolution goes this high.  Not a big issue, but something to be aware of.  I hope this helps some more of you get extended display working.  It’s very nice :)

October 31, 2007
» Enabling the Motion Sensor on the Macbook for Physical Neverball!

How many of you have played Neverball raise your hands? If you actually raised your hand you get a cookie. If you haven’t played Neverball and you have a Macbook you’re going to start playing because this tutorial makes it *so* much more fun! We can make use of the motion sensors built into the Macbook hardware to allow us to play physical neverball.

Activating the driver

We’ll need to load the proper module into the kernel for this to work. We can do that using this command:

sudo modprobe applesmc

If you want this module to automagically load at boot time you can also use this command:

echo applesmc | sudo tee -a /etc/modules

Launching Neverball

You’ll now want to pick up a copy of the game Neverball which is available in the repositories.

sudo aptitude install neverball

Now launch the game (you’ll find it in your Games menu, or via the command neverball). Select “Play”, select your difficulty level and start the game. Now, here’s the best part, pick up your Macbook to play. Trust me, pick up the macbook and tilt the actual laptop to control tilting the floor within the game. Now that’s playing games with your laptop!

For the rest of you that want to play but don’t have the motion sensors you can just use your boring old mouse to play. Enjoy!

October 25, 2007
» Enabling Suspend on the Macbook : Ubuntu 7.10

In continued testing on my macbook it appears that I have suspend working solidly. If you enjoy this feature you may want to look into this tutorial. I have never really used suspend/hibernate much in the past because it has been buggy, but now that it appears to be working well I think I may give it a try.

note: To use suspend (in my experience) on the macbook you have to downgrade the 2.6.22-14 kernel (current in 7.10) to the 2.6.22-12 kernel. I don’t think there are many huge changes between the two, and I have not seen a loss of other functionality, but I figured I should get that out of the way right at the start. If you’re not comfortable reverting your kernel or know a specific reason you should not, you can stop reading here.

Suspend on the Macbook

Suspend is a nice feature that lets you virtually “pause” your machine to be brought back in its exact state at a later time. This is very nice for laptops and mobile machines that are always on the go and going up and down quite a bit. The current kernel in Ubuntu 7.10, the 2.6.22-14 kernel, has a few issues with suspend. It will allow machines to go into suspend, but not properly come back again. (bug #151016).

Installing the required kernel packages

As mentioned above the last known kernel version to properly support suspend on the macbook (and some other models - see the bug report for details) is the 2.6.22-12 kernel. The following steps will help you install the packages needed in order to run that kernel version and enable the suspend feature. Install the following packages in this order:

  1. sudo aptitude install linux-image-2.6.22-12-generic
  2. sudo aptitude install linux-headers-2.6.22-12
  3. sudo aptitude install linux-headers-2.6.22-12-generic
  4. sudo aptitude install linux-ubuntu-modules-2.6.22-12-generic
  5. sudo aptitude install linux-restricted-modules-2.6.22-12-generic

You’ll next need to update your grub settings to use this kernel instead of the current latest automagically at boot time. If you are running the stock Ubuntu 7.10 installation with the 2.6.22-14 kernel (at the time of this writing this is the only kernel released for 7.10) it is a very simple update. Edit the /boot/grub/menu.lst file and change the default line from 0 to 2.

If you have other kernel images installed take a look into the file, view the boot entries near the bottom and look for the one listed as 2.6.22-12. Count down from the first entry starting with 0 (ie; 0,1,2,3…) and replace your default line to that number. REMEMBER GRUB STARTS COUNTING AT ZERO, NOT ONE.

At this point you should be able to reboot and test suspend. In my use it has been solid since making the above changes. Also note that if you have compiled anything against your previous kernel you’ll need to do it again for this version. (ie; if you followed yesterdays post about compiling wireless support for the macbook you’ll need to repeat those steps.)

October 24, 2007
» How To Enable Wireless Networking on the Macbook : Ubuntu 7.10

With the new release of Ubuntu 7.10 I figured I should go back and revisit some of my macbook specific tutorials.  Today I’ll touch on configuring / enabling wireless on the macbook (second-gen) in Ubuntu 7.10.

Enable Wireless on the Macbook

  1. sudo aptitude install build-essential
  2. wget -c http://snapshots.madwifi.org/madwifi-trunk-current.tar.gz
  3. tar -zxf madwifi-trunk-current.tar.gz
  4. cd madwifi-ng-*
  5. make
  6. sudo make install
  7. sudo modprobe ath_pci
  8. sudo modprobe wlan_scan_sta

You should now be able to scan for wireless broadcasts and connect to available networks without restarting your machine.  Enjoy.