Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPLD support #2

Open
Silveriomrs opened this issue Jul 5, 2023 · 10 comments
Open

CPLD support #2

Silveriomrs opened this issue Jul 5, 2023 · 10 comments
Labels
enhancement New feature or request

Comments

@Silveriomrs
Copy link

Silveriomrs commented Jul 5, 2023

After following your instructions:

/Xilinx/libxpc$ sudo apt-get install libusb-1.0

Leyendo lista de paquetes... Hecho
Creando árbol de dependencias... Hecho
Leyendo la información de estado... Hecho
Nota, seleccionando «libusb-1.0-0-dev» para la expresión regular «libusb-1.0»
Nota, seleccionando «libusb-1.0-doc» para la expresión regular «libusb-1.0»
Nota, seleccionando «libusb-1.0-0» para la expresión regular «libusb-1.0»
libusb-1.0-0 ya está en su versión más reciente (2:1.0.25-1ubuntu2).
Se instalarán los siguientes paquetes NUEVOS:
libusb-1.0-0-dev libusb-1.0-doc
0 actualizados, 2 nuevos se instalarán, 0 para eliminar y 3 no actualizados.
Se necesita descargar 259 kB de archivos.
Se utilizarán 1.940 kB de espacio de disco adicional después de esta operación.
¿Desea continuar? [S/n] s
Des:1 http:https://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libusb-1.0-0-dev amd64 2:1.0.25-1ubuntu2 [76,3 kB]
Des:2 http:https://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libusb-1.0-doc all 2:1.0.25-1ubuntu2 [183 kB]
Descargados 259 kB en 1s (339 kB/s)
Seleccionando el paquete libusb-1.0-0-dev:amd64 previamente no seleccionado.
(Leyendo la base de datos ... 513651 ficheros o directorios instalados actualmente.)
Preparando para desempaquetar .../libusb-1.0-0-dev_2%3a1.0.25-1ubuntu2_amd64.deb ...
Desempaquetando libusb-1.0-0-dev:amd64 (2:1.0.25-1ubuntu2) ...
Seleccionando el paquete libusb-1.0-doc previamente no seleccionado.
Preparando para desempaquetar .../libusb-1.0-doc_2%3a1.0.25-1ubuntu2_all.deb ...
Desempaquetando libusb-1.0-doc (2:1.0.25-1ubuntu2) ...
Configurando libusb-1.0-doc (2:1.0.25-1ubuntu2) ...
Configurando libusb-1.0-0-dev:amd64 (2:1.0.25-1ubuntu2) ...
Procesando disparadores para doc-base (0.11.1) ...
Procesando 1 archivo doc-base añadido...
user@user:/Xilinx/libxpc$ ./xpc init
bash: ./xpc: No existe el archivo o el directorio
user@user:
/Xilinx/libxpc$ make
gcc -c -Wall -Wextra -fsanitize=address -g3 -D_GNU_SOURCE -oobj/main.o main.c
gcc -c -Wall -Wextra -fsanitize=address -g3 -D_GNU_SOURCE -oobj/bitfile.o bitfile.c
gcc -c -Wall -Wextra -fsanitize=address -g3 -D_GNU_SOURCE -oobj/driver.o driver.c
rm -f libxpc.a
ar rcs libxpc.a obj/bitfile.o obj/driver.o
gcc -oxpc obj/main.o libxpc.a -lusb-1.0 -fsanitize=address
user@user:/Xilinx/libxpc$ make install
cp -av xpc /usr/bin/
'xpc' -> '/usr/bin/xpc'
cp: no se puede crear el fichero regular '/usr/bin/xpc': Permiso denegado
make: *** [Makefile:17: install] Error 1
user@user:
/Xilinx/libxpc$ sudo make install
cp -av xpc /usr/bin/
'xpc' -> '/usr/bin/xpc'
user@user:/Xilinx/libxpc$ ./xpc init
main.c:81:main | EAGAIN (Resource temporarily unavailable) | Platform cable not found or already initialized
user@user:
/Xilinx/libxpc$ ./xpc identify
main.c:20:main | EAGAIN (Resource temporarily unavailable) | Platform cable initialization failure
user@user:~/Xilinx/libxpc$

