aboutsummaryrefslogtreecommitdiff
path: root/src/jtag
diff options
context:
space:
mode:
authorAhmed BOUDJELIDA <aboudjelida@nanoxplore.com>2023-11-21 17:45:55 +0100
committerAntonio Borneo <borneo.antonio@gmail.com>2024-01-13 14:47:10 +0000
commit995a7af21d6f97f628382e26dc21dc38e4fa846e (patch)
treed6b416a6066bb5e7c4961a0bea2fb1b7aa1ea1b8 /src/jtag
parentfce7aa754f40475228db345c9dd0bf3eb929fc7b (diff)
downloadriscv-openocd-995a7af21d6f97f628382e26dc21dc38e4fa846e.zip
riscv-openocd-995a7af21d6f97f628382e26dc21dc38e4fa846e.tar.gz
riscv-openocd-995a7af21d6f97f628382e26dc21dc38e4fa846e.tar.bz2
jtag/drivers: send bitstream size to firmware via libusb
Send bitstream size to firmware to initialize the GPIF count registers, since we're going to send this size via GPIF, we need to give the exact number of bytes to be sent, then the GPIF counter will decrement with every clock cycle (every byte sent) until reaching zero and stops. Change-Id: Ib4e8e0f95a6a4a95ef4888ba8a04a0ea45567f5a Signed-off-by: Ahmed BOUDJELIDA <aboudjelida@nanoxplore.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7988 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Diffstat (limited to 'src/jtag')
-rw-r--r--src/jtag/drivers/angie.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/jtag/drivers/angie.c b/src/jtag/drivers/angie.c
index b6bde5b..b7d1f8a 100644
--- a/src/jtag/drivers/angie.c
+++ b/src/jtag/drivers/angie.c
@@ -17,6 +17,7 @@
#include <stdlib.h>
#include <math.h>
#include "helper/system.h"
+#include <helper/types.h>
#include <jtag/interface.h>
#include <jtag/commands.h>
#include <target/image.h>
@@ -61,7 +62,7 @@
#define ANGIE_FIRMWARE_FILE PKGDATADIR "/angie/angie_firmware.bin"
/** Default location of ANGIE firmware image. */
-#define ANGIE_BITSTREAM_FILE PKGDATADIR "/angie/angie_bitstream.bit"
+#define ANGIE_BITSTREAM_FILE PKGDATADIR "/angie/angie_bitstream.bit"
/** Maximum size of a single firmware section. Entire EZ-USB ANGIE code space = 16kB */
#define SECTION_BUFFERSIZE 16384
@@ -404,15 +405,7 @@ static int angie_load_bitstream(struct angie *device, const char *filename)
FILE *bitstream_file = NULL;
char *bitstream_data = NULL;
size_t bitstream_size = 0;
-
- /* CFGopen */
- ret = jtag_libusb_control_transfer(device->usb_device_handle,
- 0x00, 0xB0, 0, 0, NULL, 0, LIBUSB_TIMEOUT_MS, &transferred);
- if (ret != ERROR_OK) {
- LOG_ERROR("Failed opencfg");
- /* Abort if libusb sent less data than requested */
- return ERROR_FAIL;
- }
+ uint8_t gpifcnt[4];
/* Open the bitstream file */
bitstream_file = fopen(bitstream_file_path, "rb");
@@ -442,6 +435,17 @@ static int angie_load_bitstream(struct angie *device, const char *filename)
return ERROR_FAIL;
}
+ h_u32_to_be(gpifcnt, bitstream_size);
+
+ /* CFGopen */
+ ret = jtag_libusb_control_transfer(device->usb_device_handle,
+ 0x00, 0xB0, 0, 0, (char *)gpifcnt, 4, LIBUSB_TIMEOUT_MS, &transferred);
+ if (ret != ERROR_OK) {
+ LOG_ERROR("Failed opencfg");
+ /* Abort if libusb sent less data than requested */
+ return ERROR_FAIL;
+ }
+
/* Send the bitstream data to the microcontroller */
int actual_length = 0;
ret = jtag_libusb_bulk_write(device->usb_device_handle, 0x02, bitstream_data, bitstream_size, 1000, &actual_length);