From: openocd-gerrit <ope...@us...> - 2025-08-17 13:38:02
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 18d5ea95e59e83ebee8379f0de459d2f8f0482f4 (commit) from 9a150e326a655c9bd2fbead1be43748ca640764c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 18d5ea95e59e83ebee8379f0de459d2f8f0482f4 Author: Ahmed BOUDJELIDA <abo...@na...> Date: Wed Jan 15 16:44:28 2025 +0100 contrib/firmware/angie: correct usb descriptor issues Correct the issue of usb descriptor does not appear near the PID and VID, Cypress USB controller cannot handle direct pointers to memory CODE area, so we copy the data in the external RAM area and point to it. Change-Id: I3221627dc8576f6341b444acd9c554fd5cc47918 Signed-off-by: Ahmed BOUDJELIDA <abo...@na...> Reviewed-on: https://review.openocd.org/c/openocd/+/8736 Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/contrib/firmware/angie/c/include/usb.h b/contrib/firmware/angie/c/include/usb.h index 37d3b8ae2..dbf41fe8e 100644 --- a/contrib/firmware/angie/c/include/usb.h +++ b/contrib/firmware/angie/c/include/usb.h @@ -104,7 +104,7 @@ struct usb_endpoint_descriptor { struct usb_language_descriptor { uint8_t blength; /**< Size of this descriptor in bytes. */ uint8_t bdescriptortype; /**< STRING descriptor type. */ - uint16_t wlangid[]; /**< LANGID codes. */ + uint16_t wlangid; /**< LANGID codes. */ }; /** USB String Descriptor. See USB 2.0 Spec */ diff --git a/contrib/firmware/angie/c/src/usb.c b/contrib/firmware/angie/c/src/usb.c index 9b48e8353..6a07cc5d3 100644 --- a/contrib/firmware/angie/c/src/usb.c +++ b/contrib/firmware/angie/c/src/usb.c @@ -19,6 +19,7 @@ #include "i2c.h" #include <stdint.h> #include <stdio.h> +#include <string.h> // #define PRINTF_DEBUG @@ -122,7 +123,7 @@ __code struct usb_endpoint_descriptor bulk_ep8_in_endpoint_descriptor = { __code struct usb_language_descriptor language_descriptor = { .blength = 4, .bdescriptortype = DESCRIPTOR_TYPE_STRING, - .wlangid = {0x0409} /* US English */ + .wlangid = 0x0409 /* US English */ }; __code struct usb_string_descriptor strmanufacturer = @@ -134,15 +135,11 @@ __code struct usb_string_descriptor strproduct = __code struct usb_string_descriptor strserialnumber = STR_DESCR(6, '0', '0', '0', '0', '0', '1'); -__code struct usb_string_descriptor strconfigdescr = - STR_DESCR(12, 'J', 'T', 'A', 'G', ' ', 'A', 'd', 'a', 'p', 't', 'e', 'r'); - /* Table containing pointers to string descriptors */ -__code struct usb_string_descriptor *__code en_string_descriptors[4] = { +__code struct usb_string_descriptor *__code en_string_descriptors[3] = { &strmanufacturer, &strproduct, - &strserialnumber, - &strconfigdescr + &strserialnumber }; void sudav_isr(void)__interrupt SUDAV_ISR { @@ -196,7 +193,6 @@ void ep6_isr(void)__interrupt EP6_ISR i2c_recieve(); /* Execute I2C communication */ EXIF &= ~0x10; /* Clear USBINT: Main global interrupt */ EPIRQ = 0x40; /* Clear individual EP6OUT IRQ */ - REVCTL = 0x3; /* REVCTL.0 and REVCTL.1 set to 1 */ } void ep8_isr(void)__interrupt EP8_ISR { @@ -328,63 +324,6 @@ void usb_reset_data_toggle(uint8_t ep) TOGCTL |= BMRESETTOGGLE; } -/** - * Handle GET_STATUS request. - * - * @return on success: true - * @return on failure: false - */ -bool usb_handle_get_status(void) -{ - uint8_t *ep_cs; - switch (setup_data.bmrequesttype) { - case GS_DEVICE: - /* Two byte response: Byte 0, Bit 0 = self-powered, Bit 1 = remote wakeup. - * Byte 1: reserved, reset to zero */ - EP0BUF[0] = 0; - EP0BUF[1] = 0; - - /* Send response */ - EP0BCH = 0; - syncdelay(3); - EP0BCL = 2; - syncdelay(3); - break; - case GS_INTERFACE: - /* Always return two zero bytes according to USB 1.1 spec, p. 191 */ - EP0BUF[0] = 0; - EP0BUF[1] = 0; - - /* Send response */ - EP0BCH = 0; - syncdelay(3); - EP0BCL = 2; - syncdelay(3); - break; - case GS_ENDPOINT: - /* Get stall bit for endpoint specified in low byte of wIndex */ - ep_cs = usb_get_endpoint_cs_reg(setup_data.windex & 0xff); - - if (*ep_cs & EPSTALL) - EP0BUF[0] = 0x01; - else - EP0BUF[0] = 0x00; - - /* Second byte sent has to be always zero */ - EP0BUF[1] = 0; - - /* Send response */ - EP0BCH = 0; - syncdelay(3); - EP0BCL = 2; - syncdelay(3); - break; - default: - return false; - } - return true; -} - /** * Handle CLEAR_FEATURE request. * @@ -480,12 +419,17 @@ bool usb_handle_get_descriptor(void) case DESCRIPTOR_TYPE_STRING: if (setup_data.windex == 0) { /* Supply language descriptor */ - SUDPTRH = HI8(&language_descriptor); - SUDPTRL = LO8(&language_descriptor); + __xdata struct usb_language_descriptor temp_descriptor; + memcpy(&temp_descriptor, &language_descriptor, sizeof(language_descriptor)); + SUDPTRH = HI8(&temp_descriptor); + SUDPTRL = LO8(&temp_descriptor); } else if (setup_data.windex == 0x0409 /* US English */) { /* Supply string descriptor */ - SUDPTRH = HI8(en_string_descriptors[descriptor_index - 1]); - SUDPTRL = LO8(en_string_descriptors[descriptor_index - 1]); + __xdata uint8_t temp_descriptors[3]; + memcpy(temp_descriptors, en_string_descriptors[descriptor_index - 1], + ((struct usb_string_descriptor *)en_string_descriptors[descriptor_index - 1])->blength); + SUDPTRH = HI8(temp_descriptors); + SUDPTRL = LO8(temp_descriptors); } else { return false; } @@ -610,6 +554,8 @@ bool usb_handle_vcommands(void) ; /* wait to finish transferring in EP0BUF, until not busy */ gcnt = ((uint32_t)(eptr[0]) << 24) | ((uint32_t)(eptr[1]) << 16) | ((uint32_t)(eptr[2]) << 8) | (uint32_t)(eptr[3]); + /* REVCTL.0 and REVCTL.1 set to 1 */ + REVCTL = 0x3; /* Angie board FPGA bitstream download */ PIN_RDWR_B = 0; /* Initialize GPIF interface transfer count */ @@ -632,6 +578,10 @@ bool usb_handle_vcommands(void) EP4AUTOINLENL = (uint8_t)((uint32_t)(gcnt) & 0x000000ff); /* Trigger GPIF IN transfer on EP4 */ GPIFTRIG = BMGPIFREAD | GPIF_EP4; + while (!(GPIFTRIG & BMGPIFDONE)) // poll GPIFTRIG.7 GPIF Done bit + ; + /* REVCTL.0 and REVCTL.1 set to 0 */ + REVCTL = 0; break; default: return true; /* Error: unknown VR command */ @@ -646,8 +596,12 @@ void usb_handle_setup_data(void) { switch (setup_data.brequest) { case GET_STATUS: - if (!usb_handle_get_status()) - STALL_EP0(); + EP0BUF[0] = 0; + EP0BUF[1] = 0; + /* Send response */ + EP0BCH = 0; + EP0BCL = 2; + syncdelay(3); break; case CLEAR_FEATURE: if (!usb_handle_clear_feature()) @@ -880,7 +834,9 @@ void interrupt_init(void) /* Clear SUDAV interrupt */ USBIRQ = SUDAVI; - /* Enable Interrupts */ + /* Enable Interrupts (Do not confuse this with + * EA External Access pin, see ANGIE Schematic) + */ EA = 1; } diff --git a/src/jtag/drivers/angie/angie_firmware.bin b/src/jtag/drivers/angie/angie_firmware.bin index 6ba2babb1..ecf2cfd51 100644 Binary files a/src/jtag/drivers/angie/angie_firmware.bin and b/src/jtag/drivers/angie/angie_firmware.bin differ ----------------------------------------------------------------------- Summary of changes: contrib/firmware/angie/c/include/usb.h | 2 +- contrib/firmware/angie/c/src/usb.c | 100 +++++++++--------------------- src/jtag/drivers/angie/angie_firmware.bin | Bin 4487 -> 4478 bytes 3 files changed, 29 insertions(+), 73 deletions(-) hooks/post-receive -- Main OpenOCD repository |