contrib/firmware: Change USB interruption handling for JTAG/I2C communications 74/8074/8
authorAhmed BOUDJELIDA <aboudjelida@nanoxplore.com>
Fri, 22 Dec 2023 09:59:52 +0000 (10:59 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 13 Jan 2024 14:48:56 +0000 (14:48 +0000)
Before this change, when we send an I2C Bulk data at the same
time while Jtag bitbanging functions execute, the microcontroller
puts JTAG bitbanging on wait and executes all I2C bitbanging
function, which causes problems like loss of Ack in DAP responses
and other errors.

With this commit, When I2C interruption occurs, it sets a variable
to true and continues JTAG bitbanging, when it finish it executes
the I2C bitbang.

Change-Id: Ia80bac21f8a259f4a1176b5346bf74ed0aa6e38b
Signed-off-by: Ahmed BOUDJELIDA <aboudjelida@nanoxplore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8074
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
contrib/firmware/angie/c/include/usb.h
contrib/firmware/angie/c/src/protocol.c
contrib/firmware/angie/c/src/usb.c
src/jtag/drivers/angie/angie_firmware.bin

index e10947d3340ac6d1f1f17e14d971d1e361b3b4e3..ad8be787e4cd0d0e18301f6036a1215a63021887 100644 (file)
@@ -129,6 +129,7 @@ struct setup_data {
  * the USB module */
 extern volatile bool ep1_out;
 extern volatile bool ep1_in;
+extern volatile bool ep6_out;
 
 extern volatile __xdata __at 0xE6B8 struct setup_data setup_data;
 
index d84534bf2f6e6b36d1eff3962a4ccc339e703062..e32808db8f8a7c08d004099cdf36bb2cbad73ea9 100644 (file)
@@ -157,30 +157,36 @@ void command_loop(void)
                cmd_id_index = 0;
                payload_index_in = 0;
 
-               /* Wait until host sends EP1 Bulk-OUT packet */
-               while (!ep1_out)
+               /* Wait until host sends Bulk-OUT packet */
+               while ((!ep1_out) && (!ep6_out))
                        ;
-               ep1_out = false;
-
-               /* Execute the commands */
-               last_command = false;
-               while (!last_command)
-                       last_command = execute_command();
-
-               /* Send back EP6 Bulk-IN packet if required */
-               if (payload_index_in > 0) {
-                       EP1INBC = payload_index_in;
+               if (ep6_out) {
+                       /* Execute I2C command */
+                       i2c_recieve();
+                       ep6_out = false;
+               }
+               if (ep1_out) {
+                       ep1_out = false;
+                       /* Execute the commands */
+                       last_command = false;
+                       while (!last_command)
+                               last_command = execute_command();
+
+                       /* Send back EP1 Bulk-IN packet if required */
+                       if (payload_index_in > 0) {
+                               EP1INBC = payload_index_in;
+                               syncdelay(3);
+
+                               while (!ep1_in)
+                                       ;
+                               ep1_in = false;
+                       }
+
+                       /* Re-arm EP1-OUT after command execution */
+                       EP1OUTBC = 0;
+                       syncdelay(3);
+                       EP1OUTBC = 0;
                        syncdelay(3);
-
-                       while (!ep1_in)
-                               ;
-                       ep1_in = false;
                }
-
-               /* Re-arm EP1-OUT after command execution */
-               EP1OUTBC = 0;
-               syncdelay(3);
-               EP1OUTBC = 0;
-               syncdelay(3);
        }
 }
index a137d3d37e636c043872ce72357170966eb0f2e4..ed23dcfa5ace9921709a2b03b26151a27d57a7b9 100644 (file)
@@ -25,6 +25,7 @@
  */
 volatile bool ep1_out;
 volatile bool ep1_in;
+volatile bool ep6_out;
 
 volatile __xdata __at 0xE6B8 struct setup_data setup_data;
 
@@ -195,27 +196,24 @@ void ep0out_isr(void)__interrupt  EP0OUT_ISR
 void ep1in_isr(void)__interrupt        EP1IN_ISR
 {
        ep1_in = true;
-
        EXIF &= ~0x10;  /* Clear USBINT: Main global interrupt */
        EPIRQ = 0x04;   /* Clear individual EP1IN IRQ */
 }
 void ep1out_isr(void)__interrupt       EP1OUT_ISR
 {
        ep1_out = true;
-
        EXIF &= ~0x10;  /* Clear USBINT: Main global interrupt */
        EPIRQ = 0x08;   /* Clear individual EP1OUT IRQ */
 }
 void ep2_isr(void)__interrupt  EP2_ISR
 {
-       ep1_out = false; /* Does nothing but required by the compiler */
 }
 void ep4_isr(void)__interrupt  EP4_ISR
 {
 }
 void ep6_isr(void)__interrupt  EP6_ISR
 {
-       i2c_recieve();
+       ep6_out = true;
        EXIF &= ~0x10;  /* Clear USBINT: Main global interrupt */
        EPIRQ = 0x40;   /* Clear individual EP6OUT IRQ */
 
index bc85208415324c9d2e92c0639a52433b8b98f5d2..68486ef8f09865c663966cf80cc334ec93405b5c 100644 (file)
Binary files a/src/jtag/drivers/angie/angie_firmware.bin and b/src/jtag/drivers/angie/angie_firmware.bin differ

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)