User avatar
Cycl0ne
Posts: 102
Joined: Mon Jun 25, 2012 8:03 am

[BareMetal] USB

Sat Jul 07, 2012 5:45 am

Hi,

Im thinking of writing an own USB Stack for my little bare metal project. What makes me a bit dizzy: What kind of controller sits on the Raspberry PI (not meaning the manufacturer). I know there is EHCI, OHCI, UHCI Standard. But when I have a look at the synopsys site, I only read: USB2.0 and perhaps OTG and sometimes AMBA, but no sign on the standard used.

Next thing, in the BCM Manual it refers to the site of synopsys, but as far as i can see, the documents there are only for registered users with "special" access. Anyone have a document on the USB with ports and how they work? Or is it again a "digging" in the linux source thing?

Thanks for the help.

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: [BareMetal] USB

Sat Jul 07, 2012 6:00 am

Contact synopsys, but I doubt if you'll get any docs. It's digging time.

There's a *BSD driver too

User avatar
Cycl0ne
Posts: 102
Joined: Mon Jun 25, 2012 8:03 am

Re: [BareMetal] USB

Sat Jul 07, 2012 8:03 am

Hmm,

Raspi Linux Source on Git :
#define DWC_DRIVER_VERSION "2.90b 6-MAY-2010"
#define DWC_DRIVER_DESC "HS OTG USB Controller driver"

Driver Version on Synopsys Page:

Description USB 2.0 Hi-Speed OTG Linux Software
Name dwc_usb_2_0_hs_otg_linux_software
Version 2.94a

Perhaps this solves some problems I read on another Thread about 8000 Irqs a sec.

Still diggin ;)

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm
Contact: Website

Re: [BareMetal] USB

Sat Jul 07, 2012 12:21 pm

I know you and many other bare metal coders do not want to hear this.
But writing a bare metal USB stack is a wast of time.
I have written usb stack for x86 in full asm and had lots of doc's and it took a long time, not only to code it, but to debug its.
You get problem like this device will work, but this one will not.
Plus the idea of a bare metal usb, that at best takes 20% of cpu is a bad idea.

Save yourself a lot of work and buy one of these.
http://www.hobbytronics.co.uk/usb-host-board
Batteries not included, Some assembly required.

User avatar
Cycl0ne
Posts: 102
Joined: Mon Jun 25, 2012 8:03 am

Re: [BareMetal] USB

Sat Jul 07, 2012 7:12 pm

Here Dexos,

thats cool. I dont need to get stuck with an own USB Stack ;-)
How am i going to get this thing on the RASPI?

Btw: USB is not soooooooooo fuzzy.. if you have the right docs.. look at this book here:

http://www.amazon.de/USB-The-Universal- ... 212&sr=8-1

Its from someone whos also coding bare metal in C (not asm ;-) and its really cool described. at the pc i have the first steps taken and my EHCI Detection works really cool.
And to Quote the OSDEV.org People: Real Man code Real USB Stacks on their own :lol:

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5708
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: [BareMetal] USB

Sat Jul 07, 2012 8:32 pm

Cycl0ne wrote:Hmm,

Raspi Linux Source on Git :
#define DWC_DRIVER_VERSION "2.90b 6-MAY-2010"
#define DWC_DRIVER_DESC "HS OTG USB Controller driver"

Driver Version on Synopsys Page:

Description USB 2.0 Hi-Speed OTG Linux Software
Name dwc_usb_2_0_hs_otg_linux_software
Version 2.94a

Perhaps this solves some problems I read on another Thread about 8000 Irqs a sec.

Still diggin ;)
We have had 2.94a running on Pi, but it locked up just running netcat, so we've stuck with 2.90.
However it is possible that once that lockup is fixed things might be better, although I'm certain it still had the 8000 irqs per second.

If anyone wanted to investigate we can provide the Pi port of 2.94a.

asb
Forum Moderator
Forum Moderator
Posts: 853
Joined: Fri Sep 16, 2011 7:16 pm
Contact: Website

Re: [BareMetal] USB

