Implementing a USB Driver


84 posts   Page 2 of 4   1, 2, 3, 4
by jamesh » Tue Jan 01, 2013 7:57 pm
Rene_is_I wrote:dwelch67 wrote:
Bare metal, that is for folks that are willing to work for their education and results anyway, dont want to take the lazy path.

Agreed but there is a limit of what is realistically achievable if the facts and figures are kept secret.


As with anything in the whole wide world. The Foundation has not control over releasing the USB docs/RTL, and neither does Broadcom. "horse dead a Flogging" - rearrange as necessary.
Volunteer at the Raspberry Pi Foundation, helper at Picademy September and October 2014.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 12163
Joined: Sat Jul 30, 2011 7:41 pm
by Rene_is_I » Tue Jan 01, 2013 8:23 pm
jamesh wrote:
"horse dead a Flogging" - rearrange as necessary.


Can't, algorithm is protected by a NDA and not available. :)
Posts: 172
Joined: Tue Dec 25, 2012 12:52 pm
by mark_3094 » Fri Jan 04, 2013 11:26 am
I've been reading some manuals for other USB chips to try to understand some of the RPi USB driver, and I've got another question about USB hardware in general.

It seems that the Synopsys SoC can be used in Host or Device mode. As I understand it, this is because the chip can be incorporated into either an end device (eg, a printer) or into a host (eg, the RPi).

Does this mean that any registers that are listed as 'device' in those manuals would not apply to a 'host' such as the Raspberry Pi?


Thanks
Posts: 74
Joined: Mon Jul 02, 2012 8:38 am
Location: Australia
by Chadderz » Fri Jan 04, 2013 11:30 am
Yes, there are several banks of registers in the Synopsys SoC: core, host, device, power. The device block is completely useless on the Pi.
User avatar
Posts: 63
Joined: Thu Aug 30, 2012 12:50 pm
Location: Cambridge, UK
by ghans » Fri Jan 04, 2013 11:46 am
I know that OTG mode is not possible due to missing pins ,but
does you statement refer to the propability of Device mode
on the Model A ? Am I confusing things ?


ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org
Posts: 4771
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany
by mark_3094 » Fri Jan 04, 2013 8:47 pm
ghans wrote:I know that OTG mode is not possible due to missing pins ,but
does you statement refer to the propability of Device mode
on the Model A ? Am I confusing things ?


Sorry, I don't know what you mean about device mode on Model A...


Chadderz wrote:Yes, there are several banks of registers in the Synopsys SoC: core, host, device, power. The device block is completely useless on the Pi.


This mostly answers my question. I just wanted to be sure I could ignore anything device specific. What if something is marked as 'device only' in the core block. Can that be ignored as well?
Posts: 74
Joined: Mon Jul 02, 2012 8:38 am
Location: Australia
by Chadderz » Fri Jan 04, 2013 8:50 pm
mark_3094 wrote:This mostly answers my question. I just wanted to be sure I could ignore anything device specific. What if something is marked as 'device only' in the core block. Can that be ignored as well?

Yes, they're safe to ignore.
User avatar
Posts: 63
Joined: Thu Aug 30, 2012 12:50 pm
Location: Cambridge, UK
by DavidS » Sat Jan 05, 2013 12:05 am
HAs any one looked at the RISC OS USB stuff yet? I am not sure which license the USB falls under, though at very least it should be a start in creating the documentation for the USB hardware.
ARM Assembly Language: For those that want: Simple, Powerful, Easy to learn, and Easy to debug.
User avatar
Posts: 1251
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
by mark_3094 » Sat Jan 05, 2013 9:39 am
I have completed some unofficial documentation on this controller.

You can find it here:
http://networkdirection.net/index.php?option=com_content&view=article&id=106:rasperry-pi-usb-controller&catid=45:raspberry-pi&Itemid=54

It still needs more added to it, but it should be useful to someone.
Posts: 74
Joined: Mon Jul 02, 2012 8:38 am
Location: Australia
by Rene_is_I » Sat Jan 05, 2013 9:56 am
Hi mark_3094

Nice piece of work, thank you.
I do however have a question about page 26, is it correct or am I missing something?
It starts off by stating that the BCM2835 sets the direction (first entry) then the BCM numbers
increase up to BCM2850.
Are there that many chips?
Posts: 172
Joined: Tue Dec 25, 2012 12:52 pm
by jamesh » Sat Jan 05, 2013 10:13 am
Rene_is_I wrote:Hi mark_3094

Nice piece of work, thank you.
I do however have a question about page 26, is it correct or am I missing something?
It starts off by stating that the BCM2835 sets the direction (first entry) then the BCM numbers
increase up to BCM2850.
Are there that many chips?


That's a typo, there are no chips with those numbers.
Volunteer at the Raspberry Pi Foundation, helper at Picademy September and October 2014.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 12163
Joined: Sat Jul 30, 2011 7:41 pm
by ghans » Sat Jan 05, 2013 10:39 am
@mark_3094
I heard that the model A was capable of acting as USB device.
I asked Chadderz if his statement was referring to this.

The guide looks useful to me. Could you put it on the Wiki for
others to extend and correct ?

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org
Posts: 4771
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany
by mark_3094 » Sat Jan 05, 2013 11:25 am
jamesh wrote:That's a typo, there are no chips with those numbers.


There are probably lots of inaccuracies. I have pieced this together as best as I could under the circumstances.
I'll look into it and see if I can fix it.

ghans wrote:Could you put it on the Wiki for others to extend and correct ?


