flat assembler
Message board for the users of flat assembler.

Index > OS Construction > UHCI IN Transfert Descriptor fail

Author
Thread Post new topic Reply to topic
N-LG



Joined: 14 Feb 2019
Posts: 40
Location: france
N-LG 06 Oct 2019, 17:28
I'm trying to program a UHCI, I managed for the moment to send the change of address command and it works
I try to send a request to read the main descriptor, the function is sent without problems but impossible to send a function IN the transfer descriptor is marked STALL as soon as I activate it

when I make an IN of 8 byte on the endpoint 0 I have 18800000h on the "TD control and status dword" and 00E00069h on the "TD token" and the controller immediately passes the "TD control and status dword" has the value 184007FFh

and I do not understand what's wrong, I fill the td pretty much in the same way the td for a SETUP (except the PID course) and it works

edit: the setup data i send just before is 80h,06h,01h,00h,00h,00h,14h,00h
Post 06 Oct 2019, 17:28
View user's profile Send private message Reply with quote
BAiC



Joined: 22 Mar 2011
Posts: 272
Location: California
BAiC 07 Oct 2019, 07:37
I don't know if this is your problem but I'm going to say it just in case.....

there is a "Chicken-or-the-egg" problem with USB. you need to know the Max Packet Size of the DEVICE before you issue any packets to/from the device. the problem is that the Max Packet Size is a field in the Device Descriptor that you need to issue packets to get. hence the chicken/egg.

the Max Packet Size field is in the 7th byte of the Device Descriptor: send a request for the first 8bytes of the Device Descriptor and validate the Transfer Length received in the UHCI data structure to ensure 8 bytes were read before any potential error (an error wont necessarily occur). then use the Max Packet Size field to read in the full descriptor.

Stefan
Post 07 Oct 2019, 07:37
View user's profile Send private message Visit poster's website Reply with quote
N-LG



Joined: 14 Feb 2019
Posts: 40
Location: france
N-LG 07 Oct 2019, 16:35
i try to do a read of only 8 bytes of descriptor but it doesnt work
i test different usb device and all doesnt work and one devide doesnt accept my setup frame, so i have a doubt whit the format of the setup frame and i test to reverse the wLength in MSB first format but it doesnt work too

do you think the setup frame i use is good?
Post 07 Oct 2019, 16:35
View user's profile Send private message Reply with quote
QuarkMan



Joined: 21 Sep 2019
Posts: 6
Location: Suzano - São Paulo - Brasil
QuarkMan 07 Oct 2019, 18:22
If you are trying to do something similar to:
Code:
in rax, dx    

Here is your error, because x86 cannot read/write 8 Bytes at time, the maximum is 4 Bytes.
Post 07 Oct 2019, 18:22
View user's profile Send private message Reply with quote
N-LG



Joined: 14 Feb 2019
Posts: 40
Location: france
N-LG 07 Oct 2019, 19:24
read data from usb device is diffrent than reading I/O port, its more complex
Post 07 Oct 2019, 19:24
View user's profile Send private message Reply with quote
BAiC



Joined: 22 Mar 2011
Posts: 272
Location: California
BAiC 07 Oct 2019, 20:10
QuarkMan wrote:
If you are trying to do something similar to:
Code:
in rax, dx    

Here is your error, because x86 cannot read/write 8 Bytes at time, the maximum is 4 Bytes.


ROTFLMAO

_________________
byte me.
Post 07 Oct 2019, 20:10
View user's profile Send private message Visit poster's website Reply with quote
BAiC



Joined: 22 Mar 2011
Posts: 272
Location: California
BAiC 07 Oct 2019, 20:17
N-LG wrote:
i try to do a read of only 8 bytes of descriptor but it doesnt work
i test different usb device and all doesnt work and one devide doesnt accept my setup frame, so i have a doubt whit the format of the setup frame and i test to reverse the wLength in MSB first format but it doesnt work too

do you think the setup frame i use is good?


I use an expression of identifiers for my SETUP packet so I wouldn't recognize the 8 byte numeric string offhand.

I suggest creating identifiers for each option instead of using literal numbers. it serves to expose bugs that are very difficult to see when reduced to numbers.

edit: I just looked at my early device descriptor retrieval code and it's a combination of identifiers and literals... oops.

Code:
 mov rdi, 18 shl (8*6) + 0 shl (8*4) + usb.wValue.DEVICE shl (8*3) + 0 shl (8*2) + usb.bRequest.GET_DESCRIPTOR + 1 shl 7 + 0 shl 5 + 0 shl 0    

_________________
byte me.
Post 07 Oct 2019, 20:17
View user's profile Send private message Visit poster's website Reply with quote
N-LG



Joined: 14 Feb 2019
Posts: 40
Location: france
N-LG 07 Oct 2019, 20:44
in my code i use this:

mov byte[usb_commande],10000000b ;bmRequestType
mov byte[usb_commande+1],6 ;bRequest (ici get descriptor)
mov byte[usb_commande+2],1 ;LSB wValue (type)
mov byte[usb_commande+3],0 ;MSB wValue (index)
mov word[usb_commande+4],0 ;wIndex
mov word[usb_commande+6],18 ;wLength

i have a doubt about the word of the structure's command, in assembly we use LSB first but it seem to be a MSB first in the setup structure
Post 07 Oct 2019, 20:44
View user's profile Send private message Reply with quote
BAiC



Joined: 22 Mar 2011
Posts: 272
Location: California
BAiC 07 Oct 2019, 20:51
usb.wValue.DEVICE = 1
usb.bRequest.GET_DESCRIPTOR = 6 shl 8
Post 07 Oct 2019, 20:51
View user's profile Send private message Visit poster's website Reply with quote
BAiC



Joined: 22 Mar 2011
Posts: 272
Location: California
BAiC 07 Oct 2019, 20:53
you've got the wValue backwards
Post 07 Oct 2019, 20:53
View user's profile Send private message Visit poster's website Reply with quote
BAiC



Joined: 22 Mar 2011
Posts: 272
Location: California
BAiC 07 Oct 2019, 21:02
LOL. my code doesn't properly express what that field is... oops..

wValue is being used as a two byte field. one byte is the Descriptor Type and the other is the Descriptor Index.
Post 07 Oct 2019, 21:02
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.