[SOLVED]Usb mass storage + bochs

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
pikasoo
Member
Member
Posts: 30
Joined: Sun Sep 02, 2012 11:04 am
Contact:

[SOLVED]Usb mass storage + bochs

Post by pikasoo »

Hi, here i am with my odd question again.

when i try to read on a usb mass storage on bochs it randomly trow this error :
USB MSD handle_data: unexpected mode at USB_TOKEN_IN

i dot get that bug on real hardware so i dont know if its a bug in bochs or a bug on my code, i expect the last one.
since the protocol is prety strait forward i belive it must be some kind of timing problem....

here a log of bochs:

01390770000d[USBMS] Packet contents (in hex):
01390770000d[USBMS] 0x0000 55 53 42 43 69 05 00 00 08 00 00 00 80 00 0A 25
01390770000d[USBMS] 0x0010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
01390770000d[USBMS] command on LUN 0
01390770000d[USBMS] command tag 0x569 flags 00000080 len 10 data 8
01390770000d[USBMS] data in 64/8
01390770000d[USBMS] command complete 0
01390770000d[USBMS] Packet contents (in hex):
01390770000d[USBMS] 0x0000 00 04 00 00 00 00 02 00
01390770000d[USBMS] command status 0 tag 0x569, len 32
01390770000d[USBMS] Packet contents (in hex):
01390770000d[USBMS] 0x0000 55 53 42 53 69 05 00 00 00 00 00 00 00
01392750000d[USBMS] Packet contents (in hex):
01392750000d[USBMS] 0x0000 55 53 42 43 69 05 00 00 00 02 00 00 80 00 0A 28
01392750000d[USBMS] 0x0010 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00
01392750000d[USBMS] command on LUN 0
01392750000d[USBMS] command tag 0x569 flags 00000080 len 10 data 512
01392750000d[USBMS] data in 64/512
01392750000d[USBMS] Packet contents (in hex):
01392750000d[USBMS] 0x0000 33 C0 8E D8 8E C0 8E D0 BC 00 7C 8B F4 BF 00 06
01392750000d[USBMS] 0x0010 B9 00 01 FC F3 A5 EA 1B 00 60 00 0E 1F 06 E8 95
01392750000d[USBMS] 0x0020 00 07 80 3E 97 01 01 74 75 80 3E 97 01 02 74 00
01392750000d[USBMS] 0x0030 C6 06 94 01 00 E8 04 01 BE BE 01 B3 04 F6 04 80
01392840000d[USBMS] data in 64/448
01392840000d[USBMS] Packet contents (in hex):
01392840000d[USBMS] 0x0000 75 0F 83 C6 10 FE CB 75 F4 CD 18 BE 5D 01 E8 FC
01392840000d[USBMS] 0x0010 00 BB 00 7C 06 53 50 55 8B EC C7 46 02 00 00 5D
01392840000d[USBMS] 0x0020 50 55 8B EC C7 46 02 00 00 5D FF 74 0A FF 74 08
01392840000d[USBMS] 0x0030 06 53 50 55 8B EC C7 46 02 01 00 5D 50 55 8B EC
01392930000d[USBMS] data in 64/384
01392930000d[USBMS] Packet contents (in hex):
01392930000d[USBMS] 0x0000 C7 46 02 10 00 5D 16 1F 8B F4 B4 42 CD 13 83 C4
01392930000d[USBMS] 0x0010 10 EB 00 CB C6 06 95 01 00 E8 A0 00 EB 00 BB 00
01392930000d[USBMS] 0x0020 7C 06 53 B8 01 02 B5 00 B1 05 B6 00 B2 80 CD 13
01392930000d[USBMS] 0x0030 C6 06 94 01 01 CB B8 00 F0 8E C0 33 C0 8B F0 BB
01393020000d[USBMS] data in 64/320
01393020000d[USBMS] Packet contents (in hex):
01393020000d[USBMS] 0x0000 FF FF 26 81 3C 53 77 74 08 83 C6 01 4B 75 F3 EB
01393020000d[USBMS] 0x0010 1A 26 81 7C 02 53 6D 74 02 EB EE 26 81 7C 04 69
01393020000d[USBMS] 0x0020 40 74 02 EB E4 83 C6 06 E8 01 00 C3 1E 57 26 8B
01393020000d[USBMS] 0x0030 14 26 8A 44 03 EE 26 8B 44 07 8E D8 26 8B 44 05
01393110000d[USBMS] data in 64/256
01393110000d[USBMS] Packet contents (in hex):
01393110000d[USBMS] 0x0000 8B F8 C7 05 43 58 C7 45 02 5C 00 26 8A 44 02 EE
01393110000d[USBMS] 0x0010 B1 02 8A 65 05 80 FC FF 74 13 80 FC 80 76 0E C7
01393110000d[USBMS] 0x0020 45 02 5D 00 80 EC 80 88 65 05 EE B1 01 26 8B 14
01393110000d[USBMS] 0x0030 26 8A 44 04 EE 5F 1F 88 0E 97 01 C3 BB 00 06 B8
01393200000d[USBMS] data in 64/192
01393200000d[USBMS] Packet contents (in hex):
01393200000d[USBMS] 0x0000 01 03 B5 00 B1 01 B6 00 B2 80 CD 13 C3 AC 3C 00
01393200000d[USBMS] 0x0010 74 0A B4 0E B7 00 B3 07 CD 10 EB F1 C3 4D 69 73
01393200000d[USBMS] 0x0020 73 69 6E 67 20 6F 70 65 72 61 74 69 6E 67 20 73
01393200000d[USBMS] 0x0030 79 73 74 65 6D 00 00 00 00 00 00 00 00 00 00 00
01393290000d[USBMS] data in 64/128
01393290000d[USBMS] Packet contents (in hex):
01393290000d[USBMS] 0x0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
01393290000d[USBMS] 0x0010 46 44 53 54 00 00 3E 02 00 27 00 00 BC 0A 8D 7E
01393290000d[USBMS] 0x0020 67 20 6F 70 65 72 61 74 69 6E 67 20 73 79 73 74
01393290000d[USBMS] 0x0030 65 6D 00 00 00 63 7B 9A C7 91 F8 89 00 00 80 20
01393380000d[USBMS] data in 64/64
01393380000d[USBMS] command complete 0
01393380000d[USBMS] Packet contents (in hex):
01393380000d[USBMS] 0x0000 21 00 07 DF 13 0C 00 08 00 00 00 20 03 00 00 00
01393380000d[USBMS] 0x0010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
01393380000d[USBMS] 0x0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
01393380000d[USBMS] 0x0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA
01394730000d[USBMS] command status 0 tag 0x569, len 16
01394730000d[USBMS] Packet contents (in hex):
01394730000d[USBMS] 0x0000 55 53 42 53 69 05 00 00 00 00 00 00 00
01475280000e[USBMS] USB MSD handle_data: unexpected mode at USB_TOKEN_IN

i put 2 qh in the usb stack: 1 qh for the command then i create 1 qh for the data
when i look at the stack result i get a stall on command and data buffer
but sending the command alone, then the data, i will get a stall only on the data. then command packet apear in the log but still have the error.


FIXED: Just in case some ppl get the same problem, my bug was with bochs only and was a timming problem. normaly a usb frame last 1ms(and i made sure by configuring the controler) so my code was made to let 2+ms to the controler beafor analysing the result and clearing the frame. Problem is that bochs take about 10ms to do 2.5 frame. so i was clearing the curent frame and using previous td/qh memory for some new packet wich was then processed by the controler as part of the old frame... hard to fallow?? i know i had some fun time debuging it :)
Post Reply