Sat Jul 07, 2012 8:41 pm

You might be interested in:

* The stripped down dwc_otg introduced for u-boot https://github.com/gonzoua/u-boot-pi/commits/rpi
* dotg from FreeBSD (an alternative dwc_otg implementation, though not yet used against the pi) http://zrouter.org/hg/FreeBSD/head/file ... controller
* Simon Arlott's start at a new dwc_otg implementation (unfinished) https://github.com/lp0/linux/commits/rpi-usb

User avatar
Cycl0ne
Posts: 102
Joined: Mon Jun 25, 2012 8:03 am

Re: [BareMetal] USB

Sat Jul 07, 2012 9:54 pm

Hi,

thanks so much infos, i will dig through it. one question.. im sitll abit fuzzled about otg thing. is oth something special or is it EHCI, or am i getting this completely wrong?

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm
Contact: Website

Re: [BareMetal] USB

Sat Jul 07, 2012 10:04 pm

Cycl0ne wrote:Here Dexos,

thats cool. I dont need to get stuck with an own USB Stack ;-)
How am i going to get this thing on the RASPI?

Btw: USB is not soooooooooo fuzzy.. if you have the right docs.. look at this book here:

http://www.amazon.de/USB-The-Universal- ... 212&sr=8-1

Its from someone whos also coding bare metal in C (not asm ;-) and its really cool described. at the pc i have the first steps taken and my EHCI Detection works really cool.
And to Quote the OSDEV.org People: Real Man code Real USB Stacks on their own :lol:
You can connect it to the mini Uart gpio on the R-PI, as it convert hid to uart.

That book is very good, i have a copy, if you look in the contributers to the book, you will see "steve DexOS"
A member of team DexOS.
Batteries not included, Some assembly required.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13684
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: [BareMetal] USB

Sun Jul 08, 2012 2:29 pm

As an alternative to using USB you could consider using non USB peripherals, such as serial mice, and PS/2 keyboards. (both using the same mini-din connector by the way). For mice you could use the UART, for PS/2 I'm afraid you need to add a little bit of logic, and some bit banging drivers on the GPIO, but it would be a lot easier to pull this off than writing an USB stack! And would also give you some 20% more CPU power too!

reggie
Posts: 151
Joined: Fri Aug 26, 2011 11:51 am

Re: [BareMetal] USB

Mon Jul 09, 2012 12:34 am

You could use one of the teensy boards or a v-usb solution to convert ps2 keyboards/mouse to serial. You can also use gpio-keys as a keyboard driver and gpio-mouse as a mouse driver but for a decent keyboard matrix you'd probably need a shift register or 2.

see here for gpio-mouse/gpio-keys information for the pi: http://www.raspberrypi.org/phpBB3/viewt ... =50&t=8842

User avatar
Cycl0ne
Posts: 102
Joined: Mon Jun 25, 2012 8:03 am

Re: [BareMetal] USB

Tue Jul 10, 2012 10:29 am

Hi,

thanks for all your help, my USB Stack is now working :)

Code: Select all

