This is an automated email from Gerrit.

"ahmed BOUDJELIDA <aboudjel...@nanoxplore.com>" just uploaded a new patch set 
to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8736

-- gerrit

commit f5d457eefe0ec7888b38fd5552215ab158dddedd
Author: Ahmed BOUDJELIDA <aboudjel...@nanoxplore.com>
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 <aboudjel...@nanoxplore.com>

diff --git a/contrib/firmware/angie/c/include/usb.h 
b/contrib/firmware/angie/c/include/usb.h
index 37d3b8ae28..dbf41fe8e5 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/main.c 
b/contrib/firmware/angie/c/src/main.c
index 657694b6c1..b1ddb73248 100644
--- a/contrib/firmware/angie/c/src/main.c
+++ b/contrib/firmware/angie/c/src/main.c
@@ -64,7 +64,7 @@ void gpif_init(void);
 int main(void)
 {
        CPUCS = ((CPUCS & ~bmclkspd) | (CLK_48M << 3) | CLKOE); /* required for 
sio0_init */
-       sio0_init(115200);      /* needed for printf */
+       sio0_init(38400);       /* needed for printf */
 
        ep_init();
        gpif_init();
diff --git a/contrib/firmware/angie/c/src/usb.c 
b/contrib/firmware/angie/c/src/usb.c
index 96f0df908f..b0681560a1 100644
--- a/contrib/firmware/angie/c/src/usb.c
+++ b/contrib/firmware/angie/c/src/usb.c
@@ -19,6 +19,8 @@
 #include "i2c.h"
 #include <stdint.h>
 #include <stdio.h>
+#include <stdio.h>
+#include <string.h>
 
 // #define PRINTF_DEBUG
 
@@ -122,7 +124,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 +136,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
 {
@@ -328,63 +326,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 +421,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;
                }
@@ -535,8 +481,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())
@@ -675,6 +625,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 */
@@ -697,6 +649,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 */
@@ -880,7 +836,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.c b/src/jtag/drivers/angie.c
index c3761084ec..89f284e8b5 100644
--- a/src/jtag/drivers/angie.c
+++ b/src/jtag/drivers/angie.c
@@ -65,7 +65,7 @@
 #define FIRMWARE_ADDR  0x0000
 
 /** Delay (in microseconds) to wait while EZ-USB performs ReNumeration. */
-#define ANGIE_RENUMERATION_DELAY_US    800000
+#define ANGIE_RENUMERATION_DELAY_US    2500000
 
 /** Default location of ANGIE firmware image. */
 #define ANGIE_FIRMWARE_FILE    PKGDATADIR "/angie/angie_firmware.bin"
@@ -626,7 +626,8 @@ static int angie_load_bitstream(struct angie *device, const 
char *filename)
        // CFG Open
        h_u32_to_be(gpifcnt, bitstream_size);
        ret = jtag_libusb_control_transfer(device->usbdev,
-                                                                       0x00, 
VR_CFGOPEN, 0, 0, (char *)gpifcnt, 4, 100, &transferred);
+                                                                       
LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
+                                                                       
VR_CFGOPEN, 0, 0, (char *)gpifcnt, 4, 100, &transferred);
        if (ret != ERROR_OK) {
                LOG_ERROR("Failed opencfg");
                return ERROR_FAIL;
diff --git a/src/jtag/drivers/angie/angie_firmware.bin 
b/src/jtag/drivers/angie/angie_firmware.bin
index d739d0b9ce..ec9cf18574 100644
Binary files a/src/jtag/drivers/angie/angie_firmware.bin and 
b/src/jtag/drivers/angie/angie_firmware.bin differ

-- 

Reply via email to