Archive for the ‘Linux’ Category

Building a FAT file image for NDS Homebrew

Saturday, June 10th, 2006

While working on PicoDriveDS, I figured it would be easier to test if I used WMB instead of swapping SD cards all the time. I set up WMB, but much to my dismay, it didn’t appear to work correctly with my SCSD - the program would start, but it couldn’t read the files or directories. Due to testing by other people, I knew the CF version worked fine this way, but I didn’t have a CF cartridge to use. I did, however, have a 256Mbit GBA cart, and chishm’s FAT library has a driver called FCSR which can access a FAT image stored on a normal flash cart. The problem is finding instructions for how to build this properly. Here’s how I did it:

dd if=/dev/zero of=fat.img bs=512 count=32000
sudo losetup /dev/loop0 fat.img
sudo mkdosfs -F16 /dev/loop0
sudo losetup -d /dev/loop0

Now you can mount fat.img to your favorite mountpoint, copy files to it, then unmount. After that, what you have to do is open it up in a hex editor, go to offset 0×100 (nothing should be there, don’t worry), and insert the string “FCSR Chishm FAT”, ensuring it is null-terminated. For write support, following this null-terminated string should be the start sectors for 4 SRAM overlays, then followed by each of their sizes (I have not tested this). If you just want a filesystem on the cart so you can access it over WMB (like me), you can flash the image to a cart now. Otherwise, any rom you wish to use should be padded so that the image will be aligned on a multiple of 512 bytes, then prepended to the image.

Printing Envelopes on the ML-2010 with TeX

Monday, March 20th, 2006

I recently needed to print some size 10 envelopes using a Samsung ML-2010 laser printer under Linux. While printing envelopes using OpenOffice is possible, after a few trial runs I wasn’t really happy with the output and decided TeX/LaTeX might be better suited to the job. Adapting Michael Stutz’s code from here gave me the following:

% envelope.tex
% Print a #10 envelope

\font\cmssa = cmss12
\font\cmssc = cmss14

%setup:

\parindent 0 pt\nopagenumbers\parskip 10 pt
\hsize 9.5 in\vsize 3.25 in
\voffset 1.25 in
\cmssc

%document:

FROM-NAME

FROM-STREET ADDRESS

FROM-CITY, STATE, \ ZIP

\vskip .4 in\parindent 3.5 in

TO-NAME

TO-STREET ADDRESS

TO-CITY, STATE, \ ZIP
\end

Compile with:

tex envelope.tex; dvips -t landscape -m envelope.dvi

Then you can print with cupsdoprint or your favorite PostScript printing application. The envelopes should be inserted landscape-style, face up, open edge on the right side, in the center of the feed tray with all other paper removed and the guide tabs adjusted to fit the height of the envelope. The source TeX file is also available here.

libavcodec / libavformat sample code

Thursday, March 16th, 2006

Due to some changes in libavformat, the sample code at http://www.inb.uni-luebeck.de/~boehme/libavcodec_update.html no longer compiles correctly.

avcodec_sample.0.4.9.cpp: In function ‘int main(int, char**)’:
avcodec_sample.0.4.9.cpp:83: error: request for member ‘codec_type’ in 
    ‘pFormatCtx->AVFormatContext::streams[i]->AVStream::codec’, 
    which is of non-class type ‘AVCodecContext*’
avcodec_sample.0.4.9.cpp:92: error: cannot convert ‘AVCodecContext**’ 
    to ‘AVCodecContext*’ in assignment
avcodec_sample.0.4.9.cpp:105: error: ‘struct AVCodecContext’ has 
    no member named ‘frame_rate’
avcodec_sample.0.4.9.cpp:105: error: ‘struct AVCodecContext’ has 
    no member named ‘frame_rate_base’
avcodec_sample.0.4.9.cpp:106: error: ‘struct AVCodecContext’ has 
    no member named ‘frame_rate_base’

I’ve created a patch as well as a fixed example for the code. I’m not entirely sure about commenting out the frame rate correction hack, but those frame rate variables are no longer members of the AVCodecContext struct.

Also, for compiling under Debian, the recommended usage is not to change the include directives, but to use:

g++ `ffmpeg-config --cflags` -o filename filename.cpp 
    `ffmpeg-config --libs avformat --libs avcodec`

Not This Again

Monday, July 11th, 2005

Well, I got an 80GB PQI mPack P800 a few days ago after a bit of searching. The iAudio X5-series devices were at the top of the list for quite a while, as I rip most of my albums to FLAC and it’s one of about four players that supports it. The video support appeared kind of tacked-on (low-resolution low-fps only), however, and since I would be spending the money anyway it was a feature I was looking for. The i-Station series portables got some consideration, but there are basically no US distributors. I looked over Archos’s offerings, but none seemed to play video files over 700×480 or so. The mPack’s availability from NewEgg, broad format support, and large drive space won me over in the end.

