From 624c6655697f72177f5d5240a6e805aedc8c850b Mon Sep 17 00:00:00 2001 From: Oleksij Rempel Date: Tue, 13 Aug 2013 11:31:04 +0200 Subject: [PATCH] patch bcdDevice value for k2 to make easy firmware detection. Signed-off-by: Oleksij Rempel --- .../magpie_fw_dev/target/hif/k2_fw_usb_api.c | 39 ++++++++++++------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/target_firmware/magpie_fw_dev/target/hif/k2_fw_usb_api.c b/target_firmware/magpie_fw_dev/target/hif/k2_fw_usb_api.c index 83a72a9..fe66c93 100755 --- a/target_firmware/magpie_fw_dev/target/hif/k2_fw_usb_api.c +++ b/target_firmware/magpie_fw_dev/target/hif/k2_fw_usb_api.c @@ -715,13 +715,18 @@ ERR_DONE: ; } +extern uint16_t *u8UsbDeviceDescriptor; extern uint16_t *u8ConfigDescriptorEX; extern uint16_t *pu8DescriptorEX; extern uint16_t u16TxRxCounter; extern BOOLEAN bGet_descriptor(void); +uint16_t DeviceDescriptorPatch[9]; uint16_t ConfigDescriptorPatch[30]; + +#define BCD_DEVICE 6 +#define BCD_DEVICE_FW_SIGNATURE 0xffff #define EP3_TRANSFER_TYPE_OFFSET 17 #define EP3_INT_INTERVAL 19 #define EP4_TRANSFER_TYPE_OFFSET 21 @@ -729,13 +734,21 @@ uint16_t ConfigDescriptorPatch[30]; BOOLEAN bGet_descriptor_patch(void) { - if (mDEV_REQ_VALUE_HIGH() == 2) { - uint8_t *p = (uint8_t *)u8ConfigDescriptorEX; + int i; + switch (mDEV_REQ_VALUE_HIGH()) { + case 1: + ath_hal_memcpy(DeviceDescriptorPatch, + u8UsbDeviceDescriptor, sizeof(DeviceDescriptorPatch)); - /* Copy ConfigDescriptor */ - ath_hal_memcpy(ConfigDescriptorPatch, p, sizeof(ConfigDescriptorPatch)); + DeviceDescriptorPatch[BCD_DEVICE] = BCD_DEVICE_FW_SIGNATURE; - p = (uint8_t *)ConfigDescriptorPatch; + pu8DescriptorEX = DeviceDescriptorPatch; + u16TxRxCounter = mTABLE_LEN(DeviceDescriptorPatch[0]); + break; + case 2: + /* Copy ConfigDescriptor */ + ath_hal_memcpy(ConfigDescriptorPatch, + u8ConfigDescriptorEX, sizeof(ConfigDescriptorPatch)); /* Patch the transfer type of EP3 and EP4 */ ConfigDescriptorPatch[EP3_TRANSFER_TYPE_OFFSET] = 0x0283; @@ -753,16 +766,16 @@ BOOLEAN bGet_descriptor_patch(void) default: return FALSE; } - - if (u16TxRxCounter > mDEV_REQ_LENGTH()) - u16TxRxCounter = mDEV_REQ_LENGTH(); - - A_USB_EP0_TX_DATA(); - return TRUE; - } - else { + break; + default: return bGet_descriptor(); } + + if (u16TxRxCounter > mDEV_REQ_LENGTH()) + u16TxRxCounter = mDEV_REQ_LENGTH(); + + A_USB_EP0_TX_DATA(); + return TRUE; } extern BOOLEAN bStandardCommand(void); -- 2.31.1