element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum libusb and OpenOCD?
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 9 replies
  • Answers 1 answer
  • Subscribers 674 subscribers
  • Views 2022 views
  • Users 0 members are here
  • raspberry_pi
Related

libusb and OpenOCD?

johnbeetem
johnbeetem over 12 years ago

I have a some questions about libusb and OpenOCD.  There might be a better group to ask about these, but a number of people who comment in this group know about these sorts of things.  Besides, I will want to run this stuff on RasPi so it applies.

 

Basically, I'm interested in learning to do low-level USB programming for talking to external USB devices.  I don't want to write a device driver -- I want to do everything from Userland.  From what I've read, libusb appears to be the right software for this, but it's confusing.  Before I get started, I'd like to learn from others' experience.  Here are some specific questions:

 

1.  There are several versions of libusb out there, and it appears to have an interesting FLOSS history.  There's libusb-0.1 which is old, but stable.  There's libusb-1.0 which has a different API, but it's actively being developed.  Then there's libusbx which is a fork of libusb-1.0, but it may have rejoined since libusb.org today lists libusbx-1.0.16 (2013-07-11) as the latest version.  Has anyone here developed with any of version of libusb and has some tips to share?  Also, does anyone here know about libusb history?

 

2.  Is there any better libusb documentation that what's available at libusb.org?  Google found me this this tutorial from Jan 2010, which seems to be a good start.  I'd appreciate any pointers.  There's no point doing "program by experiment" if someone has already done it and written it up.

 

I'm also interested in OpenOCD.  Has anyone here used it at the API level?  I took a quick look at the user guide and the developer documentation, and from a first impression it seems overly complex.  I need to decide if it's worth delving into OpenOCD or whether I'm better off building on my own JTAG code already written.

 

