USB Driver STALL problem

hii all
i have written a USB Class driver .it is working fine if i am
transferring less number of data & also it is stable.if i am
trying to write more number of datas It is working fine for the first
time but when i am going to write again sometimes it is writting
properly & sometimes it is showing error in URB status(bulk out)
that is operation is not completed & the usb bulk pipe is stalled
what might be the problem?
can anybody suggest some solutions to this problem.

with regards
anthony

anthony <sashi_1432002@yahoo.co-dot-in.no-spam.invalid> wrote in message
news:cuctpu$oek$1@inn.qnx.com

hii all
i have written a USB Class driver .it is working fine if i am
transferring less number of data & also it is stable.if i am
trying to write more number of datas It is working fine for the first
time but when i am going to write again sometimes it is writting
properly & sometimes it is showing error in URB status(bulk out)
that is operation is not completed & the usb bulk pipe is stalled
what might be the problem?
can anybody suggest some solutions to this problem.

What type of device are you working with ?
A STALL indicates a problem with the pipe. If the device
didn’t like the data you sent on the pipe it would issue a STALL.
You would then need to reset the pipe to clear the condition.

Henry

with regards
anthony

hi henry
thanks for the reply.i am writting for modem.i am also
resetting the pipe.i am also getting another problem while reading
that is urb status as timeout with incomplete operation.
can u give any suggestions to rectify it.

with regards
anthony

You need to determine why the device is STALLing your io request
and why the read is timing out. The read request will timeout if the device
hasnt sent the requested data in the time specified in the usbd_io request.
Possibly you need to set this to infinity ? (depends on the nature of the
device)

Henry

anthony <sashi_1432002@yahoo.co-dot-in.no-spam.invalid> wrote in message
news:cuet2r$9uj$1@inn.qnx.com

hi henry
thanks for the reply.i am writting for modem.i am also
resetting the pipe.i am also getting another problem while reading
that is urb status as timeout with incomplete operation.
can u give any suggestions to rectify it.

with regards
anthony

hii henry
thanks for your suggestion.in usbd_io i have set time
flag as USBD_TIME_INFINITY.but even that it is showing timeout.i
think in my write part some problem is there that is, it is not
writing properly.if it will not write properly then in read we will
get timeout?
please clarify me if i am wrong.

take care
with regards
anthony

hii henry
i have sorted out the timeout & the stall in bulk out
pipe.now another problem came that is the read i.e., bulk in pipe is
stalled while reading.why it is stalling i am unable to sort it
out.what might be the problem?please give me a reply.

take care
with regards
anthony

The device issues a STALL if there is some error with the pipe/device.

For instance if you send a command on the control pipe that the device
doesnt undertstand,. the device will issue a STALL when trying to read
data back. This is the devices way of indicating it recieved data it did
not understand. ( ie an unknown command)

You need to figure out what is causing the STALL condition. Possibly you
are sending a bad command to the device, not following some protocol
that the device uses …

Henry


anthony <sashi_1432002@yahoo.co-dot-in.no-spam.invalid> wrote in message
news:cupeib$6g7$1@inn.qnx.com

hii henry
i have sorted out the timeout & the stall in bulk out
pipe.now another problem came that is the read i.e., bulk in pipe is
stalled while reading.why it is stalling i am unable to sort it
out.what might be the problem?please give me a reply.

take care
with regards
anthony

hii henry
thanks . the maximum packet size is 64 bytes.say if i am
going to write 400 bytes then my driver should write 64 bytes each
time & it is writing perfectly but if the bytes remaining are
less than 64 bytes then it is showing “alen” in usbd_urb_status
wrong.that is
400-64=336,(64 bytes are written & alen = 64)
336-64=272,(64 bytes are written & alen = 64)
272-64=208,(64 bytes are written & alen = 64)
208-64=144,(64 bytes are written & alen = 64)
144-64=80,(64 bytes are written & alen = 64)
80-64=24,(64 bytes are written & alen = 64)
upto this it is writting correctly then the problem lies …
now my driver should write the remaining 24bytes ,i am setting up the
bulk urb for 24 bytes & using usbd_io i am trasferring 24 bytes
but in usbd_urb_status it is showing alen = 64 after that my count is
becoming negative.i am not getting, howcome it is showing alen = 64 as
i am writing 24 bytes.
after this when it is reading it is showing STALL error with i/o non
completion.
i think this might be causing the problem of STALL.
please give me some suggestions how to get rid of it.

