All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] {Spam?} usage of DMA
@ 2011-01-11 21:51 Marcel
  2011-01-16  7:56 ` Albert ARIBAUD
  0 siblings, 1 reply; 10+ messages in thread
From: Marcel @ 2011-01-11 21:51 UTC (permalink / raw)
  To: u-boot

Hi,

I'm implementing the USB device controller for the SAM9G45 and got to a point 
where I've got endpoint 0 to work, so basically all descriptors are received 
by the host.
I did however have an issue getting past this and found it's related to the 
linux driver using DMA for all the other endpoints.

Somehow I managed to get endpoint 3 (status) to work with ether.c and got the 
device recognised as an ethernet gadget, however endpoints 1 and 2 still don't 
work. This was using DMA.

I'm a little stuck with the DMA part and have some questions about it :

1) I suppose this can also work work without DMA and it would make the driver 
a whole lot simpler I guess. Is this prefered in U-boot ?

2) If I want to use DMA so I can port most things from Linux, how would I deal 
with functions like 
dma_sync_single_for_device (doesn't seem to exist)
dma_map_single
dma_unmap_single

I tried to make it work without DMA and implemented the part that switched off 
DMA for the controller. I think this code works well.
Unfortunately I have no idea how to read data from the endpoints in this case 
yet. I see that data arrives (I see the out packet arrives and it tries to 
read) but I probably don't read it correctly.

I guess question 1 is most important. If using DMA is not preferred I will try 
to make it work without DMA and can forget about question 2.

Best regards,
Marcel 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] {Spam?} usage of DMA
  2011-01-11 21:51 [U-Boot] {Spam?} usage of DMA Marcel
@ 2011-01-16  7:56 ` Albert ARIBAUD
  2011-01-17 20:48   ` [U-Boot] " Marcel
  0 siblings, 1 reply; 10+ messages in thread
From: Albert ARIBAUD @ 2011-01-16  7:56 UTC (permalink / raw)
  To: u-boot

Hi Marcel,

Le 11/01/2011 22:51, Marcel a ?crit :
> Hi,
>
> I'm implementing the USB device controller for the SAM9G45 and got to a point
> where I've got endpoint 0 to work, so basically all descriptors are received
> by the host.
> I did however have an issue getting past this and found it's related to the
> linux driver using DMA for all the other endpoints.
>
> Somehow I managed to get endpoint 3 (status) to work with ether.c and got the
> device recognised as an ethernet gadget, however endpoints 1 and 2 still don't
> work. This was using DMA.
>
> I'm a little stuck with the DMA part and have some questions about it :
>
> 1) I suppose this can also work work without DMA and it would make the driver
> a whole lot simpler I guess. Is this prefered in U-boot ?
>
> 2) If I want to use DMA so I can port most things from Linux, how would I deal
> with functions like
> dma_sync_single_for_device (doesn't seem to exist)
> dma_map_single
> dma_unmap_single
>
> I tried to make it work without DMA and implemented the part that switched off
> DMA for the controller. I think this code works well.
> Unfortunately I have no idea how to read data from the endpoints in this case
> yet. I see that data arrives (I see the out packet arrives and it tries to
> read) but I probably don't read it correctly.
>
> I guess question 1 is most important. If using DMA is not preferred I will try
> to make it work without DMA and can forget about question 2.

As for question 1:

Generally speaking, simpler code means smaller code, which is, I think, 
the most important factor in U-boot; also, simpler code means less prone 
to bugs, which is also important for a bootloader.

In your case, I would suggest finding and thouroughly reading the device 
specifications or datasheets. Are they available?

As for question 2 :

Taking code from Linux is generally allowed. However, keep in mind that 
depending on what code you're speaking of, this may imply either pulling 
more code than you need or having to modify the code you pull.

> Best regards,
> Marcel

Amicalement,
-- 
Albert.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] usage of DMA
  2011-01-16  7:56 ` Albert ARIBAUD
@ 2011-01-17 20:48   ` Marcel
  2011-01-18 13:36     ` Vitaly Kuzmichev
  0 siblings, 1 reply; 10+ messages in thread
From: Marcel @ 2011-01-17 20:48 UTC (permalink / raw)
  To: u-boot

> Hi Marcel,
> 
> Le 11/01/2011 22:51, Marcel a ?crit :
> > Hi,
> > 
> > I'm implementing the USB device controller for the SAM9G45 and got to a
> > point where I've got endpoint 0 to work, so basically all descriptors
> > are received by the host.
> > I did however have an issue getting past this and found it's related to
> > the linux driver using DMA for all the other endpoints.
> > 
> > Somehow I managed to get endpoint 3 (status) to work with ether.c and got
> > the device recognised as an ethernet gadget, however endpoints 1 and 2
> > still don't work. This was using DMA.
> > 
> > I'm a little stuck with the DMA part and have some questions about it :
> > 
> > 1) I suppose this can also work work without DMA and it would make the
> > driver a whole lot simpler I guess. Is this prefered in U-boot ?
> > 
> > 2) If I want to use DMA so I can port most things from Linux, how would I
> > deal with functions like
> > dma_sync_single_for_device (doesn't seem to exist)
> > dma_map_single
> > dma_unmap_single
> > 
> > I tried to make it work without DMA and implemented the part that
> > switched off DMA for the controller. I think this code works well.
> > Unfortunately I have no idea how to read data from the endpoints in this
> > case yet. I see that data arrives (I see the out packet arrives and it
> > tries to read) but I probably don't read it correctly.
> > 
> > I guess question 1 is most important. If using DMA is not preferred I
> > will try to make it work without DMA and can forget about question 2.
> 
> As for question 1:
> 
> Generally speaking, simpler code means smaller code, which is, I think,
> the most important factor in U-boot; also, simpler code means less prone
> to bugs, which is also important for a bootloader.
> 
> In your case, I would suggest finding and thouroughly reading the device
> specifications or datasheets. Are they available?
> 
> As for question 2 :
> 
> Taking code from Linux is generally allowed. However, keep in mind that
> depending on what code you're speaking of, this may imply either pulling
> more code than you need or having to modify the code you pull.
> 
> > Best regards,
> > Marcel

Hi Albert,

I have already reduced the code quite far. Basically all dma related stuff is 
gone. 
The device is recognised by the host without errors, but there are some issues 
left as the OUT data doesn't get processed by ether.c.
I'm pulling my hair on this one, but since the data arrives in the OUT fifo and 
I can read it from the controller part I guess all end points are really up 
and running but the interfacing to the gadget system maybe isn't correct.
Perhaps that's related to the driver I'm porting which comes from a 2.6.33 
kernel.

I read quite a lot of the USB device specification for my controller and so far 
think I've done everything right regarding the registers. 
Since the host also does believe things are running correctly and sends data, 
I believe the main issue is in some other part.

A USB trace of a working at91_udc implementation would help, but I have no 
such controller at hand to try it.

Anyway, I'm slowly moving forward on this and probably port again when I have 
it working. 

Regards,
Marcel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] usage of DMA
  2011-01-17 20:48   ` [U-Boot] " Marcel
@ 2011-01-18 13:36     ` Vitaly Kuzmichev
  2011-01-18 14:06       ` Vitaly Kuzmichev
  2011-01-18 18:11       ` Marcel
  0 siblings, 2 replies; 10+ messages in thread
