Tuesday, November 24, 2009

Dell mini 10 with ubuntu jaunty xorg crash: stolenbase

Good grief. Did a dist-upgrade on the Dell mini 10, and now xorg is broken again. Something about a stolenbase in Xorg.0.log.

Thanks to this blog for the fix:

sudo apt-get remove --purge psb-kernel-source
sudo apt-get install psb-kernel-source

Since when did I become a full time distro installer?

Monday, November 23, 2009

Ubuntu Karmic: install -pae kernel breaks nvidia driver

Since I have > 3GB of RAM, I installed linux-image-generic-pae so that I could access up to 16GB on my Karmic Koala install. Note that installing a new kernel doesn't choose it as the default in grub (which is actually now grub2). So in /etc/default/grub I set GRUB_DEFAULT=saved so that it'd remember my choice, and then rebooted and hit SHIFT during the (very brief) grub blip to pull up the menu and choose the new kernel, which it then remembers.

Unfortunately, that broke my nvidia driver: when I rebooted into the kernel, the text login screen just flickered as xorg restarted constantly. This is due to 2 bugs:



Summary: I had to

apt-get remove --purge linux-headers-2.6.31-15

And then, when I did an

apt-get install linux-headers-2.6.31-15-pae

it automatically rebuilt (successfully) the nvidia.ko.

Saturday, November 21, 2009

Asus EEE pc 900 frequency scaling

I just got Ubuntu Jaunty running on this cursed EEE 900, and noticed it was running hot. But I just turned on CPU frequency scaling, so now the machine can automatically slow itself down from 900mhz to as low as 112mhz.

Right click on the menu bar and click "Add to panel", then select "CPU Frequency Scaling Monitor". When I first did this, it complained "CPU Frequency scaling unsupported". Turns out the celeron needs a particular kernel module installed for that to work. Here's my source for this fix, translated from Italian.

sudo apt-get install cpufrequtils sysfsutils
sudo modprobe p4_clockmod

Then add p4_clockmod to your /etc/modules with your favorite text editor or by:

sudo bash
echo p4_clockmod >>/etc/modules

Asus EEE pc 900 linux howto

(Update: linked to my post on frequency scaling down at the bottom).

Wow, I can't believe how many hours I've spent trying to make Linux work on this EEE 900. Our 900A seems to be okay, but ubunty karmic is completely broken with the 900, and hardy is seriously deficient. I tried eeebuntu, moblin, and I don't even remember what other distros. All failed miserably. Here's how I got Jaunty to work reliably with the VESA video driver.

The main problem is the xserver-xorg-video-intel driver, which locks up quickly after (or during) boot. For some reason, the i915 just seems to cause everybody huge headaches. And unfortunately, switching to the (slower) vesa xorg driver in many distros (such as Karmic Koala) causes it to lose video sync and be even more unfixable, since then the VTs (alt-F1, etc.) won't work.

Ubuntu Jaunty is the only thing that even comes close to working for me. It installs okay, and uses the vesa video driver, but has the standard trouble with the mind-rendingly awful netbook-launcher, which has plagued every netbook install I've ever tried. netbook-launcher sucks in a big way. It tries to be fancy by using OpenGL for visual effects, but in doing so either breaks video drivers or just eats up 100% CPU all the time.