[INIT] Adding Memory
[INIT] SysBase Preperation
[INIT] Create Idle Task
[INIT] RTF_SINGLETASK
[INIT] RTF_COLDSTART
(COLDSTART)InitResident timer.device (1d350)
(COLDSTART)InitResident usb.library (1d408)
USB:   [èñäñ:45320] ø(0x000154a8)
[èñäñ:45320] hc_reg[121500]->hcchar=0x00015578
[èñäñ:45320] data_fifo[121500]=0x00015600
[èñäñ:45320] hwcfg1=0001da9c
[èñäñ:45320] hwcfg2=0001da9c
[èñäñ:45320] hwcfg3=0001da9c
[èñäñ:45320] hwcfg4=0001da9c
[èñäñ:45320] hcfg=0001da9c
[èñäñ:45320] op_mode=1da9c
[èñäñ:45320] arch=1da9c
[èñäñ:45320] num_dev_ep=121500
[èñäñ:45320] num_host_chan=121500
[èñäñ:45320] nonperio_tx_q_depth=0x1da9c
[èñäñ:45320] host_perio_tx_q_depth=0x1da9c
[èñäñ:45320] dev_token_q_depth=0x1da9c
[èñäñ:45320] Total FIFO SZ=121500
[èñäñ:45320] xfer_size_cntr_width=1da9c
Core Release: 40ff158.b1081da9c158d0
[èñäñ:45320] Setting default values for core params
[èñäñ:45320] Finished setting default values for core params
[èñäñ:45320] dwc_otg_core_init(0x0001da9c) regs at 0x00016570
[èñäñ:45320] f
èñäñ() HANG! Soft Reset GRSTCTL=b108
[èñäñ:45320] Total FIFO SZ=121500
[èñäñ:45320] Rx FIFO SZ=121500
[èñäñ:45320] NP Tx FIFO SZ=121500
[èñäñ:45320]  ULPI interface 
[èñäñ:45320] Di
èñäñ() HANG! Soft Reset GRSTCTL=b108
[èñäñ:45320] Internal DMA Mode
[èñäñ:45320] Using Buffer DMA mode
[èñäñ:45320] DMA enable: 121500(00016c84)
[èñäñ:45320] Periodic Transfer Interrupt Enhancement - 8
[èñäñ:45320] Multiprocessor Interrupt Enhancement - 8
[èñäñ:45320] Host Mode
[èñäñ:45320] @(0x00015d04)
[èñäñ:45320] Initializing HCFG.FSLSPClkSel to 0x1da4c
[èñäñ:45320] Total FIFO Size=121500
[èñäñ:45320] Rx FIFO Size=121500
[èñäñ:45320] NP Tx FIFO Size=121500
[èñäñ:45320] P Tx FIFO Size=121500
[èñäñ:45320] initial grxfsiz=0001da9c
[èñäñ:45320] new grxfsiz=0001da9c
[èñäñ:45320] initial gnptxfsiz=0001da9c
[èñäñ:45320] new gnptxfsiz=0001da9c
[èñäñ:45320] initial hptxfsiz=0001da9c
[èñäñ:45320] new hptxfsiz=0001da9c
[èñäñ:45320] Flush Tx FIFO 121420
[èñäñ:45320] È`
[èñäñ:45320] @: Halt channel 90644 regs 0x0001c7ac
[èñäñ:45320] Init: Port Power? op_state=121500
[èñäñ:45320] Init: Power Port (121500,000162f8)
scanning bus for devices... 1 USB Device(s) found
[INIT] Timer Activation
[INIT] Activating SysBase Permit/Enable
[INIT] RTF_AFTERDOS
[INIT] Schedule
[DEMO] Started
Will try to code the HID for Mouse/Keyboard as a next part.

Usb isnt so complicated thanks to the sources (linux, barebox, freebsd) in the Internet and the book i told you of.

bobc
Posts: 86
Joined: Fri Apr 06, 2012 8:01 am

Re: [BareMetal] USB

Tue Jul 10, 2012 12:57 pm

Cycl0ne wrote:Hi,
thanks for all your help, my USB Stack is now working :)
Nice job! Once you get your brain around the concepts, USB can be made quite simple.

asb
Forum Moderator
Forum Moderator
Posts: 853
Joined: Fri Sep 16, 2011 7:16 pm
Contact: Website

Re: [BareMetal] USB

Tue Jul 10, 2012 12:59 pm

Cycl0ne wrote:Hi,

thanks for all your help, my USB Stack is now working :)

Code: Select all

[INIT] Adding Memory
[INIT] SysBase Preperation
[INIT] Create Idle Task
[INIT] RTF_SINGLETASK
[INIT] RTF_COLDSTART
(COLDSTART)InitResident timer.device (1d350)
(COLDSTART)InitResident usb.library (1d408)
USB:   [èñäñ:45320] ø(0x000154a8)
[èñäñ:45320] hc_reg[121500]->hcchar=0x00015578
[èñäñ:45320] data_fifo[121500]=0x00015600
[èñäñ:45320] hwcfg1=0001da9c
[èñäñ:45320] hwcfg2=0001da9c
[èñäñ:45320] hwcfg3=0001da9c
[èñäñ:45320] hwcfg4=0001da9c
[èñäñ:45320] hcfg=0001da9c
[èñäñ:45320] op_mode=1da9c
[èñäñ:45320] arch=1da9c
[èñäñ:45320] num_dev_ep=121500
[èñäñ:45320] num_host_chan=121500
[èñäñ:45320] nonperio_tx_q_depth=0x1da9c
[èñäñ:45320] host_perio_tx_q_depth=0x1da9c
[èñäñ:45320] dev_token_q_depth=0x1da9c
[èñäñ:45320] Total FIFO SZ=121500
[èñäñ:45320] xfer_size_cntr_width=1da9c
Core Release: 40ff158.b1081da9c158d0
[èñäñ:45320] Setting default values for core params
[èñäñ:45320] Finished setting default values for core params
[èñäñ:45320] dwc_otg_core_init(0x0001da9c) regs at 0x00016570
[èñäñ:45320] f
èñäñ() HANG! Soft Reset GRSTCTL=b108
[èñäñ:45320] Total FIFO SZ=121500
[èñäñ:45320] Rx FIFO SZ=121500
[èñäñ:45320] NP Tx FIFO SZ=121500
[èñäñ:45320]  ULPI interface 
[èñäñ:45320] Di
èñäñ() HANG! Soft Reset GRSTCTL=b108
[èñäñ:45320] Internal DMA Mode
[èñäñ:45320] Using Buffer DMA mode
[èñäñ:45320] DMA enable: 121500(00016c84)
[èñäñ:45320] Periodic Transfer Interrupt Enhancement - 8
[èñäñ:45320] Multiprocessor Interrupt Enhancement - 8
[èñäñ:45320] Host Mode
[èñäñ:45320] @(0x00015d04)
[èñäñ:45320] Initializing HCFG.FSLSPClkSel to 0x1da4c
[èñäñ:45320] Total FIFO Size=121500
[èñäñ:45320] Rx FIFO Size=121500
[èñäñ:45320] NP Tx FIFO Size=121500
[èñäñ:45320] P Tx FIFO Size=121500
[èñäñ:45320] initial grxfsiz=0001da9c
[èñäñ:45320] new grxfsiz=0001da9c
[èñäñ:45320] initial gnptxfsiz=0001da9c
[èñäñ:45320] new gnptxfsiz=0001da9c
[èñäñ:45320] initial hptxfsiz=0001da9c
[èñäñ:45320] new hptxfsiz=0001da9c
[èñäñ:45320] Flush Tx FIFO 121420
[èñäñ:45320] È`
[èñäñ:45320] @: Halt channel 90644 regs 0x0001c7ac
[èñäñ:45320] Init: Port Power? op_state=121500
[èñäñ:45320] Init: Power Port (121500,000162f8)
scanning bus for devices... 1 USB Device(s) found
[INIT] Timer Activation
[INIT] Activating SysBase Permit/Enable
[INIT] RTF_AFTERDOS
[INIT] Schedule
[DEMO] Started
Will try to code the HID for Mouse/Keyboard as a next part.

