Friday, December 17, 2010

Building Hypermammut in Debian.

So, I've been trying to get hypermammut to compile and run for me.  The released tarball has a few problems in it.  I've gotten it to compile, but it still crashes when I try to open a file.  However, I figure the steps I've shown are at least closer to getting it to work.

I should note that I am on a 64 bit system, but I think I will explicitly point out everywhere where this is relevant.

First of all, you need to install the proper dev files.  Obviously you need a C++ compiler, etc, but the libraries you need to install specially are (and I list them with their Debian package names): magick++-dev libfftw3-dev
libwxgtk2.8-dev libaudiofile-dev.  You also need to install the build tool scons.  I should note that there is also a package named libmagick++-dev, which is not the same as magick++-dev.  The former will not work, and the two are mutually exclusive.

 Second the Scons build script is horribly broken (SConstruct).  I don't know scons, but I was able to figure out enough to fix it.

It would try to generate commands like

g++ -o IO/AInput.o -c -fPIE -pie "-ggdb `wx-config --cppflags` -Wno-unused-macros" IO/AInput.cpp

The double quotation marks just messing things up.  Additionally, it was missing the correct flags for fftw and audiofile in some cases.

I was able to clean it up enough to this point (I am only posting the bottom part of the file, because the top is just a big list, which I didn't change at all.)


env = Environment();
SConsignFile(".scons-signatures")
env.ParseConfig('Magick++-config --ldflags --libs')
env.ParseConfig('wx-config  --libs --cppflags')
env.ParseConfig('pkg-config fftw3f audiofile --libs')
env.Append(CCFLAGS = '-ggdb')
env.Append(LINKFLAGS = '-ggdb')
env.Program('test_s2i2s',lista);

Another issue which popped up (I'm pretty sure only due to 64 bit architecture) was in Process/Generator/Random.cpp. In the function Random::Random(), you need to replace the line

s1=get32bits()+(int) this;
with
s1=get32bits()+(int) ((intptr_t)this);

and add the include

#include <stdint.h>

to the top of the file.  This basically does the proper cast when ints and pointers aren't necessarily the same size.

Also, the file UI/ParametersDialog.cpp is missing the include

#include <wx/wx.h>

Now, run 

scons

It will build (at least on my system).  It will create the executable "test_s2i2s".  Unfortunately, whenever I try to load a file, it crashes.  If it is an audio file, it says

Audio File Library: could not open file 'test.wav' [error 3]
ERROR: Could not import audio file.

If it is an image file, it says 

test_s2i2s: magick/semaphore.c:525: LockSemaphoreInfo: Assertion `semaphore_info != (SemaphoreInfo *) ((void *)0)' failed.
Aborted

I don't have the time nor energy to track down these bugs, but they seem to be much deeper than misconfigured dependencies.  Hopefully I've sent someone down the right path to getting it to build correctly.

Tuesday, December 7, 2010

Uninstall/Disable feature/plugin in Eclipse Helios (3.6)

Not that I want to editorialize often, but Eclipse is just horrible when trying to remove a plugin.

I tried going to help ->install new software -> check what's already installed... The uninstall option is grayed out for all the relevant plugins.  No indication whatsoever why, or how to fix this.

I instead try going to Help-> Check for New updates.  It simply pops up a dialog saying no updates were found.  No further options.

I try going to Help-> Eclipse marketplace.  It seems Solutions (which are the only things you can modify using this dialog) are different than plugins.

I try going to Help->about eclipse ->installation details.  I get the same menu as if I click install new software.

I try googling.  It either says go to Help->about eclipse ->installation details (which I already tried), or to do  Help -> Software Updates -> Manage Configuration. The second suggestion is simply not available on Eclipse Helios.  I assume I am looking at the documentation for a different version of eclipse.  I find the documentation for Eclipse Helios (3.6), and nope, it's exactly the same.  At this point I hit a lucky break, and I notice that the text describing the menus to open is a link.  I click on it and it says "you can only do this with local help".  I find the same page again in the local eclipse help.  I click the link.  Viola, the magical hidden window pops up that finally allows me do uninstall the plugins.  Did it really have to be that hard?

Saturday, August 14, 2010

Grub not listing Windows (7) installation.

(This works for me on Debian, but probably works on similar systems as well.)

If your grub menu does not list an OS partition which you know is installed, try running update-grub.  If it still isn't listed, try installing os-prober (apt-get install os-prober). This is a program designed to locate non-linux OSes.  Run sudo os-prober.  Hopefully, it will detect the Windows installation you want it to, and it will print out a line indicating the device name and detected OS.  If it doesn't, I can't really help you, but your next step would be to somehow get os-prober to detect the installation.  Assuming you have os-prober detecting the OS as you want it too, try running update-grub again.  It will print out a line indicating that it has detected the installation.  When you reboot, the option should appear on the grub menu.

If os-prober is detecting the OS, but update-grub isn't, look for the file /etc/grub.d/30_os-prober (or something similar), that is the problem (either it isn't installed there, or it is misconfigured).

This really should be the first step you take if it isn't detecting a windows install properly.  No need to do Wndows MBR recovery or any sort of custom grub.d configuration.

EDIT: I found that there can also be issues detecting the install if the Windows 7 bootmgr is corrupted (don't ask me how that happened).  If you start up the windows recovery environment (you can download a recovery CD iso easily if you google) and then recover the boot manager, os-prober will now detect the install.  Just run update-grub to add it to the startup menu.

Thursday, August 12, 2010

Building Tartini on Debian

Tartini is a cool real-time "music analysis" program (http://miracle.otago.ac.nz/tartini/index.html).  The issue is that the sources don't immediately compile on my Debian system.

UPDATE: I've actually gone through and fixed all the issues and created a Debian package for it.  You can download the source at https://github.com/jeremysalwen/tartini-debian  Hopefully it will be in debian too soon.

Obviously, as the instructions say, qt 4, fftw 3, and qwt 5 must be installed for it to compile.  Installing the packages fftw3-dev and libqt4-dev is straightforward.  Make sure that if qt3 is installed, all of the build tools point to the qt4 versions. However, be careful with qwt, as the debian repositories contain a package "qwt-dev" which is not version five.  Instead, install libqwt5-qt4-dev.


As the build instructions state, you then have to modify pitch.pro to tell it where the includes and libraries are.  On a typical debian system, the important part of the file should look like:

unix{
  macx{ #MacOSX
    MY_LIB_PATH += -L/Users/student/usr/local/lib
    MY_INCLUDE_PATH += /Users/student/usr/local/include
  }else{ #Linux
    MY_LIB_PATH += -L/usr/lib
    MY_INCLUDE_PATH += /usr/include/qt4 /usr/include/qwt-qt4 /usr/include
  }
}

Then, qmake will still give you the error

RCC: Error in 'pitch.qrc': Cannot find file 'pics/tartinilogo.png'

For some reason it's looking for a png when the file is really a jpg.  Just modify pitch.qrc to replace tartinilogo.png with tartinilogo.jpg

qmake will then work, but make will still complain about

error: invalid conversion from ‘const char*’ to ‘char*’

a bunch of times.   mystring.cpp and mystring.h are the offending files.  Basically there is a bunch of code that seems to be just *wrong* in how it handles constness.  If you make the local variable "char * ext;" into "const char * ext;" in two functions, and make getFileExtension return type "const char*" instead of "char*", it will work.  (don't forget to change the function in both the cpp and the header file.

Meanwhile, prony.cpp gives a cryptic warning about the included file "cstdio", which seems to be caused by the line:
#define _GLIBCXX_USE_C99

I am not really sure if this affects the functionality of the code, but when I comment it out, it compiles and runs fine.  Apparently there is strange functionality surrounding this symbol anyway: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=443234

You will also get a linking error because it tries to link with -lqwt, when the qwt5 package only provides qwt-qt4.  Again, under the linux section of pitch.pro, replace the line

LIBS += $$MY_LIB_PATH -lfftw3f -lqwt -lasound

with

LIBS += $$MY_LIB_PATH -lfftw3f -lqwt-qt4 -lasound

Still, when you build it, it segfaults when you try to run fixing up calculateAnalysisData in mytransforms.cpp, we replace

if(chunk > 0 ) {
with

if(chunk > 0 && prevAnalysisData->highestCorrelationIndex!=-1) {

To stop the segmentation fault if the previous highest correlation index is -1 (not found).

And that should be enough to get a working Tartini build on Debian.  I would post a diff or a zip of all the corrections, but I can't attach it here.

Thursday, August 5, 2010

Wireless issues on Eeepc under linux

I was running into issues with network-manager (nm-applet) on my Eepc, where at one point I disabled the wireless networking by right clicking on it, but when I attempted to re-enable it, the check box was grayed out.  Restarting and killing the applet did nothing.  In addition, when I tried to connect using iwconfig and iwlist, I was getting errors with "network down".  It seems that at least in my case, the issue was that the interface wlan0 was "down", the solution being "ifconfig wlan0 up".  However, when I tried running that command, I would get the error "SIOCSIFFLAGS unkown error 132".  After some amount of googling, it appears that this error is because of a hardware off switch on the laptop for the wireless.  Confusingly, the Eeepc only had a key combo to disable the wireless, and I was under the impression that it wasn't working under linux, as most of the other hardware hotkey combos didn't.  By pressing Fn-F2, I was able to toggle the Wireless card, and I noticed the little wireless light went on and off.  Surprisingly, it was very inconsistent.  If I pressed it once, sometimes the light and error wouldn't change.  Other times, It would change the light, but get a different error message from ifconfig.  The light sometimes would indicate that it was on, sometimes indicate that it was off.  I figured out that if I pressed it four times and tried ifconfig between each press, at least one of the times it would run without an error.

Turning on the hardware switch meant that the wlan0 interface was "up", allowing me to run iwlist and iwconfig.  However, the issue still remained with network-manager.  Although I assume that the box was initially greyed out because of the hardware switch, it wouldn't un-grey out even when the wireless was back up.  I realized that it was saving the "enabled" state in a configuration file somewhere.  After editing /var/lib/NetworkManager/NetworkManager.state and setting "WirelessEnabled=true", I restarted nm-applet (/etc/init.d/network-manager restart), and suddenly wireless worked again.  Although all the information you need to solve this problem is online, it took several levels of indirection to find it, and a lot of slogging through Ubuntu bug-reports.  I figured I'd compile all the information together here.

Saturday, July 24, 2010

Microcontrollers

I will update this post with more useful tidbits.

I'm dealing with PIC chips here. So far PIC18f*** but I also have a 16f which I might go back to later.

SDCC- Small Device C compiler
You can look up information about SDCC, but the one part that wasn't obvious is the meaning of all the registers included in the header files. They aren't just made up by SDCC. They correspond directly to the names given by the chip manufacturers. So basically if you want to do some SDCC programming, pop open the datasheet of the chip you are looking at, and that will give you an "API" of sorts to use from SDCC.

USB Stack
It seems there are quite a few USB stacks for PICs, but none are *definitive*. Microchip (the company who makes the chips) has their own for their own compiler, but the source is only somewhat open; you can only use it with Microchip devices, so not GPL compatible. A lot of them also seem to be derived from a Nuts and Volts article, which has a GPL source. Right now I'm looking at http://www.microchip.com/forums/tm.aspx?m=382900 which seems promising.

update: with minimal changes I got it to work with SDCC in /usr/ (instead of /usr/local/) and changed it to compile for pic18f4550 instead of 2550.  At least with the minimal changes I made to the makefile, linux recognizes the chip as a USB device when I plug it in.  Here is the source.  It is derived from the above forum post which is derived from the GPL code in the magazine, so it is also GPL.

update: I have found another implementation which seems even better.  It worked with even less modification, and most significantly, it implements USB CDC as well as HID.  This basically means you can do serial port (rs232) emulation with it straight out of the box.  I'm going to need to do some configuration with baud rates for the debug from the actual rs232 port, because right now it's printing garbage.  Here is the source: http://pic-o-rama.org/index.php?option=com_content&view=article&id=2:simple-usb-board&catid=1:evaluation-boards&Itemid=3  Look to the bottom.  This one is also derived from the Nuts and Volts source.

Just a Note

This blog is intended to walk people through doing things which I found difficult to do, essentially helping people who are in the same situation I was in. Generally I expect it to be things involving computers to some degree, and programming as well.

Essentially, I am making a blog of things that took a long time to discover, but I wish had been available as the first result of a google search. This can be very general (how to use USB hardware with SDCC), or very specific (What does error message X mean?). Basically anything that's not documented in an easy to access form for a complete beginner. It's not intended to be a complete information source, nor definitive, but simply helpful.