aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKévin Redon <kredon@sysmocom.de>2018-07-01 18:11:01 +0200
committerKing Kévin <kingkevin@cuvoodoo.info>2018-07-04 17:10:06 +0200
commita1012b170adc8630e3b6d1dd8edd277176d7b979 (patch)
treedc1319aa5e95da68097055ea235d5ac68d6b592d
parent42bd02641661f6b5d8a80be4a4f2732bca68aa39 (diff)
USB: add central file to define USB IDs, classes, and endpoints
-rw-r--r--firmware/atmel_softpack_libraries/usb/device/dfu/dfu_desc.c2
-rw-r--r--firmware/libboard/common/include/board_common.h15
-rw-r--r--firmware/libboard/owhw/include/board.h1
-rw-r--r--firmware/libboard/qmod/include/board.h1
-rw-r--r--firmware/libboard/simtrace/include/board.h1
-rw-r--r--firmware/libcommon/include/simtrace.h13
-rw-r--r--firmware/libcommon/include/simtrace_usb.h67
-rw-r--r--firmware/libcommon/source/mode_cardemu.c17
-rw-r--r--firmware/libcommon/source/simtrace_iso7816.c3
-rw-r--r--firmware/libcommon/source/usb.c105
-rw-r--r--firmware/libcommon/source/usb_buf.c1
11 files changed, 121 insertions, 105 deletions
diff --git a/firmware/atmel_softpack_libraries/usb/device/dfu/dfu_desc.c b/firmware/atmel_softpack_libraries/usb/device/dfu/dfu_desc.c
index f6d484c..75fded1 100644
--- a/firmware/atmel_softpack_libraries/usb/device/dfu/dfu_desc.c
+++ b/firmware/atmel_softpack_libraries/usb/device/dfu/dfu_desc.c
@@ -28,7 +28,7 @@ static const USBDeviceDescriptor fsDevice = {
.bDeviceClass = 0,
.bDeviceSubClass = 0,
.bDeviceProtocol = 0,
- .bMaxPacketSize0 = BOARD_USB_ENDPOINTS_MAXPACKETSIZE(0),
+ .bMaxPacketSize0 = USBEndpointDescriptor_MAXCTRLSIZE_FS,
.idVendor = BOARD_USB_VENDOR_ID,
.idProduct = BOARD_DFU_USB_PRODUCT_ID,
.bcdDevice = BOARD_USB_RELEASE,
diff --git a/firmware/libboard/common/include/board_common.h b/firmware/libboard/common/include/board_common.h
index 64bdf0f..a995d88 100644
--- a/firmware/libboard/common/include/board_common.h
+++ b/firmware/libboard/common/include/board_common.h
@@ -108,21 +108,6 @@
// D+ has external pull-up
#define BOARD_USB_PULLUP_EXTERNAL
-#define BOARD_USB_NUMENDPOINTS 8
-
-// FIXME: in all other cases return 0?
-#define BOARD_USB_ENDPOINTS_MAXPACKETSIZE(i) (((i == 4) || (i == 5))? 512 : 64)
-#define BOARD_USB_ENDPOINTS_BANKS(i) (((i == 0) || (i == 3)) ? 1 : 2)
-
-#define USB_VENDOR_OPENMOKO 0x1d50
-#define USB_PRODUCT_OWHW_SAM3_DFU 0x4001 /* was 0x4000 */
-#define USB_PRODUCT_OWHW_SAM3 0x4001
-#define USB_PRODUCT_QMOD_HUB 0x4002
-#define USB_PRODUCT_QMOD_SAM3_DFU 0x4004 /* was 0x4003 */
-#define USB_PRODUCT_QMOD_SAM3 0x4004
-#define USB_PRODUCT_SIMTRACE2_DFU 0x60e3 /* was 0x60e2 */
-#define USB_PRODUCT_SIMTRACE2 0x60e3
-
#define BOARD_USB_DFU
#define BOARD_DFU_BOOT_SIZE (16 * 1024)
#define BOARD_DFU_RAM_SIZE (2 * 1024)
diff --git a/firmware/libboard/owhw/include/board.h b/firmware/libboard/owhw/include/board.h
index c770749..def3d8b 100644
--- a/firmware/libboard/owhw/include/board.h
+++ b/firmware/libboard/owhw/include/board.h
@@ -1,5 +1,6 @@
#pragma once
#include "board_common.h"
+#include "simtrace_usb.h"
/** Name of the board */
#define BOARD_NAME "OWHW"
diff --git a/firmware/libboard/qmod/include/board.h b/firmware/libboard/qmod/include/board.h
index b8af8d8..2db94ab 100644
--- a/firmware/libboard/qmod/include/board.h
+++ b/firmware/libboard/qmod/include/board.h
@@ -1,5 +1,6 @@
#pragma once
#include "board_common.h"
+#include "simtrace_usb.h"
#define LED_USIM1 LED_GREEN
#define LED_USIM2 LED_RED
diff --git a/firmware/libboard/simtrace/include/board.h b/firmware/libboard/simtrace/include/board.h
index 891ab33..b21d4fb 100644
--- a/firmware/libboard/simtrace/include/board.h
+++ b/firmware/libboard/simtrace/include/board.h
@@ -1,5 +1,6 @@
#pragma once
#include "board_common.h"
+#include "simtrace_usb.h"
/* Name of the board */
#define BOARD_NAME "SAM3S-SIMTRACE"
diff --git a/firmware/libcommon/include/simtrace.h b/firmware/libcommon/include/simtrace.h
index cbf1948..3c414bc 100644
--- a/firmware/libcommon/include/simtrace.h
+++ b/firmware/libcommon/include/simtrace.h
@@ -5,21 +5,8 @@
#include "board.h"
#include <usb/device/dfu/dfu.h>
-/* Endpoint numbers */
-#define DATAOUT 1
-#define DATAIN 2
-#define INT 3
-
#define BUFLEN 512
-#define PHONE_DATAOUT 4
-#define PHONE_DATAIN 5
-#define PHONE_INT 6
-
-#define CARDEM_USIM2_DATAOUT DATAOUT
-#define CARDEM_USIM2_DATAIN DATAIN
-#define CARDEM_USIM2_INT INT
-
#define CLK_MASTER true
#define CLK_SLAVE false
diff --git a/firmware/libcommon/include/simtrace_usb.h b/firmware/libcommon/include/simtrace_usb.h
new file mode 100644
index 0000000..969d890
--- /dev/null
+++ b/firmware/libcommon/include/simtrace_usb.h
@@ -0,0 +1,67 @@
+/* This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * (C) 2018 by sysmocom -s.f.m.c. GmbH, Author: Kevin Redon <kredon@sysmocom.de>
+ * All Rights Reserved
+ */
+
+/* SIMtrace USB IDs */
+#define USB_VENDOR_OPENMOKO 0x1d50
+#define USB_PRODUCT_OWHW_SAM3_DFU 0x4001 /* was 0x4000 */
+#define USB_PRODUCT_OWHW_SAM3 0x4001
+#define USB_PRODUCT_QMOD_HUB 0x4002
+#define USB_PRODUCT_QMOD_SAM3_DFU 0x4004 /* was 0x4003 */
+#define USB_PRODUCT_QMOD_SAM3 0x4004
+#define USB_PRODUCT_SIMTRACE2_DFU 0x60e3 /* was 0x60e2 */
+#define USB_PRODUCT_SIMTRACE2 0x60e3
+
+/* USB proprietary class */
+#define USB_CLASS_PROPRIETARY 0xff
+
+/* SIMtrace USB sub-classes */
+/*! Sniffer USB sub-class */
+#define SIMTRACE_SNIFFER_USB_SUBCLASS 1
+/*! Card-emulation USB sub-class */
+#define SIMTRACE_CARDEM_USB_SUBCLASS 2
+
+/* Generic USB endpoint numbers */
+/*! Card-side USB data out (host to device) endpoint number */
+#define SIMTRACE_USB_EP_CARD_DATAOUT 1
+/*! Card-side USB data in (device to host) endpoint number */
+#define SIMTRACE_USB_EP_CARD_DATAIN 2
+/*! Card-side USB interrupt endpoint number */
+#define SIMTRACE_USB_EP_CARD_INT 3
+/*! Phone-side USB data out (host to device) endpoint number */
+#define SIMTRACE_USB_EP_PHONE_DATAOUT 4
+/*! Phone-side USB data in (device to host) endpoint number */
+#define SIMTRACE_USB_EP_PHONE_DATAIN 5
+/*! Phone-side USB interrupt endpoint number */
+#define SIMTRACE_USB_EP_PHONE_INT 6
+
+/* Card-emulation USB endpoint numbers */
+/*! USIM1 USB data out (host to device) endpoint number */
+#define SIMTRACE_CARDEM_USB_EP_USIM1_DATAOUT 4
+/*! USIM1 USB data in (device to host) endpoint number */
+#define SIMTRACE_CARDEM_USB_EP_USIM1_DATAIN 5
+/*! USIM1 USB interrupt endpoint number */
+#define SIMTRACE_CARDEM_USB_EP_USIM1_INT 6
+/*! USIM2 USB data out (host to device) endpoint number */
+#define SIMTRACE_CARDEM_USB_EP_USIM2_DATAOUT 1
+/*! USIM2 USB data in (device to host) endpoint number */
+#define SIMTRACE_CARDEM_USB_EP_USIM2_DATAIN 2
+/*! USIM2 USB interrupt endpoint number */
+#define SIMTRACE_CARDEM_USB_EP_USIM2_INT 3
+
+/*! Maximum number of endpoints */
+#define BOARD_USB_NUMENDPOINTS 6
diff --git a/firmware/libcommon/source/mode_cardemu.c b/firmware/libcommon/source/mode_cardemu.c
index 2d9af99..104691f 100644
--- a/firmware/libcommon/source/mode_cardemu.c
+++ b/firmware/libcommon/source/mode_cardemu.c
@@ -10,6 +10,7 @@
#include <osmocom/core/msgb.h>
#include "llist_irqsafe.h"
#include "usb_buf.h"
+#include "simtrace_usb.h"
#include "simtrace_prot.h"
#include "sim_switch.h"
@@ -53,9 +54,9 @@ struct cardem_inst cardem_inst[] = {
.id = ID_USART1,
.state = USART_RCV
},
- .ep_out = PHONE_DATAOUT,
- .ep_in = PHONE_DATAIN,
- .ep_int = PHONE_INT,
+ .ep_out = SIMTRACE_CARDEM_USB_EP_USIM1_DATAOUT,
+ .ep_in = SIMTRACE_CARDEM_USB_EP_USIM1_DATAIN,
+ .ep_int = SIMTRACE_CARDEM_USB_EP_USIM1_INT,
#ifdef PIN_SET_USIM1_PRES
.pin_insert = PIN_SET_USIM1_PRES,
#endif
@@ -68,9 +69,9 @@ struct cardem_inst cardem_inst[] = {
.id = ID_USART0,
.state = USART_RCV
},
- .ep_out = CARDEM_USIM2_DATAOUT,
- .ep_in = CARDEM_USIM2_DATAIN,
- .ep_int = CARDEM_USIM2_INT,
+ .ep_out = SIMTRACE_CARDEM_USB_EP_USIM2_DATAOUT,
+ .ep_in = SIMTRACE_CARDEM_USB_EP_USIM2_DATAIN,
+ .ep_int = SIMTRACE_CARDEM_USB_EP_USIM2_INT,
#ifdef PIN_SET_USIM2_PRES
.pin_insert = PIN_SET_USIM2_PRES,
#endif
@@ -398,7 +399,7 @@ void mode_cardemu_init(void)
PIO_ConfigureIt(&pin_usim1_vcc, usim1_vcc_irqhandler);
PIO_EnableIt(&pin_usim1_vcc);
#endif /* DETECT_VCC_BY_ADC */
- cardem_inst[0].ch = card_emu_init(0, 2, 0, PHONE_DATAIN, PHONE_INT);
+ cardem_inst[0].ch = card_emu_init(0, 2, 0, SIMTRACE_CARDEM_USB_EP_USIM1_DATAIN, SIMTRACE_CARDEM_USB_EP_USIM1_INT);
sim_switch_use_physical(0, 1);
#ifdef CARDEMU_SECOND_UART
@@ -413,7 +414,7 @@ void mode_cardemu_init(void)
PIO_ConfigureIt(&pin_usim2_vcc, usim2_vcc_irqhandler);
PIO_EnableIt(&pin_usim2_vcc);
#endif /* DETECT_VCC_BY_ADC */
- cardem_inst[1].ch = card_emu_init(1, 0, 1, CARDEM_USIM2_DATAIN, CARDEM_USIM2_INT);
+ cardem_inst[1].ch = card_emu_init(1, 0, 1, SIMTRACE_CARDEM_USB_EP_USIM2_DATAIN, SIMTRACE_CARDEM_USB_EP_USIM2_INT);
sim_switch_use_physical(1, 1);
#endif /* CARDEMU_SECOND_UART */
diff --git a/firmware/libcommon/source/simtrace_iso7816.c b/firmware/libcommon/source/simtrace_iso7816.c
index 466bd65..6c0d363 100644
--- a/firmware/libcommon/source/simtrace_iso7816.c
+++ b/firmware/libcommon/source/simtrace_iso7816.c
@@ -33,6 +33,7 @@
#include "board.h"
#include "simtrace.h"
+#include "simtrace_usb.h"
#include "ringbuffer.h"
#include "iso7816_fidi.h"
@@ -67,7 +68,7 @@ void ISR_PhoneRST(const Pin * pPin)
}
if ((ret =
- USBD_Write(PHONE_INT, "R", 1,
+ USBD_Write(SIMTRACE_USB_EP_PHONE_INT, "R", 1,
(TransferCallback) & Callback_PhoneRST_ISR,
0)) != USBD_STATUS_SUCCESS) {
TRACE_ERROR("USB err status: %d (%s)\n", ret, __FUNCTION__);
diff --git a/firmware/libcommon/source/usb.c b/firmware/libcommon/source/usb.c
index d317435..e929a05 100644
--- a/firmware/libcommon/source/usb.c
+++ b/firmware/libcommon/source/usb.c
@@ -33,15 +33,13 @@
#include "board.h"
#include "simtrace.h"
+#include "simtrace_usb.h"
#include "utils.h"
#include <cciddriverdescriptors.h>
#include <usb/common/dfu/usb_dfu.h>
#include <usb/device/dfu/dfu.h>
-#define SIMTRACE_SUBCLASS_SNIFFER 1
-#define SIMTRACE_SUBCLASS_CARDEM 2
-
/*------------------------------------------------------------------------------
* USB String descriptors
*------------------------------------------------------------------------------*/
@@ -94,8 +92,8 @@ static const SIMTraceDriverConfigurationDescriptorSniffer
.bInterfaceNumber = 0,
.bAlternateSetting = 0,
.bNumEndpoints = 3,
- .bInterfaceClass = 0xff,
- .bInterfaceSubClass = SIMTRACE_SUBCLASS_SNIFFER,
+ .bInterfaceClass = USB_CLASS_PROPRIETARY,
+ .bInterfaceSubClass = SIMTRACE_SNIFFER_USB_SUBCLASS,
.bInterfaceProtocol = 0,
.iInterface = SNIFFER_CONF_STR,
},
@@ -105,11 +103,9 @@ static const SIMTraceDriverConfigurationDescriptorSniffer
.bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_OUT,
- PHONE_DATAOUT),
+ SIMTRACE_USB_EP_CARD_DATAOUT),
.bmAttributes = USBEndpointDescriptor_BULK,
- .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(
- PHONE_DATAOUT),
- USBEndpointDescriptor_MAXBULKSIZE_FS),
+ .wMaxPacketSize = USBEndpointDescriptor_MAXBULKSIZE_FS,
.bInterval = 0,
},
/* Bulk-IN endpoint descriptor */
@@ -118,11 +114,9 @@ static const SIMTraceDriverConfigurationDescriptorSniffer
.bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_IN,
- PHONE_DATAIN),
+ SIMTRACE_USB_EP_CARD_DATAIN),
.bmAttributes = USBEndpointDescriptor_BULK,
- .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(
- PHONE_DATAIN),
- USBEndpointDescriptor_MAXBULKSIZE_FS),
+ .wMaxPacketSize = USBEndpointDescriptor_MAXBULKSIZE_FS,
.bInterval = 0,
},
// Notification endpoint descriptor
@@ -131,11 +125,9 @@ static const SIMTraceDriverConfigurationDescriptorSniffer
.bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_IN,
- PHONE_INT),
+ SIMTRACE_USB_EP_CARD_INT),
.bmAttributes = USBEndpointDescriptor_INTERRUPT,
- .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(
- PHONE_INT),
- USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
+ .wMaxPacketSize = USBEndpointDescriptor_MAXINTERRUPTSIZE_FS,
.bInterval = 0x10,
},
DFURT_IF_DESCRIPTOR(1, 0),
@@ -205,9 +197,7 @@ static const CCIDDriverConfigurationDescriptors configurationDescriptorCCID = {
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT,
CCID_EPT_DATA_OUT),
.bmAttributes = USBEndpointDescriptor_BULK,
- .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(
- CCID_EPT_DATA_OUT),
- USBEndpointDescriptor_MAXBULKSIZE_FS),
+ .wMaxPacketSize = USBEndpointDescriptor_MAXBULKSIZE_FS,
.bInterval = 0x00,
},
// Bulk-IN endpoint descriptor
@@ -218,9 +208,7 @@ static const CCIDDriverConfigurationDescriptors configurationDescriptorCCID = {
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
CCID_EPT_DATA_IN),
.bmAttributes = USBEndpointDescriptor_BULK,
- .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(
- CCID_EPT_DATA_IN),
- USBEndpointDescriptor_MAXBULKSIZE_FS),
+ .wMaxPacketSize = USBEndpointDescriptor_MAXBULKSIZE_FS),
.bInterval = 0x00,
},
// Notification endpoint descriptor
@@ -231,9 +219,7 @@ static const CCIDDriverConfigurationDescriptors configurationDescriptorCCID = {
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
CCID_EPT_NOTIFICATION),
.bmAttributes = USBEndpointDescriptor_INTERRUPT,
- .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(
- CCID_EPT_NOTIFICATION),
- USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
+ .wMaxPacketSize = USBEndpointDescriptor_MAXINTERRUPTSIZE_FS,
.bInterval = 0x10,
},
DFURT_IF_DESCRIPTOR(1, 0),
@@ -282,8 +268,8 @@ static const SIMTraceDriverConfigurationDescriptorPhone
.bInterfaceNumber = 0,
.bAlternateSetting = 0,
.bNumEndpoints = 3,
- .bInterfaceClass = 0xff,
- .bInterfaceSubClass = SIMTRACE_SUBCLASS_CARDEM,
+ .bInterfaceClass = USB_CLASS_PROPRIETARY,
+ .bInterfaceSubClass = SIMTRACE_CARDEM_USB_SUBCLASS,
.bInterfaceProtocol = 0,
.iInterface = CARDEM_USIM1_INTF_STR,
},
@@ -293,10 +279,9 @@ static const SIMTraceDriverConfigurationDescriptorPhone
.bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_OUT,
- PHONE_DATAOUT),
+ SIMTRACE_CARDEM_USB_EP_USIM1_DATAOUT),
.bmAttributes = USBEndpointDescriptor_BULK,
- .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(PHONE_DATAOUT),
- USBEndpointDescriptor_MAXBULKSIZE_FS),
+ .wMaxPacketSize = USBEndpointDescriptor_MAXBULKSIZE_FS,
.bInterval = 0 /* Must be 0 for full-speed bulk endpoints */
},
/* Bulk-IN endpoint descriptor */
@@ -305,10 +290,9 @@ static const SIMTraceDriverConfigurationDescriptorPhone
.bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_IN,
- PHONE_DATAIN),
+ SIMTRACE_CARDEM_USB_EP_USIM1_DATAIN),
.bmAttributes = USBEndpointDescriptor_BULK,
- .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(PHONE_DATAIN),
- USBEndpointDescriptor_MAXBULKSIZE_FS),
+ .wMaxPacketSize = USBEndpointDescriptor_MAXBULKSIZE_FS,
.bInterval = 0 /* Must be 0 for full-speed bulk endpoints */
},
/* Notification endpoint descriptor */
@@ -317,10 +301,9 @@ static const SIMTraceDriverConfigurationDescriptorPhone
.bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_IN,
- PHONE_INT),
+ SIMTRACE_CARDEM_USB_EP_USIM1_INT),
.bmAttributes = USBEndpointDescriptor_INTERRUPT,
- .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(PHONE_INT),
- USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
+ .wMaxPacketSize = USBEndpointDescriptor_MAXINTERRUPTSIZE_FS,
.bInterval = 0x10
},
#ifdef CARDEMU_SECOND_UART
@@ -331,8 +314,8 @@ static const SIMTraceDriverConfigurationDescriptorPhone
.bInterfaceNumber = 1,
.bAlternateSetting = 0,
.bNumEndpoints = 3,
- .bInterfaceClass = 0xff,
- .bInterfaceSubClass = SIMTRACE_SUBCLASS_CARDEM,
+ .bInterfaceClass = USB_CLASS_PROPRIETARY,
+ .bInterfaceSubClass = SIMTRACE_CARDEM_USB_SUBCLASS,
.bInterfaceProtocol = 0,
.iInterface = CARDEM_USIM2_INTF_STR,
},
@@ -342,10 +325,9 @@ static const SIMTraceDriverConfigurationDescriptorPhone
.bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_OUT,
- CARDEM_USIM2_DATAOUT),
+ SIMTRACE_CARDEM_USB_EP_USIM2_DATAOUT),
.bmAttributes = USBEndpointDescriptor_BULK,
- .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(CARDEM_USIM2_DATAOUT),
- USBEndpointDescriptor_MAXBULKSIZE_FS),
+ .wMaxPacketSize = USBEndpointDescriptor_MAXBULKSIZE_FS,
.bInterval = 0 /* Must be 0 for full-speed bulk endpoints */
}
,
@@ -355,10 +337,9 @@ static const SIMTraceDriverConfigurationDescriptorPhone
.bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_IN,
- CARDEM_USIM2_DATAIN),
+ SIMTRACE_CARDEM_USB_EP_USIM2_DATAIN),
.bmAttributes = USBEndpointDescriptor_BULK,
- .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(CARDEM_USIM2_DATAIN),
- USBEndpointDescriptor_MAXBULKSIZE_FS),
+ .wMaxPacketSize = USBEndpointDescriptor_MAXBULKSIZE_FS,
.bInterval = 0 /* Must be 0 for full-speed bulk endpoints */
},
/* Notification endpoint descriptor */
@@ -367,10 +348,9 @@ static const SIMTraceDriverConfigurationDescriptorPhone
.bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_IN,
- CARDEM_USIM2_INT),
+ SIMTRACE_CARDEM_USB_EP_USIM2_INT),
.bmAttributes = USBEndpointDescriptor_INTERRUPT,
- .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(CARDEM_USIM2_INT),
- USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
+ .wMaxPacketSize = USBEndpointDescriptor_MAXINTERRUPTSIZE_FS,
.bInterval = 0x10,
},
DFURT_IF_DESCRIPTOR(2, 0),
@@ -466,9 +446,7 @@ static const SIMTraceDriverConfigurationDescriptorMITM
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT,
CCID_EPT_DATA_OUT),
.bmAttributes = USBEndpointDescriptor_BULK,
- .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(
- CCID_EPT_DATA_OUT),
- USBEndpointDescriptor_MAXBULKSIZE_FS),
+ .wMaxPacketSize = USBEndpointDescriptor_MAXBULKSIZE_FS,
.bInterval = 0x00,
},
// Bulk-IN endpoint descriptor
@@ -479,9 +457,7 @@ static const SIMTraceDriverConfigurationDescriptorMITM
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
CCID_EPT_DATA_IN),
.bmAttributes = USBEndpointDescriptor_BULK,
- .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(
- CCID_EPT_DATA_IN),
- USBEndpointDescriptor_MAXBULKSIZE_FS),
+ .wMaxPacketSize = USBEndpointDescriptor_MAXBULKSIZE_FS,
.bInterval = 0x00,
},
// Notification endpoint descriptor
@@ -492,9 +468,7 @@ static const SIMTraceDriverConfigurationDescriptorMITM
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
CCID_EPT_NOTIFICATION),
.bmAttributes = USBEndpointDescriptor_INTERRUPT,
- .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(
- CCID_EPT_NOTIFICATION),
- USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
+ .wMaxPacketSize = USBEndpointDescriptor_MAXINTERRUPTSIZE_FS,
.bInterval = 0x10,
},
@@ -516,10 +490,9 @@ static const SIMTraceDriverConfigurationDescriptorMITM
.bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_OUT,
- PHONE_DATAOUT),
+ SIMTRACE_USB_EP_PHONE_DATAOUT),
.bmAttributes = USBEndpointDescriptor_BULK,
- .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(PHONE_DATAOUT),
- USBEndpointDescriptor_MAXBULKSIZE_FS),
+ .wMaxPacketSize = USBEndpointDescriptor_MAXBULKSIZE_FS,
.bInterval = 0, /* Must be 0 for full-speed bulk endpoints */
},
/* Bulk-IN endpoint descriptor */
@@ -528,10 +501,9 @@ static const SIMTraceDriverConfigurationDescriptorMITM
.bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_IN,
- PHONE_DATAIN),
+ SIMTRACE_USB_EP_PHONE_DATAIN),
.bmAttributes = USBEndpointDescriptor_BULK,
- .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(PHONE_DATAIN),
- USBEndpointDescriptor_MAXBULKSIZE_FS),
+ .wMaxPacketSize = USBEndpointDescriptor_MAXBULKSIZE_FS,
.bInterval = 0, /* Must be 0 for full-speed bulk endpoints */
},
/* Notification endpoint descriptor */
@@ -540,10 +512,9 @@ static const SIMTraceDriverConfigurationDescriptorMITM
.bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_IN,
- PHONE_INT),
+ SIMTRACE_USB_EP_PHONE_INT),
.bmAttributes = USBEndpointDescriptor_INTERRUPT,
- .wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(PHONE_INT),
- USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
+ .wMaxPacketSize = USBEndpointDescriptor_MAXINTERRUPTSIZE_FS,
.bInterval = 0x10
},
DFURT_IF_DESCRIPTOR(2, 0),
@@ -573,7 +544,7 @@ const USBDeviceDescriptor deviceDescriptor = {
.bDeviceClass = 0,
.bDeviceSubClass = 0,
.bDeviceProtocol = 0,
- .bMaxPacketSize0 = BOARD_USB_ENDPOINTS_MAXPACKETSIZE(0),
+ .bMaxPacketSize0 = 64,
.idVendor = BOARD_USB_VENDOR_ID,
.idProduct = BOARD_USB_PRODUCT_ID,
.bcdDevice = 2, /* Release number */
diff --git a/firmware/libcommon/source/usb_buf.c b/firmware/libcommon/source/usb_buf.c
index 848fd24..b8d4dd7 100644
--- a/firmware/libcommon/source/usb_buf.c
+++ b/firmware/libcommon/source/usb_buf.c
@@ -1,6 +1,7 @@
#include "board.h"
#include "trace.h"
#include "usb_buf.h"
+#include "simtrace_usb.h"
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/msgb.h>