I'd be happy to do this. Not sure of the procedure to do it though. Can I create and edit Wiki articles? Is there a guide I should read first?
Posts: 74
Joined: Mon Jul 02, 2012 8:38 am
Location: Australia
by mark_3094 » Sat Jan 05, 2013 11:40 am
OK, I see the typo now. I have fixed it and uploaded a new version.

I used Excel to document all the data, and I copied the cells down, which automatically incremented the processor number.

All good now
Posts: 74
Joined: Mon Jul 02, 2012 8:38 am
Location: Australia
by Rene_is_I » Sat Jan 05, 2013 12:11 pm
Thanks mark_3094.
It may well have inaccuracies but for now it's a good start not only for driver development but
also simpler things like detecting if a device (and which type) is connected to a USB port.

As regards the wiki, the only down side is if others change/contribute/edit things too eagerly
without testing them first, it will quickly become a case of too many cooks.

Why not include an email address which you can setup especially for this and ask people for
changes/contributions this way and via this forum.
You can include the email address in the actual document.
That way there is only one person changing the "official" unofficial guide.
Posts: 172
Joined: Tue Dec 25, 2012 12:52 pm
by phil95 » Sat Jan 05, 2013 4:31 pm
@mark_3094
Hello, I have tried to download
"Rasperry Pi - USB Controller"
"Written by Luke Robertson"
But I have only these 2 lines, no more text.
Any explanation ?
regards
Philippe
Posts: 121
Joined: Wed Sep 12, 2012 8:10 am
Location: Paris
by 9pi » Sat Jan 05, 2013 5:36 pm
DavidS wrote:HAs any one looked at the RISC OS USB stuff yet?
The RISC OS usb host controller driver is essentially a copy of the linux driver.
Posts: 31
Joined: Sat Aug 11, 2012 6:14 pm
by mark_3094 » Sat Jan 05, 2013 9:35 pm
phil95 wrote:@mark_3094
Hello, I have tried to download
"Rasperry Pi - USB Controller"
"Written by Luke Robertson"
But I have only these 2 lines, no more text.
Any explanation ?
regards
Philippe


You've probably downloaded the HTML page. The link above goes to a web page, which has a link to the PDF. I have done it this way so I can update the document without having to change the link on the forum.
This way the forum link will not go stale.
Posts: 74
Joined: Mon Jul 02, 2012 8:38 am
Location: Australia
by mark_3094 » Sat Jan 05, 2013 10:49 pm
v1.02
Updated a few initial values, thanks to Richard Miller from Plan 9
Posts: 74
Joined: Mon Jul 02, 2012 8:38 am
Location: Australia
by 9pi » Sun Jan 06, 2013 9:41 am
jamesh wrote:There's a lot of code already in this driver - it would be a brave man who attempted to completely rewrite it although some will try, certainly the bare metal people!
Rewriting 50,000+ lines of code might take bravery, but ignoring the linux driver and just writing a new and simpler one from scratch (as I did for Plan 9) is a more manageable task.
Posts: 31
Joined: Sat Aug 11, 2012 6:14 pm
by Rene_is_I » Sun Jan 06, 2013 11:09 am
9pi wrote:Rewriting 50,000+ lines of code might take bravery, but ignoring the linux driver and just writing a new and simpler one from scratch (as I did for Plan 9) is a more manageable task.


Absolutely, especially if one does not need all the features such as support for cameras,
scanners, and a whole bunch of other peripherals.
A cut down version with just keyboard, mouse and perhaps HDD support would be more then adequate
for many experimental OS's.

If I'm not mistaken, DexOS is busy writing one for his DexBasic.
Posts: 172
Joined: Tue Dec 25, 2012 12:52 pm
by DavidS » Sun Jan 06, 2013 12:43 pm
9pi wrote:The RISC OS usb host controller driver is essentially a copy of the linux driver.


Ok, Thank you for saving me the time of trying to reverse engineer that. Unfortunately most Linux drivers have way to much unneeded code, as well as external dependencies that are just as bad.

I had thought if the RISC OS driver was developed separately from the Linux driver it should be easier to understand.
ARM Assembly Language: For those that want: Simple, Powerful, Easy to learn, and Easy to debug.
User avatar
Posts: 1251
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
by DavidS » Sun Jan 06, 2013 12:45 pm
mark_3094 wrote:I have completed some unofficial documentation on this controller.
... ...
It still needs more added to it, but it should be useful to someone.

Nice thank you much.
ARM Assembly Language: For those that want: Simple, Powerful, Easy to learn, and Easy to debug.
User avatar
Posts: 1251
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
by 9pi » Sun Jan 06, 2013 1:52 pm
DavidS wrote:I had thought if the RISC OS driver was developed separately from the Linux driver it should be easier to understand.
There's also a freebsd driver now, which appears to be all original code. It's a lot smaller and clearer to read than the linux one. Looks like it will support isochronous endpoints too (needed for audio cards), which the Plan 9 driver doesn't do yet. Google for "dev/usb/controller/dwc_otg.c"
Posts: 31
Joined: Sat Aug 11, 2012 6:14 pm
by tritonium » Sun Jan 06, 2013 4:29 pm
mark_3094 wrote:
phil95 wrote:@mark_3094
Hello, I have tried to download
"Rasperry Pi - USB Controller"
"Written by Luke Robertson"
But I have only these 2 lines, no more text.
Any explanation ?
regards
Philippe


You've probably downloaded the HTML page. The link above goes to a web page, which has a link to the PDF. I have done it this way so I can update the document without having to change the link on the forum.
This way the forum link will not go stale.


Well I too can find nothing to read - the link shows an empty box???

Dave
Posts: 78
Joined: Tue Jan 03, 2012 7:10 pm