AnsweredAssumed Answered

STM32F2 JTAG without NJTRST unusable

Question asked by smith.jason.002 on Jun 30, 2013
Latest reply on Jul 11, 2013 by Amel N
We have a STM32F205RCT6 connected via JTAG.

The JTAG emulator uses TDI, TDO, TMS, TCK and SRST (system reset). The NJTRST (JTAG reset) pin is electrically not connected to the JTAG pin header.

As long as the software is set up to configure all JTAG pins as "alternate function" everything works. As soon as the software configures the pin PB4 (NJTRST) as INPUT or OUTPUT or any other alternate function, JTAG stops working. This happens even though this pin is actually not used at all and electrically not connected at all (should be used as SPI lateron).

According to RM0033, p.137, "Full SWJ (JTAG-DP + SW-DP) but without NJTRST" should be available when PB4/NJTRST is configured as something else than alternate function 0. This is also what STM32F2xx_StdPeriph_Examples/GPIO/JTAG_Remap/main.c attempts to do.

We find that contrary to the documentation, JTAG is rendered completely useless as soon as NJTRST is disabled even though NJTRST is not used by our JTAG adapter.

To our impression we are either doing something seriously wrong or this is a silicon bug or wrong documentation.

Please comment on our findings.

How to reproduce: Firmware sets up IOs and works as expected. If the last line (MODER assignment) is added to the firmware, JTAG stops working upon executing that line.


// 0 -> input, 1 -> output, 2 -> alternate, 3 -> analog
// pin 4 -> bit shift by 8
unsigned int mask = 3U << (4*2);
unsigned int bits = 0U << (4*2);  // 0U and 1U disable JTAG
// This line actually disables JTAG when executed.
GPIOB->MODER = (GPIOB->MODER & ~mask) | bits;