Fix USB driver on GNU/Linux.

This commit is contained in:
NIIBE Yutaka
2017-07-06 15:52:46 +09:00
parent 478dd2c784
commit 5d9802388c
4 changed files with 20 additions and 23 deletions

View File

@@ -1,3 +1,9 @@
2017-07-06 NIIBE Yutaka <gniibe@fsij.org>
* mcu/usb-usbip.c (hc_handle_data_urb): Fix the condition of the
end of transaction.
(read_data_transaction): Allow partial read by host.
2017-07-05 NIIBE Yutaka <gniibe@fsij.org> 2017-07-05 NIIBE Yutaka <gniibe@fsij.org>
* example-fraucheky: New. * example-fraucheky: New.

View File

@@ -9,6 +9,7 @@ vidpid=none
verbose=no verbose=no
debug=no debug=no
with_fraucheky=yes with_fraucheky=yes
with_index=./INDEX.HTM
if test -d ../.git; then if test -d ../.git; then
REVISION=`git describe --dirty="-modified"` REVISION=`git describe --dirty="-modified"`
@@ -34,8 +35,6 @@ for option; do
verbose=yes ;; verbose=yes ;;
--vidpid=*) --vidpid=*)
vidpid=$optarg ;; vidpid=$optarg ;;
--with-index=*)
with_index=$optarg ;;
*) *)
echo "Unrecognized option \`$option'" >&2 echo "Unrecognized option \`$option'" >&2
echo "Try \`$0 --help' for more information." >&2 echo "Try \`$0 --help' for more information." >&2

View File

@@ -289,12 +289,6 @@ static char __process3_stack_base__[4096];
#define main emulated_main #define main emulated_main
#endif #endif
void
usb_lld_write (uint8_t ep_num, const void *buf, size_t len)
{
usb_lld_tx_enable_buf (ep_num, buf, len);
}
/* /*
* Entry point. * Entry point.
* *

View File

@@ -505,7 +505,7 @@ hc_handle_data_urb (struct usb_control *usbc_p)
urb->data_p += count; urb->data_p += count;
urb->remain -= count; urb->remain -= count;
if (count < 64) if (urb->remain == 0 || count < 64)
{ {
size_t len = urb->len - urb->remain; size_t len = urb->len - urb->remain;
@@ -532,11 +532,11 @@ hc_handle_data_urb (struct usb_control *usbc_p)
urb->remain -= r; urb->remain -= r;
urb->data_p += r; urb->data_p += r;
if (r < 64) if (urb->remain == 0 || r < 64)
{ {
size_t len = urb->len - urb->remain; size_t len = urb->len - urb->remain;
fprintf (stderr, "<-data: %lu\n", len); fprintf (stderr, "<-data: %lu %d\n", len, r);
// successfully finished // successfully finished
if (len) if (len)
{ {
@@ -1257,7 +1257,7 @@ control_read_data_transaction (char *buf, uint16_t count)
if (usbc_ep0.state == USB_STATE_READY) if (usbc_ep0.state == USB_STATE_READY)
{ {
if (usbc_ep0.len > count) if (usbc_ep0.len > count)
fprintf (stderr, "*** length %d\n", usbc_ep0.len); fprintf (stderr, "***c read: length %d > %d\n", usbc_ep0.len, count);
else else
count = usbc_ep0.len; count = usbc_ep0.len;
@@ -1339,16 +1339,14 @@ read_data_transaction (struct usb_control *usbc_p,
int ep_num, char *buf, uint16_t count) int ep_num, char *buf, uint16_t count)
{ {
if (usbc_p->len > count) if (usbc_p->len > count)
{ fprintf (stderr, "*** length %d > %d\n", usbc_p->len, count);
fprintf (stderr, "*** length %d\n", usbc_p->len); else
usbc_p->state = USB_STATE_STALL; count = usbc_p->len;
return -EPIPE;
}
usbc_p->state = USB_STATE_NAK; usbc_p->state = USB_STATE_NAK;
memcpy (buf, usbc_p->buf, usbc_p->len); memcpy (buf, usbc_p->buf, count);
notify_device (USB_INTR_DATA_TRANSFER, ep_num, USBIP_DIR_IN); notify_device (USB_INTR_DATA_TRANSFER, ep_num, USBIP_DIR_IN);
return usbc_p->len; return count;
} }
void chx_handle_intr (uint32_t irq_num); void chx_handle_intr (uint32_t irq_num);
@@ -2135,14 +2133,14 @@ usb_lld_setup_endp (struct usb_dev *dev, int ep_num, int rx_en, int tx_en)
void void
usb_lld_stall_tx (int ep_num) usb_lld_stall_tx (int ep_num)
{ {
printf ("stall tx %d", ep_num); printf ("stall tx %d\n", ep_num);
usbc_ep_in[ep_num].state = USB_STATE_STALL; usbc_ep_in[ep_num].state = USB_STATE_STALL;
} }
void void
usb_lld_stall_rx (int ep_num) usb_lld_stall_rx (int ep_num)
{ {
printf ("stall rx %d", ep_num); printf ("stall rx %d\n", ep_num);
usbc_ep_out[ep_num].state = USB_STATE_STALL; usbc_ep_out[ep_num].state = USB_STATE_STALL;
} }
@@ -2175,5 +2173,5 @@ usb_lld_tx_enable_buf (int ep_num, const void *buf, size_t len)
usbc_p->len = len; usbc_p->len = len;
write (usbc_p->eventfd, &l, sizeof (l)); write (usbc_p->eventfd, &l, sizeof (l));
pthread_mutex_unlock (&usbc_p->mutex); pthread_mutex_unlock (&usbc_p->mutex);
printf ("usb_lld_tx_enable_buf: %d\n", ep_num); printf ("usb_lld_tx_enable_buf: %d %ld\n", ep_num, len);
} }