This is an automated email from Gerrit. "Adrien Charruel <acharr...@nanoxplore.com>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8712
-- gerrit commit 4e3dcd4d11f2acd471d2e97ea1b3602ae6411d55 Author: Ahmed BOUDJELIDA <aboudjel...@nanoxplore.com> Date: Thu Dec 12 09:08:11 2024 +0100 contrib/firmware/angie: reorganize the endpoints of the microcontroller The new firmware of ANGIE will not use Bitbang method to transfer jtag data to the target chip. instead, it will use the the GPIF module to bypass JTAG data directly to the FPGA and then to target chip. So we delete the protocol and jtag files which handle bitbang. We are going to use endpoint 2/4 for OUT/IN GPIF transactions, and we deactivate the endpoints 1IN and 1OUT. we will keep the endpoint 6/8 for i2c inchanged. Change-Id: I0fcb23690526f6a7da044b702217b32522be727a Signed-off-by: Ahmed BOUDJELIDA <aboudjel...@nanoxplore.com> diff --git a/contrib/firmware/angie/c/src/usb.c b/contrib/firmware/angie/c/src/usb.c index c9335aacaf..bc888c9f77 100644 --- a/contrib/firmware/angie/c/src/usb.c +++ b/contrib/firmware/angie/c/src/usb.c @@ -26,6 +26,7 @@ volatile __xdata __at 0xE6B8 struct setup_data setup_data; */ #define NUM_ENDPOINTS 2 + __code struct usb_device_descriptor device_descriptor = { .blength = sizeof(struct usb_device_descriptor), .bdescriptortype = DESCRIPTOR_TYPE_DEVICE, @@ -52,7 +53,7 @@ __code struct usb_config_descriptor config_descriptor = { ((NUM_ENDPOINTS * 2) * sizeof(struct usb_endpoint_descriptor)), .bnuminterfaces = 2, .bconfigurationvalue = 1, - .iconfiguration = 1, /* String describing this configuration */ + .iconfiguration = 4, /* String describing this configuration */ .bmattributes = 0x80, /* Only MSB set according to USB spec */ .maxpower = 50 /* 100 mA */ }; @@ -66,7 +67,7 @@ __code struct usb_interface_descriptor interface_descriptor00 = { .binterfaceclass = 0XFF, .binterfacesubclass = 0x00, .binterfaceprotocol = 0x00, - .iinterface = 4 + .iinterface = 5 }; __code struct usb_endpoint_descriptor bulk_ep2_endpoint_descriptor = { @@ -96,7 +97,7 @@ __code struct usb_interface_descriptor interface_descriptor01 = { .binterfaceclass = 0x0A, .binterfacesubclass = 0x00, .binterfaceprotocol = 0x00, - .iinterface = 0x00 + .iinterface = 6 }; __code struct usb_endpoint_descriptor bulk_ep6_out_endpoint_descriptor = { @@ -189,11 +190,11 @@ void ep4_isr(void)__interrupt EP4_ISR } void ep6_isr(void)__interrupt EP6_ISR { - REVCTL = 0; /* REVCTL.0 and REVCTL.1 set to 0 */ - 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 */ + REVCTL = 0; /* REVCTL.0 and REVCTL.1 set to 0 */ + 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 { @@ -523,6 +524,18 @@ void usb_handle_set_interface(void) EP8BCH = 0; EP8BCL = 0x80; syncdelay(3); + EP2BCH = 0; + EP2BCL = 0x80; + syncdelay(3); + EP4BCH = 0; + EP4BCL = 0x80; + syncdelay(3); + EP6BCH = 0; + EP6BCL = 0x80; + syncdelay(3); + EP8BCH = 0; + EP8BCL = 0x80; + syncdelay(3); } /** @@ -571,8 +584,9 @@ void usb_handle_setup_data(void) case GET_INTERFACE: /* ANGIE only has one interface, return its number */ EP0BUF[0] = interface_descriptor00.binterfacenumber; + EP0BUF[1] = interface_descriptor01.binterfacenumber; EP0BCH = 0; - EP0BCL = 1; + EP0BCL = 2; syncdelay(3); break; case SET_INTERFACE: @@ -592,109 +606,54 @@ void usb_handle_setup_data(void) /* Initialize GPIF interface transfer count */ void set_gpif_cnt(uint32_t count) { - GPIFTCB3 = (uint8_t)(((uint32_t)(count) >> 24) & 0x000000ff); + EP1INCFG = 0x00; /* non VALID */ syncdelay(3); - GPIFTCB2 = (uint8_t)(((uint32_t)(count) >> 16) & 0x000000ff); + EP1OUTCFG = 0x00; /* non VALID */ syncdelay(3); - GPIFTCB1 = (uint8_t)(((uint32_t)(count) >> 8) & 0x000000ff); + + /* JTAG */ + EP2CFG = 0xA2; /* VALID | OUT | BULK | 512 Bytes | Double buffer */ + syncdelay(3); + EP4CFG = 0xE2; /* VALID | IN | BULK | 512 Bytes | Double buffer */ syncdelay(3); - GPIFTCB0 = (uint8_t)((uint32_t)(count) & 0x000000ff); -} -/* - * Vendor commands handling: -*/ -#define VR_CFGOPEN 0xB0 -#define VR_DATAOUTOPEN 0xB2 + /* I2C */ + EP6CFG = 0xA2; /* VALID | OUT | BULK | 512 Bytes | Double buffer */ + syncdelay(3); + EP8CFG = 0xE2; /* VALID | IN | BULK | 512 Bytes | Double buffer */ + syncdelay(3); -uint8_t ix; -uint8_t bcnt; -uint8_t __xdata *eptr; -uint16_t wcnt; -uint32_t __xdata gcnt; -bool usb_handle_vcommands(void) -{ - eptr = EP0BUF; /* points to EP0BUF 64-byte register */ - wcnt = setup_data.wlength; /* total transfer count */ + /* arm EP6-OUT */ + EP6BCL = 0x80; + syncdelay(3); + EP6BCL = 0x80; + syncdelay(3); - /* Clear EP0BUF for OUT requests */ - if (setup_data.bmrequesttype & 0x80) { - bcnt = ((wcnt > 64) ? 64 : wcnt); - for (ix = 0; ix < bcnt; ix++) - eptr[ix] = 0; - } + /* REVCTL.0 and REVCTL.1 set to 1 */ + REVCTL = 0x3; + /* Arm both EP2 buffers to “prime the pump” */ + OUTPKTEND = 0x82; + syncdelay(3); + OUTPKTEND = 0x82; + syncdelay(3); - switch (setup_data.brequest) { - case VR_CFGOPEN: - /* Clear bytecount / to allow new data in / to stops NAKing */ - EP0BCH = 0; - EP0BCL = 0; - while (EP0CS & EPBSY) - ; /* 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]); - /* Angie board FPGA bitstream download */ - switch ((setup_data.wvalue) & 0x00C0) { - case 0x00: - /* Apply RPGM- pulse */ - PIN_PROGRAM_B = 0; - syncdelay(1); - /* Negate RPGM- pulse */ - PIN_PROGRAM_B = 1; - /* FPGA init time < 10mS */ - delay_ms(10); - /* Initialize GPIF interface transfer count */ - set_gpif_cnt(gcnt); - PIN_RDWR_B = 0; - PIN_SDA = 0; - /* Trigger GPIF OUT transfer on EP2 */ - GPIFTRIG = GPIF_EP2; - while (!(GPIFTRIG & BMGPIFDONE)) // poll GPIFTRIG.7 GPIF Done bit - ; - PIN_SDA = 1; - PIN_RDWR_B = 1; - /* Choose wich Waveform to use */ - GPIFWFSELECT = 0xF6; - break; - default: - break; - } - break; - case VR_DATAOUTOPEN: - /* Clear bytecount / to allow new data in / to stops NAKing */ - EP0BCH = 0; - EP0BCL = 0; - while (EP0CS & EPBSY) - ; /* 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]); - /* Angie board FPGA bitstream download */ - PIN_RDWR_B = 0; - /* Initialize GPIF interface transfer count */ - GPIFTCB3 = (uint8_t)(((uint32_t)(gcnt) >> 24) & 0x000000ff); - GPIFTCB2 = (uint8_t)(((uint32_t)(gcnt) >> 16) & 0x000000ff); - GPIFTCB1 = (uint8_t)(((uint32_t)(gcnt) >> 8) & 0x000000ff); - GPIFTCB0 = (uint8_t)((uint32_t)(gcnt) & 0x000000ff); - /* Trigger GPIF OUT transfer on EP2 */ - GPIFTRIG = GPIF_EP2; - while (!(GPIFTRIG & BMGPIFDONE)) // poll GPIFTRIG.7 GPIF Done bit - ; - PIN_RDWR_B = 1; - /* Initialize GPIF interface transfer count */ - GPIFTCB3 = (uint8_t)(((uint32_t)(gcnt) >> 24) & 0x000000ff); - GPIFTCB2 = (uint8_t)(((uint32_t)(gcnt) >> 16) & 0x000000ff); - GPIFTCB1 = (uint8_t)(((uint32_t)(gcnt) >> 8) & 0x000000ff); - GPIFTCB0 = (uint8_t)((uint32_t)(gcnt) & 0x000000ff); - /* Initialize AUTOIN transfer count */ - EP4AUTOINLENH = (uint8_t)(((uint32_t)(gcnt) >> 8) & 0x000000ff); - EP4AUTOINLENL = (uint8_t)((uint32_t)(gcnt) & 0x000000ff); - /* Trigger GPIF IN transfer on EP4 */ - GPIFTRIG = BMGPIFREAD | GPIF_EP4; - break; - default: - return true; /* Error: unknown VR command */ - } - return false; /* no error; command handled OK */ + /* Standard procedure to reset FIFOs */ + FIFORESET = BMNAKALL; /* NAK all transfers during the reset */ + syncdelay(3); + FIFORESET = BMNAKALL | 0x02; /* reset EP2 FIFO */ + syncdelay(3); + FIFORESET = BMNAKALL | 0x04; /* reset EP4 FIFO */ + syncdelay(3); + FIFORESET = 0x00; /* deactivate the NAK all */ + syncdelay(3); + + /* configure EP2 in AUTO mode with 8-bit interface */ + EP2FIFOCFG = 0x00; + syncdelay(3); + EP2FIFOCFG = BMAUTOOUT; /* 8-bit Auto OUT mode */ + syncdelay(3); + EP4FIFOCFG = BMAUTOIN | BMZEROLENIN; /* 8-bit Auto IN mode */ + syncdelay(3); } void i2c_recieve(void) --