Usb isnt so complicated thanks to the sources (linux, barebox, freebsd) in the Internet and the book i told you of.
Very exciting. Please do share the code when you're ready, preferably under an MIT/BSD license so others can benefit.

User avatar
Cycl0ne
Posts: 102
Joined: Mon Jun 25, 2012 8:03 am

Re: [BareMetal] USB

Tue Jul 10, 2012 7:34 pm

Hi,

depends, the code has 4 parts, 2 parts come from synopsys and are those : dwc_otg files. Those are the low level usb driver. the third part from me is taken from u-boot, who have taken it from linux. its published under gpl. and the fourth part is mine, with no license at the moment ;-)

at the moment i have no repo online, because i wanted to get to a defined state with my code and publish it then, but whoever is interessted, can have infos until then.

my defined state for the source release is:
graphics running, the machine booting up into a shell with mouse and keyboard and the following subsystems initialised:
- graphics
- console.dev
- pdos
- lean filesystem
- some handlers for pdos (null:, con:, ram:)
----
at the moment im still fiddling with the usb.. and i broke it :D it seems that it is _very_ important that all structures are 64-bit alligned and all access is alligned too.

User avatar
Cycl0ne
Posts: 102
Joined: Mon Jun 25, 2012 8:03 am

Re: [BareMetal] USB

