RISC OS Open
A fast and easily customised operating system for ARM devices
ROOL
Home | News | Downloads | Bugs | Bounties | Forum | Documents | Photos | Contact us
Account
Forums → General →

USB stack on Raspberry Pi

Subscribe to USB stack on Raspberry Pi 24 posts, 13 voices

 
Jan 17, 2012 4:50pm
Avatar Chris Hall (132) 2924 posts

How is the work going on this. Can anyone help? Will ROOL be at the SouthWest show on 25th February? Will the ROOL pen drives be on sale there? Will there be a RPI on show there? Are these all rhetorical questions?

 
Jan 18, 2012 3:05pm
Avatar Steve Revill (20) 1337 posts

The RISC OS port to RPi is entirely in Adrian Lees’ hands – we’re hoping he can get ROOL a copy so that we can help out but this hasn’t happened thus far. As such, nobody can help with this at the moment.

ROOL are deciding about the South West show – it’s always hard because it’s such a long way and so knocks a lot out of our weekend (and the Friday). Having said that, we’ve not been for a few years so maybe we’re overdue for a visit.

If we go, we’d expect to be selling the USB sticks. We also hope that we’ll have sample RPi hardware that we could show. There are a few other things we could possibly bring along to demo. All in all, the case for us going to the SW Show looks quite strong… :)

 
Feb 20, 2012 12:04pm
Avatar Theo Markettos (89) 757 posts

Adrian hasn’t been able to spend as much time on this as he’d hoped, so we were wondering if anyone else would be interested in working on the RPi USB driver? It would be particularly helpful if there was anyone with experience of the RISC OS/NetBSD USB stack, as that’s the main area where many of us lack experience.

A rundown of the story so far…

The BCM2835 uses a soft IP block from Synopsys’ DesignWare library (DWC), specifically the block is called dwc_usb_2_0_hs_otg_subsystem-ahb_se (“USB 2.0 Hi-Speed OTG Controller Subsystem w/AHB Interface SE”).

There is no public documentation for this, and pretty much zero chance of anyone getting hold of it even with NDA (Adrian has full access, I have access to a few marketing details but not much more). However, there’s a Linux driver written by Synopsys (dwc_usb). The best place to find this driver is the RPi Linux source tree:
https://github.com/raspberrypi/linux

Specifically
https://github.com/raspberrypi/linux/tree/rpi-patches/drivers/usb/host

directories dwc_common_port and dwc_otg.

The Synopsys code is actually under a fairly permissive licence – it’s not GPL, it’s similar to BSD (’don’t sue us if it breaks’ is pretty much the only clause). So this should not be a barrier to porting the code to RISC OS.

The code is really well written, with a nice partition between the work done by the driver (dwc_otg, which is fairly involved, given the host does more work than a conventional EHCI driver), and the interface to Linux (dwc_common_port).

I’ve put a local copy of the code (which is not tracking github so will become out of date) here for you to browse:
http://www.cl.cam.ac.uk/~atm26/ephemeral/rpi/
That has doxygen-generated documentation for dwc_otg and dwc_common_port . In particular I recommend reading the first page of the dwc_common_port doxygen.

Therefore a RISC OS port should probably only need provision of relevant changes to dwc_common_port. The main things I can see are:

  1. Provision of necessary headers to get it to compile
  2. Provision of necessary functions (main issues are wait queues, threads, work queues, tasklets, timers, spinlocks and mutexes – see my post on multithreading )
  3. Interfacing between RISC OS/NetBSD USB stack and the driver. dwc_otg/dwc_otg_hcd_linux.c looks like the place to start.

1 is possible using some external headers that are designed for porting Linux USB (device) drivers to FreeBSD – see linux-kmod-compat website and 20080408 source tarball
I had a brief try building some of the Synopsys code with these headers (on Linux, using GCC, but without Linux system headers) and a good chunk compiles out of the box. However, given the clean-ness of the Synopsys interface it may be simpler just to rewrite it to directly talk to RISC OS, as I think the Linux bits of the headers are only required for the dwc_common_port library.