From: Vitaly Kuzmichev @ 2011-01-18 13:36 UTC (permalink / raw)
  To: u-boot

Hi Marcel,

Marcel wrote:
> 
> I have already reduced the code quite far. Basically all dma related stuff is 
> gone. 

According to your first message in this thread I suppose that you are
using  atmel_usba_udc  driver. Am I right?
Looks like it's able to use PIO mode transfer (I mean linux driver).
Each EP has can_dma flag which can be passed through platform_data.
So:
1) Could you please make sure that this driver is working in linux in
PIO mode (with can_dma set to zero)?
2) Could you port this driver to u-boot w/o changes in functions that
talk with hardware registers and try to use PIO mode (with can_dma set
to zero and commented DMA function calls)?

> The device is recognised by the host without errors, but there are some issues 
> left as the OUT data doesn't get processed by ether.c.

After the device descriptor is received the host usually wants to setup
the device.
Has the setup stage been done?

> I'm pulling my hair on this one, but since the data arrives in the OUT fifo and 
> I can read it from the controller part I guess all end points are really up 
> and running but the interfacing to the gadget system maybe isn't correct.
> Perhaps that's related to the driver I'm porting which comes from a 2.6.33 
> kernel.

2.6.33 controller driver should be compatible with 2.6.24 gadget stack
(which was ported to u-boot).

> I read quite a lot of the USB device specification for my controller and so far 
> think I've done everything right regarding the registers. 

Nobody can be sure in such thing :) Even if everything works

Could you enable debug output for ether.c and for your UDC driver and
show the results?

____
With best regards,
Vitaly.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] usage of DMA
  2011-01-18 13:36     ` Vitaly Kuzmichev
@ 2011-01-18 14:06       ` Vitaly Kuzmichev
  2011-01-18 18:12         ` Marcel
  2011-01-18 18:11       ` Marcel
  1 sibling, 1 reply; 10+ messages in thread
From: Vitaly Kuzmichev @ 2011-01-18 14:06 UTC (permalink / raw)
  To: u-boot

Hi Marcel,

In addition, did you enable CONFIG_USB_GADGET_DUALSPEED option in your
u-boot config file?

____
With best regards,
Vitaly.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] usage of DMA
  2011-01-18 13:36     ` Vitaly Kuzmichev
  2011-01-18 14:06       ` Vitaly Kuzmichev
@ 2011-01-18 18:11       ` Marcel
  2011-01-19  9:04         ` Vitaly Kuzmichev
  1 sibling, 1 reply; 10+ messages in thread
From: Marcel @ 2011-01-18 18:11 UTC (permalink / raw)
  To: u-boot

Hi Vitaly,

> Hi Marcel,
> 
> Marcel wrote:
> > I have already reduced the code quite far. Basically all dma related
> > stuff is gone.
> 
> According to your first message in this thread I suppose that you are
> using  atmel_usba_udc  driver. Am I right?
> Looks like it's able to use PIO mode transfer (I mean linux driver).
> Each EP has can_dma flag which can be passed through platform_data.
> So:
> 1) Could you please make sure that this driver is working in linux in
> PIO mode (with can_dma set to zero)?
> 2) Could you port this driver to u-boot w/o changes in functions that
> talk with hardware registers and try to use PIO mode (with can_dma set
> to zero and commented DMA function calls)?

I use the driver in Linux in DMA mode and have not tried it in non-DMA mode in 
Linux. I can of course try this. Basically I think it should work.

For my u-boot port I started in DMA mode using the exact same code as in 
Linux. At that moment I manages to get endpoint 0 and 3 (status) to work and 
probably also the other endpoints worked, but I think I got misleaded that 
they where not working because some buffer for the ethernet part seemed not 
initialised. 

Than I disabled DMA and implemented the code to actually disable DMA according 
to the G45 specification. Still I couldn't get endpoints 1 and 2 running 
(actually the exact same result as with-DMA. 
I than started to strip down the code to make it easier to read and basically 
also because if DMA is not really needed I think the code should be such way 
that either it's compiled as a CONFIG choice rather than a flag in usba_ep.

I have all previous code, so I can revert back to what I had with DMA but first 
I need to find out what happens in the current code because that problem exist 
in all my versions.

> > The device is recognised by the host without errors, but there are some
> > issues left as the OUT data doesn't get processed by ether.c.
> 
> After the device descriptor is received the host usually wants to setup
> the device.
> Has the setup stage been done?

Yes, but I'm not sure it's completely finished. From the host side it appears 
to be done as it fully recognises the device. 

> > I'm pulling my hair on this one, but since the data arrives in the OUT
> > fifo and I can read it from the controller part I guess all end points
> > are really up and running but the interfacing to the gadget system maybe
> > isn't correct. Perhaps that's related to the driver I'm porting which
> > comes from a 2.6.33 kernel.
> 
> 2.6.33 controller driver should be compatible with 2.6.24 gadget stack
> (which was ported to u-boot).

OK, nice to know.

> > I read quite a lot of the USB device specification for my controller and
> > so far think I've done everything right regarding the registers.
> 
> Nobody can be sure in such thing :) Even if everything works
> 
> Could you enable debug output for ether.c and for your UDC driver and
> show the results?