with regards
anthony

anthony <sashi_1432002@yahoo.co-dot-in.no-spam.invalid> wrote in message
news:cus9v6$csl$1@inn.qnx.com

hii henry
thanks . the maximum packet size is 64 bytes.say if i am
going to write 400 bytes then my driver should write 64 bytes each
time & it is writing perfectly but if the bytes remaining are
less than 64 bytes then it is showing “alen” in usbd_urb_status
wrong.that is
400-64=336,(64 bytes are written & alen = 64)
336-64=272,(64 bytes are written & alen = 64)
272-64=208,(64 bytes are written & alen = 64)
208-64=144,(64 bytes are written & alen = 64)
144-64=80,(64 bytes are written & alen = 64)
80-64=24,(64 bytes are written & alen = 64)
upto this it is writting correctly then the problem lies …
now my driver should write the remaining 24bytes ,i am setting up the
bulk urb for 24 bytes & using usbd_io i am trasferring 24 bytes
but in usbd_urb_status it is showing alen = 64 after that my count is
becoming negative.i am not getting, howcome it is showing alen = 64 as
i am writing 24 bytes.

There was a bug in 6.30(fixed in SP1) where this could happen. As a work
around
could you call usbd_urb_status() a second time to see it the length gets set
correctly.
The actual transfer to the device is 24 bytes, its just that the status
complete is being set
before the completed size in the URB done processing thread.

Henry

after this when it is reading it is showing STALL error with i/o non
completion.
i think this might be causing the problem of STALL.
please give me some suggestions how to get rid of it.

with regards
anthony

Henry VanDyke <henry@qnx.com> wrote in message
news:cut0e9$166$1@inn.qnx.com

anthony <> sashi_1432002@yahoo.co-dot-in.no-spam.invalid> > wrote in message
news:cus9v6$csl$> 1@inn.qnx.com> …
hii henry
thanks . the maximum packet size is 64 bytes.say if i am
going to write 400 bytes then my driver should write 64 bytes each
time & it is writing perfectly but if the bytes remaining are
less than 64 bytes then it is showing “alen” in usbd_urb_status
wrong.that is
400-64=336,(64 bytes are written & alen = 64)
336-64=272,(64 bytes are written & alen = 64)
272-64=208,(64 bytes are written & alen = 64)
208-64=144,(64 bytes are written & alen = 64)
144-64=80,(64 bytes are written & alen = 64)
80-64=24,(64 bytes are written & alen = 64)

80-64=16 ?

upto this it is writting correctly then the problem lies …
now my driver should write the remaining 24bytes ,i am setting up the
bulk urb for 24 bytes & using usbd_io i am trasferring 24 bytes
but in usbd_urb_status it is showing alen = 64 after that my count is
becoming negative.i am not getting, howcome it is showing alen = 64 as
i am writing 24 bytes.

There was a bug in 6.30(fixed in SP1) where this could happen. As a work
around
could you call usbd_urb_status() a second time to see it the length gets
set
correctly.
The actual transfer to the device is 24 bytes, its just that the status
complete is being set
before the completed size in the URB done processing thread.

Henry

after this when it is reading it is showing STALL error with i/o non
completion.
i think this might be causing the problem of STALL.
please give me some suggestions how to get rid of it.

with regards
anthony

hii henry
thanks.i am trying to implement it.i will get back to you
with some results.

take care
with regards
anthony

hii henry
i have tried it, still the problem is not sorted out.in write part i
am doing :