Wed Jul 11, 2012 12:47 am

I hate it.... it took me the whole day. i refactored and recoded my code for usb about 4 times.. i looked and looked and couldnt believe why it didnt work.....

Then it was this Power Management:

Code: Select all

	volatile UINT32 *mbox0_read = (volatile UINT32 *)BCM2835_ARM_MBOX0_BASE;
	volatile UINT32 *mbox0_write = (volatile UINT32 *)BCM2835_ARM_MBOX1_BASE;
	volatile UINT32 *mbox0_status = (volatile UINT32 *)(BCM2835_ARM_MBOX0_BASE + 0x18);
	volatile UINT32 *mbox0_config = (volatile UINT32 *)(BCM2835_ARM_MBOX0_BASE + 0x1C);
	UINT32 val = 0;

	val |= 8 << 4;

	while (*mbox0_status & 0x80000000) {
	}

	*mbox0_write = MBOX_MSG(0, val); 
DAMN.. how should someone know something like this?!?!?

Here now the new results, still some new errors, but im getting closer.

Code: Select all

[INIT] Schedule
[DEMO] Started
USB:   Core Release: 2.80a
scanning bus for devices... i: 0
Error condition at line 672:  XACTERR
Error condition at line 672:  XACTERR
2 USB Device(s) found

Device Tree:
  1  Hub (480 Mb/s, 0mA)
  |  DWC OTG RootHub  
  |
  +-2  Hub (480 Mb/s, 2mA)

valtonia
Posts: 26
Joined: Wed Jul 04, 2012 9:09 pm

Re: [BareMetal] USB

Thu Jul 12, 2012 11:55 am

@Cycl0ne

I would be very interested in getting an early look at your code. I was just about to start in on a usb driver for my own bare-metal os, so this could save some time.

Like you, I was waiting to get to a specific point functionality-wise before publishing my code, but if anything I've done is of interest to you I'd be happy to share. So far I have boot, fb (in 8/16/24/32 bpp), printf, dma, basic clib, gpio and some graphics primitives (pixel, line, circle etc).
I'm fast approaching the point where I need to be able to type into the Rpi so usb was going to be my next target.

Regards,
V.

User avatar
Cycl0ne
Posts: 102
Joined: Mon Jun 25, 2012 8:03 am

Re: [BareMetal] USB

Thu Jul 12, 2012 4:18 pm

you just got a pm.

for the code (for the others) there is good news.. one part is synopsys, two BSD one GPL. and if someone like they can rewrite the GPL code.

at the moment im completely stuck. i cant write to the second hub, it seems im missing something. i alligned my pointers, i tried here and there and even contacted gonzo the original author.... we will see. i opened up an account at github. as soon as usb works as inspected, i will publish it to all. for ppl interessted earlier, give me a pm. but you need to have some baremetal code running to get it up:

malloc, free, printf, mset, mcpy, mdelay and udelay

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm
Contact: Website

Re: [BareMetal] USB

Thu Jul 12, 2012 5:46 pm

Are you do the Memory Barrier as detailed in the broadcom PDF ?
Exampe:

Code: Select all

align 4
; -----------------------------------------------------
; MemoryBarrier.
; Modified from the Linux kernel source (raspberry pi)
; -----------------------------------------------------
MemoryBarrier:						 ;
	stmfd  sp!,{r0-r8, r12, lr}			 ; Store registers
	mcr    p15, 0, ip, c7, c5,  0			 ;  invalidate I cache
	mcr    p15, 0, ip, c7, c5,  6			 ;  invalidate BTB
	mcr    p15, 0, ip, c7, c10, 4			 ;  drain write buffer
	mcr    p15, 0, ip, c7, c5,  4			 ;  prefetch flush
	ldmfd  sp!,{r0-r8, r12, pc}			 ; Restore registers and return