dwc_common_port includes a variety of crypto functions which I think aren’t used – it appears to also be used for ultrawideband (UWB) and wireless USB (WUSB) drivers where crypto will be an issue, but it isn’t going to be for plain wired USB. So I think these can be ignored.

So… anyone interested in having a go? We can probably arrange hardware for you if necessary.

 
Feb 20, 2012 1:30pm
Avatar Jeffrey Lee (213) 5820 posts

However, given the clean-ness of the Synopsys interface it may be simpler just to rewrite it to directly talk to RISC OS, as I think the Linux bits of the headers are only required for the dwc_common_port library.

I think removing/rewriting the Linux bits would be the best option. There’s no point having an extra API translation layer getting in the way.

So… anyone interested in having a go? We can probably arrange hardware for you if necessary.

Well I’m probably the one with the most experience with the USB stack. Not entirely sure if I want to volunteer for this though; it’s not a particularly easy codebase to work with!

 
Feb 21, 2012 10:52am
Avatar Chris Hall (132) 2924 posts
ROOL are deciding about the South West show – it’s always hard because it’s such a long way and so knocks a lot out of our weekend (and the Friday). Having said that, we’ve not been for a few years so maybe we’re overdue for a visit.

All in all, the case for us going to the SW Show looks quite strong… :)

Shall you be there on Saturday 25th February?

 
Feb 21, 2012 11:28am
Avatar Chris Johnson (125) 720 posts

ROOL are deciding about the South West show – it’s always hard because it’s such a long way

… and it’s even further to come down from Edinburgh, which I shall be doing :)

 
Feb 21, 2012 11:45am
Avatar Trevor Johnson (329) 1652 posts

Edinburgh

Wow! Do you fancy flyposting some trains/stations/motorway services/airports on your way down?

 
Feb 21, 2012 1:05pm
Avatar Dave Higton (281) 668 posts

Well I’m probably the one with the most experience with the USB stack. Not entirely sure if I want to volunteer for this though; it’s not a particularly easy codebase to work with!

I would dearly love to be able to make a contribution to the USB stack. However, the reality is that I have never been able to make sense of the existing, working, RISC OS code base. Nor have I ever been able to take over any existing code of any project.

Coding standards are, I feel, woefully lacking in many OSS projects. Good coding standards, adequately enforced, could be a significant contributor to ease of maintenance.

 
Feb 21, 2012 1:24pm
Avatar Bryan Hogan (339) 427 posts

Just wanted to say Yes, ROOL will be at the SW Show. Time for an update of the News page, which still has them on christmas break!

 
Feb 21, 2012 10:56pm
Avatar Rob Kendrick (86) 56 posts

Dave: Both Linux and NetBSD have extensive, extreme, and strict standards for any code that is to be considered merged. You should have no problem with their sources, and I assume CTL/Pace/whoever did not ruin this when they imported the NetBSD code.

NetSurf too has a strict standard for any newly written code, which includes much of the recent additions such as the CSS and HTML parsers. In fact, most large OSS projects I’m aware of do, beyond media-based ones, which are always horrible.

 
Feb 22, 2012 12:14am
Avatar Chris Johnson (125) 720 posts

Wow! Do you fancy flyposting some trains/stations/motorway services/airports on your way down?

Not sure what this is about, but shall be setting off down the motorway before anything could reach me by post anyway.

 
Feb 22, 2012 7:21pm
Avatar Trevor Johnson (329) 1652 posts

Not to be taken seriously… anyway I was referring to flyposting.

 
Feb 23, 2012 3:23pm
Avatar WPB (1391) 314 posts

Not to be taken seriously…