Worse, Jaunty has a bug when turning it off that leaves you without a working window manager. System... Preferences... Switch Desktop Mode turns it off, and everything looks great, but as soon as you restart, you'll get a blank desktop with no menu bar, task bar, or gnome menus. Here's how to fix it, summarizing from the above link. (The above link also has ideas about what to do if you've already switched and are in that broken state).

To shut off netbook-launcher and get back to the normal gnome menus in Jaunty UNR, first switch to "Classic" mode from System... Preferences... Switch Desktop Mode. Everything should look great, but it'll break if you logout or restart now. To make sure the gnome menus load the next time, open System... Preferences... Startup Applications. Make sure UNR Launcher and Maximus are unchecked. Now click "Add" and create a "GNOME Panel" entry, running the command "gnome-panel" (no path needed). Add another called "GNOME Window Manager", running command "gnome-wm".

That should do it! You'll be limited to 800x600, instead of the native 1024x600, and of course the VESA video won't be as fast as a working accelerated driver would be. If that bothers you, feel free to spend a few days downloading and installing distros that'll break the machine entirely. Then reinstall Jaunty and reapply this fix, and you'll appreciate the suboptimal yet stable performance. Youtube and hulu work with flashplugin-nonfree, although not so much in HD or fullscreen modes.

Next up, enabling CPU frequency scaling to extend battery life.

Wednesday, November 11, 2009

Carmichael orrery

It occurs to me that it ought to be possible to demonstrate pseudoprimality with a purely mechanical device.

For instance, we could demonstrate 2^560%561 with 560 2:1 (or equivalently, 35 65536:1) gear amplifications followed by a 1:561 reduction, and rotate the input shaft once to see the output gear rest at 1. Of course, 2^560 ~ 3.8E168, so you'd have to turn the crank fairly hard.

You could also do a single 65536:1:561 train cranked n times for individual 65536n (mod 561) reductions, and repeat 35 iterations for 65536^35%561.

That would provide a (false) Fermat witness of 2. Simile for the other integers < 561. Not very interesting so far, but perhaps there's something more elegant.

Thursday, November 05, 2009

Math and music

If you represent the notes in the musical scale as the numbers 0 to 11 (0=A, 1=A#, 2=B, etc.), then the wheel of fifths is merely the multiples of 7 modulo 12. Likewise, the wheel of fourths is 5 mod 12. For some reason, the internets appear to be silent on this relationship.

Monday, November 02, 2009

Capturing sound in Linux using a USB headset (Plantronics DA40)

I picked up a Plantronics DA40 USB headset today and figured out how to capture .wav files to disk and play them back through the headset.

There are lots of other options, but I like this one because it's USB and I could use it with any Linux system, whereas if I used the native souncard, I'd probably have to do more per-machine troubleshooting. dmesg showed that it was detected okay:

[14563.672694] input: Plantronics DA40 Adapter as /devices/pci0000:00/0000:00:1d.3/usb4/4-2/4-2:1.3/input/input6
[14563.728138] input,hidraw3: USB HID v1.00 Device [Plantronics DA40 Adapter] on usb-0000:00:1d.3-2
[14563.909787] usbcore: registered new interface driver snd-usb-audio

Usually the mic comes muted by default, so I pulled up alsamixer to check. It came up with my native sound card first. So I ran "alsamixer -c 1" to try it with the second card, and that was indeed the DA40. Hitting TAB let met toggle between record and playback settings.

In the playback tab, there's a Mic option. You want to mute that ("m"), since that just loops the mic back through the speakers. On the Capture tab, there's a "Mic" field, and that's the one that actually sets the mic gain.

To record, I ran:

arecord -r 44100 -f S16_LE -D hw:1,0 foo.wav

(Hit control-c to end capture.) hw:1,0 let me record from card 1, the second sound card. It refused to record at its default setting of 8000Hz, so the 44100 and S16_LE were necessary. Then I was able to play back foo.wav with:

mplayer -ao alsa:device=hw=1.0 foo.wav

So far so good. Next, I wanted to know how much deviation I was getting (was the gain turned up enough?) so I downloaded a nifty, very old program called Wavesurfer, available as a statically linked binary:


I selected a "waveform" panel and loaded up foo.wav, and could see that I was only getting around +-500 units max (out of +-32767). In File... Preferences... Sound I/O, I set the Input and Output device to /dev/dsp1 (which I believe is the OSS version of the second sound card). Now I can record and playback from wavesurfer. I used alsamixer to tweak the Mic setting (remember to use the Record tab!) until I got +-10000 or so on my recordings. Anything over +-1000 would probably have been fine.

(BTW, wavesurfer will also show you nifty spectrograms, from which I learned a lot about the human voice.)

Here's a trivial script to start arecord recording in the background, and another script to kill it when you've had enough.

$more start-recording.sh

arecord -r 44100 -f S16_LE -D hw:1,0 /tmp/recording-in-progress.wav &
echo Recording. Wrote arecord pid of $ARECORD_PID to /tmp/arecord.pid
echo $ARECORD_PID > /tmp/arecord.pid

$more stop-recording.sh

kill "`cat /tmp/arecord.pid`"