Sorry it not in C, but its not possible in that language :shock:
Batteries not included, Some assembly required.

User avatar
Cycl0ne
Posts: 102
Joined: Mon Jun 25, 2012 8:03 am

Re: [BareMetal] USB

Thu Jul 12, 2012 6:23 pm

Hmm,

as far as i know RPI boots up with all disabled (cache,...) do you think i really need the memorybarrier? The usb code runs little modified in the u-boot. Gonzo also does no memorybarrier.

Here is the "C" Code of your assembler part ;)

Code: Select all

void memorybarrier (void)
{
	asm ("mcr p15, 0, %0, c7, c5, 0": :"r" (0));
	asm ("mcr p15, 0, %0, c7, c5, 6": :"r" (0));
	asm ("mcr p15, 0, %0, c7, c10, 4": :"r" (0));
	asm ("mcr p15, 0, %0, c7, c5, 4": :"r" (0));
}
ok i tried it:

Code: Select all

void dwc_write_reg32(volatile uint32_t *addr, uint32_t value)
{
	*addr = value;
	memorybarrier();
}
but got still the error:

Code: Select all

Error condition at line 695:  XACTERR
Error condition at line 695:  XACTERR

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm
Contact: Website

Re: [BareMetal] USB

Thu Jul 12, 2012 8:17 pm

Have you tried
To recover from USB transfers which fail with a USB status of USBD_STATUS_XACT_ERROR, USB device driver developers should take the following actions:

* Issue a URB_FUNCTION_RESET_PIPE request for the USB endpoint that is the target of the failed transfer. This action is normally expected to clear errors such as a Transaction Error (XactErr), and allow subsequent USB transfers to resume.
* Before issuing a URB_FUNCTION_RESET_PIPE request, a URB_FUNCTION_ABORT_PIPE request should be issued for the USB endpoint that is the target of the failed transfer. The URB_FUNCTION_ABORT_PIPE request will cancel all pending transfers for the specified endpoint, which is documented in the Windows Driver Kit (WDK) as a prerequisite to issuing a URB_FUNCTION_RESET_PIPE request.
* If the above actions fail to allow subsequent USB transfers to resume for the specified USB device and endpoint, an IOCTL_INTERNAL_USB_RESET_PORT request may be issued by a kernel-mode USB device driver to reset the USB port to which the USB device is attached. All pending transfers to all endpoints of the USB device should be cancelled via URB_FUNCTION_ABORT_PIPE requests, and the USB device driver should wait for these transfers to complete, before isssuing this request.
* Finally, if all of the above actions fail to restore communications with the USB device following a Transaction Error, a kernel-mode USB device driver may issue an IOCTL_INTERNAL_USB_CYCLE_PORT to cause the USB device to be effectively removed from and re-enumerated on the USB port to which it is attached. All pending transfers to all endpoints of the USB device should be cancelled via URB_FUNCTION_ABORT_PIPE requests, and the USB device driver should wait for these transfers to complete, before isssuing this request.

Also that error can be from faulty devices or cables.
Check them first.
Batteries not included, Some assembly required.

User avatar
Cycl0ne
Posts: 102
Joined: Mon Jun 25, 2012 8:03 am

Re: [BareMetal] USB

Thu Jul 12, 2012 8:24 pm

i will give it a try. but guess what:

my usb on raspi is naked. nothing connected. normaly it should present it to me like this:
Root Hub
Hub
Ethernet

Cause i got nothing connected to the hub.

the interessting factor here is: the code is unmodified from the u-boot raspi port ... and there it works and shows all 3 devices.

User avatar
Cycl0ne
Posts: 102
Joined: Mon Jun 25, 2012 8:03 am

Re: [BareMetal] USB

Fri Jul 13, 2012 8:15 am

AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
I found my bug !! :)