I enabled a lot of extra debugging messages so this is not very short.
The output attached below is including start of macb but USB device behave the 
same when I don't enable that.

Regards,
Marcel


U-Boot 2010.12-09833-gb2c475d-dirty (Jan 18 2011 - 01:04:28)

U-Boot code: 73F00000 -> 73F40988  BSS: -> 73F51D74
CPU: AT91SAM9G45
Crystal frequency:       12 MHz
CPU clock        :      400 MHz
Master clock     :  133.333 MHz
dram init 
monitor len: 00051D74
ramsize: 08000000
TLB table at: 77ff0000
Top of RAM usable for U-Boot at: 77ff0000
Reserving 327k for U-Boot at: 77f9e000
Reserving 384k for malloc() at: 77f3e000
Reserving 24 Bytes for Board Info at: 77f3dfe8
Reserving 144 Bytes for Global Data at: 77f3df58
New Stack Pointer is: 77f3df50
RAM Configuration:
Bank #0: 70000000 128 MiB
relocation Offset is: 0409e000
starting relocate 77f3df50 , 77f9e000
monitor flash len: 00040988
USB host init 
Now running in RAM - U-Boot at: 77f9e000
FLASH: flash detect cfi
fwc addr 10000000 cmd f0 f0 8bit x 8 bit
fwc addr 10000000 cmd ff ff 8bit x 8 bit
fwc addr 10000055 cmd 98 98 8bit x 8 bit
is= cmd 51(Q) addr 10000010 is= 5 51
fwc addr 10000555 cmd 98 98 8bit x 8 bit
is= cmd 51(Q) addr 10000010 is= 5 51
fwc addr 10000000 cmd f0 f0f0 16bit x 8 bit
fwc addr 10000000 cmd ff ffff 16bit x 8 bit
fwc addr 100000aa cmd 98 9898 16bit x 8 bit
is= cmd 51(Q) addr 10000020 is= 5151 5151
is= cmd 52(R) addr 10000022 is= 5252 5252
is= cmd 59(Y) addr 10000024 is= 5959 5959
device interface is 0
found port 2 chip 1 port 16 bits chip 8 bits
00 : 51 52 59 02 00 40 00 00 00 00 00 27 36 00 00 04  QRY.. at .....'6...
10 : 00 0a 00 05 00 04 00 13 00 00 00 00 01 07 00 00  ................
20 : 01 00 00 00 00 00 00 00 00 00 00 00 00 ec c3 fe  ................
fwc addr 10000000 cmd f0 f0f0 16bit x 8 bit
fwc addr 10000aaa cmd aa aaaa 16bit x 8 bit
fwc addr 10000554 cmd 55 5555 16bit x 8 bit
fwc addr 10000aaa cmd 90 9090 16bit x 8 bit
fwc addr 10000000 cmd f0 f0f0 16bit x 8 bit
fwc addr 100000aa cmd 98 9898 16bit x 8 bit
manufacturer is 2
manufacturer id is 0xc2
device id is 0x4f
device id2 is 0x0
cfi version is 0x3130
size_ratio 2 port 16 bits chip 8 bits
found 1 erase regions
erase region 0: 0x01000007
erase_region_count = 8 erase_region_size = 65536
fwc addr 10000000 cmd f0 f0f0 16bit x 8 bit
flash_protect ON: from 0x10000000 to 0x10040987
protect on 0
protect on 1
protect on 2
flash_protect ON: from 0x100E0000 to 0x100FFFFF
protect on 7
1 MiB
NAND:  256 MiB
*** Warning - bad CRC, using default environment

