BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/)
-   Linux Users Corner (http://www.blackberryforums.com/linux-users-corner/)
-   -   HowTo: Use bcharge to charge your BB under linux (http://www.blackberryforums.com/linux-users-corner/65653-howto-use-bcharge-charge-your-bb-under-linux.html)

rivviepop 02-19-2007 01:17 PM

HowTo: Use bcharge to charge your BB under linux
 
Barry Homepage:
Net Direct :: Open Solutions

SourceForge Project Downloads:
SourceForge.net: Files

'bcharge' is a utility that's part of the Barry project - which aims to be a complete desktop toolset for interfacing your BlackBerry with linux. The purpose of the bcharge tool is to detect when a BB has been plugged in and then alter the current to the USB port - it will increase the default 100mA flow up to 500mA, which is what the BlackBerry is expecting. This is exactly what the Windows driver does.

The 0.1 version currently available (2007-02-19) will work with any BlackBerry older than the Pearl 8100; for the 8100 (and presumably the 8800, unreleased at this time) you'll need to get the latest version of the code from CVS (only "bcharge.cc" is needed); the product ID internally has changed from '0x0001' to '0x0006' in this newer handset. The latest CVS version will recognize both older and newer devices, but the newer CVS code includes some special action to take when "seeing" an 8100 device.

CVS link for post-0.1 bcharge.cc:
SourceForge.net Repository - [barry] Index of /barry/tools

Compiling the code is beyond the scope of this HowTo, but it's extremely simple and uses all the standard linux-isms (autoconf, g++, etc.) -- if you can compile any generic application you should be able to compile bcharge; because this code interfaces with USB ports, make sure you have the 'libusb-devel' (exact name depends on your distro) installed so it'll find the headers and link libraries. There may already be installable packages available download as well (.deb/.rpm) - your need to compile may vary.

There are two parts to 'bcharge' - the main binary itself and a "udev" script. You can use the tool without doing anything, just plug in your BlackBerry to any USB port and type ./bcharge (substitute the path if needed). This will scan all the USB devices plugged in, find your BB handset, and adjust the current flow. It's that simple.

But, to automate the process you can copy a script from CVS (or the official downloads) to your /etc/udev/rules.d/ directory (location may vary depending on distro) to have everything done for you. First, copy the compiled binary (bcharge) to /usr/sbin/ and make sure it's at least mode 0755 (executable), owned by root (for security's sake). Now copy one of the scripts from here:

SourceForge.net Repository - [barry] Index of /barry/udev

...to the udev rules directory mentioned above. Obviously if you're using Debian (and maybe Ubuntu?) use the one called "Debian". :)

NOTE: if you have a newer Pearl device you will need to update the ProductID in this script. Replace this code:

Code:

SYSFS{idProduct}=="0001"
...with this code:

Code:

SYSFS{idProduct}=="0006"
It should make perfect sense why you're doing this. You could also just copy/paste the line to a new line and add both products at once -- the choice is yours. Maybe you have both an older and newer BB device and need it both ways. :)

Reboot. I say again, Reboot. 'udev' rules don't seem to work quite right unless they're loaded at startup (when udev runs), so just save yourself some hassle and sacrifice your uptime with a reboot. Now plug in your BB device and it should initially flash on the handset the error message about insifficient charge, but then the message will go away in 1sec (or so) when bcharge runs and performs the adjustment.

You can use the 'lsusb' tool to verify the current has been changed - run 'lsusb -v | less' as root, find the RIM BlackBerry section and it'll show the current USB port power flow. It should say 500mA and not 100mA.

edit: blogged.
bcharge: charge your BlackBerry under linux rivviepop phantom

blakeatl 02-19-2007 03:50 PM

Very nice. I hope the option for the Pearl comes soon.

Glate 02-21-2007 08:30 PM

Wicked. I've been looking for this for years... You are officially my hero. Now to see if there's a Gentoo ebuild..

LunkHead 02-23-2007 03:20 PM

Got it! Sweet!!!! Working as advertised! :)

@rivviepop

Any luck getting the MicroSD card in the BB recognized?????

rivviepop 02-23-2007 04:02 PM

Quote:

Originally Posted by LunkHead
Any luck getting the MicroSD card in the BB recognized?????

