Changes between Initial Version and Version 1 of jtag_instructions


Ignore:
Timestamp:
10/22/2017 05:28:45 AM (7 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • jtag_instructions

    v1 v1  
     1[[PageOutline]]
     2
     3= JTAG USB User's Guide =
     4The [http://shop.gateworks.com/index.php?act=viewProd&productId=56 Gateworks GW16042 JTAG Adapter] is used for flashing firmware to Gateworks Boards as well as serial console access.
     5
     6The device is primarily used used to access Gateworks devices for debugging and developing purposes.
     7
     8Gateworks provides a software utility application with support for both [#Linux Linux] and [#Windows Windows] operating systems (Note that for the Ventana product family, you must use the Linux tool). In order to use the windows utility please install the drivers which are also available at the link below (CDM20814_Setup.exe).
     9
     10[[Image(wiki:jtag_instructions:gw16042.JPG,200px)]]
     11
     12References:
     13 * [http://shop.gateworks.com/index.php?act=viewProd&productId=56 GW16042 on Gateworks on-line store]
     14 * [http://svn.gateworks.com/jtag/ Gateworks JTAG Utilities]
     15
     16
     17== JTAG Executables ==
     18The latest Gateworks JTAG Utilities are found [http://svn.gateworks.com/jtag/ here]
     19
     20
     21== Physical Connections ==
     22Depending on the board model, the Gateworks SBC may have a larger 14pin JTAG header or a smaller 10pin JTAG header on it.
     23
     24The header can be identified by looking at the connectors and identifying which one has the word JTAG by it silkscreened onto the board.
     25
     26Below are images showing the connections depending on a 14pin or 10pin board.
     27
     28
     29=== 10 pin: (Typically smaller Laguna boards, Ventana Boards) - Adapter !May/May Not be Needed ===
     30[[Image(VentanaJTAG.jpg,400px)]]
     31
     32
     33=== 14 pin: (Typically larger Laguna boards, Avila, Cambria Boards) ===
     34[[Image(LagunaJTAG.jpg,400px)]]
     35
     36
     37= Instructions =
     38[#Linux Linux Instructions]
     39
     40[#Windows Windows Instructions]
     41
     42
     43[=#linux-jtag]
     44== Linux ==
     45The Gateworks '''jtag_usb''' utility supports x86 32bit and 64bit Linux systems. Ubuntu is supported, however most x86 Linux distros should work as well.
     46
     47 * ''' Note virtual machines are NOT recommended'''
     48
     49 * If using a 64-bit system and proper operation is not occurring, please try the command:
     50{{{
     51sudo apt-get install ia32-libs
     52}}}
     53 * Please contact support@gateworks.com with any other questions
     54
     55The most recent version '''jtag_usbv4''' supports all Gateworks product families and can be downloaded [http://svn.gateworks.com/jtag/ here]
     56
     57The GW16042 JTAG dongle uses a FTDI FT2232C Dual USB-UART/FIFO chip and when enumerated on the USB bus will show as:
     58{{{
     59lsusb | grep 0403:6010
     60Bus 001 Device 007: ID 0403:6010 Future Technology Devices International, Ltd FT2232C Dual USB-UART/FIFO IC
     61}}}
     62
     63With the Linux kernel '''ftdi-sio''' driver installed this will expose two USB serial devices:
     64{{{
     65ls -l /dev/ttyUSB*
     66crw-rw---- 1 root dialout 188, 0 Apr  2 07:04 /dev/ttyUSB0
     67crw-rw---- 1 root dialout 188, 1 Apr  2 07:04 /dev/ttyUSB1
     68}}}
     69
     70The first serial device (/dev/ttyUSB0) is used for JTAG and the second device (/dev/ttyUSB1) is connected to the target board's serial console UART. Note that you must remove the Linux ftdi_sio driver (which will remove both of the above serial devices) in order to use the jtag_usb application (see below).
     71
     72Note that because the jtag_usb works by loading a small application onto the target processor over JTAG which runs out of SDRAM. Therefore the jtag_usb application will configure SDRAM and occasionally you may need to update to the latest version in order to have support for new boards or memory configurations.
     73
     74
     75References:
     76 * Latest Linux x86 jtag_usb download: http://svn.gateworks.com/jtag/linux/x86/
     77
     78
     79=== Conflict with ftdi-sio driver ===
     80The jtag_usb application requires that the Linux ftdi_sio kernel module not be loaded to run. You can temporarily unload it, then reload it (ie by hotplugging the jtag dongle) when done if you require it:
     81{{{
     82sudo rmmod ftdi_sio
     83}}}
     84
     85You can determine if the ftdi_sio module is loaded with lsmod:
     86{{{
     87lsmod | grep ftdi
     88ftdi_sio               39858  1
     89usbserial              42355  3 ftdi_sio
     90}}}
     91 * Here the ftdi_sio IS loaded, and we must remove it to use jtag_usb
     92
     93If you want to re-load the ftdi_sio module you can either unplug and reconnect the Gateworks JTAG-USB Programmer on the USB bus (which triggers a hotplug event and loads the appropriate driver for the device) or manually load it with a 'sudo modprobe ftdi_sio'.
     94
     95
     96=== Linux permissions on USB device ===
     97If you encounter permission errors when running jtag_usb it is likely that you require root privileges to access the USB device via libusb:
     98{{{
     99$ jtag_usbv4
     100libusb couldn't open USB device /dev/bus/usb/001/005: Permission denied.
     101libusb requires write access to USB device nodes.
     102libusb couldn't open USB device /dev/bus/usb/001/005: Permission denied.
     103libusb requires write access to USB device nodes.
     104$ ls -l /dev/bus/usb/001/005
     105crw-rw-r-- 1 root root 189, 4 Apr  2 06:54 /dev/bus/usb/001/005
     106}}}
     107 * the above shows that you must be root to read/write to /dev/bus/usb/0
     108
     109You can either use 'sudo jtag_usbv4' or 'sudo chmod 666' on the particular directory for the device however its likely that you want to install a udev rule to change the device permissions of this particular device every time its enumerated on the bus. You can do this by adding a udev rule that identifies the VendorID and ProductID of the Gateworks JTAG-USB Programmer and executes a chmod on it:
     110{{{
     111sudo cat <<EOF > /etc/udev/rules.d/51-gateworks-jtag-ftdi.rules
     112# Gateworks USB-JTAG Programmer for normal users (FTDI 2232C Dual USB-ART/FIFO IC)
     113SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", SYSFS{idVendor}=="0403", SYSFS{idProduct}=="6010", MODE="0666", NAME="bus/usb/$env{BUSNUM}/$env{DEVNUM}", RUN+="/bin/chmod 0666 %c"
     114EOF
     115sudo udevadm control --reload-rules # reload udev rules
     116}}}
     117 * following this unplug the Gateworks JTAG-USB Programmer and re-connect to re-enumerate the bus and invoke this new rule.
     118
     119The above udev configuration works for Ubuntu, however this configuration may vary on other Linux distro's that use something other than udev.
     120
     121[=#linux-jtag-flashing]
     122=== Using jtag_usb to read/write Firmware, Programming Software ===
     123Please see above for the download link to the latest jtag_usb executable. Note that an update may be required for new board models or memory configurations.
     124
     1251. Connect the GW11008 JTAG-USB Programmer to the JTAG header on a Gateworks Single Board Computer using the attached ribbon cable.
     126
     1272. Power on the Gateworks Single Board Computer.
     128
     1293. Connect the JTAG-USB Programmer to a PC USB port using the supplied USB cable.
     130
     1314. If trying to use the JTAG programmer to flash a new .bin binary image to the board, make sure the FTDI module is not loaded:
     132{{{
     133sudo rmmod ftdi_sio ; # remove module from running kernel
     134}}}
     135
     1365. Run the JTAG program with the syntax shown below.
     137{{{
     138./jtag_usbv4 –p <filename> –u <filename> –v <filename>
     139}}}
     140
     141If you encounter any errors see the [#Troubleshooting Troubleshooting] section below
     142
     143jtag_usb options:
     144||= Option =||= Operation =||= Notes =||
     145||-p        ||Program Flash device using specified filename|| ||
     146||-v        ||Verify Flash device using specified filename|| ||
     147||-u        ||Upload Flash device using specified filename|| Ventana not supported ||
     148||-m        ||Program GSC Firmware using specified filename|| ||
     149||-x        ||Verify GSC Firmware using specified filename || ||
     150
     151
     152==== Examples ====
     153Example 1: Program the Flash with avila_16.bin image.
     154{{{
     155./jtag_usbv4 -p avila_16.bin
     156}}}
     157Example 2: Program and verify Flash with avila_16.bin image.
     158{{{
     159./jtag_usbv4 -p avila_16.bin -v avila_16.bin
     160}}}
     161Example 3: Output from programming a binary
     162{{{
     163./jtag_usbv4 -p ./laguna_nor_1408.bin
     164
     165
     166Gateworks JTAG Programmer v4.0 r327
     167Copyright (C) 2004-2014, Gateworks Corporation, All Rights Reserved
     168Built 08:28:20, Oct 29 2014
     169Using USB Port
     170
     171Channel #      S01                                                             
     172--------------------------------------------------------------------------------
     173USB Open Rev    r0                                                             
     174JTAG_ID #00    CNS                                                             
     175JTAG_ID #01    CNS                                                             
     176JTAG_ID #02    MSP                                                             
     177Core 0 DRAM     OK                                                             
     178Load Debugger   OK                                                             
     179Flash Size      16                                                             
     180Flash Erase     OK                                                             
     181Flash Prog      OK     
     182}}}
     183
     184==== Troubleshooting ====
     185
     186 * ''' Note virtual machines are NOT recommended'''
     187 * Permission denied: '''libusb couldn't open USB device''' - [#LinuxpermissionsonUSBdevice see above] regarding Linux permissions
     188 * fOP: '''USB Open Rev  fOP''' - failure to open the USB device via libusb - you likely have the ftdi_sio serial driver loaded - [#conflictwithftdi-siodriver see above]
     189 * FAL: '''JTAG_ID_#00  FAL''' - failure to identify a supported JTAG TAP on the target device - likely you have not powered the target board
     190 * If while programming a board it gets stuck an invalid image may have locked up the board or the board is not powered on. Please try powering on the board. 
     191 *  JTAG utility stuck at '''Core 0 DRAM 00%''' while programming a Laguna family board - A lockup may have occurred in which a detailed fix may be available.  Please contact Gateworks support at support@gateworks.com.
     192 *  Flashing a invalid image. There are times when downloading files that the html version was downloaded rather than the file itself.  Check the file extension and file size to be sure you have the correct file.
     193 *  While programming, if it gets stuck at "Load Debugger: fS3' or fS2, this may mean there are issues with the GSC.  Please re-flash the GSC firmware as demonstrated here: http://trac.gateworks.com/wiki/gsc#GSCUpdates
     194
     195
     196[=#ventana-images]
     197=== Creating jtagable images for Ventana ===
     198In order to create a jtagable image for our Ventana family line, you can use our [http://svn.gateworks.com/ventana/images/mkimage_jtag mkimage_jtag] script which can be downloaded [http://svn.gateworks.com/ventana/images/mkimage_jtag here]. (You may need to chmod the mkimage_jtag script to make executable. Be sure it does not have any extension such as txt) The usage varies, depending on typical use cases. For example, you can create jtagable images that only update the bootloader without erasing all of NAND. You can also create jtagable images with both the bootloader and a ubi image which will erase all of nand. Below are several examples on how to use this script. Also note that the script outputs to std out, so in the examples below, we redirect it to a file.
     199
     200To update just the bootloader, create a jtagable image with just the two parts:
     201{{{
     202$ ./mkimage_jtag SPL u-boot.img > uboot.bin
     203}}}
     204
     205To update both the bootloader and rootfs (ubi)
     206{{{
     207$ ./mkimage_jtag SPL u-boot.img openwrt-ventana-rootfs.ubi > image.bin
     208}}}
     209
     210To update just the rootfs
     211{{{
     212$ ./mkimage_jtag openwrt-ventana-rootfs.ubi > image.bin
     213}}}
     214
     215Once these steps are complete and the bin file has been generated, follow the other instructions on this page to flash this .bin file to the board. Linux instructions for programming are here [#linux-jtag-flashing]
     216
     217==== Troubleshooting mkimage_jtag ====
     218 1. Be sure the mkimage_jtag script does not have any file extensions such as txt. If so, rename it to mkimage_jtag
     219 2. Be sure the mkimage_jtag script has executable permissions. If not, run the command:
     220{{{
     221chmod 777 mkimage_jtag
     222}}}
     223
     224
     225[=#linux-serial]
     226=== Serial Console Access on Linux ===
     227The JTAG connector on all Gateworks Families includes a serial port.
     228
     229You may use the device with your favorite linux terminal program (Screen, etc...) at 115,200 baud, 8 data bits, 1 stop bit, no parity and no flow control
     230
     231'''Gateworks suggests using the program screen to access the serial console.'''
     232
     233Example: open /dev/ttyUSB1 (Note that the device may vary on your system if you had /dev/ttyUSB devices prior to plugging the JTAG adapter into your USB bus)
     234{{{
     235screen /dev/ttyUSB1 115200,cs8
     236}}}
     237 * Typically /dev/tty* nodes are owned by root.dialout which means you need to be root or a member of the dialout group. If this is the case you will get a permissions error and you can either run the command with a 'sudo' in front of it, or add your user to the dialout group
     238
     239Troubleshooting:
     240 * you will likely need to add your user to the dialog group by editing the /etc/group file:
     241{{{
     242ls -l /dev/ttyUSB*
     243}}}
     244 * make sure modem-manager is not installed as this will perform serial operations on new tty devices when they appear on the system and likely cause issues with using screen on the same port:
     245{{{
     246sudo apt-get remove --purge modem-manager
     247}}}
     248
     249
     250
     251[=#windows]
     252== Windows ==
     253
     254=== Installing the Drivers for Windows ===
     255
     2561. Download and run the file CDM20814_Setup.exe on to your windows machine ([http://svn.gateworks.com/jtag/ Download JTAG Executables]). A window should open and close on its own:
     257
     258[[Image(wiki:jtag_instructions:winjtag.JPG)]]
     259
     2602. Once that is finished running, download and install winjtagsetup_0_1_5.msi
     261
     262[[Image(wiki:jtag_instructions:winjtag2.JPG)]]
     263
     2643. Choose a location to install the Gateworks Win JTAG.
     265
     266[[Image(wiki:jtag_instructions:winjtag3.JPG)]]
     267
     268{{{
     269#!html
     270<h3 style="color:red">NOTE:  There have been reports of an error regarding a missing DLL file.  If this error is seen, please try to find the DLL on the system, and copy it into the same directory as the executable.</h3>
     271}}}
     272
     273
     274[=#windows-jtag]
     275=== Operating Instructions For Programming ===
     276''' Please note, Windows Programming is not supported for Ventana'''
     277
     2781. Connect the Gateworks JTAG-USB Programmer to the JTAG header on the board using the attached ribbon cable.
     279
     2802. Power on the board and connect the Gateworks JTAG-USB Programmer to a Windows PC using the supplied USB cable.
     281
     2823. Run the Gateworks !WinJTAG program.
     283
     2844. Click on Open next to the Program File field and select the file location of a binary image.
     285
     2865. If desired, select a verify file or click on "Set Verify to Program File."
     287
     288[[Image(wiki:jtag_instructions:winjtag4.JPG)]]
     289
     2906. Click on Go and wait for the programming to be complete.
     291
     292
     293[=#windows-terminal]
     294=== Operating Instructions For Serial ===
     295You can use a terminal program for windows such as [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html Putty] / Hyperterminal to connect to the Gateworks board serially over the JTAG / or serial port.
     296
     297Connect the the jtag programmer to the computer, or connect a serial cable from the Gateworks board to the computer (if serial is available)
     298
     299Please reference the device manager area on your windows computer to detect which 'COM' port the JTAG is connected on.
     300
     301Then, start a standard serial connection on that port.  Configure the terminal program for 115,200 baud, 8 data bits, 1
     302stop bit, no parity and no flow control.
     303
     304Power the board, and wait for text to output.  Hitting the 'Enter' key may also bring up a prompt.
     305
     306Please see these excellent howto's for various terminal program on Windows:
     307- [http://kb.cyberoam.com/default.asp?id=2193 Setup Serial Console Connection using PuTTy]
     308- [http://www.microsemi.com/document-portal/doc_view/130815-configuring-serial-terminal-emulation-programs Configuring Serial Terminal Emulation Programs (Hyperterm, PuTTy, and Terra Term Pro)]
     309
     310
     311= General Troubleshooting =
     312
     313 1. If while programming a board it gets stuck an invalid image may have locked up the board or the board is not powered on. Please try powering on the board. 
     314 2. JTAG utility stuck at '''Core 0 DRAM 00%''' while programming a Laguna family board - A lockup may have occurred in which a detailed fix may be available.  Please contact Gateworks support at support@gateworks.com.
     315 3. Flashing a invalid image. There are times when downloading files that the html version was downloaded rather than the file itself.  Check the file extension and file size to be sure you have the correct file.
     316 4. While programming, if it gets stuck at "Load Debugger: fS3' or fS2, this may mean there are issues with the GSC.  Please re-flash the GSC firmware as demonstrated here: http://trac.gateworks.com/wiki/gsc#GSCUpdates
     317
     318If still have difficulties, please contact Gateworks support at support@gateworks.com
     319
     320
     321= OpenOCD =
     322Please see out JTAG hardware page here: [wiki:jtag#OpenOCD JTAG OCD]
     323
     324
     325= JTAG Programmer Hardware =
     326Please see out JTAG hardware page here: [wiki:jtag JTAG Hardware PAGE]