BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/)
-   General 8100 Series Discussion - Pearl (http://www.blackberryforums.com/general-8100-series-discussion-pearl/)
-   -   Linux USB charging? (http://www.blackberryforums.com/general-8100-series-discussion-pearl/58938-linux-usb-charging.html)

rivviepop 12-22-2006 06:54 PM

Linux USB charging?
 
I have a laptop at home, dual boot with WinXP and Linux. When in WinXP with the Pearl plugged into USB, the phone charges as you'd expect since the Desktop software is installed. When I boot back to Linux though, the phone complains about insufficient juice to charge or a missing driver (duh).

Anyone know the trick to get this thing charging over USB with your generic Linux machine? On my main workstation here at work I get the same BB message, but I know the USB ports on this beast can do it (other USB-charging phones work just fine).

Thanks! Of course I'm at work, the battery is dying and my charger is at home. *sigh* :)

StarKnight83 12-23-2006 12:53 AM

AFAIK the usb port in passive mode (which it most likely is in) only delivers 100mAh, to put it into its high/active mode there might be a command to send to the kernel to drive it high but I dont know the usb code so not much help beyond that

rivviepop 12-23-2006 11:43 AM

Hi,

Yeah - some googling and help on another forum and a little poking at "lsusb -v" tells me that the way this device is built, when it plugs in it announces to the PC that it draws 100mA only. Then, some sort of communication (nobody's debugged it yet) happens between the Windows driver and the device; the device then switches into 500mA draw mode, announces it to the PC and the juice flows.

OSX users have the same problem -- what has to happen is that someone (I may attempt :) ) has to use snoop to debug the USB port during plugin and watch the query/response flow between the two ends (or get specs from RIM). Then we can fake the funk in non-Windows systems to tell the device to crank up the heat.

titetanium 01-01-2007 11:38 AM

Do a google search or search on sourceforge.net for barry. That utility uses libusb to change the charging rate from 100mA to 500mA. There are packages in .deb, rpm, and tgz formats. Happy charging without rebooting!

rivviepop 01-01-2007 01:37 PM

Quote:

Originally Posted by titetanium
Do a google search or search on sourceforge.net for barry. That utility uses libusb to change the charging rate from 100mA to 500mA. There are packages in .deb, rpm, and tgz formats. Happy charging without rebooting!

Thanks! They just released 0.1 of "bcharge" on the 29th:

SourceForge.net: Barry's bcharge version 1.0 released

It doesn't work out-of-the-box with the Pearl, since the idProduct is different; I made a quick patch and it's at least now trying to work:

Code:

$ bcharge
Scanning for Blackberry devices...
Found...attempting to adjust charge setting.
1 device adjusted.

Here's the small patch for anyone interested:

Code:

--- barry-0.1/10-blackberry.rules.orig  2007-01-01 11:23:09.000000000 -0800
+++ barry-0.1/10-blackberry.rules      2007-01-01 11:23:37.000000000 -0800
@@ -1,3 +1,3 @@
 # Blackberry devices
 #
-BUS=="usb", ACTION=="add", SYSFS{idVendor}=="0fca", SYSFS{idProduct}=="0001", SYMLINK+="bb-%k", RUN="/usr/sbin/bcharge"
+BUS=="usb", ACTION=="add", SYSFS{idVendor}=="0fca", SYSFS{idProduct}=="0006", SYMLINK+="bb-%k", RUN="/usr/sbin/bcharge"
--- barry-0.1/bcharge.cc.orig  2007-01-01 11:23:26.000000000 -0800
+++ barry-0.1/bcharge.cc        2007-01-01 11:23:52.000000000 -0800
@@ -26,7 +26,7 @@
 #include <unistd.h>
 
 #define VENDOR_RIM            0x0fca
-#define PRODUCT_RIM_BLACKBERRY 0x0001
+#define PRODUCT_RIM_BLACKBERRY 0x0006
 
 #define BLACKBERRY_INTERFACE          0
 #define BLACKBERRY_CONFIGURATION      1

Houston, we have contact.

titetanium 01-01-2007 10:05 PM

I had already built my version of barry before posting and made a deb for it. It works fine with my 7130c. Now, if I can find a way to have the DM functionality on linux like Pocketmac for the Mac, then I'm all set. I would be able to finally get rid of dual-booting into windows and reclaim the space for virtual machines in its place.

blakeatl 01-02-2007 12:52 PM

I will be printing this page out as soon as I finish posting. I am one more step away from Windoze and one more step towards Ubuntu Edgy.

rivviepop 01-02-2007 01:32 PM

Quote:

Originally Posted by titetanium
Now, if I can find a way to have the DM functionality on linux like Pocketmac for the Mac, then I'm all set.

What features of the DM are you looking for, if I might ask? I've created a few workarounds and am developing my own non-Windows usage, curious to hear what others have done. I personally use SyncML to keep contacts and calendar online (http://mobical.net), and installed the Nexthaus SyncML plugin for the Blackberry, it's working as advertised.

I do my installs OTA from my own webserver (JAD-based), wrote a quick script to generate missing JAD files from jarballs (see >>here<<), the next step is to write a script that converts an ALX to a JAD, allowing OTA .cod installs as well.

titetanium 01-03-2007 12:14 AM

Pretty much the ability to back up my blackberry to a file like DM does. That's a huge deal to me. and some files dont install ota correctly. So I end up booting into windows, just for those. Ugh. I really don't like booting into windows if I can't help it.

metsfan 01-04-2007 10:04 PM

Great, this worked for me! I have to attach the Pearl, get the error message, run bcharge, and then disconnect and reconnect it, and it charges. Also, it works as a USB mass storage device for me so I can browse the microSD card.

rivviepop 01-06-2007 09:29 PM

Hey guys -- been working a little with Chris (barry/bcharge author) feeding him USB snoop logs and such. He gave me a one-line addition to the patch (as well as a new bcharge.cc that support Pearl *and* non-Pearl) which makes it work on first plug-in; you no longer need to plug it in, unplug, then plug again. With this fix it'll flash that initial "non enough power" message on your Pearl but then go away after a second (i.e. after bcharge fires up and adjusts the power flow).

Code:

diff -uNr barry-0.1-orig/10-blackberry.rules barry-0.1/10-blackberry.rules
--- barry-0.1-orig/10-blackberry.rules  2006-12-21 11:59:46.000000000 -0800
+++ barry-0.1/10-blackberry.rules      2007-01-06 18:46:19.000000000 -0800
@@ -1,3 +1,3 @@
 # Blackberry devices
 #
-BUS=="usb", ACTION=="add", SYSFS{idVendor}=="0fca", SYSFS{idProduct}=="0001", SYMLINK+="bb-%k", RUN="/usr/sbin/bcharge"
+BUS=="usb", ACTION=="add", SYSFS{idVendor}=="0fca", SYSFS{idProduct}=="0006", SYMLINK+="bb-%k", RUN="/usr/sbin/bcharge"
diff -uNr barry-0.1-orig/bcharge.cc barry-0.1/bcharge.cc
--- barry-0.1-orig/bcharge.cc  2006-12-21 11:40:31.000000000 -0800
+++ barry-0.1/bcharge.cc        2007-01-06 18:47:27.000000000 -0800
@@ -4,6 +4,15 @@
 ///            to 500mA.  Cycles through all devices attached to USB,
 ///            attempting to set all matching Blackberry devices to charge.
 ///
+///            This file is part of the Barry project:
+///
+///            http://www.netdirect.ca/software/packages/barry/index.php
+///            http://sourceforge.net/projects/barry
+///
+///            Compile with the following command (needs libusb):
+///
+///            g++ -o bcharge bcharge.cc -lusb
+///
 
 /*
    Copyright (C) 2006, Net Direct Inc. (http://www.netdirect.ca/)
@@ -27,6 +36,7 @@
 
 #define VENDOR_RIM            0x0fca
 #define PRODUCT_RIM_BLACKBERRY 0x0001
+#define PRODUCT_RIM_PEARL      0x0006
 
 #define BLACKBERRY_INTERFACE          0
 #define BLACKBERRY_CONFIGURATION      1
@@ -48,6 +58,7 @@
        sleep(3);
 
        // cleanup
+      usb_reset(handle);
        usb_close(handle);
 }
 
@@ -70,7 +81,8 @@
                for (dev = bus->devices; dev; dev = dev->next) {
                        // Is this a blackberry?
                        if( dev->descriptor.idVendor == VENDOR_RIM &&
-                          dev->descriptor.idProduct == PRODUCT_RIM_BLACKBERRY ) {
+                          (dev->descriptor.idProduct == PRODUCT_RIM_BLACKBERRY ||
+                            dev->descriptor.idProduct == PRODUCT_RIM_PEARL) ) {
                                printf("Found...");
                                if( dev->config &&
                                    dev->descriptor.bNumConfigurations >= 1 &&

The magic line in this case is that call to usb_reset(). According to Chris:

Quote:

Originally Posted by Chris Frey
On Blackberries I've tested, it resets itself automatically when the
special commands are given. Even udev detects this and runs bcharge again,
which is why I had to put in the 500mA check, or it would run forever.

Looks like the Pearl waits to be reset, which is more sane behaviour
in my opinion.


rivviepop 01-06-2007 09:32 PM

Quote:

Originally Posted by titetanium
Pretty much the ability to back up my blackberry to a file like DM does. That's a huge deal to me. and some files dont install ota correctly. So I end up booting into windows, just for those. Ugh. I really don't like booting into windows if I can't help it.

I ran an entire device Backup (in real WindowsXP) while under the USBsnoop, then sent the resultant (huge) logfile to the author; he said it'll take awhile but he's going to digest the info and try and get the Pearl working.

I'm sure they could use some help if you want to email and offer up some logs or something.... (see the SourceForge project page) The more of us helping them out, the better tool we'll get. :)

metsfan 01-15-2007 12:39 AM

I got annoyed having to run bcharge manually every time I connected my Pearl, so I hacked something up. Unfortunately, it really is a hack.

This will work if you use gnome-volume-manager to automount devices (most GNOME desktop systems use that these days). It should also work with any system that uses pmount-hal to mount devices, as gvm does.

Move /usr/bin/pmount-hal to a new file.
Code:

sudo mv /usr/bin/pmount-hal /usr/bin/pmount-hal-bin
Create a new file, /usr/bin/pmount-hal
Code:

sudo echo #!/bin/sh > /usr/bin/pmount-hal
sudo echo /usr/local/bin/bcharge >> /usr/bin/pmount-hal
sudo echo /usr/bin/pmount-hal-bin $1 $2 $3 $4 $5 $6 $7 $8 $9 >> /usr/bin/pmount-hal

Make the new script executable:
Code:

sudo chmod a+x /usr/bin/pmount-hal
For this to work, you may have to set the suid bit on bcharge:
Code:

sudo chmod +s /usr/local/bin/bcharge
This will run bcharge before mounting any removable device. If you connect anything other than a BlackBerry, it'll just not find anything and exit. This is an awful hack, but I couldn't find any way to execute a command before mount with gvm. I was able to do it with ivman, but I prefer to use gvm, if only to keep my system as close to a default install as possible.

Edit: Forgot to mention that for this to work, the Pearl needs to be set up to always go into mass storage mode when connected to a computer.

rivviepop 01-15-2007 03:59 PM

metsfan - what distro are you using? The barry project bcharge tarball includes a udev script that works perfectly on my Fedora Core system; it launches bcharge when the Pearl is plugged in and does it's thing. I did have to reboot though for it to be recognized - I'm not very familiar with udev to know how to do a runtime reload (or even if it's possible).

My bcharge RPM is at home to look for certain, but I think it goes into /etc/udev/rules.d/ and was a simple 1-liner; note my patch above patches that udev rule to support the Pearl (product = 0x0006). It works regardless of mass storage mode setting, as it's based on the RIM product simply showing up on the bus (lsusb -v).

metsfan 01-15-2007 04:04 PM

Hmm.. yeah, of course. I had no idea what that file is when I first installed cause I hadn't looked into udev first... and then I forgot about it when I started looking into how to actually get this done. I made the change to the file, but never put it where it needed to be. I'm using Ubuntu 6.10, I'll give it a try. Also, the path to the binary in the udev file doesn't match the location the default install puts bcharge.

Edit: this worked, using the .Debian rules file included with barry.


All times are GMT -5. The time now is 09:07 AM.

Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.