There is a fencepost error in usb_dev.c related to NUM_ENDPOINTS. This bit me because I'm setting NUM_ENDPOINTS to 1, and I was getting STALL errors when trying to talk to endpoint 1; this was because usb_dev.c was never setting up the endpoint. After applying the patch, bulk transfers to endpoint 1 are working as expected.
Here is the patch:
Code:
--- usb_dev.c~ 2012-11-13 06:16:06.304414405 -0800
+++ usb_dev.c 2012-11-29 22:11:52.757192844 -0800
@@ -113,14 +113,14 @@
reg = &USB0_ENDPT1;
cfg = usb_endpoint_config_table;
// clear all BDT entries, free any allocated memory...
- for (i=4; i < NUM_ENDPOINTS*4; i++) {
+ for (i=4; i <= NUM_ENDPOINTS*4; i++) {
if (table[i].desc & BDT_OWN) {
usb_free((usb_packet_t *)((uint8_t *)(table[i].addr) - 8));
table[i].desc = 0;
}
}
usb_rx_memory_needed = 0;
- for (i=1; i < NUM_ENDPOINTS; i++) {
+ for (i=1; i <= NUM_ENDPOINTS; i++) {
epconf = *cfg++;
*reg = epconf;
reg += 4;