enumarating USB device
- naiksidd_85
- Member
- Posts: 76
- Joined: Thu Jan 17, 2008 1:15 am
enumarating USB device
hi all,
can any one please help me as to how can I enumerate and interact with the USB devices?
I have gone through the wiki it says that I will have to read the HID but i have no idea as to how it should be done also I am in process of detecting all the devices. For rest of the devices I have used the port information to validate the presence by sending commands to the port.
but as the USB works on shared bus I have no idea how it should be don
can any one please help me as to how can I enumerate and interact with the USB devices?
I have gone through the wiki it says that I will have to read the HID but i have no idea as to how it should be done also I am in process of detecting all the devices. For rest of the devices I have used the port information to validate the presence by sending commands to the port.
but as the USB works on shared bus I have no idea how it should be don
Learning a lot these days THANKS to OSdev users
As I understand it, USB is extremely difficult and not many hobbyists have it working.
I believe that Dex has it, but was unwilling to share code/information due to it being so difficult and it's what sets his OS apart from the rest. I totally understand this view, and no doubt would feel the same had I implemented it!
I suggest a thorough read of the manuals and specifications, along with packet sniffing maybe. Tutorials won't help you here!
I believe that Dex has it, but was unwilling to share code/information due to it being so difficult and it's what sets his OS apart from the rest. I totally understand this view, and no doubt would feel the same had I implemented it!
I suggest a thorough read of the manuals and specifications, along with packet sniffing maybe. Tutorials won't help you here!
I think that's just an urban myth started by those who have created a USB stack and propagated by those too lazy to try. But that's just my take, I admit to not having tried it myself.JamesM wrote:As I understand it, USB is extremely difficult and not many hobbyists have it working.
I really doubt whether USB is "extremely difficult" compared to all the other difficult stuff you have to deal with when coding an OS. The most difficult part comes, I think, in designing a proper stack, with proper driver layering etc., and integrating that with the other drivers (e.g. USB drive vs. ATA, USB keyboard vs. PS/2, etc.).
JAL
That's pretty much my opinion too. As I understand it, you need one of two drivers installed to interface with one of the common USB chipsets. After that, it's 'just' a matter of sending packets to communicate with the devices. For common device classes such as HID and Mass Storage, I don't see why this isn't possible in a basic hobby OS.jal wrote:I think that's just an urban myth started by those who have created a USB stack and propagated by those too lazy to try.
Cheers,
Adam
-
- Member
- Posts: 134
- Joined: Thu Aug 18, 2005 11:00 pm
- Location: Sol. Earth. Europe. Romania. Bucuresti
- Contact:
Yes, USB is pretty easy to be done.
Once I started coding it was done in 2 (two) weekend days.
And my OS (Sol_OS) has it now, Menuet has it now... Octa OS had it a long time ago .... hence it is not so hard for a "hobby" OS ...
Start coding!
(and read the documentations/specifications very carefully...every comma...)
Once I started coding it was done in 2 (two) weekend days.
And my OS (Sol_OS) has it now, Menuet has it now... Octa OS had it a long time ago .... hence it is not so hard for a "hobby" OS ...
Start coding!
(and read the documentations/specifications very carefully...every comma...)
Ambition is a lame excuse for the ones not brave enough to be lazy; Solar_OS http://www.oby.ro/os/
-
- Member
- Posts: 1600
- Joined: Wed Oct 18, 2006 11:59 am
- Location: Vienna/Austria
- Contact:
*shrugs*
I reckon that's something I'm gonna do on one of the days of free time which are to approach ...
I'll dissect the visopsys source and take a Look at what andy mclaughlin has done in order to learn.
Just have no time currently with ongoing studying and onstanding diploma thesis.
I reckon that's something I'm gonna do on one of the days of free time which are to approach ...
I'll dissect the visopsys source and take a Look at what andy mclaughlin has done in order to learn.
Just have no time currently with ongoing studying and onstanding diploma thesis.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
BlueillusionOS iso image
-
- Member
- Posts: 134
- Joined: Thu Aug 18, 2005 11:00 pm
- Location: Sol. Earth. Europe. Romania. Bucuresti
- Contact:
To help the OP...
The brief sequence of operations is like this:
1) Find Host controller type and info and IO addr via PCI enumeration
2) Reset Host , reset Port
3) Check Port status to detect device insertion, enable port.
4) Get Device Descriptor of device
5) Get Config Descriptor of Device
6) Set Address of device
7) Set Configuration of Device
Device is ready to accept communications. Protocol depends on device type.
From now on commands depend on device type but are sent and received in the same way as used in step 4,5,6,7.
For those steps (starting from 4) you will have to setup Queue Heads and Transfer Descriptors linked lists in memory and populate them with valid data and inform the Host controller about them in order to make an USB transaction work.
Specific detail might depend on Host controller type: OHCI UHCI EHCI. My advice: start with UHCI.
For Mass Storage device (USB memory stick) you will have to send specific commands wrapped in CBW and CBS structures.
In this case you also have to check the SCSI commands: Inquiry, Get_Capacity and Read_10 or Write_10.
The brief sequence of operations is like this:
1) Find Host controller type and info and IO addr via PCI enumeration
2) Reset Host , reset Port
3) Check Port status to detect device insertion, enable port.
4) Get Device Descriptor of device
5) Get Config Descriptor of Device
6) Set Address of device
7) Set Configuration of Device
Device is ready to accept communications. Protocol depends on device type.
From now on commands depend on device type but are sent and received in the same way as used in step 4,5,6,7.
For those steps (starting from 4) you will have to setup Queue Heads and Transfer Descriptors linked lists in memory and populate them with valid data and inform the Host controller about them in order to make an USB transaction work.
Specific detail might depend on Host controller type: OHCI UHCI EHCI. My advice: start with UHCI.
For Mass Storage device (USB memory stick) you will have to send specific commands wrapped in CBW and CBS structures.
In this case you also have to check the SCSI commands: Inquiry, Get_Capacity and Read_10 or Write_10.
Ambition is a lame excuse for the ones not brave enough to be lazy; Solar_OS http://www.oby.ro/os/
Here my two cents,
First i would say that the USB stack is one of the hardest thing a Hobby OS maker would need to code, dew in part to lack of good info (eg: the main doc are encrypted and have been written by a committees).
Example of this is that the OS's mentioned eg: menuet, sol_OS, Octa are made by the most experienced OS Dev's.
Second, i did not release the code because DexOS was closed source (as are most of the above OS's).
But now DexOS is open source, there is some start USB code, that will get coders started on my web Site and has been there for some weeks.
http://dex4u.com/download.htm
Its called USB.zip
And other than the USB doc you will find this link usefull http://www.usbmadesimple.co.uk/index.html
PS: Linux codes know there stuff, how long as it took to get good USB support on linux ? and why if its so easy.
First i would say that the USB stack is one of the hardest thing a Hobby OS maker would need to code, dew in part to lack of good info (eg: the main doc are encrypted and have been written by a committees).
Example of this is that the OS's mentioned eg: menuet, sol_OS, Octa are made by the most experienced OS Dev's.
Second, i did not release the code because DexOS was closed source (as are most of the above OS's).
But now DexOS is open source, there is some start USB code, that will get coders started on my web Site and has been there for some weeks.
http://dex4u.com/download.htm
Its called USB.zip
And other than the USB doc you will find this link usefull http://www.usbmadesimple.co.uk/index.html
PS: Linux codes know there stuff, how long as it took to get good USB support on linux ? and why if its so easy.
Because in the early days, USB was far from standard, and many devices didn't adhere to the standards. Nowadays, all devices adhere, and are far easier to communicate with (or so I've been told). Making a proper USB stack is difficult, just as making a proper networking stack is, or a proper VFS (and I mean a proper one), as it's about OS design, not implementation. But simple communication with a USB device, that's not the most difficult thing ever.Dex wrote:PS: Linux codes know there stuff, how long as it took to get good USB support on linux ? and why if its so easy.
JAL
- naiksidd_85
- Member
- Posts: 76
- Joined: Thu Jan 17, 2008 1:15 am
- naiksidd_85
- Member
- Posts: 76
- Joined: Thu Jan 17, 2008 1:15 am
ok I went through USB 2.0 specs. I think i should first try to communicate with the USB controller. Also I a have gone through the Data structures and register process.
I want to know how do i find the base address or rather the memory area where USB is mapped.
I also went through the DEX code but am afraid did not understand much.
I know this is very childish question but need to complete it at any cost and want to contribute atleast some thing on this forum
I want to know how do i find the base address or rather the memory area where USB is mapped.
I also went through the DEX code but am afraid did not understand much.
I know this is very childish question but need to complete it at any cost and want to contribute atleast some thing on this forum
Learning a lot these days THANKS to OSdev users