Destroy Hash Table: 77fdef34 table = (null)
Create Hash Table: N=84
INSERT: table 77fdef34, filled 1/89 rv 77f3f514 ==> name="bootargs" 
value="root=1F01 rootfstype=jffs2"
INSERT: table 77fdef34, filled 2/89 rv 77f3f3d0 ==> name="bootcmd" 
value="mtdparts default; nand read 0x71000000 nand0,0; bootm 0x71000000"
INSERT: table 77fdef34, filled 3/89 rv 77f3f568 ==> name="bootdelay" value="3"
INSERT: table 77fdef34, filled 4/89 rv 77f3f3e8 ==> name="baudrate" 
value="115200"
INSERT: table 77fdef34, filled 5/89 rv 77f3f5e0 ==> name="ipaddr" 
value=""192.168.1.50""
INSERT: free(data = 77f3f2a0)
INSERT: done
In:    serial
Out:   serial
Err:   serial
Net:   USB host init 
MACB initialize 
USB probe 
USBA : Probing USB controller
USBA : Enable controller
maxpacket = 64
UDPHS_CTRL after reset 0x900
UDPHS ep 1 disable DMA
UDPHS_DMACONTROL = 0x0
UDPHS_EPTCTLDIS = 0x0
UDPHS_EPTCFG = 0x0
UDPHS_DMASTATUS = 0x0
UDPHS_IPNAME1 = 0x48555342
UDPHS ep 2 disable DMA
UDPHS_DMACONTROL = 0x0
UDPHS_EPTCTLDIS = 0x0
UDPHS_EPTCFG = 0x0
UDPHS_DMASTATUS = 0x0
UDPHS_IPNAME1 = 0x48555342
UDPHS ep 3 disable DMA
UDPHS_DMACONTROL = 0x0
UDPHS_EPTCTLDIS = 0x0
UDPHS_EPTCFG = 0x0
UDPHS_DMASTATUS = 0x0
UDPHS_IPNAME1 = 0x48555342
UDPHS ep 4 disable DMA
UDPHS_DMACONTROL = 0x0
UDPHS_EPTCTLDIS = 0x0
UDPHS_EPTCFG = 0x0
UDPHS_DMASTATUS = 0x0
UDPHS_IPNAME1 = 0x48555342
UDPHS ep 5 disable DMA
UDPHS_DMACONTROL = 0x0
UDPHS_EPTCTLDIS = 0x0
UDPHS_EPTCFG = 0x0
UDPHS_DMASTATUS = 0x0
UDPHS_IPNAME1 = 0x48555342
UDPHS ep 6 disable DMA
UDPHS_DMACONTROL = 0x0
UDPHS_EPTCTLDIS = 0x0
UDPHS_EPTCFG = 0x0
UDPHS_DMASTATUS = 0x0
UDPHS_IPNAME1 = 0x48555342
UDPHS ep 7 disable DMA
UDPHS_DMACONTROL = 0x0
UDPHS_EPTCTLDIS = 0x0
UDPHS_EPTCFG = 0x0
UDPHS_DMASTATUS = 0x0
UDPHS_IPNAME1 = 0x48555342
USBA : Probing finished
USB_ETH_INITIALIZE
macb0, usb_ether
Reset Ethernet PHY
Reset PHY called 
Trying macb0
macb0: PHY present at 0
macb0: Starting autonegotiation...
macb0: Autonegotiation timed out (status=0x7849)
macb0: link down (status: 0x7849)
FAIL
Trying usb_ether
USBA : registering driver
UDC set selfpowered
using atmel_usba_udc, OUT ep2 IN ep1 STATUS ep3
MAC 00:1f:e5:00:1c:7c
HOST MAC 0a:fa:63:8b:e8:0a
udc: alloc_req: request[0]
udc: alloc_req: request[1]
USBA : USBA_DET_SUSPEND
USBA : USBA_END_OF_RESET
USBA : reset all endpoints
USBA : High speed
USBA : USBA_END_OF_RESET - finished
USBA : USBA_END_OF_RESET
USBA : reset all endpoints
USBA : High speed
USBA : USBA_END_OF_RESET - finished
EP 0 = control
ep0 [0]: s/80855000 c/00001001
USBA : USBA_RX_SETUP
Packet length: 8
Copying ctrl request from 0x00600000:
USBA : EP0 setup
deligate SETUP Type =    6  100    0
ETH setup
eth_setup
respond with data transfer before status phase
ep0: queue req 77fec848, len 18
WE TRANSMITTED DATA ep= ep0
ep_queue 18 req80.06 v0100 i0000 l64
ETH control Status 00000000
END OF USBA_CONTRL_IRQ !!!!
EP 0 = control
ep0 [1]: s/00014000 c/00001801
usba_control_irq : USBA_TX_PK_RDY
ep0 : submit_request: req 77fec848 (length 18)
ep0: submit_transaction, req 77fec848 (length 18), done
ep0 [1]: s/01254800 c/00001401
END OF USBA_CONTRL_IRQ !!!!
USBA : USBA_END_OF_RESET
USBA : reset all endpoints
ep0: req 77fec848 complete: status -104, actual 18
setup complete --> -104, 18/18
USBA : High speed
USBA : USBA_END_OF_RESET - finished
EP 0 = control
ep0 [0]: s/80845000 c/00001001
USBA : USBA_RX_SETUP
Packet length: 8
Copying ctrl request from 0x00600000:
USBA : EP0 setup
USBA :  USB_REQ_SET_ADDRESS
USBA : set address 123
Send status
END OF USBA_CONTRL_IRQ !!!!
EP 0 = control
ep0 [5]: s/00004400 c/00001401
usba_control_irq : USBA_TX_COMPLETE
USBA : Status stage addr
ep0 [0]: s/00004000 c/00001001
END OF USBA_CONTRL_IRQ !!!!
EP 0 = control
ep0 [0]: s/80855000 c/00001001
USBA : USBA_RX_SETUP
Packet length: 8
Copying ctrl request from 0x00600000:
USBA : EP0 setup
deligate SETUP Type =    6  100    0
ETH setup
eth_setup
respond with data transfer before status phase
ep0: queue req 77fec848, len 18
WE TRANSMITTED DATA ep= ep0
ep_queue 18 req80.06 v0100 i0000 l18
ETH control Status 00000000
END OF USBA_CONTRL_IRQ !!!!
EP 0 = control
ep0 [1]: s/00014000 c/00001801
usba_control_irq : USBA_TX_PK_RDY
ep0 : submit_request: req 77fec848 (length 18)
ep0: submit_transaction, req 77fec848 (length 18), done
ep0 [1]: s/01254800 c/00001401
END OF USBA_CONTRL_IRQ !!!!
EP 0 = control
ep0 [1]: s/8085d400 c/00001401
usba_control_irq : USBA_TX_COMPLETE
USBA : DATA Stage in
ep0 [4]: s/8085d000 c/00001201
USBA : USBA_RX_SETUP
DROPPING DATA ep0
ep0: req 77fec848 complete: status 0, actual 18
Packet length: 8
Copying ctrl request from 0x00600000:
USBA : EP0 setup
deligate SETUP Type =    6  200    0
ETH setup
eth_setup
respond with data transfer before status phase
ep0: queue req 77fec848, len 9
WE TRANSMITTED DATA ep= ep0
ep_queue 9 req80.06 v0200 i0000 l9
ETH control Status 00000000
END OF USBA_CONTRL_IRQ !!!!
EP 0 = control
ep0 [1]: s/0001c000 c/00001801
usba_control_irq : USBA_TX_PK_RDY
ep0 : submit_request: req 77fec848 (length 9)
ep0: submit_transaction, req 77fec848 (length 9), done
ep0 [1]: s/0095c800 c/00001401
END OF USBA_CONTRL_IRQ !!!!
EP 0 = control
ep0 [1]: s/8085d400 c/00001401
usba_control_irq : USBA_TX_COMPLETE
USBA : DATA Stage in
ep0 [4]: s/8085d000 c/00001201
USBA : USBA_RX_SETUP
DROPPING DATA ep0
ep0: req 77fec848 complete: status 0, actual 9
Packet length: 8
Copying ctrl request from 0x00600000:
USBA : EP0 setup
deligate SETUP Type =    6  200    0
ETH setup
eth_setup
respond with data transfer before status phase
ep0: queue req 77fec848, len 80
WE TRANSMITTED DATA ep= ep0
ep_queue 80 req80.06 v0200 i0000 l80
ETH control Status 00000000
END OF USBA_CONTRL_IRQ !!!!
EP 0 = control
ep0 [1]: s/0001c000 c/00001801
usba_control_irq : USBA_TX_PK_RDY
ep0 : submit_request: req 77fec848 (length 80)
ep0: submit_transaction, req 77fec848 (length 64)
ep0 [1]: s/0405c800 c/00001801
END OF USBA_CONTRL_IRQ !!!!
EP 0 = control
ep0 [1]: s/0001c400 c/00001801
usba_control_irq : USBA_TX_PK_RDY
ep0: submit_transaction, req 77fec848 (length 16), done
ep0 [1]: s/0105cc00 c/00001401
usba_control_irq : USBA_TX_COMPLETE
USBA : DATA Stage in
ep0 [4]: s/8085d000 c/00001201
USBA : USBA_RX_SETUP
DROPPING DATA ep0
ep0: req 77fec848 complete: status 0, actual 80
Packet length: 8
Copying ctrl request from 0x00600000:
USBA : EP0 setup
deligate SETUP Type =    6  300    0
ETH setup
eth_setup
wValue and 0xff = 0x0  4
String = Atmel1 G45
respond with data transfer before status phase
ep0: queue req 77fec848, len 4
WE TRANSMITTED DATA ep= ep0
ep_queue 4 req80.06 v0300 i0000 l255
ETH control Status 00000000
END OF USBA_CONTRL_IRQ !!!!
EP 0 = control
ep0 [1]: s/0001c000 c/00001801
usba_control_irq : USBA_TX_PK_RDY
ep0 : submit_request: req 77fec848 (length 4)
ep0: submit_transaction, req 77fec848 (length 4), done
ep0 [1]: s/0045c800 c/00001401
END OF USBA_CONTRL_IRQ !!!!
EP 0 = control
ep0 [1]: s/8085d400 c/00001401
usba_control_irq : USBA_TX_COMPLETE
USBA : DATA Stage in
ep0 [4]: s/8085d000 c/00001201
USBA : USBA_RX_SETUP
DROPPING DATA ep0
ep0: req 77fec848 complete: status 0, actual 4
Packet length: 8
Copying ctrl request from 0x00600000:
USBA : EP0 setup
deligate SETUP Type =    6  302  409
ETH setup
eth_setup
wValue and 0xff = 0x2  32
String = 
respond with data transfer before status phase
ep0: queue req 77fec848, len 32
WE TRANSMITTED DATA ep= ep0
ep_queue 32 req80.06 v0302 i0409 l255
ETH control Status 00000000
END OF USBA_CONTRL_IRQ !!!!
EP 0 = control
ep0 [1]: s/0001c000 c/00001801
usba_control_irq : USBA_TX_PK_RDY
ep0 : submit_request: req 77fec848 (length 32)
ep0: submit_transaction, req 77fec848 (length 32), done
ep0 [1]: s/0205c800 c/00001401
END OF USBA_CONTRL_IRQ !!!!
EP 0 = control
ep0 [1]: s/8085d400 c/00001401
usba_control_irq : USBA_TX_COMPLETE
USBA : DATA Stage in
ep0 [4]: s/8085d000 c/00001201
USBA : USBA_RX_SETUP
DROPPING DATA ep0
ep0: req 77fec848 complete: status 0, actual 32
Packet length: 8
Copying ctrl request from 0x00600000:
USBA : EP0 setup
deligate SETUP Type =    6  301  409
ETH setup
eth_setup
wValue and 0xff = 0x1  22
String = Ethernet Gadget
respond with data transfer before status phase
ep0: queue req 77fec848, len 22
WE TRANSMITTED DATA ep= ep0
ep_queue 22 req80.06 v0301 i0409 l255
ETH control Status 00000000
END OF USBA_CONTRL_IRQ !!!!
EP 0 = control
ep0 [1]: s/0001c000 c/00001801
usba_control_irq : USBA_TX_PK_RDY
ep0 : submit_request: req 77fec848 (length 22)
ep0: submit_transaction, req 77fec848 (length 22), done
ep0 [1]: s/0165c800 c/00001401
END OF USBA_CONTRL_IRQ !!!!
EP 0 = control
ep0 [1]: s/8084d400 c/00001401
usba_control_irq : USBA_TX_COMPLETE
USBA : DATA Stage in
ep0 [4]: s/8084d000 c/00001201
USBA : USBA_RX_SETUP
DROPPING DATA ep0
ep0: req 77fec848 complete: status 0, actual 22
Packet length: 8
Copying ctrl request from 0x00600000:
USBA : EP0 setup
deligate SETUP Type =    9    1    0
ETH setup
eth_setup
ETH set config
Set ETH config
Endpoint enable ep 3
ep3: EPT_SIZE = 1 (maxpacket = 16)
ep3: is IN endpoint
ep3: is INT endpoint
ep3 CFG = 0x79
ep3 not using DMA
EPT_CFG3 after init: 0x80000079
INT_ENB after init: 0x000952
INT_STA after init: 0x000025
EPT_CTL_ENB3 after init: 0x000000
EPT_CTL_DIS3 after init: 0x000000
EPT_CTL3 after init: 0x000001
EPT_STA3 after init: 0x000000
udc: alloc_req: request[2]
alloc requests
udc: alloc_req: request[3]
high speed config #1: 2 mA, Ethernet Gadget, using CDC Ethernet
respond with data transfer before status phase
ep0: queue req 77fec848, len 0
WE TRANSMITTED DATA ep= ep0
ep_queue 0 req00.09 v0001 i0000 l0
ETH control Status 00000000
END OF USBA_CONTRL_IRQ !!!!
EP 0 = control
ep0 [3]: s/0000c000 c/00001801
usba_control_irq : USBA_TX_PK_RDY
ep0 : submit_request: req 77fec848 (length 0)
ep0: submit_transaction, req 77fec848 (length 0), done
ep0 [3]: s/0004c800 c/00001401
END OF USBA_CONTRL_IRQ !!!!
EP 0 = control
ep0 [3]: s/8085d400 c/00001401
usba_control_irq : USBA_TX_COMPLETE
USBA : Status stage in
ep0: req 77fec848 complete: status 0, actual 0
ep0 [0]: s/8085d000 c/00001001
USBA : USBA_RX_SETUP
Packet length: 8
Copying ctrl request from 0x00600000:
USBA : EP0 setup
deligate SETUP Type =    6  307  409
ETH setup
eth_setup
wValue and 0xff = 0x7  26
String = <NULL>
respond with data transfer before status phase
ep0: queue req 77fec848, len 26
WE TRANSMITTED DATA ep= ep0
ep_queue 26 req80.06 v0307 i0409 l255
ETH control Status 00000000
END OF USBA_CONTRL_IRQ !!!!
EP 0 = control
ep0 [1]: s/0001c000 c/00001801
usba_control_irq : USBA_TX_PK_RDY
ep0 : submit_request: req 77fec848 (length 26)
ep0: submit_transaction, req 77fec848 (length 26), done
ep0 [1]: s/01a5c800 c/00001401
END OF USBA_CONTRL_IRQ !!!!
EP 0 = control
ep0 [1]: s/8085d400 c/00001401
usba_control_irq : USBA_TX_COMPLETE
USBA : DATA Stage in
ep0 [4]: s/8085d000 c/00001201
USBA : USBA_RX_SETUP
DROPPING DATA ep0
ep0: req 77fec848 complete: status 0, actual 26
Packet length: 8
Copying ctrl request from 0x00600000:
USBA : EP0 setup
deligate SETUP Type =    6  305  409
ETH setup
eth_setup
wValue and 0xff = 0x5  54
String = CDC Ethernet
respond with data transfer before status phase
ep0: queue req 77fec848, len 54
WE TRANSMITTED DATA ep= ep0
ep_queue 54 req80.06 v0305 i0409 l255
ETH control Status 00000000
END OF USBA_CONTRL_IRQ !!!!
EP 0 = control
ep0 [1]: s/0001c000 c/00001801
usba_control_irq : USBA_TX_PK_RDY
ep0 : submit_request: req 77fec848 (length 54)
ep0: submit_transaction, req 77fec848 (length 54), done
ep0 [1]: s/0365c800 c/00001401
END OF USBA_CONTRL_IRQ !!!!
EP 0 = control
ep0 [1]: s/8084d400 c/00001401
usba_control_irq : USBA_TX_COMPLETE
USBA : DATA Stage in
ep0 [4]: s/8084d000 c/00001201
USBA : USBA_RX_SETUP
DROPPING DATA ep0
ep0: req 77fec848 complete: status 0, actual 54
Packet length: 8
Copying ctrl request from 0x00600000:
USBA : EP0 setup
deligate SETUP Type =    b    1    1
ETH setup
eth_setup
Set data
Endpoint disable ep 1
Endpoint disable ep 2
Endpoint enable ep 1
ep1: EPT_SIZE = 6 (maxpacket = 512)
ep1: is IN endpoint
ep1: is BULK endpoint
ep1 CFG = 0x6e
ep1 not using DMA
EPT_CFG1 after init: 0x8000006e
INT_ENB after init: 0x000b52
INT_STA after init: 0x000025
EPT_CTL_ENB1 after init: 0x000000
EPT_CTL_DIS1 after init: 0x000000
EPT_CTL1 after init: 0x000001
EPT_STA1 after init: 0x000000
Endpoint enable ep 2
ep2: EPT_SIZE = 6 (maxpacket = 512)
ep2: is BULK endpoint
ep2 CFG = 0x66
ep2 not using DMA
EPT_CFG2 after init: 0x80000066
INT_ENB after init: 0x000f52
INT_STA after init: 0x000029
EPT_CTL_ENB2 after init: 0x000000
EPT_CTL_DIS2 after init: 0x000000
EPT_CTL2 after init: 0x000001
EPT_STA2 after init: 0x000040
Issue start status
Endpoint disable ep 3
Endpoint enable ep 3
ep3: EPT_SIZE = 1 (maxpacket = 16)
ep3: is IN endpoint
ep3: is INT endpoint
ep3 CFG = 0x79
ep3 not using DMA
EPT_CFG3 after init: 0x80000079
INT_ENB after init: 0x000f52
INT_STA after init: 0x000029
EPT_CTL_ENB3 after init: 0x000000
EPT_CTL_DIS3 after init: 0x000000
EPT_CTL3 after init: 0x000001
EPT_STA3 after init: 0x000000
ep3: queue req 77fec880, len 8
WE TRANSMITTED DATA ep= ep3
respond with data transfer before status phase
ep0: queue req 77fec848, len 0
WE TRANSMITTED DATA ep= ep0
ep_queue 0 req01.0b v0001 i0001 l0
ETH control Status 00000000
END OF USBA_CONTRL_IRQ !!!!
EP 0 = control
ep0 [3]: s/0000c000 c/00001801
usba_control_irq : USBA_TX_PK_RDY
ep0 : submit_request: req 77fec848 (length 0)
ep0: submit_transaction, req 77fec848 (length 0), done
ep0 [3]: s/0004c800 c/00001401
END OF USBA_CONTRL_IRQ !!!!
EP = 3
ep3: interrupt, status: 0x00000000
ep3: TX PK ready
TX submit ep3
ep3 : submit_request: req 77fec880 (length 8)
ep3: submit_transaction, req 77fec880 (length 8), done
last transaction ep3
ep3: req 77fec880 complete: status 0, actual 8
ep3: queue req 77fec880, len 16
WE TRANSMITTED DATA ep= ep3
send SPEED_CHANGE --> 0
ep3 status = 840800
EP 0 = control
ep0 [3]: s/8085d400 c/00001401
usba_control_irq : USBA_TX_COMPLETE
USBA : Status stage in
ep0: req 77fec848 complete: status 0, actual 0
ep0 [0]: s/8085d000 c/00001001
USBA : USBA_RX_SETUP
Packet length: 8
Copying ctrl request from 0x00600000:
USBA : EP0 setup
deligate SETUP Type =    6  303  409
ETH setup
eth_setup
wValue and 0xff = 0x3  26
String = Ethernet Data
respond with data transfer before status phase
ep0: queue req 77fec848, len 26
WE TRANSMITTED DATA ep= ep0
ep_queue 26 req80.06 v0303 i0409 l255
ETH control Status 00000000
END OF USBA_CONTRL_IRQ !!!!
EP 0 = control
ep0 [1]: s/0001c000 c/00001801
usba_control_irq : USBA_TX_PK_RDY
ep0 : submit_request: req 77fec848 (length 26)
ep0: submit_transaction, req 77fec848 (length 26), done
ep0 [1]: s/01a5c800 c/00001401
END OF USBA_CONTRL_IRQ !!!!
EP 0 = control
ep0 [1]: s/8085d400 c/00001401
usba_control_irq : USBA_TX_COMPLETE
USBA : DATA Stage in
ep0 [4]: s/8085d000 c/00001201
USBA : USBA_RX_SETUP
DROPPING DATA ep0
ep0: req 77fec848 complete: status 0, actual 26
Packet length: 8
Copying ctrl request from 0x00600000:
USBA : EP0 setup
deligate SETUP Type =    6  304  409
ETH setup
eth_setup
wValue and 0xff = 0x4  28
String = 0AFA638BE80A
respond with data transfer before status phase
ep0: queue req 77fec848, len 28
WE TRANSMITTED DATA ep= ep0
ep_queue 28 req80.06 v0304 i0409 l255
ETH control Status 00000000
END OF USBA_CONTRL_IRQ !!!!
EP 0 = control
ep0 [1]: s/0001c000 c/00001801
usba_control_irq : USBA_TX_PK_RDY
ep0 : submit_request: req 77fec848 (length 28)
ep0: submit_transaction, req 77fec848 (length 28), done
ep0 [1]: s/01c5c800 c/00001401
END OF USBA_CONTRL_IRQ !!!!
EP 0 = control
ep0 [1]: s/8005c640 c/00001401
usba_control_irq : USBA_TX_COMPLETE
USBA : DATA Stage in
ep0 [4]: s/8005c240 c/00001201
USBA : USBA_RX_BK_RDY
ep0 : USBA :STATUS_STAGE_OUT
ep0 : USBA :call request complete
ep0: req 77fec848 complete: status 0, actual 28
ep0 [0]: s/0001c040 c/00001001
END OF USBA_CONTRL_IRQ !!!!
EP = 3
ep3: interrupt, status: 0x00000440
ep3: TX PK ready
TX submit ep3
ep3 : submit_request: req 77fec880 (length 16)
ep3: submit_transaction, req 77fec880 (length 16), done
last transaction ep3
ep3: req 77fec880 complete: status 0, actual 16
Speed value --> 0
event 2a --> 0
USB network up!
ep3 status = 1040c40
rx_submit
size 1 = 1570
size 2 = 2081
size 3 = 2048
ep2: queue req 77fec8f0, len 2048
udc: invalid request
NO REQUEST BUF
Received ETH pack : 00 00 00 00 00 00 00 00
ERROR: rx submit --> -22
at ether.c:1289/rx_submit()
### main_loop entered: bootdelay=3

