Fix Windows XP RNDIS+CDC serial port enumeration

This commit is contained in:
dak664 2010-10-28 19:30:14 +00:00
parent a7c882a6de
commit ad6712736b
3 changed files with 48 additions and 26 deletions

View file

@ -146,7 +146,6 @@ caps /* bmCapabilities */
masterInterface, /* bMasterInterface, The controlling interface for the union (bInterfaceNumber of a Communication or Data Class interface in this configuration) */ \ masterInterface, /* bMasterInterface, The controlling interface for the union (bInterfaceNumber of a Communication or Data Class interface in this configuration) */ \
slaveInterface /* bSlaveInterface0, The controlled interace in the union (bInterfaceNumber of an interface in this configuration) */ \ slaveInterface /* bSlaveInterface0, The controlled interace in the union (bInterfaceNumber of an interface in this configuration) */ \
#define RNDIS_INTERFACES \ #define RNDIS_INTERFACES \
USB_INTERFACEDESC( \ USB_INTERFACEDESC( \
INTERFACE0_NB, \ INTERFACE0_NB, \
@ -177,8 +176,6 @@ USB_INTERFACEDESC( \
USB_ENDPOINT(ENDPOINT_NB_2,EP_ATTRIBUTES_2,EP_SIZE_2,EP_INTERVAL_2), \ USB_ENDPOINT(ENDPOINT_NB_2,EP_ATTRIBUTES_2,EP_SIZE_2,EP_INTERVAL_2), \
USB_ENDPOINT(ENDPOINT_NB_3,EP_ATTRIBUTES_3,EP_SIZE_3,EP_INTERVAL_3) USB_ENDPOINT(ENDPOINT_NB_3,EP_ATTRIBUTES_3,EP_SIZE_3,EP_INTERVAL_3)
#define CDC_SERIAL_INTERFACES \ #define CDC_SERIAL_INTERFACES \
USB_INTERFACEDESC( \ USB_INTERFACEDESC( \
INTERFACE2_NB, \ INTERFACE2_NB, \
@ -208,10 +205,6 @@ USB_INTERFACEDESC( \
USB_ENDPOINT(ENDPOINT_NB_5,EP_ATTRIBUTES_5,EP_SIZE_5,EP_INTERVAL_5), \ USB_ENDPOINT(ENDPOINT_NB_5,EP_ATTRIBUTES_5,EP_SIZE_5,EP_INTERVAL_5), \
USB_ENDPOINT(ENDPOINT_NB_6,EP_ATTRIBUTES_6,EP_SIZE_6,EP_INTERVAL_6) USB_ENDPOINT(ENDPOINT_NB_6,EP_ATTRIBUTES_6,EP_SIZE_6,EP_INTERVAL_6)
#define CDC_EEM_INTERFACES \ #define CDC_EEM_INTERFACES \
USB_INTERFACEDESC( \ USB_INTERFACEDESC( \
EEM_INTERFACE0_NB, \ EEM_INTERFACE0_NB, \
@ -295,26 +288,43 @@ USB_INTERFACEDESC( \
//This doesn't seem to hurt anything but beware, system corruption is //This doesn't seem to hurt anything but beware, system corruption is
//a possibility. //a possibility.
#if USB_CONF_MACINTOSH #if USB_CONF_MACINTOSH
/* Prefer CDC-ECM network enumeration (Macintosh, linux) */
FLASH uint8_t usb_dev_config_order[] = { FLASH uint8_t usb_dev_config_order[] = {
USB_CONFIG_ECM_DEBUG, //Prefer CDC-ECM network enumeration USB_CONFIG_RNDIS, //windows gets networking only (if not here gets serial only)
#if USB_CONF_SERIAL
USB_CONFIG_ECM_DEBUG, //mac, linux get networking and serial port
#endif
USB_CONFIG_ECM, USB_CONFIG_ECM,
#if USB_CONF_SERIAL
USB_CONFIG_RNDIS_DEBUG, USB_CONFIG_RNDIS_DEBUG,
USB_CONFIG_RNDIS, #endif
// USB_CONFIG_RNDIS,
USB_CONFIG_EEM, USB_CONFIG_EEM,
#if USB_CONF_STORAGE #if USB_CONF_STORAGE
USB_CONFIG_MS, USB_CONFIG_MS,
#endif #endif
}; };
#else #else
/* Prefer RNDIS network enumeration (Windows, linux) */
FLASH uint8_t usb_dev_config_order[] = { FLASH uint8_t usb_dev_config_order[] = {
USB_CONFIG_RNDIS_DEBUG, //Prefer RNDIS network enumeration
// USB_CONFIG_ECM, //windows doesnt like this here, will not go on to RNDIS
#if USB_CONF_SERIAL
USB_CONFIG_RNDIS_DEBUG,
#else
USB_CONFIG_RNDIS, USB_CONFIG_RNDIS,
#endif
#if 0 //XP may have a problem with these extra configurations
USB_CONFIG_RNDIS,
#if USB_CONF_SERIAL
USB_CONFIG_ECM_DEBUG, USB_CONFIG_ECM_DEBUG,
#endif
USB_CONFIG_ECM, USB_CONFIG_ECM,
USB_CONFIG_EEM, USB_CONFIG_EEM,
#if USB_CONF_STORAGE #if USB_CONF_STORAGE
USB_CONFIG_MS, USB_CONFIG_MS,
#endif #endif
#endif
}; };
#endif /* USB_CONF_MACINTOSH */ #endif /* USB_CONF_MACINTOSH */
@ -334,7 +344,8 @@ FLASH S_usb_device_descriptor usb_dev_desc_composite =
, USB_STRING_MAN , USB_STRING_MAN
, USB_STRING_PRODUCT , USB_STRING_PRODUCT
, USB_STRING_SERIAL , USB_STRING_SERIAL
, (sizeof(usb_dev_config_order)/sizeof(*usb_dev_config_order)) , sizeof(usb_dev_config_order)
//, (sizeof(usb_dev_config_order)/sizeof(*usb_dev_config_order)) //TODO:was this right?
}; };
@ -573,8 +584,9 @@ FLASH S_usb_language_id usb_user_language_id = {
PGM_VOID_P Usb_get_dev_desc_pointer(void) PGM_VOID_P Usb_get_dev_desc_pointer(void)
{ {
#if 1
return &(usb_dev_desc_composite.bLength); return &(usb_dev_desc_composite.bLength);
/* #else //these are all the same length
if (usb_mode == rndis_only) if (usb_mode == rndis_only)
return &(usb_dev_desc_network.bLength); return &(usb_dev_desc_network.bLength);
@ -585,15 +597,15 @@ PGM_VOID_P Usb_get_dev_desc_pointer(void)
return &(usb_dev_desc_eem.bLength); return &(usb_dev_desc_eem.bLength);
return &(usb_dev_desc_mass.bLength); return &(usb_dev_desc_mass.bLength);
*/ #endif
} }
U8 Usb_get_dev_desc_length(void) U8 Usb_get_dev_desc_length(void)
{ {
#if 1
return sizeof(usb_dev_desc_composite); return sizeof(usb_dev_desc_composite);
/* #else //these are all the same size
if (usb_mode == rndis_only) if (usb_mode == rndis_only)
return sizeof(usb_dev_desc_network); return sizeof(usb_dev_desc_network);
@ -604,7 +616,7 @@ U8 Usb_get_dev_desc_length(void)
return sizeof(usb_dev_desc_eem); return sizeof(usb_dev_desc_eem);
return sizeof(usb_dev_desc_mass); return sizeof(usb_dev_desc_mass);
*/ #endif
} }

View file

@ -65,11 +65,12 @@
// USB Device descriptor // USB Device descriptor
#define USB_SPECIFICATION 0x0200 #define USB_SPECIFICATION 0x0200
#if 1 #if USB_CONF_MACINTOSH
#define COMPOSITE_DEVICE_CLASS 0x02 // Misc #define COMPOSITE_DEVICE_CLASS 0x02 // Misc
#define COMPOSITE_DEVICE_SUB_CLASS 0x00 // Common #define COMPOSITE_DEVICE_SUB_CLASS 0x00 // Common
#define COMPOSITE_DEVICE_PROTOCOL 0x00 // IAD #define COMPOSITE_DEVICE_PROTOCOL 0x00 // IAD
#else //Windows wants these for composite device, but above seems to work anyway #else //Windows wants these for composite device
//Above seems to work for Vista and Win7 but XP and Ubuntu 904 might need the old values
#define COMPOSITE_DEVICE_CLASS 0xEF // Misc #define COMPOSITE_DEVICE_CLASS 0xEF // Misc
#define COMPOSITE_DEVICE_SUB_CLASS 0x02 // Common #define COMPOSITE_DEVICE_SUB_CLASS 0x02 // Common
#define COMPOSITE_DEVICE_PROTOCOL 0x01 // IAD #define COMPOSITE_DEVICE_PROTOCOL 0x01 // IAD
@ -89,8 +90,17 @@
#define EP_CONTROL_LENGTH 64 #define EP_CONTROL_LENGTH 64
#define VENDOR_ID 0x03EB // Atmel vendor ID = 03EBh #define VENDOR_ID 0x03EB // Atmel vendor ID = 03EBh
#if USB_CONF_MACINTOSH
//A different product ID avoids instant windows corruption when it tries to use the cached drivers
//TODO:Get some valid ID's from Atmel
#define COMPOSITE_PRODUCT_ID 0x9921 //Product ID for composite device
#define NETWORK_PRODUCT_ID 0x9919 //Product ID for just CDC-ECM device
#else
#define COMPOSITE_PRODUCT_ID 0x2021 //Product ID for composite device #define COMPOSITE_PRODUCT_ID 0x2021 //Product ID for composite device
#define NETWORK_PRODUCT_ID 0x2019 //Product ID for just RNDIS device #define NETWORK_PRODUCT_ID 0x2019 //Product ID for just RNDIS device
#endif
#define MASS_PRODUCT_ID 0x202F //Product ID for mass storage #define MASS_PRODUCT_ID 0x202F //Product ID for mass storage
#define RELEASE_NUMBER 0x1000 #define RELEASE_NUMBER 0x1000
@ -229,7 +239,6 @@ enum {
#define EP_SIZE_6 0x20 #define EP_SIZE_6 0x20
#define EP_INTERVAL_6 0x01 #define EP_INTERVAL_6 0x01
/*** Mass Storage ***/ /*** Mass Storage ***/
#define MS_INTERFACE_NB 0 #define MS_INTERFACE_NB 0
@ -280,7 +289,6 @@ enum {
#define EEM_EP_SIZE_2 0x40 //64 byte max size #define EEM_EP_SIZE_2 0x40 //64 byte max size
#define EEM_EP_INTERVAL_2 0x01 #define EEM_EP_INTERVAL_2 0x01
/******* ECM Configuration *******/ /******* ECM Configuration *******/
// Interface 0 descriptor // Interface 0 descriptor

View file

@ -184,16 +184,17 @@ extern void mac_log_802_15_4_rx(const uint8_t* buffer, size_t total_len);
/* ************************************************************************** */ /* ************************************************************************** */
/* Set USB_CONF_MACINTOSH to prefer CDC-ECM+DEBUG enumeration for Mac/Linux /* Set USB_CONF_MACINTOSH to prefer CDC-ECM+DEBUG enumeration for Mac/Linux
* Leave undefined to prefer RNDIS+DEBUG enumeration for Windows/Linux * Leave undefined to prefer RNDIS+DEBUG enumeration for Windows/Linux
* TODO:Serial port will enumerate in all cases and prevent falling through to * TODO:Serial port would enumerate in all cases and prevent falling through to
* the supported network interface if USB_CONF_MACINTOSH is used with Windows * the supported network interface if USB_CONF_MACINTOSH is used with Windows
* or vice versa. If Windows has previously cached the RNDIS driver for the stick * or vice versa. The Mac configuration is set up to still enumerate as RNDIS-ONLY
* it will attempt to use it and give "device can not start" error. * on Windows (without the serial port).
* This doesn't seem to hurt anything but can potentially damage the OS! * At present the Windows configuration will not enumerate on the Mac at all,
* since it wants a custom descriptor for USB composite devices.
*/ */
#define USB_CONF_MACINTOSH 0 #define USB_CONF_MACINTOSH 0
/* Set USB_CONF_SERIAL to enable the USB serial port that allows control of the /* Set USB_CONF_SERIAL to enable the USB serial port that allows control of the
* run-time configuration (COMx on Windows, ttyACMx on Linux, tty.usbx on Mac) * run-time configuration (COMx on Windows, ttyACMx on Linux, tty.usbmodemx on Mac)
* Debug printfs will go to this port unless USB_CONF_RS232 is set. * Debug printfs will go to this port unless USB_CONF_RS232 is set.
*/ */
#define USB_CONF_SERIAL 1 #define USB_CONF_SERIAL 1
@ -201,8 +202,9 @@ extern void mac_log_802_15_4_rx(const uint8_t* buffer, size_t total_len);
/* RS232 debugs have less effect on network timing and are less likely /* RS232 debugs have less effect on network timing and are less likely
* to be dropped due to buffer overflow. Only tx is implemented at present. * to be dropped due to buffer overflow. Only tx is implemented at present.
* The tx pad is the middle one behind the jackdaw leds. * The tx pad is the middle one behind the jackdaw leds.
* RS232 output will work with or without enabling the USB serial port
*/ */
#define USB_CONF_RS232 1 #define USB_CONF_RS232 0
/* Disable mass storage enumeration for more program space */ /* Disable mass storage enumeration for more program space */
//#define USB_CONF_STORAGE 1 /* TODO: Mass storage is currently broken */ //#define USB_CONF_STORAGE 1 /* TODO: Mass storage is currently broken */