Discussion:
[UrJTAG-dev] ch341 and your parallel port knowledge
Benjamin Henrion
2017-03-07 17:39:47 UTC
Permalink
Hi,

I got a ch341 devboard for cheap from Electrodragon:

http://www.electrodragon.com/product/ch341-usb-convert-flash-board-usb-ttl-iic-spi-etc/

I also have this one:

http://www.zoobab.com/ch341-usb-spi-i2c-uart-isp-dongle

I found the parallel port driver for linux, which ships with a GTK demo app:

https://github.com/zoobab/ch341-parport

Any idea if this MEM mode would allow urjtag to treat it like an 0x378
parallel port:

Loading Image...

It creates a /dev/ch34x-gis0 entry which is of type 180 0, which is
the same as an /dev/lp0:

https://openvz.org/USB_Printing_in_VE

If MEM could not be used, there are 8 GPIOs in D0-D7 which could be
used to implement a libusb based JTAG cable.

Best,

--
Benjamin Henrion <bhenrion at ffii.org>
FFII Brussels - +32-484-566109 - +32-2-3500762
"In July 2005, after several failed attempts to legalise software
patents in Europe, the patent establishment changed its strategy.
Instead of explicitly seeking to sanction the patentability of
software, they are now seeking to create a central European patent
court, which would establish and enforce patentability rules in their
favor, without any possibility of correction by competing courts or
democratically elected legislators."
Kolja Waschk
2017-03-07 18:59:17 UTC
Permalink
Hi,
Post by Benjamin Henrion
Any idea if this MEM mode would allow urjtag to treat it like an 0x378
It does not seem to implement PPCLAIM/PPRELEASE ioctls, used e.g. in
ppdev.c. So I don't think it can be used like a generic parport. There
are other ioctls to switch between operation modes like parallel, mem,
i2c, spi.

Support for SPI might be especially interesting, as it can be used as
JTAG under certain circumstances, e.g. if one can toggle between GPIO
and SPI mode freely.

However, support for such CH341-specific mode in UrJTAG would be either
Linux-only (using the kernel driver you referenced) or implementing the
functionality using libusb, as you suggested.

Kolja
Benjamin Henrion
2017-03-08 07:24:47 UTC
Permalink
Post by Kolja Waschk
Hi,
Post by Benjamin Henrion
Any idea if this MEM mode would allow urjtag to treat it like an 0x378
It does not seem to implement PPCLAIM/PPRELEASE ioctls, used e.g. in
ppdev.c. So I don't think it can be used like a generic parport. There
are other ioctls to switch between operation modes like parallel, mem,
i2c, spi.
Support for SPI might be especially interesting, as it can be used as
JTAG under certain circumstances, e.g. if one can toggle between GPIO
and SPI mode freely.
However, support for such CH341-specific mode in UrJTAG would be either
Linux-only (using the kernel driver you referenced) or implementing the
functionality using libusb, as you suggested.
I found this simple SPI programmer based on libusb using D0-D5 pins:

https://github.com/hackpascal/ch341prog

The code is using those pins (UIO probably means Universal IO):

#define>CH341_CMD_UIO_STM_IN>--->---0x00>---// UIO Interface In ( D0 ~ D7 )
#define>CH341_CMD_UIO_STM_DIR>-->---0x40>---// UIO interface Dir( set
dir of D0~D5 )
#define>CH341_CMD_UIO_STM_OUT>-->---0x80>---// UIO Interface Output(D0~D5)
#define>CH341_CMD_UIO_STM_END>-->---0x20>---// UIO Interface End Command

Now if there is code for a similar JTAG cable libusb based, that might
be a good starting point.

--
Benjamin Henrion <bhenrion at ffii.org>
FFII Brussels - +32-484-566109 - +32-2-4148403
"In July 2005, after several failed attempts to legalise software
patents in Europe, the patent establishment changed its strategy.
Instead of explicitly seeking to sanction the patentability of
software, they are now seeking to create a central European patent
court, which would establish and enforce patentability rules in their
favor, without any possibility of correction by competing courts or
democratically elected legislators."

Loading...