Thank you for any comments you may have.

  • Sign in to reply
  • Cancel
  • shabaz
    0 shabaz over 12 years ago

    Hi John,

     

    There is some information on libusbx here - basically at the time I did have a discussion with the developers (they have a very responsive e-mail group and are very helpful) and they mentioned that the project was created because libusb was slow in improvements and had infrequent releases - so I went with the more 'dynamic' fork :-) @selsinork has provided lots of useful information in the comments at that URL by the way.

    I've not used OpenOCD before however.

     

    EDIT): A google search reveals that there is a kickstarter called 'laika' which looks like pretty much an FTDI chip and the libusb and libftdi code, so that's confirmation that libusb works on the RPI. I couldn't find the schematic however - if it is intentionally unavailable then to me it seems rather mean considering it looks like an educational project. Maybe they do intend on revealing it. Still, the URL mentioned above should be sufficient information for anyone to make their own equivalent easily, since the FTDI chips are so integrated..

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
  • johnbeetem
    0 johnbeetem over 12 years ago in reply to shabaz

    Thank you so much, shabaz.  Your 'blog post is exactly what I need to get started.  I already have an FT2232H Mini-Module (it's abot 60% down on the page) which I've used on Windows 2000 with FTDI drivers.  Now that my main development system is Ubuntu, I'll switch my code over to libftdi.  One nice thing about libftdi is that I can let it worry about which libusb API to use.  Eventually I'll "eliminate the middleman" and go directly to libusb, but the first device I need to talk to is the FT2232H so libftdi is the obvious way to do.  Your 'blog will be very helpful.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • shabaz
    0 shabaz over 12 years ago in reply to johnbeetem

    Hi John,

     

    You're welcome! I hope it helps.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 12 years ago

    John Beetem wrote:

     

    I have a some questions about libusb and OpenOCD.  There might be a better group to ask about these, but a number of people who comment in this group know about these sorts of things.  Besides, I will want to run this stuff on RasPi so it applies.

    I can see no reason why libusb won't work on the Pi, but haven't specifically tried myself. Not sure if the combination of OOCD on a low powered Pi with known usb problems would fill me with confidence though.

    I don't want to write a device driver -- I want to do everything from Userland.

    You mean you want to write a userspace device driver image

    1.  There are several versions of libusb out there, and it appears to have an interesting FLOSS history.  There's libusb-0.1 which is old, but stable.  There's libusb-1.0 which has a different API, but it's actively being developed.  Then there's libusbx which is a fork of libusb-1.0, but it may have rejoined since libusb.org today lists libusbx-1.0.16 (2013-07-11) as the latest version.  Has anyone here developed with any of version of libusb and has some tips to share?  Also, does anyone here know about libusb history?

    currently I'd chose libusbx-1.0, there's a compatability layer as a separate package for anything that needs libusb-0.1.

     

    for various obvious reasons, you can't have both libusb and libusbx installed in parallel, libusbx is trying to be a drop-in replacement and as such uses exactly the same soname, so you have to make a choice.

    As usual with forks, the background is political, so some research on the history is probably a good idea before making a choice.

    libusbx.org is at 1.0.17, so I'm not sure what libusb.org having 1.0.16 shows.

    Looking at the source repo on libusb.org shows the last change here http://libusb.org/changeset/7634714aa696175b08016b6f2185a75a2f55a113/libusb/ which was a year ago and their repo has a last tag of 1.0.9 - I think this 'no progress' was a large part of the reason for the libusbx fork.

     

    A little mailing list search reveals this:

    http://marc.info/?l=libusb-devel&m=137088260618024&w=2

    so reading between the lines, the original libusb is dead and libusbx is the new libusb. In my mind, this is a good thing, especially as the github direction they seem to want to take is far better than the existing Trac (no, I'm not a great fan of github either, but it mostly works and git trees are easy to clone from there).

    2.  Is there any better libusb documentation that what's available at libusb.org?  Google found me this this tutorial from Jan 2010, which seems to be a good start.  I'd appreciate any pointers.  There's no point doing "program by experiment" if someone has already done it and written it up.

     

    I'd probably try http://libusbx.sourceforge.net/api-1.0/index.html not sure how good it is, but it has to be better than the older stuff.

    Most of what I've done has been with libftdi, so a lot of what little I've learned has been from looking at how libftdi uses libusb, nothing like a working example image.  I've also found it fairly easy to move this sort of code between linux and windows.

     

    I'm also interested in OpenOCD.  Has anyone here used it at the API level?

    Not yet, I've still not finished my OOCDLink-h based design as I haven't really found a need so far.

     

    Certainly have a read at the discussion in the blog post shabaz linked to as well

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • Former Member
    0 Former Member over 12 years ago in reply to johnbeetem

    John Beetem wrote:

     

    Now that my main development system is Ubuntu, I'll switch my code over to libftdi.

    I successfully did libftdi / libusb code on windows with reference to this blog post:

    http://embedded-funk.blogspot.co.uk/2013/03/libftdi-under-windows.html

     

    biggest problem for me was working out how to get a windows app that didn't open any sort of window, but that's another story...

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • johnbeetem
    0 johnbeetem over 12 years ago

    OK, I'm making progress.  I got the "simple.c" and "find_all.c" examples working, so libftdi is able to see my FT2232H Mini-Module.  I'm still on Ubuntu 11.10 [*] so it apt-got libftdi 0.19 and still has libusb-0.1, but that should be OK for now.

     

    I didn't have to uninstall ftdi_sio explicitly: libftdi did that for me automatically.  I did have to sudo, which is an annoyance.

     

    Onward to MPSSE, JTAG, and eternal youth!

     

    [*] Why Ubuntu 11.10?  Two reasons: (1) I hate upgrading software and (2) I used a Univac 1110 in my undergrad days, so nostalgia I guess.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 12 years ago in reply to johnbeetem

    John Beetem wrote:

     

    I did have to sudo, which is an annoyance.

    https://github.com/libusbx/libusbx/wiki/FAQ#wiki-Can_I_run_libusbx_applications_on_Linux_without_root_privilege

     

    however, with an old enough setup it may be using /proc/bus/usb instead of /dev/bus/usb and so different steps need to be taken.  I don't follow ubuntu, so have no idea what needs done for 11.10, but I'd be surprised if it's still using the /proc interface.  I have a vague memory that you could compile libusb in a way that disabled the new interface and that I had to do that at one point when libusb wasn't keeping up with kernel changes.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • johnbeetem
    0 johnbeetem over 12 years ago in reply to johnbeetem

    johnbeetem wrote:

     

    Onward to MPSSE, JTAG, and eternal youth!

    Yes!  MPSSE and JTAG work very nicely.  It's so nice to be talking to my Mini-Module from GNU/Linux instead of Windows, and without the obscurity of proprietary drivers.  I really prefer the libftdi calls to FTDI's.

     

    But now for something completely different... PSoC5!  (to be continued...)

     

    Thank you again for your help.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • shabaz
    0 shabaz over 12 years ago in reply to johnbeetem

    Oh, awesome!!

     

    That's good news. I didn't get a chance to try this out at the time but I was wondering how easy/hard it was to use, or if I should stick with the few off-the-shelf USB-JTAG devices that I have. Glad it works!!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube