Root/ubb-jtag/README

1JTAG with UBB
2=============
3
4JTAG [1] typically uses 4 to 6 signals between the host and the
5target, making it perfectly suitable for UBB.
6
7UBB can be either used with just a cable or with minimum circuitry
8if level shifting is needed. If the level difference is small
9enough, simple resistive dividers that can be soldered directly to
10UBB will be sufficient.
11
12If using the "gpio" cable driver of UrTAG, we don't even need new
13code for this.
14
15[1] http://en.wikipedia.org/wiki/Jtag
16[2] http://urjtag.org/
17
18
19Overview
20--------
21
22This is an example of using UBB to communicate via JTAG with the
23Xilinx XC6SLX45 FPGA of a Milkymist One. We first describe the
24hardware setup, then configuration and installation of UrJTAG,
25and finally changes to the kernel configuration.
26
27The whole setup looks like this:
28http://downloads.qi-hardware.com/people/werner/ubb/jtag/ubb-jtag-m1-all.jpg
29
30
31UBB-JTAG-M1 hardware: 2.5 V level adaptation
32--------------------------------------------
33
34Note that this is target-specifc. No level adaptation is necessary
35if the target's JTAG interface runs at 3.3 V.
36
37Milkymist One uses 2.5 V for its JTAG interface while the Ben's
38IO runs at 3.3 V. The difference is small enough that we need no
39special provisions for going from 2.5 V to 3.3 V, but we have to
40adapt the level in the opposite direction.
41
42Since we will run the interface at fairly low speeds, simple
43resistive dividers will be sufficient. A 220/680 Ohm divider
44reduces the Ben's nominal 3.3 V to a nominal 2.5 V. Small
45through-hole resistors can be soldered directly to UBB.
46
47ubb-jtag-m1.sch shows the configuration. Since CLK is used as
48input and has no pull-up inside the Ben, no resistor is needed.
49However, it may be advisable to add a 220 Ohm series resistor
50as protection in case of misconfiguration.
51
52This is what UBB with voltage dividers (without series resistor
53on CLK) looks like:
54http://downloads.qi-hardware.com/people/werner/ubb/jtag/ubb-jtag-m1-card.jpg
55
56
57UBB-JTAG-M1 hardware: connector
58-------------------------------
59
60Milkymist One uses a shrouded 14 pin male connector with a 2 mm
61pitch for JTAG. While suitable connectors for ribbon cables are
62available, e.g., Molex 087568-1493, one can also improvise with
63female contacts designed for the ubiquitous 2.54 mm headers.
64
65If building a UBB-JTAG board with individual wires, the labels
66in m1-labels.fig can be used to identify them. Each label has
67the name of the JTAG signal and the position in the J6 connector
68of the Milkymist One.
69
70
71Building UrJTAG
72---------------
73
74Prequisite: the OpenWRT cross-compilation toolchain for the Ben
75has to be installed. I.e., mipsel-openwrt-linux-gcc and friends
76must be in PATH.
77
78git clone git://urjtag.git.sourceforge.net/gitroot/urjtag/urjtag
79cd urjtag/urjtag
80./autogen.sh --host=mipsel-openwrt-linux --enable-cable=gpio \
81   --enable-lowlevel= --without-libusb --without-libftdi
82make
83
84
85Installing UrJTAG
86-----------------
87
88Prerequisites: the Ben must be reachable via TCP/IP. We assume we
89can reach it under the name "ben". ldconfig must be installed (*).
90
91(*) E.g., with
92    wget http://downloads.qi-hardware.com/software/packages/NanoNote/Ben/2012-10-24/ldconfig_0.9.33.2-1_xburst.ipk
93    opkg install ldconfig_0.9.33.2-1_xburst.ipk
94
95scp src/apps/jtag/.libs/jtag ben:/usr/bin/
96scp src/.libs/liburjtag.so.0.0.0 ben:/usr/lib/
97ssh ben mkdir -p /usr/local/share/urjtag
98scp -r data/* ben:/usr/local/share/urjtag/
99ssh ben ldconfig
100
101
102Enabling the /sys/class/gpio/... interface
103------------------------------------------
104
105For simplicity, we use the "gpio" cable driver of UrTAG. This
106driver requires the Ben kernel to be compiled with
107CONFIG_GPIO_SYSFS (this option is not available as a module).
108If /sys/class/gpio does not exist, we need to rebuild the
109kernel.
110
111Prerequisite: you have checked out and set up the openwrt-xburst
112repository from Qi-Hardware.
113
114make kernel_menuconfig
115
116Then go to "Device Drivers" > "GPIO Support" and enable
117"/sys/class/gpio/... (sysfs interface)" (GPIO_SYSFS)
118
119
120Enabling ZRAM
121-------------
122
123UrTAG spends memory fairly generously and loading a bitstream for
124the XC6LX45 of Milkymist One is likely to exceed the memory
125available on the Ben.
126
127Since we can't swap on ubifs and we can't use an SD card for swap
128since the 8:10 card slot is already occupied, the next best choice
129is to use ZRAM.
130
131Note that this is not necessary if the driver for the respective
132target isn't quite as memory-hungry as the one for Xilinx FPGAs,
133or if the bitstream is smaller.
134
135make kernel_menuconfig
136
137Then go to "Device Drivers" and enable "Staging drivers" (STAGING).
138After that, enter "Staging drivers" and enable "Compressed RAM
139block device support" (ZRAM).
140
141
142Building and installing the OpenWRT kernel
143------------------------------------------
144
145make -j5
146scp bin/xburst/openwrt-xburst-qi_lb60-uImage.bin ben:
147ssh ben flash_eraseall /dev/mtd1
148ssh ben nandwrite -p /dev/mtd1 openwrt-xburst-qi_lb60-uImage.bin
149
150
151Using UBB-JTAG-M1
152-----------------
153
154First connect UBB-JTAG-M1 to the Milkymist One (powered off) but
155without inserting UBB into the Ben. This should look like this:
156
157http://downloads.qi-hardware.com/people/werner/ubb/jtag/ubb-jtag-m1-j6.jpg
158
159Then boot the Ben and disable the MMC driver with
160
161echo jz4740-mmc.0 >/sys/bus/platform/drivers/jz4740-mmc/unbind
162
163Now UBB-JTAG-M1 can be safely connected to the Ben. After connecting
164power to the Milkymist One, we can probe it with
165
166ben# jtag
167jtag> cable gpio tdi=107 tdo=105 tck=109 tms=108
168jtag> detect
169
170
171For the next step, we need fjmem.bit, e.g., available here:
172http://milkymist.org/updates/fjmem.bit.bz2
173
174We also need to enable swap space on ZRAM. 32 MB should be
175sufficient:
176
177ben# echo 33554432 >/sys/block/zram0/disksize
178ben# mkswap /dev/zram0
179ben# swapon /dev/zram0
180
181Now fjmem.bit can be loaded and executed:
182
183jtag> instruction CFG_OUT 000100 BYPASS
184jtag> instruction CFG_IN 000101 BYPASS
185jtag> pld load "fjmem.bit"
186jtag> initbus fjmem opcode=000010
187jtag> detectflash 0
188
189Since the sysfs GPIO interface is rather slow and we make things
190worse by swapping to compressed RAM, the loading of fjmem.bit
191takes about four or five minutes.
192
193
194Going faster
195------------
196
197In many applications, UrJTAG will be able to run without compressed
198swap and thus faster. Smaller amounts of data will also make even
199slow transfers more bearable.
200
201To further increase the speed, a Ben-specific GPIO driver could be
202written that accesses registers directly without the very long
203detour through sysfs.
204
205Finally, even higher speeds could be reached by using the MMC
206controller to send data, similar to UBB-VGA. For this purpose, CMD
207and DAT0 have been left unconnected. When connecting them to each
208other, they could be used to generate fake start bits, signaling
209the MMC controller to begin a transfer. (See ubb-vga for details.)
210

Archive Download this file

Branches:
master



interactive