### main_loop: bootcmd="mtdparts default; nand read 0x71000000 nand0,0; bootm 
0x71000000"
Hit any key to stop autoboot:  0 
Sam9g45>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] usage of DMA
  2011-01-18 14:06       ` Vitaly Kuzmichev
@ 2011-01-18 18:12         ` Marcel
  0 siblings, 0 replies; 10+ messages in thread
From: Marcel @ 2011-01-18 18:12 UTC (permalink / raw)
  To: u-boot

On Tuesday, January 18, 2011 03:06:21 pm Vitaly Kuzmichev wrote:
> Hi Marcel,
> 
> In addition, did you enable CONFIG_USB_GADGET_DUALSPEED option in your
> u-boot config file?

Yes I did enabled this.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] usage of DMA
  2011-01-18 18:11       ` Marcel
@ 2011-01-19  9:04         ` Vitaly Kuzmichev
  2011-01-19 21:33           ` Marcel
  2011-01-19 22:44           ` Marcel
  0 siblings, 2 replies; 10+ messages in thread
From: Vitaly Kuzmichev @ 2011-01-19  9:04 UTC (permalink / raw)
  To: u-boot

Hi Marcel,

Marcel wrote:
>> Could you enable debug output for ether.c and for your UDC driver and
>> show the results?
> 
> I enabled a lot of extra debugging messages so this is not very short.
> The output attached below is including start of macb but USB device behave the 
> same when I don't enable that.
> 
> [...]
> 
> USB network up!
> ep3 status = 1040c40
> rx_submit
> size 1 = 1570
> size 2 = 2081
> size 3 = 2048
> ep2: queue req 77fec8f0, len 2048
> udc: invalid request
> NO REQUEST BUF
> Received ETH pack : 00 00 00 00 00 00 00 00
> ERROR: rx submit --> -22
> at ether.c:1289/rx_submit()
> ### main_loop entered: bootdelay=3
> 
> ### main_loop: bootcmd="mtdparts default; nand read 0x71000000 nand0,0; bootm 
> 0x71000000"
> Hit any key to stop autoboot:  0 
> Sam9g45>