it was my MEMSET written in Assembler ;-), I changed it to a C version, and now it works :D The Assembler was perhaps too optimized ;)

Here the output:
Root Hub
The RASPI Hub (3 Ports)
Ethernet connected

Code: Select all

[DEMO] Started
USB:   Core Release: 2.80a
scanning bus for devices... 3 USB Device(s) found

Device Tree:
  1  Hub (480 Mb/s, 0mA)
  |  DWC OTG RootHub  
  |
  +-2  Hub (480 Mb/s, 2mA)
    |
    +-3  Vendor specific (12 Mb/s, 2mA)
       
1: Hub,  USB Revision 1.10
 - DWC OTG RootHub  
 - Class: Hub
 - PacketSize: 8  Configurations: 1
 - Vendor: 0x%04x  Product 0x%04x Version 0.0
   Configuration: 1
   - Interfaces: 1 Self Powered 0mA
     Interface: 0
     - Alternate Setting 0, Endpoints: 1
     - Class Hub
     - Endpoint 1 In Interrupt MaxPacket 8 Interval 255ms

2: Hub,  USB Revision 2.0
 - Class: Hub
 - PacketSize: 64  Configurations: 1
 - Vendor: 0x%04x  Product 0x%04x Version 1060.38162
   Configuration: 1
   - Interfaces: 1 Self Powered Remote Wakeup 2mA
     Interface: 0
     - Alternate Setting 0, Endpoints: 1
     - Class Hub
     - Endpoint 1 In Interrupt MaxPacket 1 Interval 255ms

3: Vendor specific,  USB Revision 2.0
 - Class: Vendor specific
 - PacketSize: 64  Configurations: 1
 - Vendor: 0x%04x  Product 0x%04x Version 1060.60416
   Configuration: 1
   - Interfaces: 1 Self Powered Remote Wakeup 2mA
     Interface: 0
     - Alternate Setting 0, Endpoints: 3
     - Class Vendor specific
     - Endpoint 1 In Bulk MaxPacket 64
     - Endpoint 2 Out Bulk MaxPacket 64
     - Endpoint 3 In Interrupt MaxPacket 16 Interval 1ms
With Mouse and Keyboard connected, but it seems the stack has problems with the keyboard :-( :

Code: Select all

Device Tree:
  1  Hub (480 Mb/s, 0mA)
  |  DWC OTG RootHub  
  |
  +-2  Hub (480 Mb/s, 2mA)
    |
    +-3  Vendor specific (12 Mb/s, 2mA)
    |  
    +-4  See Interface (12 Mb/s, 0mA)
    |  
    +-5  See Interface (1.5 Mb/s, 0mA)
Here with my Keyboard with integrated Hub, as I can see the keyboard is not lit up and all sorts of debug errors coming up.

Code: Select all

Device Tree:
  1  Hub (480 Mb/s, 0mA)
  |  DWC OTG RootHub  
  |
  +-2  Hub (480 Mb/s, 2mA)
    |
    +-3  Vendor specific (12 Mb/s, 2mA)
    |  
    +-4  See Interface (12 Mb/s, 0mA)
    |  
    +-5  Hub (12 Mb/s, 100mA)
      |   USB2.0 Hub 
      |
      +-6  Human Interface (12 Mb/s, 100mA)

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm
Contact: Website

Re: [BareMetal] USB

Fri Jul 13, 2012 12:00 pm

Cycl0ne wrote:AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
I found my bug !! :)

it was my MEMSET written in Assembler ;-), I changed it to a C version, and now it works :D The Assembler was perhaps too optimized ;)
Cool, and your bug is why i always advices asm coders, to code unoptimized first, then when it fully working, go back and finded the bottlenecks.
Batteries not included, Some assembly required.

User avatar
Cycl0ne
Posts: 102
Joined: Mon Jun 25, 2012 8:03 am

Re: [BareMetal] USB

Fri Jul 13, 2012 6:58 pm

Dexos, do you have a fast memcpy/memset for me?

Return to “Bare metal, Assembly language”