# devel/urjtag broken / not working?



## tingo (Nov 4, 2020)

Recently, I installed the urjtag package on my FreeBSD 11.4 machine

```
tingo@kg-core2$ uname -a
FreeBSD kg-core2.kg4.no 11.4-RELEASE-p3 FreeBSD 11.4-RELEASE-p3 #0: Tue Sep  1 08:22:33 UTC 2020     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
```
urjtag

```
root@kg-core2# pkg info urjtag*
urjtag-2019.12
root@kg-core2# pkg options urjtag
urjtag - FTDI: on
urjtag - JEDEC: off
urjtag - NLS: on
urjtag - PYTHON: off
urjtag - USB: on
```
I connected up a DirtyJTAG adapter (aka STM32 "Blue Pill" with DirtyJTAG firmware). The JTAG adapter is correctly identified:

```
root@kg-core2# usbconfig -d ugen0.4
ugen0.4: <DirtyJTAG Jean THOMAS> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (100mA)
root@kg-core2# ls -l /dev/ugen0.4 /dev/usb/0.4.0
lrwxr-xr-x  1 root  wheel         9 Nov  4 22:18 /dev/ugen0.4 -> usb/0.4.0
crw-rw----  1 root  operator  0x2d4 Nov  4 22:18 /dev/usb/0.4.0
```
and it has permissions so that my user can access it:

```
tingo@kg-core2$ groups tingo
tingo wheel operator video dialer cups
```
but, urjtag doesn't want to talk to the adapter

```
tingo@kg-core2$ jtag

UrJTAG 2019.12 #
Copyright (C) 2002, 2003 ETC s.r.o.
Copyright (C) 2007, 2008, 2009 Kolja Waschk and the respective authors

UrJTAG is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
There is absolutely no warranty for UrJTAG.

warning: UrJTAG may damage your hardware!
Type "quit" to exit, "help" for help.

jtag> cable dirtyjtag
error: Couldn't connect to suitable USB device.
jtag> quit
```
I also tried with [command]sudo jtag[/command] - no difference
and I tried to build urjtag from ports - it fails in the same way.
Ideas? suggestions?


----------



## tingo (Nov 4, 2020)