Mine works like a champ -- start a new thread on this, and post the applicable contents of /var/log/messages from your system when you plug in the device. We'll address it in that thread then...

LunkHead 02-23-2007 06:32 PM

This could also use a sticky! Mods? Thanks! :)

LunkHead 02-25-2007 04:12 PM

Here is the bcharge RPM(*)... I had to add the .zip at the end of the file to get the forums to take the upload... Just rename it by removing the .zip at the end of the filename...

(*)From RPM.Pbone.net

You will need to satisfy the following:
libusb-0.1.so.4
rpmlib <= 3.0.4-1
libstdc++.so.6
libgcc_s.so.1
libc.so.6
rtld(GNU_HASH)
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
config(bcharge) = 1.0-1
libstdc++.so.6
libc.so.6
libm.so.6

rivviepop 02-25-2007 04:35 PM

Just a note (trying to tie these two threads together) -- the above RPM is old (I think?) and doesn't use the fancy new CVS code from the Barry project; I do have a RPM for FC6 that I'll give out personally (PM me), but I don't want to share it publically. I made my own tarball and called it "0.2", it's entirely unofficial code -- I don't wish to disrespect the Barry project by accident, hence not releasing it.

It's not hard to do yourself, though. :) I'll at least post my SPEC file here to get you started; it's an enhancement of the one from the Barry project, and is intended to use the latest bcharge.cc and a patched udev ruleset (see the Barry patches page if it's not in CVS yet) to support both old and new device IDs.

Code:

Summary: BlackBerry (tm) Desktop for Linux  - bcharge utility
Name: bcharge
License: GPL
Version: 0.2
Release: 1.cvs20070219
Group: Applications/Productivity
Source: bcharge-0.2.tar.gz
URL: http://www.netdirect.ca/downloads/barry
Vendor: Net Direct Inc.
BuildRoot: /var/tmp/%{name}-buildroot
Requires: libusb
BuildRequires: libusb-devel, gcc-c++

%description
Barry is a desktop tool for managing your BlackBerry (tm) device. (BlackBerry
is a registered trademark of Research in Motion Limited.)

This packages contains the USB charge utility, bcharge.

%prep
%setup

%build
g++ -Wall -g -o bcharge bcharge.cc -lusb

%install
%{__mkdir_p} %{buildroot}%{_sbindir} %{buildroot}%{_sysconfdir}/udev/rules.d
%{__cp} bcharge %{buildroot}%{_sbindir}
%{__cp} 10-blackberry.rules %{buildroot}%{_sysconfdir}/udev/rules.d

%clean
%{__rm} -rf %{buildroot}

%files
%attr(0755,root,root) %{_sbindir}/bcharge     
%attr(0644,root,root) %config %{_sysconfdir}/udev/rules.d/10-blackberry.rules


erroneus 02-26-2007 11:05 AM

Let me just add an important note regarding the use of bbcharge.

With bbcharge active, I can use vmware+winxp and the blackberry software to perform the sync operations. Without it, I cannot. bbcharge is a necessary component to make it work.

LunkHead 02-27-2007 09:32 PM

Note: I do not have winxp....

BUT... You are able to do a complete sync with vmware after installing bcharge?

Kewl!

LunkHead 02-27-2007 11:04 PM

Quote:

Originally Posted by rivviepop
Just a note (trying to tie these two threads together) -- the above RPM is old (I think?) and doesn't use the fancy new CVS code from the Barry project;

You are correct Sir, it does not use the *new* cvs coding from barry....

godzilla8nj 02-28-2007 04:57 PM

Hope this isn't off-topic, but are there any Ubuntu 6.10 users who have already compiled Barry who could give me a hand? I'm trying to get a tethered Blackberry as a modem and would hate to get too sidetracked learning how to compile for my distro. Thanks in advance for any assistance.

LunkHead 02-28-2007 05:54 PM

It's never a bad idea, and it's actually not hard, to do... I'd say read up on how to compile and give it a shot.... You get to learn and play with the BB at the same time! :)

How To Compile A Kernel - The Ubuntu Way | HowtoForge - Linux Howtos and Tutorials

rivviepop 03-02-2007 12:54 AM

Ladies & Gents:

