Using the RIM BlackBerry Curve with Linux.
What's black, red, gold or silver all over? It's a music and video player, e-mail client, personal organizer, Web browser and high-speed modem. Oh, and it's a telephone.
Yes, you guessed it, it's the RIM BlackBerry Curve. Like a lot of LJ readers, I'm addicted to gadgets. At one point, I carried a cellular phone, an MP3 player and a PDA everywhere. That's a lot of devices to stick in your pocket though, and a year or so ago, I decided it was time to consolidate. After a lot of research, I settled on the BlackBerry Curve. It has almost everything I need in a very small, attractive package. The few things not included with the phone, like an SSH client, are available from third parties. As a longtime Linux user, I would have liked a Linux-based alternative (I once owned a Sharp Zaurus), but I couldn't locate any current Linux phones that had all the features I wanted and was easily available in the US.
Despite my willingness to use a non-Linux phone, I am not willing to give up my Linux-based computers. Research In Motion supports only Windows, so using the phone with my computers required some research and tinkering.
This article covers the following:
Charging your phone over USB.
Backing up the phone's applications and data to a Linux computer and restoring if necessary.
Transcoding video and audio files to use on the Curve.
Syncing a BlackBerry with Evolution.
The test system for this article is my HP Pavilion DV6458 laptop running Debian GNU/Linux's Lenny distribution. By the time this article is published, Lenny either will be the stable release of Debian, or it will be just short of that status. My phone is the BlackBerry Curve 8320, running on the T-Mobile network.
For it to be useful as anything but a pure telephone, you must install a microSD Flash memory card in your Curve. I use a 6GB card, which can hold 20 albums of music plus 20 podcasts at a time and still leave a couple gigs for photos and video. Installing your microSD card will expose you to one of RIM's puzzling decisions: the SD card is under the battery. Yes, that's right. You have to power-cycle the phone to change cards. As booting after a power cycle is notoriously slow for BlackBerries, this is a major annoyance. Because of this, I strongly recommend getting the highest-capacity card or cards you can afford to minimize the need to swap.
Another thing that puzzles and irritates Research In Motion's customers: RIM includes Bluetooth in its phones, but it's crippled. If you'd like to transfer data to and from your BlackBerry Curve, you must use a USB cable. The upside is, it's incredibly simple. Just plug a standard USB cable in to the phone and computer, and your system should detect the phone automatically. If you are using a disk manager, such as gnome-volume-manager, the microSD card in the BlackBerry should appear automatically as a removable disk drive. Transferring anything to or from the card is as simple as a cp command or dragging and dropping in any file manager.
First, you obviously can back up and restore the contents of the microSD card like any other mounted drive. However, the phone's own databases are not part of the filesystem, so special software is required. Luckily for me, there's a package already designed for this purpose, Barry, a project hosted and supported by NetDirect, a Canadian computer consultancy specializing in open-source solutions (www.netdirect.ca/software/packages/barry). Barry currently is alpha software, but it's quite usable. Unfortunately, it is not officially packaged for Debian. There are unofficial packages at that site for Debian Stable (Etch), but they are for the i386 architecture only, and they were problematic to install on my AMD64 system, so I was forced to compile my own. (In testing on my tower system, which runs the i386 distribution of Debian Lenny, the pre-created packages worked perfectly.) There is a special set of downloads and instructions on how to create Debian packages available at the Barry site, but unfortunately, they did not work on my system. (This may have been fixed by the time you read this.) However, the traditional make ; sudo make install combination worked perfectly. You can use stow to manage unpackaged applications.
Doing make install puts the libbarry* libraries into /usr/local/bin, but the actual executables expect them to be in /lib/tls. Rather than try to reconfigure the program, I simply copied the libraries to that location.
RPMs and instructions for creating RPMs are supplied for distributions that use that packaging system.
After installing Barry, you immediately can back up the BlackBerry databases, including contacts, appointments, settings, memos and so on. First, run the bcharge program. bcharge does two things:
You may have noticed that when you plug your BlackBerry in to a PC running Linux, you are warned that the “charging current is not sufficient”. bcharge increases charging current to 500mA and eliminates this message, plus it allows your phone to charge much faster.
It takes control of the device away from the usb_storage kernel module, so that access to the database and other functions is available. Despite this, the microSD card still can be mounted and files copied back and forth.
Note: bcharge is not compatible with the kernel module berry_charge. If lsmod reveals that berry_charge is present, use sudo modprobe -r berry_charge to remove it before running bcharge. If you plan to use bcharge routinely, blacklist berry_charge (sudo echo "blacklist berry_charge" >> /etc/modprobe.d/blacklist).
Apparently, bcharge works differently on different computers, depending on the exact device configuration and system. Try running sudo bcharge -o first. If this fails, try sudo bcharge (no flag). If even that fails, try sudo bcharge ; sudo bcharge -o. You can check whether the device has been detected using sudo btool -l. On my computer, when the device is detected I see this output:
Blackberry devices found: Device ID: 0xFFFFFF. PIN: FFFFFFF, Description: RIM 8300 Series Colour GPRS Handheld
(I have obscured my device and pin numbers in the above output.)
Barry's btool offers a lot of functionality, and I encourage you to do a man btool to learn more.
To back up my phone's databases, I used the barrybackup application. The installer did not set the program to setuid root, which is required. I had to sudo chmod +s /usr/local/bin/barrybackup before the program would work correctly.
Simply click the Backup button, and all databases are backed up. You can configure which databases are backed up and also choose to restore only certain databases, by clicking Edit→Config. Backups are stored as tar.gz files in ~/.barry/backup/FFFFFFFF, where that last hex number is your device PIN.
I got this phone specifically to replace my MP3 player. It has excellent sound and video quality (given the tiny screen's limitations), and a high-capacity microSD card can hold a lot of music. Of course, given that the card must hold music, video, photos taken with the built-in camera, ebooks and everything else, you will want to use the most efficient file formats.
First, let's discuss music. The Curve supports MP3, AAC, MIDI and WMA files for audio. Because I'm trying to use free tools as much as possible, WMA and AAC formats are problematic, leaving me with MP3. (MIDI is a specialized format not usable for recorded music.) MP3 files also are supported in fapg (see below).
For CD audio, I use A Better CD Encoder (abcde) to rip the CD, with the command:
abcde -o mp3
This rips the CD into MP3 files in the current directory. As abcde uses lame for MP3 encoding, you can control the details of the files created to the finest detail, but the default settings actually are more than good enough for me.
The video screen on the Curve has a resolution of 320x240. It accepts video in MP4, 3GP and WMV formats. Obviously, we free-software types prefer to use MP4 (even if it's a patented format) over WMV. I'm not aware of any good free tools to create 3GP (Third-Generation Phone) files.
The Swiss Army knife of free software video encoders is FFmpeg. For Debian distributions, you can obtain it by adding the repository at debian-multimedia.org to your /etc/apt/sources.list, then running sudo apt-get update && sudo apt-get install ffmpeg. Starting with any supported video, converting is as simple as this command:
ffmpeg -i myvideo.avi -s 320x240 -b 64k --ab 64k myvideo.mp4
This sets the dimensions to 320x240, and the audio and video bitrates to 64kbps. You can adjust these settings to taste. Note that the Curve can play back video compressed using only the MPEG 4 Part Two Advanced Simple Protocol (ASP). H.264, or MPEG 4 Advanced Video Codec, is not supported.
Transferring audio and video files to the handset can be done with cp or a file manager like Krusader. Audio files should be stored in /Blackberry/music, and video in /Blackberry/videos. You can create subfolders within these for your own convenience, but the handset will ignore them and catalog the media based only on metadata (also known as ID3 tags) embedded in the files. Music can be viewed by Artist, Album, Genre or Playlists. The Media application works with M3U playlists, which can be created using fapg (the FAst Playlist Generator, see Resources). M3U playlists are simple text files and can be modified using any editor.
When the Curve is disconnected from your computer, the Media application scans the music and video directories and generates lists of available audio and video files. This takes a few minutes, depending on how much is stored on the microSD card. Your songs may not be available until the scan is complete.
NetDirect has an excellent document explaining how to sync your BlackBerry Contacts and Appointments with Evolution using Barry here: www.netdirect.ca/software/packages/barry/sync.php. To do so requires that you install the Debian packages multisync-tools and libopensync0.
Before synchronizing, you must create a sync group that includes Evolution and the Barry opensync plugin (Listing 1).
Unless you have changed the default locations of the Evolution data files, you shouldn't need to change anything in the configuration file for evo2-sync. The barry-sync default configuration file looks like Listing 2.
Unless you have assigned a password for your Curve, the only change needed here is to replace 3009efe3 with the correct PIN, which you can find using btool -l. If you have trouble with sync, you can uncomment DebugMode. Before syncing, Evolution and its back-end servers should be shut down:
Then, syncing is as easy as:
msynctool --sync evo-barry
Note: on my Debian system, msynctool could not connect to the BlackBerry unless it was able to run with elevated privileges:
sudo chmod +s /usr/bin/msynctool
You also could change the permissions on the USB device to correct this problem.
Sync still is very much in alpha, and it can destroy your data! Be sure you have backups of both the Curve and Evolution databases before you sync.
My BlackBerry does not connect to a BES (BlackBerry Enterprise Server), so I have not tested any interactions between Barry and enterprise systems.
There is another free software project with the goal of making BlackBerry functionality available to Linux users. XmBlackBerry is a single GUI program, as opposed to Barry's suite of several mostly command-line tools. I went with Barry for myself and for this article, because XmBlackBerry hasn't had a release in more than a year, and I am comfortable on the command line. If you have a BlackBerry, keep an eye on XmBlackBerry, which is being actively developed and looks very promising.
Both Barry and XmBlackBerry support using the phone as a tethered modem to connect your computer to a cellular data network. However, at this time, neither works correctly with the 8320. I have reported this to the Barry developers, and by the time you read this article, the problem may have been fixed. I hope so, because using the Curve as a modem is almost the only reason I ever boot my laptop into Windows.
When I started using Linux in the early 1990s, there was a real feeling of adventure. Every time you installed a program, you were likely to have to solve some sort of problem or invent a workaround. I don't regret the fact that Linux and free software are so polished and generally easy to use. Still, it's exciting to be working with software on the cutting edge again. BlackBerry support in Linux still is a work in progress, but it's just the sort of fun challenge that got a lot of us into this in the first place. I'm looking forward to seeing how things progress.