Tuesday, October 16, 2007

javac -XD-printflat

As a self-remainder, extremely useful 'hidden' javac option I found here:

$ javac -XD-printflat

Monday, June 04, 2007

Copying EXIF tags

Somewhere along my image processing worklow (RAW -> ufraw -> tiff -> GIMP -> jpg -> flickr) I lost EXIF data. Probably it'd been stripped during conversion to tiff using ufraw. Hmm, how to automagically copy EXIF meta-data from CR2 RAW files to post-processed jpgs? Exiftool to rescue!

/home/banshee# wajig install libimage-exiftool-perl
/home/banshee# cd $ImagesDir
$ImagesDir# exiftool -tagsfromfile %d%f.CR2 -r -ext jpg .

From exiftool manpage: exiftool -tagsfromfile %d%f.CRW -r -ext JPG dir
*Recursively* rewrite all "JPG" images in "dir" with information copied from the corresponding "CRW" images in the same directories.

Thursday, February 08, 2007

As a sidenote to future self, next time before you spend an hour on debugging a completely unrelated issue, please check if you enabled auto-generating primary keys on this 'one-time debug' copy of the database... FFS.

Saturday, January 27, 2007

Mounting external ntfs partitions using ntfs-3g

When you use removable media you probably want to mount it always to the same mount point regardless of its physical dev node location which can can change depending on the order you connect the devices or the slot you connect them to. This is where LABEL/UUID fstab options come in handy.

So, instead of a fstab entry like this:

/dev/sda5 /mnt/FOTO_BCKP ntfs defaults 0 0

you make an entry like this:

LABEL=FOTO_BCKP /mnt/FOTO_BCKP ntfs defaults 0 0


But if, instead of a default ntfs driver, you want to use a new ntfs-3g driver, there's a small problem: ntfs-3g, at the time of writing this, doesn't support LABEL or UUID options. A nice workaround, which I found here is to use /dev/disk/by-label/:

/dev/disk/by-label/FOTO_BCKP /mnt/FOTO_BCKP ntfs-3g defaults,user 0 0

To check labels or uuids, connect your media and simply list /dev/disk subdirectories:

ls -l /dev/disk/by-label/
ls -l /dev/disk/by-uuid/


To set the ntfs partition's label use `ntfslabel` from ntfsprogs package.

Wednesday, January 10, 2007

How to make BCM4318 on Acer5024 work on Debian Etch

WARNING: for kernels >= 2.6.24 this note is deprecated. Use b43 driver + acer-wmi instead. I'll try to write about it in a while.

== original blognote follows ==

BCM4318 is a wireless chipset from Broadcom Corporation. Full name, as given by lspci is: Broadcom Corporation BCM4318 [AirForce One 54g] 802.11g Wireless LAN Controller.

Broadcom released only Windows driver for this chipset, so to make this card work under Linux you have two choices:

- native, open source driver included in the kernel since 2.6.17-rc2. Because Broadcom refused to provide any kind of specification for this chipset, development on this driver is based on reverse-engineering.
- Windows binary-only driver and ndiswrapper

There's an ongoing flamew^Wdiscussion whether using binary drivers as a fast way to support more hardware under Linux is a good or a bad thing. It's actually pretty interesting, if you feel like reading some more you can start by pointing your browser at Linux Kernel Mailing List Archive.
Even if you don't care much for security or ethical reasons, in the long term native driver would be a better choice because it is possible that at some point in the future kernel will ban binary modules. So, one of these choices has a future, and one of them does not, Mr. Anderson.
But reality bites and as of january 2007 native driver is said to be still in an experimental state, there's no WPA support, connection is not stable, speed is limited to 11 Mbps/sec and there are some power issues with BCM4318 in particular. Tough luck. The choice is yours :-)

For now I decided to use ndiswrapper. This is a step-by-step description how I made this little Broadcom's beast work on my Acer Aspire 5024 laptop under Debian Etch using ndiswrapper:

You will need:

  • BCM4318 driver for Windows, I got mine from Acer ftp.

  • acer_acpi

  • ndiswrapper

  • kernel headers for your kernel's version, this is a prerequisite for compiling acer_acpi and ndiswrapper modules

  • Also it's really helpful to have an extra console window running `tail -f /var/log/messages` open during the process, just to see what's going on, make sure you're on the right track or diagnose problems if you are not :-)


    Installing acer_acpi:

    0. Download tarball from the location given above, unpack it to /usr/src/ or /usr/local/src and cd to acer_acpi directory.

    1. Read 'INSTALL' file :-)

    2. As advised in 'INSTALL' file:
    make acer_acpi.ko

    3. Copy acer_acpi.ko to lib/modules/$kernelversion/kernel/drivers/char/

    4. depmod -a

    5. modprobe acer_acpi


    Installing ndiswrapper:

    0. You can get ndiswrapper from Debian repositories, so simply:
    apt-get install ndiswrapper-utils-1.9
    apt-get install ndiswrapper-source


    1. Unpack ndiswrapper-source to /usr/src or /usr/local/src and cd to its directory.

    2. Install ndiswrapper module:
    make install
    Alternatively you could use module-assistant to get, build and install ndiswrapper kernel module:
    m-a a-i ndiswrapper

    3. Download windows driver, unpack it to any directory (AFAIR you only need bcmw5.inf and bcmw5.sys files) and cd there.

    4. Install driver
    ndiswrapper -i bcm5.inf
    Check if driver installed succesfully:
    ndiswrapper -l

    5. Unload native bcm43xx driver
    modprobe -r bcm43xx
    and put it on a blacklist so it doesn't load automatically by adding entry in /etc/modprobe.d/blacklist file:
    blacklist bcm43xx

    6. Load ndiswrapper module
    modprobe ndiswrapper

    You can read here a bit more about managing modules on Debian.


    Configuring wireless card:

    acer_acpi module creates entries under /proc/acpi/acer. Now you can enable the hardware. Linux equivalent of pushing the wi-fi button on Windows is:

    echo "enabled : 1" > /proc/acpi/acer/wireless

    Show that to your girlfriend for that extra 'You're weirdo...' look :-)

    Of course typing this manually every time you want to turn your wireless on/off is out of question, so put that in your network interface configuration. On Debian you do that in /etc/networking/interfaces. Read man interfaces and man wireless for more info on commands and syntax. Here's how my wireless entry looks like:

    # wireless
    auto eth0
    iface eth0 inet dhcp
    pre-up modprobe ndiswrapper
    pre-up modprobe acer_acpi
    pre-up echo "enabled : 1" > /proc/acpi/acer/wireless; sleep 1;
    post-down echo "enabled : 0" > /proc/acpi/acer/wireless
    wireless-ESSID yourESSID
    wireless-key yourKey
    wireless-mode auto


    So ifup at first loads ndiswrapper, then acer_acpi module, then enables the hardware and finally configures interface with wireless-<> commands. These are the same parameters you would give to iwconfig.
    Note that sleeping after enabling wireless is crucial (at least on my machine...), otherwise ifup tries to configure the card too early, while it's not really enabled yet (just a guess but it behaved like that).

    Now, if everything went okay, `ifup eth0` should give you working wireless connection. Hopefully :-)