Feb 16th 2010
I’m sorry guys, but it’s gonna be a long story.
As you may have read, I received a free laptop from work. But it’s a semi-old computer : Pentium 4 2.8Ghz, 512Mb RAM, ATI Mobility Radeon 7500C. I wanted to try to use it inside the table, so that I can have an embedded system and just plug an AC outlet.
In short : use a 2.6.31 kernel + patch the PS3 drivers and the unicap lib + recompile CCV using the new unicap lib = awesomeness
To be able to get the most out of it, I decided I’d go with a minimal Linux install. Having an old Windows XP or an osx86 running on this beast would only mean wasting memory on unecessary tasks.
First step : go get a Debian, and install it ! The minimalistic Debian install I had was eating only 40Mb of RAM. I used a net install CD, and when asking for the softwares I wanted to install, I just unchecked everything. Then comes the fun part : installing only what is needed. More on that later.
Unfortunately, there was a problem : it was using the 2.6.32 kernel, and to be able to get the PS3 eye to run under linux and control it’s properties (frame rate, resolution, etc…), you have to patch some drivers. I tried Kaswy’s method with the 2.6.32 kernel but that wasn’t working.
Ok, so let’s try xubuntu. The latest Xubuntu (9.10) is shipped with the 2.6.31 kernel, so this was a good news. Bad news is that the slimest xubuntu I could get was still eating 140Mb of RAM, a hundred more than the Debian I installed a few days ago… Well, I discovered that with this kernel, compiling the PS3 eye drivers was no longer a problem.
Back to the starting block : reinstall your naked Debian, just add a lightweight window manager (I chose LXDE) and be prepared to get really geeky.
Kaswy said that he compiled his patched drivers using the 2.6.31-10 kernel, so let’s go to kernel.org, and download the sources.
Starting now, it’s just a matter of following this tutorial (ubuntu is built upon Debian, so it’s pretty easy to follow). After a few hours of compiling, I get a beautiful “segmentation fault“. Running memtest shows that I have some bad “sectors” around the 480th Mb of my 512Mb module. Ok, let’s do this again, but this time, we’ll restart linux using the mem=450M option. Compile is fine until 1 little source file (some wireless module, I think) have an error. Well, let’s comment the line and relaunch the compile… After maybe 5 or 6 hours, kernel is compiled and installed. woot !
It’s time to get patching. I try to recompile the PS3 eye drivers with my new kernel : all is well. I can now use the videomode option and such. Next, I download the sources for the unicap library v0.9.8, modify a bit Kaswy’s patch to the lib (just changed the path for the files, nothing in the code itself) and compile + install unicap. Eveything is fine : I can see the image from the cam in ucview. Unfortunately, I think the USB ports of the computer are starting to get overcrowded because if I try to run the PS3 eye at 60fps @ 640×480, image gets kind of out of sync.
And here comes the real fun stuff : getting CCV to work. I first tried using the binary build of CCV from nuigroup.com, and it was awful. I got segfaults, I got low framerate, I got a weird bug forcing me to reboot after quitting CCV, …
So let’s get the sources from the SVN and try to use Code::Blocks to build it. I have to say that I don’t like C::B. I don’t know why, but I’m more used to Eclipse (for Java + ActionScript 3) so I wanted to keep the same IDE.
First step was to get openFrameworks (CCV is built on top of oFx) to compile, and here was the real deal. oFx is meant to be used with C::B, so getting it to work with Eclipse + CDT (Eclipse plugin for C and C++ dev) was hard.
I never coded in C++ before, even though I did a bit of Objective-C, and the hardest part of getting oFx/CCV to build was to link all the libraries and sources. I’ll certainly make another post another day about how to get oFx and CCV to build from Eclipse. You have to go through a lot of aptitude install whatever to get all the libs necessary, like gstreamer and such.
I finally had the graphicsExample from oFx to build and run, so I was on a good way. I then merged the code from CCV into what I had for oFx and there was a whole lot more of problems. The worst one was that when I finally had the project to build without error, it wouldn’t launch.
GDB comes to the rescue : after some debugging, I finally see that the problem was coming from ofxGuiButton.cpp. Searching for this file on google, I find a post from Nikolaus Gradwohl on the nuigroup forum (his only post, in fact) saying that you have to change one little line of code.
After that, everything was like heaven : CCV was compiling and it was running fine. With the default settings in config.xml and as I used the patched unicap v0.9.8 lib, I’m now getting 30fps in CCV when in “big size” and 60fps when running in fast mode (space bar). But the best thing is that it’s using only 40 to 60Mb of RAM (for a grand total of max 100Mb including the OS). AND it has been running for almost an hour now. AND it has not crashed yet. The not-so-bright point : 50~60% CPU cycles, that doesn’t let me a lot of room to build the apps I want to display on my MT setup. I haven’t tried to install the proprietary ATI drivers on the machine, and I don’t really know how the GPU is used by CCV, but I’ll try to see if I can balance some of the processing power from the CPU to the GPU.
There’s not a lot of technical details in this post, but I’ll write some kind of step by step later. I think I’ll trash all the stuff I did in Eclipse and restart at 0 to make a really clean project. I’ll get sure to make a lot of screenshots.
Or I may get lazy and do nothing.
Good luck to all of you who wants to get CCV running under Linux