diff options
author | Ahmed BOUDJELIDA <aboudjelida@nanoxplore.com> | 2023-12-22 10:59:52 +0100 |
---|---|---|
committer | Evgeniy Naydanov <109669442+en-sc@users.noreply.github.com> | 2024-01-29 13:36:27 +0300 |
commit | 0c2d907a5d650f1a3b8cbeeb7af7bf840b7db038 (patch) | |
tree | e79031b097a36153a60b749e21fff143353456a5 | |
parent | ba860abcab58e244bc4cc14b24cec7a5e8e30069 (diff) | |
download | riscv-openocd-0c2d907a5d650f1a3b8cbeeb7af7bf840b7db038.zip riscv-openocd-0c2d907a5d650f1a3b8cbeeb7af7bf840b7db038.tar.gz riscv-openocd-0c2d907a5d650f1a3b8cbeeb7af7bf840b7db038.tar.bz2 |
contrib/firmware: Change USB interruption handling for JTAG/I2C communications
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>
-rw-r--r-- | contrib/firmware/angie/c/include/usb.h | 1 | ||||
-rw-r--r-- | contrib/firmware/angie/c/src/protocol.c | 50 | ||||
-rw-r--r-- | contrib/firmware/angie/c/src/usb.c | 6 | ||||
-rw-r--r-- | src/jtag/drivers/angie/angie_firmware.bin | bin | 10248 -> 10216 bytes |
4 files changed, 31 insertions, 26 deletions
diff --git a/contrib/firmware/angie/c/include/usb.h b/contrib/firmware/angie/c/include/usb.h index e10947d..ad8be78 100644 --- a/contrib/firmware/angie/c/include/usb.h +++ b/contrib/firmware/angie/c/include/usb.h @@ -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; diff --git a/contrib/firmware/angie/c/src/protocol.c b/contrib/firmware/angie/c/src/protocol.c index d84534b..e32808d 100644 --- a/contrib/firmware/angie/c/src/protocol.c +++ b/contrib/firmware/angie/c/src/protocol.c @@ -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); } } diff --git a/contrib/firmware/angie/c/src/usb.c b/contrib/firmware/angie/c/src/usb.c index a137d3d..ed23dcf 100644 --- a/contrib/firmware/angie/c/src/usb.c +++ b/contrib/firmware/angie/c/src/usb.c @@ -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 */ diff --git a/src/jtag/drivers/angie/angie_firmware.bin b/src/jtag/drivers/angie/angie_firmware.bin Binary files differindex bc85208..68486ef 100644 --- a/src/jtag/drivers/angie/angie_firmware.bin +++ b/src/jtag/drivers/angie/angie_firmware.bin |