usbd_setup_bulk(bulk_out_urb,URB_DIR_OUT|URB_SHORT_XFER_OK,bulk_out_buf,bulk_out_cnt);

usbd_io(bulk_out_urb,bulk_out_pipe,bulk_out_cbf,modem,USBD_TIME_INFINITY);

here the problem is that i am calling bulk_out_cbf from usbd_io,when
bulk_out_cnt is equal to 64 bytes it is called once & it is
working fine but when it is becoming less than 64 bytes then the
problem comes that is bulk_out_cbf is called twice .

for e.g.,
if i am writing 90bytes then
then the flow is :
write(write 64bytes)->bulk_out_cbf->write(writes
90-64=26bytes)->bulk_out_cbf->bulk_out_cbf

here atlast bulk_out_cbf is called twice.that is creating the
problem.
can you tell me why this is being called twice.just suggest me what to
do.

take care
with regards
anthony

Where are you issuing the second usbd_io for the 26 bytes ?
From the cbf ?
Are you waiting for the first usbdi_io write to complete before sending
the second one ?

You could send all of the data(90 bytes) in one
usbd_setup_bulk()/usbdi_io() call.


anthony <sashi_1432002@yahoo.co-dot-in.no-spam.invalid> wrote in message
news:cv53jk$7pj$1@inn.qnx.com

hii henry
i have tried it, still the problem is not sorted out.in write part i
am doing :


usbd_setup_bulk(bulk_out_urb,URB_DIR_OUT|URB_SHORT_XFER_OK,bulk_out_buf,bulk

_out_cnt);

usbd_io(bulk_out_urb,bulk_out_pipe,bulk_out_cbf,modem,USBD_TIME_INFINITY);

here the problem is that i am calling bulk_out_cbf from usbd_io,when
bulk_out_cnt is equal to 64 bytes it is called once & it is
working fine but when it is becoming less than 64 bytes then the
problem comes that is bulk_out_cbf is called twice .

for e.g.,
if i am writing 90bytes then
then the flow is :
write(write 64bytes)->bulk_out_cbf->write(writes
90-64=26bytes)->bulk_out_cbf->bulk_out_cbf

here atlast bulk_out_cbf is called twice.that is creating the
problem.
can you tell me why this is being called twice.just suggest me what to
do.

take care
with regards
anthony

hi henry,
thanks.i am calling cbf from write.i can’t transfer
90 bytes at a time because the maximum packet size for bulk out
endpoint is 64 bytes.one thing i am not waiting after usbd_io to
complete that is returning immediately after usbd_io.but i am calling
usbd_urb_status in cbf & i am getting status = 1000000(i/o
complete).
after usbd_io if i want to wait then how to implement this wait
please tell me.

waiting for your reply
take care
with regards
anthony

anthony <sashi_1432002@yahoo.co-dot-in.no-spam.invalid> wrote in message
news:cv6kq0$ba6$1@inn.qnx.com

hi henry,
thanks.i am calling cbf from write.i can’t transfer
90 bytes at a time because the maximum packet size for bulk out
endpoint is 64 bytes.

You can send more data than the Endpoint size. The USB stack/hardware
will send the entire buffer of data with the proper packet size for the
Endpoint.

one thing i am not waiting after usbd_io to

complete that is returning immediately after usbd_io.but i am calling
usbd_urb_status in cbf & i am getting status = 1000000(i/o
complete).
after usbd_io if i want to wait then how to implement this wait
please tell me.

write_data () {

usbd_setup_bulk(…);
usbd_io(…);
pthread_sleepon_lock( );
while( usbd_urb_status( urb, &ustatus, &alen ) == EBUSY ) {
pthread_sleepon_wait( urb );
}
pthread_sleepon_unlock( );


}


in cbf :
write_cbf (){
pthread_sleepon_lock( );
pthread_sleepon_signal( urb );
phread_sleepon_unlock( );
}

waiting for your reply
take care
with regards
anthony