SourceForge.net: Detail: 1672178 - RPM spec file to build barry-bcharge

You can use that now to build a 'barry-bcharge' RPM (for Fedora/Red Hat) right out of the official tarball. The udev rule patch isn't in CVS, so you also have to download it as well (outlined in the above link).

jfanaian 03-28-2007 02:18 PM

I'm trying to install bcharge for my Pearl 8100 but it keeps saying it isn't a perl when I run it. I found out (through lsusb) that my iProduct is actually 4 not 5. I tried changing the constant acordingly but it does not seem to modify the Max Power to 500mA instead of 100mA, even though there seem to be no error.

Here is the output I get after changing the constant to 4:
Code:

Scanning for Blackberry devices...
Found device #005...adjusting charge setting...adjusting Pearl mode to dual...done


rivviepop 03-28-2007 02:48 PM

Quote:

Originally Posted by jfanaian
I'm trying to install bcharge for my Pearl 8100 but it keeps saying it isn't a perl when I run it.

Yeah, it's a problem in the code - it adjusts your current to 500mA just fine, but then running it again says "no Pearl found".

See:
http://sourceforge.net/tracker/index...22&atid=788906

and

http://sourceforge.net/mailarchive/f...me=barry-devel

HTH.

jfanaian 03-28-2007 03:01 PM

Hrm... I tried looking at the patch and ti seems to have similar changes that the patch adds. I have the latest CVS version which already has a detection for 0x0004 which is what seemed to be in the patch so that didn't work, and I didn't find anything useful while reading through the mailing list archive. I sent an email to the mailing list and I will keep playing to see what the cause of this is.
Thanks :)

rivviepop 03-28-2007 03:07 PM

Quote:

Originally Posted by jfanaian
Hrm... I tried looking at the patch and ti seems to have similar changes that the patch adds. I have the latest CVS version which already has a detection for 0x0004 which is what seemed to be in the patch so that didn't work, and I didn't find anything useful while reading through the mailing list archive. I sent an email to the mailing list and I will keep playing to see what the cause of this is.

Basically, CVS is just plain broken. If you download the released 0.6 code then apply the patch, it will add the 0x0004 support and just work; Chris did a lot of re-working with the CVS code and it's actually worse than 0.6 code was; he said he might just undo everything he did in CVS, but I don't know.

jfanaian 03-28-2007 03:13 PM

Ah! Alright I will do that then! Thanks for the tip... I will let you know how it works out.

jfanaian 03-28-2007 03:21 PM

I tried using 0.6 with the patch and it seems to actually do some thinking in the execution unlike before. The only problem is that MaxPower is still 100mA :(

This is the output from running bcharge:
Code:

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

This is what lsusb -v says under the pearl device section:
Code:

Bus 001 Device 011: ID 0fca:0006 Research In Motion, Ltd.
Device Descriptor:
  bLength                18
  bDescriptorType        1
  bcdUSB              1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass        0
  bDeviceProtocol        0
  bMaxPacketSize0        16
  idVendor          0x0fca Research In Motion, Ltd.
  idProduct          0x0006
  bcdDevice            1.06
  iManufacturer          1
  iProduct                4
  iSerial                3
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                9
    bDescriptorType        2
    wTotalLength          32
    bNumInterfaces          1
    bConfigurationValue    1
    iConfiguration          0
    bmAttributes        0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                9
      bDescriptorType        4
      bInterfaceNumber        0
      bAlternateSetting      0
      bNumEndpoints          2
      bInterfaceClass        8 Mass Storage
      bInterfaceSubClass      6 SCSI
      bInterfaceProtocol    80 Bulk (Zip)
      iInterface              4
      Endpoint Descriptor:
        bLength                7
        bDescriptorType        5
        bEndpointAddress    0x85  EP 5 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type              None
          Usage Type              Data
        wMaxPacketSize    0x0040  1x 64 bytes
        bInterval              0
      Endpoint Descriptor:
        bLength                7
        bDescriptorType        5
        bEndpointAddress    0x06  EP 6 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type              None
          Usage Type              Data
        wMaxPacketSize    0x0040  1x 64 bytes
        bInterval              0

Thanks again


All times are GMT -5. The time now is 01:31 PM.

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