First, I don't completely understand how do you use the gadget driver.
You do not run any commands from u-boot prompt and your bootcmd does not
have any network actions.
Why your usb gadget driver becomes started?

Second, could you add the following debug printout into rx_submit and
check that NetRxPackets is really initialized?

@@ -1261,6 +1261,8 @@ static int rx_submit(struct eth_dev *dev
 	req->length = size;
 	req->complete = rx_complete;

+	printf("NetRxPackets[0] = %p !!!\n", NetRxPackets[0]);
+
 	retval = usb_ep_queue(dev->out_ep, req, gfp_flags);

 	if (retval)

---

Since NetRxPackets is defined as an array of pointers, it needs to be
initialized. And NetLoop does this:

volatile uchar *NetRxPackets[PKTBUFSRX];
...
int
NetLoop(proto_t protocol)
{
        bd_t *bd = gd->bd;
...
        if (!NetTxPacket) {
                int     i;
                /*
                 *      Setup packet buffers, aligned correctly.
                 */
                NetTxPacket = &PktBuf[0] + (PKTALIGN - 1);
                NetTxPacket -= (ulong)NetTxPacket % PKTALIGN;
                for (i = 0; i < PKTBUFSRX; i++) {
                        NetRxPackets[i] = NetTxPacket + (i+1)*PKTSIZE_ALIGN;
                }
        }
...

So I fear that your gadget is started manually. You should not do that!
The only thing that you can do with your udc driver during the board
initialization is the following:

static struct usba_platform_data usba_pdata = {
...
};

int board_eth_init(bd_t *bis)
{
       int rc = 0;
#if defined(CONFIG_USB_ETHER) && defined(CONFIG_USB_GADGET_ATMEL_USBA)
       rc = usba_udc_probe(&usba_pdata);
       if (!rc)
               rc = usb_eth_initialize(bis);
#endif
        return rc;
}

If you want to autoboot from tftp you should specify bootcmd environment
variable to something like "tftp uImage; bootm".
And always use usb gadget only with network commands like tftp, dhcp,
ping, etc.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] usage of DMA
  2011-01-19  9:04         ` Vitaly Kuzmichev
@ 2011-01-19 21:33           ` Marcel
  2011-01-19 22:44           ` Marcel
  1 sibling, 0 replies; 10+ messages in thread
From: Marcel @ 2011-01-19 21:33 UTC (permalink / raw)
  To: u-boot

Hi Vitaly,

Thanks so much for your reply. I got a little further now.

> Marcel wrote:
> >> Could you enable debug output for ether.c and for your UDC driver and
> >> show the results?
> > 
> > I enabled a lot of extra debugging messages so this is not very short.
> > The output attached below is including start of macb but USB device
> > behave the same when I don't enable that.
> > 
> > [...]
> > 
> > USB network up!
> > ep3 status = 1040c40
> > rx_submit
> > size 1 = 1570
> > size 2 = 2081
> > size 3 = 2048
> > ep2: queue req 77fec8f0, len 2048
> > udc: invalid request
> > NO REQUEST BUF
> > Received ETH pack : 00 00 00 00 00 00 00 00
> > ERROR: rx submit --> -22
> > at ether.c:1289/rx_submit()
> > ### main_loop entered: bootdelay=3
> > 
> > ### main_loop: bootcmd="mtdparts default; nand read 0x71000000 nand0,0;
> > bootm 0x71000000"
> > Hit any key to stop autoboot:  0
> > Sam9g45>
> 
> First, I don't completely understand how do you use the gadget driver.
> You do not run any commands from u-boot prompt and your bootcmd does not
> have any network actions.
> Why your usb gadget driver becomes started?

A good question. I enable it in board_eth_init as you mention below.

> Second, could you add the following debug printout into rx_submit and
> check that NetRxPackets is really initialized?
> 
> @@ -1261,6 +1261,8 @@ static int rx_submit(struct eth_dev *dev
>  	req->length = size;
>  	req->complete = rx_complete;
> 
> +	printf("NetRxPackets[0] = %p !!!\n", NetRxPackets[0]);
> +
>  	retval = usb_ep_queue(dev->out_ep, req, gfp_flags);
> 
>  	if (retval)
> 
> ---

It printed :
NetRxPackets[0] = (null) !!!


> Since NetRxPackets is defined as an array of pointers, it needs to be
> initialized. And NetLoop does this:

So far I figured as well, just not why this didn't happen.

> So I fear that your gadget is started manually. You should not do that!

I fear you where right about that. I don't know for sure what triggered it but 
after I disabled CONFIG_MACB in my config things looked a whole lot different !

> The only thing that you can do with your udc driver during the board
> initialization is the following:
> 
> static struct usba_platform_data usba_pdata = {
> ...
> };
> 
> int board_eth_init(bd_t *bis)
> {
>        int rc = 0;
> #if defined(CONFIG_USB_ETHER) && defined(CONFIG_USB_GADGET_ATMEL_USBA)
>        rc = usba_udc_probe(&usba_pdata);
>        if (!rc)
>                rc = usb_eth_initialize(bis);
> #endif
>         return rc;
> }

This is what I did.

> If you want to autoboot from tftp you should specify bootcmd environment
> variable to something like "tftp uImage; bootm".
> And always use usb gadget only with network commands like tftp, dhcp,
> ping, etc.

I'm quite sure the initialisation was the issue, causing the buffers to be fine. 
I still wonder how it exactly works, but since it's alive now, I can continue 
to find out what really happens.

I do wonder about whether I can use both normal ethernet and USB-gadget (cdc) 
at the same time, other whether it's restricted to using only one.

Thanks so much for your reply. I'm sure I could have stared at this for 
another couple of days and be looking in the wrong places over and over again.

Best regards,
Marcel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] usage of DMA
  2011-01-19  9:04         ` Vitaly Kuzmichev
  2011-01-19 21:33           ` Marcel
@ 2011-01-19 22:44           ` Marcel
  1 sibling, 0 replies; 10+ messages in thread
From: Marcel @ 2011-01-19 22:44 UTC (permalink / raw)
  To: u-boot

Hi Vitaly,

> If you want to autoboot from tftp you should specify bootcmd environment
> variable to something like "tftp uImage; bootm".
> And always use usb gadget only with network commands like tftp, dhcp,
> ping, etc.

Currently it boots to the prompt. Than when I specify things like the above it 
starts to register the gadget driver. Is that the way it's supposed to work ?

I wonder about how to deal with this from the host side as it must also set up 
the usb0 network interface but can do that only after the gadget driver is 
fully loaded.

Sorry for my little knowledge on the cdc stuff. My knowledge on USB is far 
better than ethernet. I'm basically just using ether.c because it's available 
already and sounded like a good idea to start with instead of writing a new 
driver or implement another one. Eventually I plan to include DFU or something 
else though.

best regards,
Marcel

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-01-19 22:44 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-11 21:51 [U-Boot] {Spam?} usage of DMA Marcel
2011-01-16  7:56 ` Albert ARIBAUD
2011-01-17 20:48   ` [U-Boot] " Marcel
2011-01-18 13:36     ` Vitaly Kuzmichev
2011-01-18 14:06       ` Vitaly Kuzmichev
2011-01-18 18:12         ` Marcel
2011-01-18 18:11       ` Marcel
2011-01-19  9:04         ` Vitaly Kuzmichev
2011-01-19 21:33           ` Marcel
2011-01-19 22:44           ` Marcel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.