I have (of course) verified that this hardware works on a machine with a working urjtag (no, that machine doesn't run FreeBSD). Same version  of urjtag.


----------



## tingo (Nov 6, 2020)

Tested on another machine today, this one running FreeBSD 12.2-release:

```
# freebsd-version -ku
12.2-RELEASE
12.2-RELEASE
```
urjtag installed from packages (quarterly)

```
# pkg info urjtag*
urjtag-2019.12
# pkg options urjtag
urjtag - FTDI: on
urjtag - JEDEC: off
urjtag - NLS: on
urjtag - PYTHON: off
urjtag - USB: on
```
dirtyjtag adapter installed and confirmed (via usbconfig) to be present and detected, permissions on device files checked. Testing:

```
# jtag

UrJTAG 2019.12 #
Copyright (C) 2002, 2003 ETC s.r.o.
Copyright (C) 2007, 2008, 2009 Kolja Waschk and the respective authors

UrJTAG is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
There is absolutely no warranty for UrJTAG.

warning: UrJTAG may damage your hardware!
Type "quit" to exit, "help" for help.

jtag> cable dirtyjtag
error: Couldn't connect to suitable USB device.
jtag> quit
```
Not working. What is going on here?


----------



## tingo (Nov 8, 2020)

I also tried with a freshly compiled urjtag, downloaded source, applied the path in the port and built it.

```
$ src/apps/jtag/jtag

UrJTAG 2019.12 #
Copyright (C) 2002, 2003 ETC s.r.o.
Copyright (C) 2007, 2008, 2009 Kolja Waschk and the respective authors

UrJTAG is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
There is absolutely no warranty for UrJTAG.

warning: UrJTAG may damage your hardware!
Type "quit" to exit, "help" for help.

jtag> cable dirtyjtag
error: Couldn't connect to suitable USB device.
jtag> quit
```
yes, still on the FreeBSD 12.2 machine.


----------



## tingo (Nov 8, 2020)

I also tested with an Altera USB Blaster cable on the FreeBSD 12.2 machine

```
$ src/apps/jtag/jtag

UrJTAG 2019.12 #
Copyright (C) 2002, 2003 ETC s.r.o.
Copyright (C) 2007, 2008, 2009 Kolja Waschk and the respective authors

UrJTAG is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
There is absolutely no warranty for UrJTAG.

warning: UrJTAG may damage your hardware!
Type "quit" to exit, "help" for help.

jtag> cable usbblaster
Connected to libftdi driver.
jtag> detect
Segmentation fault (core dumped)
```
I compiled urjtag from source, but everything else is installed from packages. Perhaps this is another "package X don't work on 12.2 because it was compiled for 12.1" situation?


----------



## Alexander88207 (Nov 8, 2020)

> Perhaps this is another "package X don't work on 12.2 because it was compiled for 12.1" situation?



I would say no because it doesn't depend on kernel sources.

I would like to encourage you to write a bug report.


----------



## tingo (Nov 18, 2020)

PR 251232 has been created.


----------



## a6h (Nov 18, 2020)

Is UrJTAG still alive? Beside docs and four 404 on their website, I can't find any contact information on urjtag.org. Is there any alternative?


----------



## oOiOo (Nov 18, 2020)

Hello,
I didn't know urjtag. I made a test on FB 12.2 and I have the same problem here with a DirtyJTAG "bluepill" and a jlink clone (SEGGER).


----------



## tingo (Nov 18, 2020)

vigole said:


> Is UrJTAG still alive? Beside docs and four 404 on their website, I can't find any contact information on urjtag.org. Is there any alternative?


Very much so. I don't know what up with the website (it was working fine a few days ago, now it says "maintenance"), but the repository is here: https://sourceforge.net/projects/urjtag/


----------



## oOiOo (Nov 20, 2020)

I just did some digging. In fact `libusb` is not detected with `configure`,  so no USB device is detected. Can you replace the following line in `Makefile` and rebuild the package

```
USB_CONFIGURE_ON=               --with-libusb=/usr
```
by

```
USB_CONFIGURE_ON=
```
It's works for me with the DirtyJTAG, but not with the jlink:

```
jtag> cable jlink
J-Link initial read failed, don't worry (result=0)
Vref = 0.0 TCK=0 TDI=0 TDO=0 TMS=0 TRES=1 TRST=0
error: Resetting J-Link. Please retry the cable command.
error: libusb error: Vref too low. Possibly the target isn't powered or disconnected?
```
but I suspect it's broken


----------



## tingo (Nov 20, 2020)

Heh, let me quickly test that:

```
tingo@kg-core1$ jtag

UrJTAG 2019.12 #
Copyright (C) 2002, 2003 ETC s.r.o.
Copyright (C) 2007, 2008, 2009 Kolja Waschk and the respective authors

UrJTAG is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
There is absolutely no warranty for UrJTAG.

warning: UrJTAG may damage your hardware!
Type "quit" to exit, "help" for help.

jtag> bsdl path /home/tingo/doc/Altera/docs/fpga/bsdl/
jtag> cable dirtyjtag
jtag> detect
IR length: 10
Chain length: 1
Device Id: 00000010000011110001000011011101 (0x020F10DD)
  Filename:     /home/tingo/doc/Altera/docs/fpga/bsdl//EP4CE6E22.bsd
jtag> quit
```
yes - it works. Thank you! Do you want to update the PR, oOiOo ?


----------



## tingo (Nov 20, 2020)

I also re-tested the Altera USB Blaster, with the fix that oOiOo figured out:

```
tingo@kg-core1$ jtag

UrJTAG 2019.12 #
Copyright (C) 2002, 2003 ETC s.r.o.
Copyright (C) 2007, 2008, 2009 Kolja Waschk and the respective authors

UrJTAG is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
There is absolutely no warranty for UrJTAG.

warning: UrJTAG may damage your hardware!
Type "quit" to exit, "help" for help.

jtag> bsdl path /home/tingo/doc/Altera/docs/fpga/bsdl/
jtag> cable usbblaster
Connected to libftdi driver.
jtag> detect
Segmentation fault (core dumped)
```
not working, seems to be a different problem.


----------



## oOiOo (Nov 21, 2020)

tingo said:


> yes - it works. Thank you! Do you want to update the PR, oOiOo ?


I let you do it. `libusb` shoud not be an option since it's in the base system.



tingo said:


> I also re-tested the Altera USB Blaster, with the fix that oOiOo figured out:
> 
> ```
> tingo@kg-core1$ jtag
> ...


With a little chance, a core dump can be debug with `truss`.
Hope this help


----------



## tingo (Dec 2, 2020)

PR 251533 has been created for the USB Blaster case.


----------