@fuger222
Copy link
Member

fuger222 commented Jul 5, 2023

Have you tried running it with sudo (sudo ./xpc init and sudo ./xpc identify)?
Also, can you please post the output of sudo lsusb?

@Silveriomrs
Copy link
Author

Silveriomrs commented Jul 5, 2023

Sure:

user@user:/Xilinx/libxpc$ sudo lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 04f2:b67a Chicony Electronics Co., Ltd LG HD WebCam
Bus 001 Device 003: ID 1ea7:0066 SHARKOON Technologies GmbH [Mediatrack Edge Mini Keyboard]
Bus 001 Device 002: ID 258a:002a SINO WEALTH Gaming KB
Bus 001 Device 005: ID 8087:0026 Intel Corp. AX201 Bluetooth
Bus 001 Device 006: ID 0403:6014 Future Technology Devices International, Ltd FT232H Single HS USB-UART/FIFO IC
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
user@user:
/Xilinx/libxpc$ sudo ./xpc init
main.c:81:main | EAGAIN (Resource temporarily unavailable) | Platform cable not found or already initialized
user@user:/Xilinx/libxpc$ sudo ./xpc identify
main.c:20:main | EAGAIN (Resource temporarily unavailable) | Platform cable initialization failure
user@user:
/Xilinx/libxpc$

Sorry for this lines crossing texts, I don'tt know how to remove them

@fuger222
Copy link
Member

fuger222 commented Jul 5, 2023

Thanks!
Looks like your cable uses an FTDI chip, but mine has a Cypress FX2, which I originally made this tool for.
I've uploaded a new version, which should detect everything, but it can't load bitfiles yet. Can you try if sudo ./xpc identify works with your cable?
You'll also need to install a package called libftdi1-dev, if you don't have it already.

Don't worry about those crossed lines, though.
There's a button above the text editor that you can use to insert a code block. It looks like this: <>
Anything you write there shouldn't be crossed over.

@Silveriomrs
Copy link
Author

Silveriomrs commented Jul 5, 2023

I will do it now.
Whatever, do you prefer to do a remote control to check it out by yourself?

In few minutes I will post the result.

  1. libftdi1-dev, was not installed. Now it is.
  2. The code:

`user@user:/Xilinx$ cd libxpc/
user@user:
/Xilinx/libxpc$ make
gcc -c -Wall -Wextra -fsanitize=address -g3 -D_GNU_SOURCE -oobj/main.o main.c
gcc -c -Wall -Wextra -fsanitize=address -g3 -D_GNU_SOURCE -oobj/bitfile.o bitfile.c
gcc -c -Wall -Wextra -fsanitize=address -g3 -D_GNU_SOURCE -oobj/driver.o driver.c
gcc -c -Wall -Wextra -fsanitize=address -g3 -D_GNU_SOURCE -oobj/dlc9lp.o dlc9lp.c
rm -f libxpc.a
ar rcs libxpc.a obj/bitfile.o obj/driver.o obj/dlc9lp.o
gcc -oxpc obj/main.o libxpc.a -lusb-1.0 -lftdi1 -fsanitize=address
user@user:/Xilinx/libxpc$ make install
cp -av xpc /usr/bin/
'xpc' -> '/usr/bin/xpc'
user@user:
/Xilinx/libxpc$ sudo ./xpc identify
The cable and the FPGA both seem to be connected properly.

user@user:~/Xilinx/libxpc$ sudo ./xpc init
main.c:88:main | EAGAIN (Resource temporarily unavailable) | Platform cable not found or already initialized

user@user:~/Xilinx/libxpc$ sudo ./xpc identify
The cable and the FPGA both seem to be connected properly.

user@user:~/Xilinx/libxpc$ ./xpc identify
main.c:21:main | EACCES (Permission denied) | Platform cable initialization failure

user@user:~/Xilinx/libxpc$ ./xpc init
main.c:88:main | EAGAIN (Resource temporarily unavailable) | Platform cable not found or already initialized

user@user:/Xilinx/libxpc$ sudo ./xpc identify
The cable and the FPGA both seem to be connected properly.
user@user:
/Xilinx/libxpc$ `