Sadly though, the device is far from perfect. The interface is pretty clumsy, and if you want to use the device in USB mass storage mode only without their Windows-only transfer utility, you lose the music database functionality and quite a few other things. If you have a directory structure like:

Funk/
 Funk.mp3
Funk Rock/
 Funk Rock.mp3
-Funk- Rock/
 -Funk- Rock.mp3

Then play Funk.mp3, it will just play it over and over instead of moving on to Funk Rock.

Worst of all, they’re blatantly violating the GPL (the firmware uses a modified Linux kernel, the main application embeds code from the GNU fileutils, and the firmware also uses dosfstools). I’ve requested the source from them, but I’m not too optimistic based on my experience in the past with these sorts of things (I’m the OP in the avsforum thread, and the Duke website which is no longer there was mine). Hilariously enough, the mPack apparently uses a Sigma Designs EM85XX.PVP chipset. Does Sigma distribute these things with a mandate that the manufacturers ignore and violate the GPL as much as possible?

More on LDAP and Jabber Integration

Thursday, June 30th, 2005

I have updated and modified Nikita Smirnov’s jabberd2 LDAP rosters/vCards patch for my own use, and thought some other people might be interested in it as well. This patch only includes the sm rosters and vCards modifications, and not the c2s ldapfull authentication method. It has been updated to patch cleanly with jabberd2-2.0s3. I have modified the roster publication for people using normal LDAP authentication, so the “@servername” text is appended automatically to the supplied LDAP uid before storing it in the roster (so you don’t have to maintain seperate uid’s and jid’s). I have also modified the sm.xml.dist.in example to be a little more clear. If you use a Debian-style distribution, you should be able to “apt-get source jabberd2″, put this in debian/patches, and run “debian/rules binary” to get a modified package.

Screenshot of Gossip on a server with LDAP rosters and vCards

All of this information is now being pulled from our LDAP server, which is pretty snazzy. You can get the patch here. So now, I have LDAP working for:

  • user logins to Linux
  • Samba PDC functionality (shares the same home directory etc. as their Linux account)
  • company-wide addressbook (works in mail clients, as well as the copier/scanner machines)
  • logins to intranet web apps (including the very cool Trac)
  • Jabber authentication, rosters, and vCards
  • postfix and Courier IMAP for mail handling
  • pureftpd authentication

All in all, kind of a hassle to get going, but definitely worth it. There should be a free Linux distro that assumes you want to do this kind of stuff by default. Novell OES may come close, but it’s non-free in both the monetary sense and in that it relies on the closed-source eDirectory.

Setting Up Jabberd2 for LDAP Authentication

Wednesday, May 11th, 2005

At work, my main focus for the present time is getting our massive LTSP/LDAP/HTTP/DHCP/ACRONYM Linux server up and going in to production. I thought it would be a good idea to set up a message server for employees to use for quick office communication, and Jabber seemed the obvious choice. There were a few little hitches getting it integrated with LDAP, so in case anyone else comes across this problem, here’s a small guide to the changes that need to be made to the jabberd2 conf files:

c2s.xml:

  • Disable user registration.
  • Change <host> in the LDAP section to the appropriate host.
  • Hopefully you have your server resolving to a domain name, even if it’s an internal one such as “companyserver” (if you don’t, you should set it up now. You wouldn’t want to have your users showing up as username@192.168.100.1 or something). In the <local> section, set up a new realm such as <id realm='company'>companyserver</id>.
  • Now that you’ve set up a new realm, you need to add an LDAP basedn for searching in that realm. In the LDAP section, add <basedn realm='company'>ou=people,dc=company,dc=com</basedn>, adjusting for your specific directory layout.
  • There seem to still be some issues with LDAPv3 in the version of jabberd2 (2.0s3) that’s currently in my distro. Setting jabberd2 to use LDAPv3, slapd refuses the connection with “requested protocol version not allowed”. I had to leave v3 commented out and alter my slapd.conf to allow v2 connections.
  • Change the backend module in the authreg section to “ldap”.

sm.xml:

  • Turn on user auto-create by uncommenting it.
  • Change the sm id to the realm you set up earlier. In the example’s case, this would be <id>companyserver</id>.

Now you should be able to restart jabberd2 and have users login as username@companyserver, authenticated against your LDAP directory.

If only I’d had this book beforehand:

Mr. T Pities the Fool Who Doesn't Use Jabber

Easy Fixes for Stupid Problems

Saturday, April 30th, 2005