Trevor, a combination of your obvious earnest desire to promote RISC OS far and wide and the impossibility of rendering sarcasm in text (without faux-html!) led a few people astray it seems! I have to confess I thought you were serious for a while! ;)

 
Feb 23, 2012 3:52pm
Avatar Trevor Johnson (329) 1652 posts

Double-bluff? :-p

Back on topic, I’ll donate something to Update and debug USB stack tonight.

 
Mar 4, 2012 9:50pm
Avatar Tim Powys-Lybbe (200) 6 posts

Done the same too. A fair stash of gold there now, how much longer before someone gets tempted.

 
Mar 5, 2012 8:44am
Avatar Chris Hall (132) 2924 posts

£784 is not exactly a large amount!

 
Mar 7, 2012 1:51am
Avatar Steve Revill (20) 1337 posts

It’s around 1.5 weeks at £15/hour.

 
Mar 10, 2012 8:17am
Avatar Matthew Phillips (473) 400 posts

It’s an awful lot more than nothing, which is what many RISC OS programmers effectively work for. Definitely enough to inform the tax man about!

 
Apr 7, 2012 11:50am
Avatar Chris Hall (132) 2924 posts

It looks like only the developers will have their hands on a Raspberry Pi at the moment so hopefully the USB stack will be sorted out by the time all the compliance testing is done. The delay for compliance testing may therefore be quite good news for the rest of us who just want to run RISC OS on the Pi.

 
Jun 13, 2012 6:05am
Avatar Trevor Johnson (329) 1652 posts

It’s probably already known that the Synopsys drivers burn CPU time. If there are improvements, are they likely to require extensive reworking for RISC OS?

 
Jun 13, 2012 10:51am
Avatar Steve Revill (20) 1337 posts

It’s probably already known that the Synopsys drivers burn CPU time. If there are improvements, are they likely to require extensive reworking for RISC OS?

We have ideas about that – it may not be too much of a problem. Fingers crossed.

 
Jun 13, 2012 1:32pm
Avatar Theo Markettos (89) 757 posts

Yup, you may have noticed that I posted in the Linux kernel mailing list thread linked to by those postings. Arguably RISC OS is in a better position than Linux due to its low level nature… we’ll see what happens.

 
Jun 13, 2012 3:05pm
Avatar Trevor Johnson (329) 1652 posts

Nice one – I did consider checking the mailing list but got distracted. I might’ve guessed you guys would be on the ball!

 
Jul 13, 2012 10:42am
Avatar Dave Higton (1515) 2278 posts

Hoping this is an appropriate thread on which to report it…

USBInfo on the Raspberry Pi seems to get stuck pretty much every time a USB device is removed, and sometimes when one gets added, too. Alt-Break allows it to be stopped. No other damage appears to be done, and USBInfo will run again successfully.

Reply

To post replies, please first log in.

Forums → General →

Search forums

Social

Follow us on and

ROOL Store

Buy RISC OS Open merchandise here, including SD cards for Raspberry Pi and more.

Donate! Why?

Help ROOL make things happen – please consider donating!

RISC OS IPR

RISC OS is an Open Source operating system owned by RISC OS Developments Ltd and licensed primarily under the Apache 2.0 license.

Description

General discussions.

Voices

  • Chris Hall (132)
  • Steve Revill (20)
  • Theo Markettos (89)
  • Jeffrey Lee (213)
  • Chris Johnson (125)
  • Trevor Johnson (329)
  • Dave Higton (281)
  • Bryan Hogan (339)
  • Rob Kendrick (86)
  • WPB (1391)
  • Tim Powys-Lybbe (200)
  • Matthew Phillips (473)
  • Dave Higton (1515)

Options

  • Forums
  • Login
Site design © RISC OS Open Limited 2018 except where indicated
The RISC OS Open Beast theme is based on Beast's default layout

Valid XHTML 1.0  |  Valid CSS

Powered by Beast © 2006 Josh Goebel and Rick Olson
This site runs on Rails

Hosted by Arachsys