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