So there’s this really annoying bug that a lot of GNOME users have been experiencing, including myself. The first issue is that the default GNOME layout binds the “Windows” key to Super_L/Super_R, which prevents you from using it as a modifier key. This is a relatively easy fix; run gnome-keyboard-properties and change “Layout Options->Alt\Win Behavior” to “Meta is mapped to the Win-keys” (or just about anything other than “Default”, apparently). Now, you can open up gnome-keybinding-properties and use away. But wait! It mysteriously only works for some of the actions. This is because essentially two keybinding backends are used, gnome-settings-daemon and metacity. Turns out, gnome-settings-daemon ignores Mod4 (which is what the Windows key gets mapped to as a Meta). Thankfully, it’s an easy fix! Grab my patch or if you’re running Ubuntu/Debian, you can install these deb’s which already have the patch applied and restart GNOME (these have only been tested on Ubuntu Hoary). Now, rejoice that you can finally have Windows+L mapped to “lock screen”!

Ubuntu-tastic

Friday, April 15th, 2005

After having read somewhere that installing gnome-volume-manager on Debian was all kinds of cool, I gave it a shot. Somehow, it wound up breaking udev so it no longer saw my DVD/CD-RW drive, which is pretty much the opposite of the intended effect. This probably has something to do with the fact that I’d been kludging this Debian install along for quite a while, from all sorts of fun migrating between 2.4.x and 2.6.x, to random USB hackery, to writing my own scripts to start up wireless properly, and so on. Deciding I’d hit the breaking point, I went ahead and installed Ubuntu Hoary. So far, it’s very nice. I had the foresight to put /home on a seperate partition back when I installed Debian, so everything I’d personalized for my login pretty much still works properly. I’ve already got Beagle and Tomboy (complete with C# DBus bindings out of the box) working, with no real hassle at all.

Update: Switched back to Beagle 0.0.8 so it would work with inotify, and it’s working much better now. And with the Firefox plugin provided by the Beagle project, it looks like it pretty much already does what I was looking for. Also got other things like mplayer, acroread 7, etc. up and running. Also got suspend/resume working again, however, my consoles are still messed up after running video-post. Suspend-to-disk appears to lock up completely as well.

Kernel development with qemu

Thursday, March 10th, 2005

I was doing some kernel development, and I was getting a little tired of rebooting my laptop into the new kernel after each build. Having heard about qemu, I decided to give it a go. I found a sample script for building a disk image to boot qemu off of, but it didn’t seem to work. For example, the uuencoded information in that script produces output that makes gunzip complain that it’s invalid. So I decided to roll my own disk image with the following commands:

dd if=/dev/zero of=diskimage.img bs=1M count=512
losetup /dev/loop0 diskimage.img
mke2fs /dev/loop0
mkdir mounted
mount /dev/loop0 mounted
debootstrap sid mounted/ http://ftp.us.debian.org/debian/

You should now have a nice base Debian install to diskimage.img. Clean up your mounts with:

umount mounted
losetup -d /dev/loop0

Then you can launch qemu with a command like:

qemu -hda diskimage.img -kernel /path/to/bzImage -append 
  "root=/dev/hda sb=0x220,5,1,5 
  ide1=noprobe ide2=noprobe ide3=noprobe ide4=noprobe ide5=noprobe"

Ta-da! Once you’re done, make sure you shutdown with “shutdown -h now” before closing out qemu, or you’ll probably have to mount the image to loopback again and e2fsck it manually. You can also mount the image any time you’d like with “mount -o loop diskimage.img mounted” and muck about in the filesystem, or even act like you’re on it locally by using the chroot command after you’ve mounted it. If you get an error like:

Kernel panic: VFS: Unable to mount root fs on unknown-block(0,0)

when you try to boot, make sure you have ext2 support built in to your kernel, also set CONFIG_IDE, CONFIG_BLK_DEV_IDE, and CONFIG_BLK_DEV_IDEDISK to be built in as well.

MonoDevelop on Debian

Thursday, February 24th, 2005

I upgraded mono to the latest Debian package (1.0.5-2), and it went and broke MonoDevelop.

$ /usr/bin/cli --debug /usr/share/dotnet/monodevelop/bin/MonoDevelop.exe
Creating DefaultWorkbench

(MonoDevelop:9543): Gtk-WARNING **: Error loading icon: Failed to open file 
'/home/data/resources/icons/Icons.SharpDevelopIcon': No such file or 
directory

I tried using the Ubuntu package (monodevelop_0.5.1-3_i386, one revision higher than the monodevelop_0.5.1-2_i386 provided by Debian), but it does the exact same thing (except the executable is placed in a different structure under /usr/lib/monodevelop, and the /usr/bin/monodevelop script uses mono instead of cli). Doing something silly like copying the /usr/share/dotnet/monodevelop/data directory to /home makes the icon error go away, but MonoDevelop still does not start. I even tried rebuilding the monodevelop package with the new mono install, but it does the same thing. I suspect it’s related to this bug.

Update: It has randomly decided to start working again.