Skip to content

Commit

Permalink
Touch-ups
Browse files Browse the repository at this point in the history
  • Loading branch information
kholia committed Jan 18, 2024
1 parent dc481c6 commit 0e850f4
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 15 deletions.
40 changes: 35 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ mkdir ~/repos
cd ~/repos
git clone https://github.com/raspberrypi/pico-sdk.git
cd pico-sdk; git submodule update --init
cd ~/repos
git clone https://github.com/kholia/xvc-pico.git
```

Expand All @@ -76,16 +79,27 @@ make -j4

Grab `xvcd-pico.exe` from the `builds` folder of this repository itself.

You need to install the `libusbK` driver with Zadig (https://zadig.akeo.ie/)
for all three `Interfaces`.
You need to install the `libusbK` driver with `Zadig` (https://zadig.akeo.ie/).

OR

You can install the WinLibUSB driver from `USB Drive Tool Application`
(https://visualgdb.com/UsbDriverTool/).

Credit goes to https://github.com/benitoss/ for these instructions.


### Usage

Select the `Add Xilinx Virtual Cable (XVC)` option in the `Hardware
Manager` in Vivado and mention the `IP address` of the host computer.
On the host computer with the Raspberry Pi Pico connected, run the XVC Daemon
Server.

```
./xvcd-pico
```

In Vivado, select the `Add Xilinx Virtual Cable (XVC)` option in the `Hardware
Manager` and mention the `IP address` and the `Port` of the host computer.

![Vivado Usage](./Usage-in-Vivado.png)

Expand Down Expand Up @@ -119,6 +133,23 @@ Writing `ebaz4205_top.bit (371.6 KiB)` takes only ~2.5 seconds now - thanks to
tom01h. Don't `overestimate` the speed of human programmers and Vivado though
;)

```
$ time ./openFPGALoader -c xvc-client --port 2542 --file-type bin ebaz4205_top.bin
empty
detected xvcServer version v1.0 packet size 12288
freq 6000000 166.666667 166 0
a6 0 0 0
Open file DONE
Parse file DONE
load program
Load SRAM: [==================================================] 100.00%
Done
./openFPGALoader -c xvc-client --port 2542 --file-type bin ebaz4205_top.bin 0.00s user 0.01s system 0% cpu 7.389 total
```

It seems `openFPGALoader` is a lot slower than Vivado in programming devices
via `XVC`!?

Writing `corescore_0.bit (2 MiB)` which uses ~100% FPGA LEs takes around ~9
seconds.

Expand Down Expand Up @@ -154,4 +185,3 @@ Note: /dev/ttyACM(n) will appear when Pico's USB is connected.
- https://github.com/fusesoc/blinky#ebaz4205-development-board
- https://github.com/maxnet/pico-webserver/ approach (LWIP_SOCKET is not available yet!)
- [NEXT] Do a 100% standalone port to Pico W ;)
- [TODO] Make `BUFFER_SIZE` configurable - PRs welcome!
Binary file added boards/EBAZ4205/blink.bit
Binary file not shown.
Binary file modified builds/xvcd-pico.zip
Binary file not shown.
21 changes: 11 additions & 10 deletions daemon/xvcpico.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <sys/types.h>

// #define BUFFER_SIZE 1024 * 1024 // is super fast but doesn't work on ebaz4205 board ;(
#define BUFFER_SIZE 1024 * 10 // NOTE: Reduce this in case of flashing problems!
#define BUFFER_SIZE 1024 * 20 // NOTE: Reduce this in case of flashing problems!

#ifdef __CYGWIN__
#include <libusb-1.0/libusb.h>
Expand Down Expand Up @@ -179,7 +179,7 @@ int device_init() {
int size;
size = libusb_get_max_iso_packet_size(dev, XVCPICO_WRITE_EP);

printf("write ep size = %d\n", size);
// printf("write ep size = %d\n", size);

return size; // success
}
Expand Down Expand Up @@ -228,12 +228,13 @@ static int sread(int fd, void *target, int len) {
return 1;
}

static unsigned char buffer[BUFFER_SIZE], result[BUFFER_SIZE / 2];

int handle_data(int fd, int ep_size) {
uint32_t len, nr_bytes;

do {
char cmd[16];
unsigned char buffer[BUFFER_SIZE], result[BUFFER_SIZE / 2];
memset(cmd, 0, 16);

if (sread(fd, cmd, 2) != 1)
Expand All @@ -244,7 +245,7 @@ int handle_data(int fd, int ep_size) {
return 1;
memcpy(result, xvcInfo, strlen(xvcInfo));
if (write(fd, result, strlen(xvcInfo)) != (ssize_t)strlen(xvcInfo)) {
perror("write");
perror("write 1");
return 1;
}
if (verbose) {
Expand All @@ -257,8 +258,8 @@ int handle_data(int fd, int ep_size) {
return 1;
memcpy(result, cmd + 5, 4);
if (write(fd, result, 4) != 4) {
perror("write");
return 1;
perror("write 2");
return 2;
}
if (verbose) {
printf("%u : Received command: 'settck'\n", (int)time(NULL));
Expand Down Expand Up @@ -371,8 +372,8 @@ int handle_data(int fd, int ep_size) {
gpio_write(0, 1, 0);

if (write(fd, result, nr_bytes) != nr_bytes) {
perror("write");
return 1;
perror("write 3: Reduce BUFFER_SIZE in xvcpico.c");
return 3;
}

} while (1);
Expand All @@ -391,8 +392,8 @@ int main() {
if (ep_size < 0) {
return -1;
}

fprintf(stderr, "XVCPI is listening now!\n");
fprintf(stderr, "NB: ep_size => %d\n", ep_size);
fprintf(stderr, "XVCPI is listening now with BUFFER_SIZE => %d!\n", BUFFER_SIZE/2);

s = socket(AF_INET, SOCK_STREAM, 0);
if (s < 0) {
Expand Down
Binary file modified firmware/xvcPico.uf2
Binary file not shown.

0 comments on commit 0e850f4

Please sign in to comment.