hartnett
Posts: 16
Joined: Fri Mar 01, 2013 9:00 pm

CSUD question(s)...

Thu Apr 10, 2014 6:12 pm

I'm experimenting with CSUD..

First, I see in the code (designware20.h) that ReceiveFifoSize = NonPeriodicFifoSize = PeriodicFifoSize = 20480. But doesn't the sume of those have to be less than Hardware.FifoDepth (= 4080)? And the code has ChannelCount = 16. I think (?) that should be 8.

And I think that Hardware.HostChannelCount is the number of actual channels MINUS 1 (i.e., it's 7). So (in designware20.c) the "for channel .." loops in HcdStart should really go while channel is less than OR EQUAL TO (i.e., "<=") Hardware.HostChannelCount.

But here's my current issue:

The ONE AND ONLY place where the physical FIFO size registers are set (via WriteThroughReg) is in HcdStart. I set things up so ReceiveFifoSize = NonPeriodicFifoSize = PeriodicFifoSize = 1024. (This means Receive.Size (20980024) is 00000400, NonPeriodicFifo (20980028) is 04000400 and PeriodicFifo.HostSize (20980100) is 04000800.) But if I read them back after HcdStart/HcdInitiailize are done, the values are 04000400 (okay), 01000400 (?) and 02000200 (?).

Any thoughts/suggestions?

Thanks,

Tom

phil95
Posts: 141
Joined: Wed Sep 12, 2012 8:10 am
Location: Paris

Re: CSUD question(s)...

Fri Apr 11, 2014 1:51 pm

Hello
I have tested some months ago my own USB driver
There is a bug in the documentation or CSUD driver
In my driver, I have:

#define SZ1 0x300
#define SZ2 0x100
#define SZ3 0x200
#define OFF1 0
#define OFF2 (OFF1 + SZ1)
#define OFF3 (OFF2 + SZ2)
UsbPoke(pCORERECEIVEFIFOSIZE, (OFF1 << 16) | SZ1); // 0x024
UsbPoke(pCORENONPERIODICFIFOSIZE, (SZ2 << 16) | OFF2); // 0x028
UsbPoke(pCOREPERIODICFIFOSIZE, (SZ3 << 16) | OFF3); // 0x100

With these parameters, my driver is working.
I posted these modifications in forum in 2013, but no remark ...
Philippe

hldswrth
Posts: 108
Joined: Mon Sep 10, 2012 4:14 pm

Re: CSUD question(s)...

Fri Apr 11, 2014 2:48 pm

Yeah, I also posted about this here http://www.raspberrypi.org/forums/viewt ... 72&t=54965... with the values in the driver as written you actually end up with random memory overwrites which is pretty nasty once your bare metal os gets to any size. There is also a bug in the keyboard routine at least for my keyboard as with one key pressed its not the first value in the array that's set to non-zero.
Having said that I just set the FIFO values to smaller numbers (1024 each I think) so the total is less than the reported FIFO size and left it at that as the keyboard works fine with those.

hartnett
Posts: 16
Joined: Fri Mar 01, 2013 9:00 pm

Re: CSUD question(s)...

Fri Apr 11, 2014 5:37 pm

Thanks for the replies.

Even with different sizes, I notice that the physical register values are NOT what I program them to be. I tried moving the FIFO size (receive, nonperiodicTransmit and periodicTransmit) and FIFO flushing to be AFTER the loops where he (CSUD) disables all the channels.. and now it seems fine. Go figure.

But another curiosity I noticed is that when (in HcdStart) we disable all the channels, all the channels, EXCEPT channel 1, are disabled as quickly as I can read the ChannelCharacteristic register (0x5_0+00) (and specifically the Enable bit (b31)), which is <300uS. But it takes about 37.6ms (more than 100 times longer) for channel 1 to become disabled.

Regards,

Tom

phil95
Posts: 141
Joined: Wed Sep 12, 2012 8:10 am
Location: Paris

Re: CSUD question(s)...

Fri Apr 11, 2014 6:56 pm

@hldswrth:

in my case, random memory overwrites were
removed with (cf last post of your thread)

UsbPoke(COREAHB, 0x31);
UsbPoke(COREUSB, 0x1700);
UsbPoke(HOSTFRAMEINTERVAL, 7500);
UsbPoke(HOSTCONFIG, 0x0);
...
UsbPoke(COREOTGCONTROL, 0x1c0000);

Philippe

Return to “Bare metal, Assembly language”