@fuger222
Copy link
Member

fuger222 commented Jul 6, 2023

Looks good so far! You could try sudo ./xpc identify with the latest version, which should also read the serial number of your FPGA. The reset and load commands should work too.

@fuger222 fuger222 added the enhancement New feature or request label Jul 6, 2023
@Silveriomrs
Copy link
Author

Hi,
It is the output. Identify seems to work better but not reset nor init. Load didn't try

`user@user:~/Xilinx$ git clone https://github.com/hexalinq/libxpc.git
Clonando en 'libxpc'...
remote: Enumerating objects: 38, done.
remote: Counting objects: 100% (38/38), done.
remote: Compressing objects: 100% (28/28), done.
remote: Total 38 (delta 14), reused 26 (delta 9), pack-reused 0
Recibiendo objetos: 100% (38/38), 23.83 KiB | 2.65 MiB/s, listo.
Resolviendo deltas: 100% (14/14), listo.

user@user:/Xilinx/libxpc$ make
gcc -c -Wall -Wextra -fsanitize=address -g3 -D_GNU_SOURCE -oobj/main.o main.c
gcc -c -Wall -Wextra -fsanitize=address -g3 -D_GNU_SOURCE -oobj/bitfile.o bitfile.c
gcc -c -Wall -Wextra -fsanitize=address -g3 -D_GNU_SOURCE -oobj/driver.o driver.c
gcc -c -Wall -Wextra -fsanitize=address -g3 -D_GNU_SOURCE -oobj/dlc9lp.o dlc9lp.c
rm -f libxpc.a
ar rcs libxpc.a obj/bitfile.o obj/driver.o obj/dlc9lp.o
gcc -oxpc obj/main.o libxpc.a -lusb-1.0 -lftdi1 -fsanitize=address
user@user:
/Xilinx/libxpc$ sudo make install
cp -av xpc /usr/bin/
'xpc' -> '/usr/bin/xpc'

user@user:~/Xilinx/libxpc$ sudo ./xpc identify
The cable and the FPGA both seem to be connected properly.
Reading FPGA serial number...
60 40 93 F8

user@user:~/Xilinx/libxpc$ sudo ./xpc reset
driver.c:270:JTAG_WriteInstructionRegisterBits | EAGAIN (Resource temporarily unavailable) |

user@user:/Xilinx/libxpc$ sudo ./xpc init
main.c:87:main | EAGAIN (Resource temporarily unavailable) | Platform cable not found or already initialized
user@user:
/Xilinx/libxpc$
`

@fuger222
Copy link
Member

fuger222 commented Jul 6, 2023

Fixed.
Init is actually unnecessary in your case, since your cable doesn't need a firmware to be loaded each time you plug it in. You can safely ignore that.

@Silveriomrs
Copy link
Author

Silveriomrs commented Jul 6, 2023

What is fixed?
Should I try to load a jed into the CPLD?
Is there a new ver that fix the issue?

Not sure what you mean.

By the way... I see your APP can program bitstream files... for FPGA, but what is about JED files (for CPLDs), in words of Xilinx it cannot be converted between JED to/from BIT.

I am trying to program a Xilinx CPLD.
Is it possible?

@fuger222
Copy link
Member

fuger222 commented Jul 6, 2023

I thought only the cable was unsupported, but yes, this is another problem. Bitstream files contain literally just a stream of bits, that this app sends to the programmer cable (pulls the TDO pin to GND or VCC based on whether the bit is 0 or 1), but JED files only contain the states of individual fuses, which need to be programmed in a different way.
Considering how much time it would take and the fact that I don't have a CPLD to experiment with, I don't plan making it compatible with CPLDs and a completely different file format, in the foreseeable future at least. Sorry about that.
I'll leave this issue open in case someone finds this project and decides to work on CPLD support.

If you haven't already, you could try openocd, maybe they have support for your cable + CPLD pair.

@fuger222 fuger222 changed the title Cable not found CPLD support Jul 6, 2023
@Silveriomrs
Copy link
Author

Thank you :)
I will try it with openocd.

Thank you for your great work. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants