March 11, 2010
Creative X-Fi Xtreme PCIE audio challenge
A few years ago, I bought a crappy little Dell Poweredge T105. I use it as my primary workstation. It was cheap (about $200), has a dual-core Opteron processor that supports virtualization, and came with 8 gigs of ram. It's a great little development box.
I bought a sound card for it immediately (and also a cheap video card, an ATI Radeon X1650). Since the computer only has 1x and 8x PCIE slots, I had to get the cheapest PCIE sound card that I could find. That was a Creative X-Fi Xtreme PCIE. I guess this card has a CA0110 chipset. ALSA for linux does not yet support this chip correctly (or rather, it must not support the PCIE to PCI bridge set on the card? I know very little about this PCIE stuff, being an embedded guy).
Today I throw down the gauntlet. If anyone can produce a patch for alsa to support this card, I will send them $100US. I figure a decent sound card will cost me at least that much. I have a USB sound card in this computer, but it does suck...it can barely play CDs without sputtering and popping. Produce a patch, email it to me (my email address can be found on my resumé, located at this domain name slash resume.pdf) and I'll work with you to make sure that it works. I'll mail you my sound card if you haven't got one (so long as you promise to mail it back when finished). Oh and send it to the ALSA people please. K thx.
February 27, 2010
Pascal's Paradox
A few days ago, a funny Seventh Day Adventist showed up on my door. He was a friendly enough fellow, and asked about my faith. "Atheist," I said, "and anyone that tries to tell me otherwise is probably trying to sell something."
Yeah, I like the Princess Bride. He scribbled this down in his notebook. Great, I'm probably on some kind of "prayer list" or something.
"Really?", he asked. "How can all of this subjective experience be just nothing?"
"Simple," I said, "I live my life, and then I die, and then there is nothing left to experience."
"What do you think Jesus was: son of god, historical figure, or work of fiction?"
"Probably a historical figure, but fiction seems more plausible at times."
"Well what about the objective reality?"
Obviously my time in government service left me entirely too...sober. I was growing impatient. "Look," I said, "I go through life and question every piece of information that gets thrown in front me. I don't win a lot of friends, but I do make a difference."
"You're familiar with Pascal's Wager?" he asked
Yeah, Pascal's Wager. I could use the official church jargon to explain why it is a retarded bet, akin to playing Russian Roulette (it's also a lot less exciting than Russian Roulette, I imagine). Instead, I argued with reason. "Religious people waste their entire lives praying and bowing and hoping things will happen. I make things happen, because I know that only people can make things happen. That is the fallacy of Pascal. Hope."
So today, I put my money where my mouth is. One of Laura's co-workers, Pablo, is from Chilé. His brother lives in a small town outside of Concepcion, as close to the epicenter of today's quake as possible. Pablo can't reach anyone in his family (most of his family lives near Santiago). I decided to donate my last paycheck to the Red Cross. Yeah, I probably can't afford it right now. I'm no saint, either. But money, more than prayers (or even yoga mats), is what folks in Haiti and Chile need right now.
Green Hills C Compiler bug
I had a rather proud moment a few days ago. I had been looking at a curious piece of compiled code that had an integer promotion bug. Yeah, I have some pretty weird hobbies these days. This particular bug was for the Motorola Coldfire processor. The C code, it turns out, looked like this:
unsigned char table[256] = {0xsomevals} // global array, located on process heapThe compiler compiled the code (the function part of the above) into something like this:
unsigned char array_lookup(unsigned char uc){
return table[(unsigned integer) uc];
}
link a6, #0
;; there would be a 'store registers' command here', I don't remember the syntax at the moment
;; stw.l (a0,d0), (-sp) ?
move.l -4(sp),d0
mvs.b d0,d0 ;; offending line
move.l (0,d0+a0),d0
unlink a6, #0
;; there would be a 'restore register' command here, again I don't remember syntax
rts
For the coldfire assembler unaware, the mvs operation is "move with sign extension". The effect is that the function can return memory logically *before* the array. If the unsigned char passed in is 0x80 or greater, the most significant bit of the byte is a '1'. The sign-extended move operation makes the index value negative. What is interesting here is that the compiler ignored the explicit unsigned integer cast when it dereferenced the element in the array.
It turns out that this was a bug in an older version of the Green Hills compiler. Newer versions don't exhibit this erroneous behavior. I have no information on what versions of the Green Hills compiler are affected by the bug, but if you are a vendor programming Coldfire V4 cpus (mvs was introduced in the Coldfire V4 instruction set), you may want to compile my above code snippet and make sure that your compiler is not affected.
I have to say that I was kind of impressed with myself for finding the bug. The people that produced the compiled code were kind of dumbfounded as to how I stumbled upon it. Since I have started exploring embedded systems security, I've decided that the C language is probably one of the most wretched things in the universe, and that embedded system vendors ought to use as much as peer-reviewed code (read: open source) as possible in their systems. Here I mean both compilers and process code. C compilers for these systems generally don't receive as much scrutiny as desktop application compilers, probably because the target processors are not x86.
February 13, 2010
Hacking Traffic Signals
I noticed something funny on my walk tonight. The traffic signals in Pullman are timed funny for pedestrians.
I've always lamented how horrible "downtown" Pullman is for pedestrian traffic. Smash a crosswalk button and you often have to wait for 5 minutes for the lights to change. Most of our intersections have traffic flow sensors on the signals (cheesy little things, I honestly have no idea how they work). I sat at one intersection and tried a few experiments to see how the traffic flow affected crosswalk time.
Experiment 1: Hit the button while traffic is flowing steadily through the intersection. Time to light change (and my 'walk' sign lighting up): 3:30.
Experiment 2: Hit the button while one car is going through the intersection. Little to no traffic following this car (two more cars went through the entire time I waited for this change): 3:30.
Experiment 3: Hit the button while no traffic was flowing through the intersection. There was a ten second gap in traffic. The light changed in 0:15.
Conclusion: The traffic algorithm at this particular intersection is retarded. It must measure traffic flow at the moment the 'walk' button is hit, and decide how long to wait based on that single measurement. As a pedestrian, you should wait until there is a small break in traffic to hit the walk button. You'll probably save time by not hitting the crosswalk button right away...
December 27, 2009
Lolo Pass
On this trip, I joked that Jesus must hate me for being an atheist. Things did not go exactly as planned...
Laura and I rented a cabin in Lochsa Lodge, a cozy little 200 square foot ordeal with a nice wood-burning stove for about $40 a night (more expensive due to the holidays). The lodge is about an hour and change west of Missoula, Montana, and only about fifteen minutes away from Lolo Pass, a wonderful little backcountry skiing area. What an hour it can be where Missoula is concerned...
We headed up on Christmas Day, and went straight to the Pass to do a little skiing. We arrived with not a whole lot of sunlight left. After getting the heart going and doing a few turns, it was time to check in to our cabin.
When we arrived at the Lodge, I got out to hear a very definite leaking sound from one of my rear tires. "No problem," I thought, "I have a full-sized spare." Some story from my mom's boyfriend, Jack, came to mind almost immediately. When I first drove home with the Volkswagen (back in 2006 I guess), he said, "Oh man, I hated my Audi. One time, I got a flat tire, and the wheel had this stupid special bolt on it that I couldn't get off."
You could imagine where this is going. It turns out that my VW also has a "security nut" on the wheel, which requires a special adapter to remove. Unfortunately, while moving, I mistook said special adapter for a bicycle tool and put it in my bicycle repair box. Doubly unfortunately, I don't bring my bicycle repair box with me when I go skiing very often.
Without the tool, it was impossible to remove the wheel. The friendly folks at Lochsa Lodge loaned me a portable air compressor. With it, I was able to drive to Missoula on Saturday. I was greeted in Montana by a nice piece of gravel hitting the windshield, putting a good-sized crack squarely in the center.
The VW dealer in Missoula could not locate the special tool that I needed, two auto parts store and a tire store said they were unable to remove the wheel as well. Eventually, I talked Les Schwabe Tire into trying, and they were, at least, able to get it off and patch my tire.
Another unfortunate event was noticed on the ride home. My other rear tire had developed a leak. This one wasn't as quick (a few hours from fully inflated until flat, I supposed), so I decided to worry about it later.
Saturday was more or less shot for skiing. We opted to go to Jerry Johnson hot springs instead. Jerry Johnson is without a doubt the finest spring I have visited. The pools are deep, hot, silt-free, and not so backcountry that you freeze on the way back to the car. This last bit has one sad side-effect -- bathing suits are more-or-less required.
Sadly this trip was just not going to go my way. I managed to jump onto an ice-covered rock while navigating the springs by moonlight, and landed squarely on my chin. It is my reward to nurse a nice gash for the week. Mayhaps I'll gain a nice scar from it. I hear women love those...
I managed to squeak back on my bad tire. It had perhaps 2 pounds of air left when I rolled into Pullman (and my what a drag that makes on the old fuel economy). I guess I'll take this as the same sort of sign that I treat flats on my bicycles -- time to get new tires all around. It's sad, as they have tread left. They're just dry-rotted from lack of use...








by reid
on November 23, 2009

by reid
on April 16, 2009
