Novena as JTAG adapter

From Studio Kousagi Wiki
Jump to: navigation, search

You can use your Novena as a JTAG adapter so that you can debug other JTAG capable devices.

For this your Novena needs to be updated to a current kernel (>=4.4) (to update use "apt-get dist-upgrade").

For reference, this is the mapping of "extra" pins on Novena internal serial headers to GPIO pin numbers which are used for JTAG. The layout is like this:

 | d  u
 | e  a
 | b  r
 | u  t
 | g  4  <- pin 1/GND
 | u
 | a
 | r
 | t
 | 3     <- pin 1/GND

row closer to edge row closer to buttons
NC UART4_RTS - CSI0_DAT16 - GPIO6_IO2 - linux162 - TDI
UART2_TXD - console UART4_TXD - senoko
UART2_RXD - console UART4_RXD - senoko
NC 3.3V (via diode)
NC UART4_CTS - CSI0_DAT17 - GPIO6_IO3 - linux163 - TCK
GPT_CAPIN1 - SD1_DAT0 - GPIO1_IO16 - linux16 - TMS
UART3_TXD - EIM_D24 - GPIO3_IO24 - linux88 - SRST
UART3_RXD - EIM_D25 - GPIO3_IO25 - linux89 - TRST
3.3V (via diode)
GPT_CLKIN - SD1_CLK - GPIO1_IO20 - linux20 - TDO

If you want to be able to use the additional TRST and/or SRST lines, you need to change the pinmapping of those pins. Unfortunately this cannot be done through the userspace yet, so you have to change the device-tree file for the Linux kernel.

I have a provided a ready-made device-tree file for you: Download this file and replace the one you have on the Novena boot partition with this file.

If you want to compile it yourself, you have to get the Novena Linux sources Then you have to change the following 2 lines in the file novena-linux/arch/arm/boot/dts/imx6q-novena.dts:

--- imx6q-novena.dts.orig       2016-08-16 18:33:45.031569966 +0200
+++ imx6q-novena.dts    2016-08-16 18:34:56.167303763 +0200
@@ -850,8 +850,8 @@
       uart3 {
               pinctrl_uart3_novena: uart3grp-novena {
                       fsl,pins = <
-                               MX6QDL_PAD_EIM_D24__UART3_TX_DATA 0x1b0b1
-                               MX6QDL_PAD_EIM_D25__UART3_RX_DATA 0x1b0b1
+                               MX6QDL_PAD_EIM_D24__GPIO3_IO24 0x1b0b1
+                               MX6QDL_PAD_EIM_D25__GPIO3_IO25 0x1b0b1

After the change you can compile it with "make dtbs" which generates the novena.dtb, which you can deploy on the boot partition then.

As JTAG software you need OpenOCD. Unfortunately the openocd version that comes with Debian Jessie is not compiled with sysfsgpio support, so you have to get the sources from and compile openocd yourself with "./configure -–enable-sysfsgpio ; make ; make install"

To use openocd you need the following configuration file:

openocd configuration:
interface sysfsgpio
transport select jtag
# Each of the JTAG lines need a gpio number set: tck(163) tms(16) tdi(162) tdo(20)
sysfsgpio_jtag_nums 163 16 162 20
sysfsgpio_srst_num 88
sysfsgpio_trst_num 89

Run it like "openocd -f novena.cfg"


1. GND Test

 Before you connect the Novena has JTAG adapter with the target board, measure the voltage between the 2 GND(ground) pins of the Novena and the target board with a multimeter. Ideally the voltage should be 0V.

2. GPIO Testing

Run the following toggle script with the pin-number as parameter:

./ 162
./ 20

It sets the direction of the GPIO to output and toggles the specified GPIO on and off every second, which you can measure with the Multimeter.

If you do not get a 0V / 3.3 V toggling signal on the Pin:

  • Make sure you measured at the right pin
  • Update your kernel to the latest 4.4 version or newer
  • Make sure that the device-tree (novena.dtb) is correctly configured regarding pin-muxing (PINCTRL), you can verify that in /sys/class/... but unfortunately you cannot control it from userspace at the moment. If you want to change that you either need device-tree overlays or you have to generate a new novena.dtb file.